This is a cli tool to search for Star Wars characters to find information about their height, mass and also about their homeworld details using the SWAPI (star wars API).
- Character Search
- Gets and print information about a Star Wars character the user searched.
- It has attributes such as height, mass, and birth year of the character.
- Homeworld Details
- Prints the character's homeworld name, population, and orbital - rotation.
- Calculates the time on the homeworld's character relates to Earth years and days and prints an ratio.
Install the requirements.txt at my git repository :)
Clone the repository and follow the commands to run the script :)
###for the character search###
python main.py search 'luke sky'
###for the homeworld details search of that character###
python main.py search'luke sky' --world
-
def get_all_chars():
Gets all the characters from the SWAPI. Converts the data response into JSON and extract all the info.
-
def get_char_details(char_url):
Gets the properties of a character or a planet from the URL.
-
def search_char_name(results, name):
Searches for a specific character by name from the list of fetched characters.
-
Main
Uses argparse to handle CLI commands and flags. Prints character and homeworld information based on the user's input.