From d6f33df005a81132c0831e2dcfcc4c1bc218b3e1 Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 4 Dec 2019 17:02:20 +0100 Subject: [PATCH] petr update --- projekty/star_wars/petr.md | 21 ++++++++++++++------- projekty/star_wars/petr.py | 20 +++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/projekty/star_wars/petr.md b/projekty/star_wars/petr.md index f1180b0..37b11c9 100644 --- a/projekty/star_wars/petr.md +++ b/projekty/star_wars/petr.md @@ -5,15 +5,19 @@ import json import time -# helper functions +# helper functions - Pedro +# nice, delas abstrakce coz je super def get_json(url): return requests.get(url).json() - +# dalsi abstrakce, hmm +# asi celkem v pohode, ale nazvy potencialne moc dlouhy def get_film_titles(films): list_films = [] for film in films: list_films.append(get_json(film)["title"]) + # mohl si napsat: + #return [get_json(film)["title"] for film in films] return list_films @@ -22,8 +26,9 @@ def get_character_names(characters): for character in characters: list_characters.append(get_json(character)["name"]) - return sorted(list_characters) - + return sorted(list_characters) # asi ne uplne dobry volat na tom sorted + # ztracis trochu generalizaci + # ale to je fakt detail def get_spaceship_names(spaceships): list_spaceships = [] @@ -37,7 +42,8 @@ def get_film_info(film): list_characters = get_character_names(film["characters"]) list_spaceships = get_spaceship_names(film["starships"]) return [film["title"], film["director"], film["episode_id"], - list_characters, list_spaceships] + list_characters, list_spaceships] # kdyz uz takhle formatujes tak + # muzes rovnou na vic radku def ship_detail(shipname): @@ -101,7 +107,7 @@ def crawl(title): if __name__ == "__main__": - # testing program. runs only if run as main + # testing program. runs only if run as main - Pedro print(ship_detail("Imperial shuttle")) print(species_detail("Hutt")) print(person_detail("Owen Lars")) @@ -109,4 +115,5 @@ if __name__ == "__main__": print(film_detail("The Phantom Menace", "title")) print(film_detail(2)) - crawl("A New Hope")``` \ No newline at end of file + crawl("A New Hope") +``` \ No newline at end of file diff --git a/projekty/star_wars/petr.py b/projekty/star_wars/petr.py index 10ace5b..2dadaa1 100644 --- a/projekty/star_wars/petr.py +++ b/projekty/star_wars/petr.py @@ -3,15 +3,19 @@ import json import time -# helper functions +# helper functions - Pedro +# nice, delas abstrakce coz je super def get_json(url): return requests.get(url).json() - +# dalsi abstrakce, hmm +# asi celkem v pohode, ale nazvy potencialne moc dlouhy def get_film_titles(films): list_films = [] for film in films: list_films.append(get_json(film)["title"]) + # mohl si napsat: + #return [get_json(film)["title"] for film in films] return list_films @@ -20,8 +24,9 @@ def get_character_names(characters): for character in characters: list_characters.append(get_json(character)["name"]) - return sorted(list_characters) - + return sorted(list_characters) # asi ne uplne dobry volat na tom sorted + # ztracis trochu generalizaci + # ale to je fakt detail def get_spaceship_names(spaceships): list_spaceships = [] @@ -35,7 +40,8 @@ def get_film_info(film): list_characters = get_character_names(film["characters"]) list_spaceships = get_spaceship_names(film["starships"]) return [film["title"], film["director"], film["episode_id"], - list_characters, list_spaceships] + list_characters, list_spaceships] # kdyz uz takhle formatujes tak + # muzes rovnou na vic radku def ship_detail(shipname): @@ -99,7 +105,7 @@ def crawl(title): if __name__ == "__main__": - # testing program. runs only if run as main + # testing program. runs only if run as main - Pedro print(ship_detail("Imperial shuttle")) print(species_detail("Hutt")) print(person_detail("Owen Lars")) @@ -107,4 +113,4 @@ if __name__ == "__main__": print(film_detail("The Phantom Menace", "title")) print(film_detail(2)) - crawl("A New Hope") \ No newline at end of file + crawl("A New Hope")