diff --git a/elderspy/app.py b/elderspy/app.py deleted file mode 100644 index b56fe4c..0000000 --- a/elderspy/app.py +++ /dev/null @@ -1,35 +0,0 @@ -import requests -import json - -def getStarships(url): - r = requests.get(url) - data = json.loads(r.text) - return data - -def getPilot(piloturl): - r = requests.get(piloturl) - pilot = json.loads(r.text) - name = pilot['name'] - return name - -def extractAndPrint(data): - ships = data['results'] - for x in range(len(ships)): - ship = ships[x] - if bool(ship['pilots']) != False: - print("The " + ship['name'] + " was piloted by...") - pilots = ship['pilots'] - for i in range(len(pilots)): - piloturl = pilots[i] - print("\t" + getPilot(piloturl)) - - -url = 'https://swapi.co/api/starships/' - -while url != "": - try: - data = getStarships(url) - url = data['next'] - extractAndPrint(data) - except: - quit() diff --git a/jagestah/Dockerfile b/jagestah/Dockerfile deleted file mode 100644 index 09f56fd..0000000 --- a/jagestah/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM alpine:latest -WORKDIR /app -ADD . /app -RUN apk update && apk add \ - py-pip \ - python \ - python-dev \ - alpine-sdk -RUN pip install --upgrade pip -RUN pip install \ - swapi -CMD python app.py \ No newline at end of file diff --git a/jagestah/README.md b/jagestah/README.md deleted file mode 100644 index 1758a7d..0000000 --- a/jagestah/README.md +++ /dev/null @@ -1,14 +0,0 @@ - -# Purpose - -Connect to the Star Wars API located at http://swapi.co and return a list of Starships that have a named pilots and then name those Pilots. - - - -# Directions - -The Docker image has already been built and published to jagestah/swapitest - -With docker installed on your system it should be as simple as `docker run jagestah/swapitest` - -This Repo contains the documents used to build the Docker image diff --git a/jagestah/alternate/__init__.py b/jagestah/alternate/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/jagestah/alternate/app.py b/jagestah/alternate/app.py deleted file mode 100644 index 0b8f28f..0000000 --- a/jagestah/alternate/app.py +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/python -import json -import requests -import pprint - -ship_url = 'https://swapi.co/api/starships/' -people_url = 'https://swapi.co/api/people/' - -pp = pprint.PrettyPrinter() - -#API call for the ships, looping or pagination -def get_ships(ship_url): - ships_results = requests.get(ship_url) - ship_data = ships_results.json()["results"] - while ships_results.json()["next"]: - ships_results = requests.get(ships_results.json()["next"]) - ship_data = ship_data + ships_results.json()["results"] - print("Gathered ship data") -#Sends the results of all the ships in a single list and the people_url to get_people - get_people(people_url, ship_data) - -#API call for all the people, looping for pagination -def get_people(people_url, ship_data): - people_results = requests.get(people_url) - people_data = people_results.json()["results"] - while people_results.json()["next"]: - people_results = requests.get(people_results.json()["next"]) - people_data = people_data + people_results.json()["results"] - print("Gathered people data \n\r --------------------------------") -#Passes the list of ships and the list of people to list_ships - list_ships(people_data, ship_data) - -#checks if the ships has pilots and prints the name of the ship if it does. -def list_ships(people_data, ship_data): - for ship in ship_data: - if ship["pilots"]: - print(ship["name"]) - #Passes the ship's info to list_pilots as well as the people_data from before - list_pilots(people_data, ship) - -#cross references the data from the ships that list the urls of pilots and prints the name for that entry -def list_pilots(people_data, ship): - for pilot_url in ship["pilots"]: - for person in people_data: - if person["url"] == pilot_url: - print(" "+person["name"]) - -if __name__ == "__main__": - get_ships(ship_url) diff --git a/jagestah/app.py b/jagestah/app.py deleted file mode 100755 index 17d7ea4..0000000 --- a/jagestah/app.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -import swapi -import requests - -ships = (swapi.get_all("starships")) -print (ships) - -for ship in ships.iter(): - if len(ship.pilots) > 0: - print(ship.name) - for pilot in ship.pilots: - response = requests.get(pilot) - data = response.json() - print(" "+data["name"].encode('utf-8')) \ No newline at end of file diff --git a/jagestah/requirements.txt b/jagestah/requirements.txt deleted file mode 100644 index a1e9c69..0000000 --- a/jagestah/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -swapi \ No newline at end of file diff --git a/subdirchris/chrischallenge.py b/subdirchris/chrischallenge.py deleted file mode 100644 index b4402c8..0000000 --- a/subdirchris/chrischallenge.py +++ /dev/null @@ -1,13 +0,0 @@ -import requests -import json -import swapi - -ships = swapi.get_all("starships") - -for ship in ships.iter(): - if ship.pilots: - print(ship.name) - for pilots in ship.pilots: - jason = requests.get(pilots) - data = jason.json() - print(' '+data['name'].encode('utf-8'))