From 0096e2113e72f22ec6afb65f5c3bc38b2e7d4a9a Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Fri, 27 Jan 2023 12:08:54 +0200 Subject: [PATCH 01/18] repo: new str in master --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 247c9bc..d6ae3b5 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ Practice + +add another new string From d963d7dc47550d93ac46b0726cdc092b8b54d379 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Fri, 27 Jan 2023 16:53:48 +0200 Subject: [PATCH 02/18] cheking keys --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index eb082c6..ce092fb 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ Practice add another new string command list first_branch + +check keys From 78640e3d9e85bb0ba46da9b815d3300638103008 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Fri, 27 Jan 2023 17:33:06 +0200 Subject: [PATCH 03/18] signet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce092fb..775eb2e 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ add another new string command list first_branch -check keys +check keys gpg From 01267315ef83a346d6c253aa9e96e3ec06aafe3e Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Wed, 1 Feb 2023 19:36:39 +0200 Subject: [PATCH 04/18] Add files 02ex01.py 02ex02.py --- 02ex01.py | 73 +++++++++++++++++++++++++++++++++++++++++ 02ex02.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 02ex01.py create mode 100644 02ex02.py diff --git a/02ex01.py b/02ex01.py new file mode 100644 index 0000000..18ec336 --- /dev/null +++ b/02ex01.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 + +"""Calculate deposit percent yield based on time period. + +Imagine your friend wants to put money on a deposit. +He has got many offers from different banks: +- First bank declares +A% each day; +- Second bank promises +B% each month; +- Third bank offers +C% by the end of the year; +- The 4th bank promotes +D% in a 10-year term; +- ... and so on ... + +Your friend gets a terrible headache calculating all this stuff, +and asks you to help checking everything. You quickly realize +it is a common task and having a simple script is a great idea. + +Let's implement this. + +A simplified task: +Given the SUM amount of money, and PERCENT yield promised in a +FIXED_PERIOD of time, calculate the TOTAL equivalent of money +in a SET_PERIOD of time. + +Math formula: +p = PERCENT / 100 +TOTAL = SUM * ((1 + p) ** (SET_PERIOD / FIXED_PERIOD)) +""" + + +# TODO: add lines to calculate yields for some common periods +# of time (e.g. 1 month, 1 year, 5 years, 10 years) +# TODO: change the script to output the 1-year percent yield +# as well +# TODO: (extra) Output only percents if the initial SUM is +# not known at the moment the script is run + + +USAGE = """USAGE: {script} initial_sum percent fixed_period set_period + +\tCalculate deposit yield. See script source for more details. +""" +USAGE = USAGE.strip() + + +def deposit(initial_sum, percent, fixed_period, set_period): + """Calculate deposit yield.""" + per = percent / 100 + growth = (1 + per) ** (set_period / fixed_period) + return initial_sum * growth + + +def main(args): + """Gets called when run as a script.""" + if len(args) != 4 + 1: + exit(USAGE.format(script=args[0])) + + args = args[1:] + initial_sum, percent, fixed_period, set_period = map(float, args) + + # same as + # initial_sum = float(args[0]) + # percent = float(args[1]) + # ... + + res = deposit(initial_sum, percent, fixed_period, set_period) + print(res) + + +if __name__ == '__main__': + import sys + + main(sys.argv) + diff --git a/02ex02.py b/02ex02.py new file mode 100644 index 0000000..8036fe9 --- /dev/null +++ b/02ex02.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 + +"""The famous Vikings restoraunt from the Monthy Python sketch. + +See the sketch origins video first: +https://www.youtube.com/watch?v=zLih-WQwBSc +""" + +import random + +DEF_CHOICE = 8 # how many times to repeat a dish +MENU = ['spam', 'egg', 'sausage', 'bacon'] # that's all combinations +MENU_MULTI = MENU + ['eggs', 'sausages'] # including plurals +JOINTS = [', and ', ', ', ' and ', ' with ', ' and double portion of '] +PREFERED = MENU[0] # that's what promoted most +FORBIDDEN = {'not', 'without', 'no'} + +SONG = ', '.join([PREFERED.capitalize()] + [PREFERED] * DEF_CHOICE) + '!' + +D_WELCOME = ('Welcome to the Vikings restaurant.\n' + 'What would you like to eat?') +D_CHOICE = '> ' +D_PROMOTE = "We highly recommend {dishes}" + f', and {PREFERED}...' +D_GOOD = "That's a perfect choice. Let's have more {dishes}" + f', and {PREFERED}!' +D_BAD = "Disgusting. Who eats {dishes}?" +D_UNAVAILABLE = "That's not on our menu.\nWe have {dishes}." + + +def dialog(num_choice=DEF_CHOICE): + """User dialog logic.""" + print(D_WELCOME) + + entry = input(D_CHOICE).strip() # user entry + words = entry.lower().split() + + def promote(): + print(D_PROMOTE.format(dishes=get_dishes(num_choice))) + + if set(words) & set(MENU_MULTI): + # user named something on the menu - do further check + if set(words) & set(FORBIDDEN): + # user asked not to put common dishes - blame + print(D_BAD.format(dishes=entry)) + promote() + else: + # user asked for what's on menu - compliment + print(D_GOOD.format(dishes=entry)) + print(f'Vikings: "{SONG}"') + return + + if not words: + # user haven't selected anything - promote a good menu + promote() + return + + print(D_UNAVAILABLE.format(dishes=get_dishes(num_choice))) + return + + +def get_dishes(number): + """Form a random combination of dishes""" + sel = list(MENU) + + res = [] + for i in range(number): + rnd = random.choice(sel) + #sel.remove(rnd) + res.append(rnd) + res.append(random.choice(JOINTS)) + res = res[:-1] # remove last element + + return ''.join(res) + + +TIP = """Next time call "{script} num" to set number of dishes.""" + +def main(args): + script, *args = args + + """Gets called when run as a script.""" + if len(args) > 1: + exit('Too many arguments. ' + TIP.format(script=script)) + + num = DEF_CHOICE + if len(args) > 0: + num = int(args[0]) + + dialog(num) + + if len(args) < 1: + print('\tTip:', TIP.format(script=script)) + + +if __name__ == '__main__': + import sys + + main(sys.argv) From 2dd420d135c9472d572c7e45ccad02229942015b Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Fri, 3 Feb 2023 21:51:31 +0200 Subject: [PATCH 05/18] Add extra task script --- "OnceA\320\265Roadblock.py" | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 "OnceA\320\265Roadblock.py" diff --git "a/OnceA\320\265Roadblock.py" "b/OnceA\320\265Roadblock.py" new file mode 100755 index 0000000..6dbd4bd --- /dev/null +++ "b/OnceA\320\265Roadblock.py" @@ -0,0 +1,67 @@ +# !/usr/bin/env python3 + + +import random + +GREETENG = ["Теробора України !!! Стій! Хто Іде? Ану переклади пароль з англійської"] +PASSWORD = ["hedgehog", "heaver", "eagle", "deer", "snake", "goose", "hare", "monkey", "dove", "turtle"] +N_DIALOG = ["Шо мовчиш?, москаль чи шо?", "Ану кажи пароль", "Микола, стрельни йому під ноги", "Ти шо німий?"] +NO_DIALOG = ["Підіймай руки і йди сюди, якщо не німий, то ми тебе розговоримо"] +UA_DIALOG = ["Вітаємо Козаче, Слава Україні!!!"] +PL_DIALOG = ["Powitanie nasz Рolski przyjaciel! Chwała Ukrainie!!!"] +GB_DIALOG = ["Welcome our English friend! Glory to Ukrain!!!"] +RU_DIALOG = ["Ну от і все, гейм овер!. Микола доставай пакет, будемо депортірувати на \"родіну\"."] +F_DIALOG = ["Йо Йо Йой, щось тут не те, ану ще разок", + "Микола ти це чув? Шукай гиляку. Ану ще раз", + "А ти часом не москаль? ану спробуй знову", + "Але ж ти і підозрілий! Давай знов ", + "Ану ше раз, поки Микола готує мотузку "] + +ATTEMPTS = 4 +T_PASSWORD = '> ' + + +def dialog(): + """User dialog logic.""" + password = PASSWORD[random.randrange(0, len(PASSWORD))] + print(f"{GREETENG}:\n{password}") + entry = input(T_PASSWORD).strip().lower() # user entry + attempts = ATTEMPTS + while attempts > 0: + if not entry and attempts == 1: + return print(NO_DIALOG) + elif not entry: + print(f"{N_DIALOG[random.randrange(0, len(N_DIALOG))]}") + print(password) + else: + if attempts == 1: + return print(RU_DIALOG) + for i in entry: + if i in "aeuoiy": + return print(GB_DIALOG) + for i in entry: + if i in "ąćęłńóśźż": + return print(PL_DIALOG) + for i in entry: + if i in "іїґє'": + return print(UA_DIALOG) + print(F_DIALOG[random.randrange(0, len(F_DIALOG))]) + password = PASSWORD[random.randrange(0, len(PASSWORD))] + print(password) + entry = input(T_PASSWORD).strip().lower() + attempts -= 1 + + + +def main(args): + script, *args = args + if args: + exit('Too many arguments. ' ) + + else: + dialog() + +if __name__ == '__main__': + import sys + + main(sys.argv) From b5a76ba43b80899e6038e67182b438b45a938bc3 Mon Sep 17 00:00:00 2001 From: YuriiMandrik <123733148+YuriiMandrik@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:06:51 +0200 Subject: [PATCH 06/18] =?UTF-8?q?Rename=20OnceA=D0=B5Roadblock.py=20to=20O?= =?UTF-8?q?nceAtRoadblock.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "OnceA\320\265Roadblock.py" => OnceAtRoadblock.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "OnceA\320\265Roadblock.py" => OnceAtRoadblock.py (100%) diff --git "a/OnceA\320\265Roadblock.py" b/OnceAtRoadblock.py similarity index 100% rename from "OnceA\320\265Roadblock.py" rename to OnceAtRoadblock.py From 1fd0f41dffe4b4e7dbc038ae579cde3d59a447ed Mon Sep 17 00:00:00 2001 From: YuriiMandrik <123733148+YuriiMandrik@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:09:21 +0200 Subject: [PATCH 07/18] Add script for extra task --- OnceAtRoadblock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/OnceAtRoadblock.py b/OnceAtRoadblock.py index 6dbd4bd..d3d5e0b 100755 --- a/OnceAtRoadblock.py +++ b/OnceAtRoadblock.py @@ -16,7 +16,6 @@ "А ти часом не москаль? ану спробуй знову", "Але ж ти і підозрілий! Давай знов ", "Ану ше раз, поки Микола готує мотузку "] - ATTEMPTS = 4 T_PASSWORD = '> ' From 0ec6f52c653cbb0023a9894110410f441aa2d182 Mon Sep 17 00:00:00 2001 From: YuriiMandrik <123733148+YuriiMandrik@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:38:25 +0200 Subject: [PATCH 08/18] Add script for extra task --- OnceAtRoadblock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OnceAtRoadblock.py b/OnceAtRoadblock.py index d3d5e0b..5fd91fc 100755 --- a/OnceAtRoadblock.py +++ b/OnceAtRoadblock.py @@ -4,7 +4,7 @@ import random GREETENG = ["Теробора України !!! Стій! Хто Іде? Ану переклади пароль з англійської"] -PASSWORD = ["hedgehog", "heaver", "eagle", "deer", "snake", "goose", "hare", "monkey", "dove", "turtle"] +PASSWORD = ["hedgehog", "swan", "falcon", "ant-eater", "snake", "swallow", "hare", "bear", "squirrel", "rhinoceros"] N_DIALOG = ["Шо мовчиш?, москаль чи шо?", "Ану кажи пароль", "Микола, стрельни йому під ноги", "Ти шо німий?"] NO_DIALOG = ["Підіймай руки і йди сюди, якщо не німий, то ми тебе розговоримо"] UA_DIALOG = ["Вітаємо Козаче, Слава Україні!!!"] From 7d3cbb7b44b6547b18535c7d3b35203785063458 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Sun, 12 Feb 2023 15:33:12 +0200 Subject: [PATCH 09/18] Add own class hierarchy and averege function --- AverageValue.py | 5 +++++ basicclasses.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 AverageValue.py create mode 100644 basicclasses.py diff --git a/AverageValue.py b/AverageValue.py new file mode 100644 index 0000000..37d8469 --- /dev/null +++ b/AverageValue.py @@ -0,0 +1,5 @@ +def avg(*args): + return sum(*args) / len(*args) + + + diff --git a/basicclasses.py b/basicclasses.py new file mode 100644 index 0000000..4c33015 --- /dev/null +++ b/basicclasses.py @@ -0,0 +1,30 @@ +class Seeds: + def __init__(self, sowing_rate, ripeness_group, productivity_potential): + self.sowing_rate = sowing_rate + self.ripeness_group = ripeness_group + self.productivity_potential = productivity_potential + def __repr__(self): + return f"This seed has: \n -sowing rate -> {self.sowing_rate}\n" \ + f" -ripeness group: -> {self.ripeness_group}\n" \ + f" -productivity potential -> {self.productivity_potential}" + + +class CornSeeds(Seeds): + def __init__(self, sowing_rate, ripeness_group, productivity_potential): + super().__init__(sowing_rate, ripeness_group, productivity_potential) + self.is_sugar = False + self.fao_index = None + + +class SunflowerSeeds(Seeds): + def __init__(self, sowing_rate, ripeness_group, productivity_potential): + super().__init__(sowing_rate, ripeness_group, productivity_potential) + self.express_technology = False + self.oiliness = None + + +class WheatSeeds(Seeds): + def __init__(self, sowing_rate, ripeness_group, productivity_potential): + super().__init__(sowing_rate, ripeness_group, productivity_potential) + self.winter_variety = False + self.quality_class = None From 09ccd24c8307915719cde906aff1790d1dbe244b Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Fri, 24 Feb 2023 19:26:05 +0200 Subject: [PATCH 10/18] Add new file Cards.py for HW#5 --- Cards.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Cards.py diff --git a/Cards.py b/Cards.py new file mode 100644 index 0000000..17c7eaa --- /dev/null +++ b/Cards.py @@ -0,0 +1,50 @@ +import random + + +class Cards: + RANKS = list(range(2, 11)) + list('JQKA') + SUITS = ['\u2660', '\u2665', '\u2666', '\u2663'] + + def __init__(self): + self.rank = self.RANKS + self.suits = self.SUITS + + def __repr__(self): + return f"{self.magic_cards()}" + + @classmethod + def create_deck(cls): + deck = [] + deck_list = [(str(i), j) for i in cls.RANKS for j in cls.SUITS] + for i in deck_list: + deck.append("".join(i)) + return deck + + @classmethod + def generate_card(cls, n=1): + cards_list = [] + for i in range(n): + cards_list.append(random.choice(cls.create_deck())) + return cards_list + + def magic_cards(self): + from datetime import datetime + print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n" + f"How many cards will you get?\n -->") + num_cards = input() + try: + int(num_cards) + if 0 < int(num_cards) < 5: + week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + get_cards = self.generate_card(int(num_cards)) + num_cards -= 1 + print(f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n" + f"--->>>{week_days_list[datetime.now().weekday()]}<<<---") + else: + print('too many cards you probably need to see a fortune teller') + except ValueError: + print("it seems that tomorrow......\n you will learn how letters differ from numbers") + +x = Cards() +print(x.generate_card()) +print(x.magic_cards()) From c612dd765ef361896a6f694f44d6e1bfcd72cdc9 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Mon, 6 Mar 2023 12:15:33 +0200 Subject: [PATCH 11/18] Add HW #8 WeatherClases and ExeptionsClases --- HW Lacture#8/Exceptions.py | 27 +++++++++++++ HW Lacture#8/WeatherClases.py | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 HW Lacture#8/Exceptions.py create mode 100644 HW Lacture#8/WeatherClases.py diff --git a/HW Lacture#8/Exceptions.py b/HW Lacture#8/Exceptions.py new file mode 100644 index 0000000..8fda0eb --- /dev/null +++ b/HW Lacture#8/Exceptions.py @@ -0,0 +1,27 @@ +class Errors(Exception): + pass + + +class CityNameError(Errors): + error_message = ('City name must contain only letters') + + def __init__(self): + super().__init__() + self.msg = self.error_message + + def __str__(self): + return self.msg + + +class CoordError(Errors): + error_message = ("Invalid Coords. Try again") + + def __init__(self): + super().__init__() + self.msg = self.error_message + + def __str__(self): + return self.msg + + + diff --git a/HW Lacture#8/WeatherClases.py b/HW Lacture#8/WeatherClases.py new file mode 100644 index 0000000..b63895a --- /dev/null +++ b/HW Lacture#8/WeatherClases.py @@ -0,0 +1,71 @@ +from urllib.request import urlopen +import json +from Exeptions import CityNameError, CoordError +# https://api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key} +# https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key} +TOKEN = '18c6e0f43541c0148fa43fbd483f79b4' + + +class City(): + def __init__(self, name, latitude=None, longitude=None): + self._name = name + self._latitude = latitude + self._longitude = longitude + if self._latitude is None and self._longitude is None: + self.set_coords() + + def get_coords(self): + if self._name.isalpha(): + url = f'http://api.openweathermap.org/geo/1.0/direct?q={self._name}&appid={TOKEN}' + response = urlopen(url) + data = response.read() + data = data.decode('utf-8') + res = json.loads(data) + lat = res[0]['lat'] + lon = res[0]['lon'] + else: + raise CityNameError + + + return lat, lon + + def set_coords(self): + self._latitude, self._longitude = self.get_coords() + + def __str__(self): + return f'City {self._name} has latitude:{self._latitude} ' \ + f'and longitude{self._longitude}' + + +class Weather(): + + def __init__(self, city, coords=None): + self.city = city + self.coords = coords + + def current_weather(self): + if self.coords: + try: + float(self.coords[0]) + float(self.coords[1]) + except ValueError: + raise CoordError() + + + else: + self.coords = City(self.city).get_coords() + + url = f'https://api.openweathermap.org/data/2.5/weather?lat={self.coords[0]}&lon={self.coords[1]}&units=metric&appid={TOKEN}' + response = urlopen(url).read().decode('utf-8') + res = json.loads(response) + # print(res) + return (f"Температура: {res['main']['temp']} " + f"відчувається як: {res['main']['feels_like']} " + f"швидкість вітру: {res['wind']['speed']}") + + def __str__(self): + return self.current_weather() + + + + From e940204c170b9d85a2e5f9e1091d6a86c94a94d6 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Wed, 8 Mar 2023 19:31:10 +0200 Subject: [PATCH 12/18] Add Homework #7 --- HW#7 Lecture#9/CardsExtendet.py | 173 ++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 HW#7 Lecture#9/CardsExtendet.py diff --git a/HW#7 Lecture#9/CardsExtendet.py b/HW#7 Lecture#9/CardsExtendet.py new file mode 100644 index 0000000..33f74ac --- /dev/null +++ b/HW#7 Lecture#9/CardsExtendet.py @@ -0,0 +1,173 @@ +import random + + +class CardDeck(): + LOW_CARDS = list(range(2, 11)) + HI_CARDS = list('JQKA') + SUITS = ['\u2660', '\u2665', '\u2666', '\u2663'] + + def __init__(self): + self.suits = self.SUITS + self.ranks = self.LOW_CARDS + self.HI_CARDS + self.shufle_count = 0 + self.deck = self.create_deck() + + def __repr__(self): + return f'{self.deck}' + + def create_deck(self): + deck = [] + deck_list = [(str(i), j) for i in self.ranks for j in self.suits] + for i in deck_list: + deck.append("".join(i)) + return deck + + def generate_card(self, n=1): + # Метод що вибирає мінімум одну рандомну карту з колоди + cards_list = [] + for i in range(n): + cards_list.append(random.choice(self.deck)) + return cards_list + + def shuffle(self): + random.shuffle(self.deck) + self.shufle_count += 1 + + def __len__(self): + return len(self.deck) + + def __getitem__(self, out_card): + if isinstance(out_card, int): + if out_card < len(self.deck): + return self.deck.pop(out_card) + else: + print('Колода менша за ваші амбіції') + else: + raise TypeError('Потрібно вказати номер карти') + + def __add__(self, add_card): + if isinstance(add_card, list): + return self.deck + list(add_card) + else: + print('додати можна лише список') + + def __sub__(self, out_cards): + if isinstance(out_cards, list): + for i in out_cards: + if self.__contains__(i): + self.deck.remove(i) + + else: + print(f'Карта {i} мабуть десь в рукаві') + return self.deck + else: + print('потрібен список карт') + + def __contains__(self, card): + return card in self.deck + + def __eq__(self, other): + return sorted(self.deck) < sorted(other.deck) + + def __gt__(self, other): + return sorted(self.deck) < sorted(other.deck) + + def __lt__(self, other): + return sorted(self.deck) > sorted(other.deck) + + def magic_cards(self): + from datetime import datetime + print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n" + f"How many cards will you get?\n -->") + num_cards = input() + try: + int(num_cards) + if 0 < int(num_cards) < 5: + week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + get_cards = self.generate_card(int(num_cards)) + num_cards -= 1 + print( + f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n" + f"--->>>{week_days_list[datetime.now().weekday()]}<<<---") + else: + print('too many cards you probably need to see a fortune teller') + except ValueError: + print("it seems that tomorrow......\n you will learn how letters differ from numbers") + + def __bool__(self): + return bool(self.deck) > 0 and self.shufle_count > 0 + + +class SmallDeck(CardDeck): + LOW_CARDS = list(range(6, 11)) + + def __init__(self): + super().__init__() + + +class ClassicDeck(CardDeck): + def __init__(self): + super().__init__() + + +if __name__ == '__main__': + x = ClassicDeck() + y = ClassicDeck() + s = SmallDeck() + n = ['2♠', '2♦', '3♠'] + n2 = ['2♠'] + + # #для перевірки shuffle() + # print(x) + # x.shuffle() + # print(x) + + # #для перевірки __len__() + # print(len(x)) + + # #для перевірки __getitem__() + # print(x[2]) + # print(x[55]) + + # #для перевірки __add__ + # print (x + n) + + # #для перевірки __sub__() + # print(x-n) + # x-n2 + + # #для перевірки __contains__() + # print(x) + # n = '2♠' + # print(n) + # print(n in x) + + # # для перевірки __eq__() + # y.shuffle() + # print(x) + # print(y) + # print (x == y) + # print(x) + # print(s) + # print (x == s) + + # #для перевірки __gt__() та __lt__ + # print(x < s) + # print(x > s) + + # #для перевірки __bool__ + # print(bool(x)) + # x.shuffle() + # print(bool(x)) + + # #ітерація колоди + # i = iter(x) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(type(x)) + ## наскільки я зрозумів ітератор працює завдяки наякності метода __getitem__() що дозволяє переберати елементи. + + From 63ffde4780d3e8bdf7e0716bc53a1db12183e9d6 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Wed, 8 Mar 2023 20:42:15 +0200 Subject: [PATCH 13/18] Fixed HW#5 Advanced classes --- HW#5 Advanced classes/Cards.py | 49 ++++++++++++++++++++++++++++++++ HW#5 Advanced classes/Fortune.py | 18 ++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 HW#5 Advanced classes/Cards.py create mode 100644 HW#5 Advanced classes/Fortune.py diff --git a/HW#5 Advanced classes/Cards.py b/HW#5 Advanced classes/Cards.py new file mode 100644 index 0000000..ca19afe --- /dev/null +++ b/HW#5 Advanced classes/Cards.py @@ -0,0 +1,49 @@ +import random + + +class Cards(): + RANKS = list(range(2, 11)) + list('JQKA') + SUITS = ['\u2660', '\u2665', '\u2666', '\u2663'] + + def __init__(self): + self.rank = self.RANKS + self.suits = self.SUITS + + def __repr__(self): + return f"{self.magic_cards()}" + + def create_deck(self): + deck = [] + deck_list = [(str(i), j) for i in self.RANKS for j in self.SUITS] + for i in deck_list: + deck.append("".join(i)) + return deck + + def generate_card(self, n=1): + cards_list = [] + for i in range(n): + cards_list.append(random.choice(self.create_deck())) + return cards_list + + def magic_cards(): + card = Cards() + from datetime import datetime + print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n" + f"How many cards will you get?\n -->") + num_cards = input() + try: + num_cards = int(num_cards) + if 0 < int(num_cards) < 5: + week_days_list = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + get_cards = card.generate_card(int(num_cards)) + num_cards -= 1 + print(f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n" + f"--->>>{week_days_list[datetime.now().weekday() + 1]}<<<---") + else: + print('too many cards, you probably need to see a fortune teller') + except ValueError: + print("it seems that tomorrow......\n you will learn how letters differ from numbers") + +if __name__ == '__main__': + Cards() +x = Cards() diff --git a/HW#5 Advanced classes/Fortune.py b/HW#5 Advanced classes/Fortune.py new file mode 100644 index 0000000..704ed95 --- /dev/null +++ b/HW#5 Advanced classes/Fortune.py @@ -0,0 +1,18 @@ +from Cards import Cards as game + +res = 'Friend, do not believe in delusions,\n we ourselves are the creators of our destiny' +def few_questions(): + print('Hello friend, I heard you are looking for a seer?') + if input('y/n ??? \n >---') == 'y': + print('Do you believe in fortune telling?') + if input('y/n ??? \n >---') == 'y': + print('Then you are in luck,\n' + 'because I know how to predict fate on cards') + game.magic_cards() + print ('I hope you understand my ' + res) + else: + print("I'm happy for you my " + res) + else: + print("That's good my " + res) + +few_questions() \ No newline at end of file From 4c3e669d50bf14cd11f6d706b832ec9fe1fb624a Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Sat, 18 Mar 2023 15:31:19 +0200 Subject: [PATCH 14/18] HW#8 Lecture10 --- HW#8 Lecture#10/.idea/.gitignore | 3 + HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml | 10 + .../inspectionProfiles/profiles_settings.xml | 6 + HW#8 Lecture#10/.idea/misc.xml | 4 + HW#8 Lecture#10/.idea/modules.xml | 8 + HW#8 Lecture#10/.idea/vcs.xml | 6 + HW#8 Lecture#10/CardsExtendet.py | 209 ++++++++++++++++++ HW#8 Lecture#10/DeckFile | 1 + HW#8 Lecture#10/DepWithOneYear.py | 78 +++++++ HW#8 Lecture#10/DepositArgs.txt | 15 ++ HW#8 Lecture#10/small | Bin 0 -> 16384 bytes 11 files changed, 340 insertions(+) create mode 100644 HW#8 Lecture#10/.idea/.gitignore create mode 100644 HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml create mode 100644 HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 HW#8 Lecture#10/.idea/misc.xml create mode 100644 HW#8 Lecture#10/.idea/modules.xml create mode 100644 HW#8 Lecture#10/.idea/vcs.xml create mode 100644 HW#8 Lecture#10/CardsExtendet.py create mode 100644 HW#8 Lecture#10/DeckFile create mode 100755 HW#8 Lecture#10/DepWithOneYear.py create mode 100644 HW#8 Lecture#10/DepositArgs.txt create mode 100644 HW#8 Lecture#10/small diff --git a/HW#8 Lecture#10/.idea/.gitignore b/HW#8 Lecture#10/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/HW#8 Lecture#10/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml b/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/HW#8 Lecture#10/.idea/HW#8 Lecture#10.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml b/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/HW#8 Lecture#10/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HW#8 Lecture#10/.idea/misc.xml b/HW#8 Lecture#10/.idea/misc.xml new file mode 100644 index 0000000..5bb15ec --- /dev/null +++ b/HW#8 Lecture#10/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW#8 Lecture#10/.idea/modules.xml b/HW#8 Lecture#10/.idea/modules.xml new file mode 100644 index 0000000..ae38987 --- /dev/null +++ b/HW#8 Lecture#10/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW#8 Lecture#10/.idea/vcs.xml b/HW#8 Lecture#10/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HW#8 Lecture#10/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW#8 Lecture#10/CardsExtendet.py b/HW#8 Lecture#10/CardsExtendet.py new file mode 100644 index 0000000..006da1e --- /dev/null +++ b/HW#8 Lecture#10/CardsExtendet.py @@ -0,0 +1,209 @@ +import random +import shelve + +class CardDeck(): + LOW_CARDS = list(range(2, 11)) + HI_CARDS = list('JQKA') + SUITS = ['\u2660', '\u2665', '\u2666', '\u2663'] + + def __init__(self): + self.suits = self.SUITS + self.ranks = self.LOW_CARDS + self.HI_CARDS + self.shufle_count = 0 + self.deck = self.create_deck() + + def __repr__(self): + return f'{self.deck}' + + def create_deck(self): + deck = [] + deck_list = [(str(i), j) for i in self.ranks for j in self.suits] + for i in deck_list: + deck.append("".join(i)) + return deck + + def generate_card(self, n=1): + # Метод що вибирає мінімум одну рандомну карту з колоди + cards_list = [] + for i in range(n): + cards_list.append(random.choice(self.deck)) + return cards_list + + def shuffle(self): + random.shuffle(self.deck) + self.shufle_count += 1 + + def __len__(self): + return len(self.deck) + + def __getitem__(self, out_card): + if isinstance(out_card, int): + if out_card < len(self.deck): + return self.deck.pop(out_card) + else: + print('Колода менша за ваші амбіції') + else: + raise TypeError('Потрібно вказати номер карти') + + def __add__(self, add_card): + if isinstance(add_card, list): + return self.deck + list(add_card) + else: + print('додати можна лише список') + + def __sub__(self, out_cards): + if isinstance(out_cards, list): + for i in out_cards: + if self.__contains__(i): + self.deck.remove(i) + + else: + print(f'Карта {i} мабуть десь в рукаві') + return self.deck + else: + print('потрібен список карт') + + def __contains__(self, card): + return card in self.deck + + def __eq__(self, other): + return sorted(self.deck) < sorted(other.deck) + + def __gt__(self, other): + return sorted(self.deck) < sorted(other.deck) + + def __lt__(self, other): + return sorted(self.deck) > sorted(other.deck) + + def magic_cards(self): + from datetime import datetime + print(f"Pick from one to four cards from the deck and I'll tell you what tomorrow should be. \n" + f"How many cards will you get?\n -->") + num_cards = input() + try: + int(num_cards) + if 0 < int(num_cards) < 5: + week_days_list = ['monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + get_cards = self.generate_card(int(num_cards)) + num_cards -= 1 + print( + f"You got the following cards : \n {' '.join(get_cards)}\nand tomorrow...... \nshould be.........\n" + f"--->>>{week_days_list[datetime.now().weekday()]}<<<---") + else: + print('too many cards you probably need to see a fortune teller') + except ValueError: + print("it seems that tomorrow......\n you will learn how letters differ from numbers") + + def __bool__(self): + return bool(self.deck) > 0 and self.shufle_count > 0 + + def deck_write(self, deck_name, format='shelve'): + if format == 'shelve': + with shelve.open(str(deck_name)) as file: + file[deck_name] = self.deck + print(f'Deck {deck_name} is saved in shelve format') + elif format == 'txt': + with open('DeckFile', 'w') as file: + file.write(f'{self.deck}') + print(f'Deck {deck_name} is saved in txt format') + else: + print('Write format can be only shelve or txt') + + + + @classmethod + def deck_load(self, deck_name, format='shelve'): + if format == 'shelve': + with shelve.open(str(deck_name)) as file: + print(file[deck_name]) + return file[deck_name] + elif format == 'txt': + with open('DeckFile', 'r') as file: + print(file.read()) + return file.read() + else: + print('Format can be only shelve or txt') + + +class SmallDeck(CardDeck): + LOW_CARDS = list(range(6, 11)) + + def __init__(self): + super().__init__() + + +class ClassicDeck(CardDeck): + def __init__(self): + super().__init__() + + +if __name__ == '__main__': + x = ClassicDeck() + y = ClassicDeck() + s = SmallDeck() + n = ['2♠', '2♦', '3♠'] + n2 = ['2♠'] + + # #для перевірки shuffle() + # print(x) + # x.shuffle() + # print(x) + + # #для перевірки __len__() + # print(len(x)) + + # #для перевірки __getitem__() + # print(x[2]) + # print(x[55]) + + # #для перевірки __add__ + # print (x + n) + + # #для перевірки __sub__() + # print(x-n) + # x-n2 + + # #для перевірки __contains__() + # print(x) + # n = '2♠' + # print(n) + # print(n in x) + + # # для перевірки __eq__() + # y.shuffle() + # print(x) + # print(y) + # print (x == y) + # print(x) + # print(s) + # print (x == s) + + # #для перевірки __gt__() та __lt__ + # print(x < s) + # print(x > s) + + # #для перевірки __bool__ + # print(bool(x)) + # x.shuffle() + # print(bool(x)) + + # #ітерація колоди + # i = iter(x) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(next(i)) + # print(type(x)) + ## наскільки я зрозумів ітератор працює завдяки наякності метода __getitem__() що дозволяє переберати елементи. + + #перевірка запису в форматі txt + x.deck_write('classic', 'txt') + x.deck_load('classic', 'txt') + + # # перевірка запису в форматі shalve + # s.deck_write('small') + # s.deck_load('small') + + + diff --git a/HW#8 Lecture#10/DeckFile b/HW#8 Lecture#10/DeckFile new file mode 100644 index 0000000..e08d98b --- /dev/null +++ b/HW#8 Lecture#10/DeckFile @@ -0,0 +1 @@ +['2♠', '2♥', '2♦', '2♣', '3♠', '3♥', '3♦', '3♣', '4♠', '4♥', '4♦', '4♣', '5♠', '5♥', '5♦', '5♣', '6♠', '6♥', '6♦', '6♣', '7♠', '7♥', '7♦', '7♣', '8♠', '8♥', '8♦', '8♣', '9♠', '9♥', '9♦', '9♣', '10♠', '10♥', '10♦', '10♣', 'J♠', 'J♥', 'J♦', 'J♣', 'Q♠', 'Q♥', 'Q♦', 'Q♣', 'K♠', 'K♥', 'K♦', 'K♣', 'A♠', 'A♥', 'A♦', 'A♣'] \ No newline at end of file diff --git a/HW#8 Lecture#10/DepWithOneYear.py b/HW#8 Lecture#10/DepWithOneYear.py new file mode 100755 index 0000000..d67ba12 --- /dev/null +++ b/HW#8 Lecture#10/DepWithOneYear.py @@ -0,0 +1,78 @@ + +#!/usr/bin/env python3 + + +USAGE = """USAGE: {script} initial_sum percent fixed_period set_period + +\tCalculate deposit yield. See script source for more details. +""" +USAGE = USAGE.strip() + + +def deposit(initial_sum, percent, fixed_period, set_period): + """Calculate deposit yield.""" + per = percent / 100 + one_year = (1 + per) + growth_five = one_year ** 5 + growth_ten = one_year ** 10 + growth_set = one_year ** (set_period / fixed_period) + res = f"One month yield: {'%.2f' % (initial_sum * one_year / 12)}\n" \ + f"One year yield: {'%.2f' % (initial_sum * one_year)}\n" \ + f"Five year yield: {'%.2f' % (initial_sum * growth_five)}\n" \ + f"Ten year yield: {'%.2f' % (initial_sum * growth_ten)}\n" \ + f"Set period yield: {'%.2f' % (initial_sum * growth_set)}" + write_deposit(res) + + + return res + +def read_deposit(): + initial_sum, percent, fixed_period, set_period = None, None, None, None + try: + with open('DepositArgs.txt', 'r', encoding='cp1251') as file: + lines = file.readlines() + + try: + initial_sum = float(lines[0].split('=')[1]) + percent = float(lines[1].split('=')[1]) + fixed_period = float(lines[2].split('=')[1]) + set_period = float(lines[3].split('=')[1]) + except: + print('Something goes wrong, check file data') + res = deposit(initial_sum, percent, fixed_period, set_period) + write_deposit(res) + print(res) + return res + except FileNotFoundError: + print('File is missing') + +def write_deposit(res): + with open('DepositArgs.txt', 'a')as file: + file.write(f'\n{res}') + + + + +def main(args): + """Gets called when run as a script.""" + if len(args) != 4 + 1: + exit(USAGE.format(script=args[0])) + + args = args[1:] + initial_sum, percent, fixed_period, set_period = map(float, args) + + # same as + # initial_sum = float(args[0]) + # percent = float(args[1]) + # ... + + res = deposit(initial_sum, percent, fixed_period, set_period) + print(res) + +read_deposit() + +# if __name__ == '__main__': +# import sys +# +# main(sys.argv) + diff --git a/HW#8 Lecture#10/DepositArgs.txt b/HW#8 Lecture#10/DepositArgs.txt new file mode 100644 index 0000000..09b9887 --- /dev/null +++ b/HW#8 Lecture#10/DepositArgs.txt @@ -0,0 +1,15 @@ +initial_sum=5000 +percent=9 +fixed_period=1 +set_period=3 + +One month yield: 454.17 +One year yield: 5450.00 +Five year yield: 7693.12 +Ten year yield: 11836.82 +Set period yield: 6475.15 +One month yield: 454.17 +One year yield: 5450.00 +Five year yield: 7693.12 +Ten year yield: 11836.82 +Set period yield: 6475.15 \ No newline at end of file diff --git a/HW#8 Lecture#10/small b/HW#8 Lecture#10/small new file mode 100644 index 0000000000000000000000000000000000000000..939abeaeefd2d3c4e94b6127f699779d674c2dde GIT binary patch literal 16384 zcmeH~y-LGi7)GPELlL3i4LCYU|FpX4s*{sAIEZ$#iYN|l9dr|?I@C!h_DbBn2fYnJ zpC@l98H$^f*dsKj_B4>5eBVp^{(P{URFfoq2xcYY$lUfJNxlLcDL?@VP=Epypa2CZ zKmiI+fC3aKVu6+HqG5!f107s|b-+4c9k36W1Iz*D0CRvjz#L!>FbDqG99W25om^%d zG~&tqT(Hs%UM&V6Ta*8fSARdwOMmNc(z|#)s?dQB`TbFp_3-(2(Y`)E?%vho>dQh^ zGo&cj&vmlzin#Asx2#*%ZN32OAzy>}Fq`Y)cImKj+BrE(YVr9?LXYob;${baDts+C)jO;6YK;#L9Se{r81>#O6in7cQ?)ze6HYg1-t!lf}LO|*zJWA z>;yZ(ZYP{zC)f$YerL_Uo4UFQ<@`;U^(fQ23G9R^?u7Ap<_QHTKmiI+fC3bt00k)U H2L*lr^>z`? literal 0 HcmV?d00001 From af73de990ab974aa35f0dee3f0efff16754dc598 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Sat, 18 Mar 2023 20:47:32 +0200 Subject: [PATCH 15/18] add HW#9Lecture#12 --- HW#9Lecture#12/.idea/.gitignore | 3 ++ HW#9Lecture#12/.idea/HW#9.iml | 10 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ HW#9Lecture#12/.idea/misc.xml | 4 ++ HW#9Lecture#12/.idea/modules.xml | 8 +++ HW#9Lecture#12/.idea/vcs.xml | 6 +++ HW#9Lecture#12/first.py | 34 ++++++++++++ .../red-Arrow/database/employees.json | 1 + HW#9Lecture#12/red-Arrow/helpers/__init__.py | 2 + .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 216 bytes .../decorators_helpers.cpython-310.pyc | Bin 0 -> 1012 bytes .../employee_helpers.cpython-310.pyc | Bin 0 -> 1510 bytes .../system_helpers.cpython-310.pyc | Bin 0 -> 660 bytes .../red-Arrow/helpers/decorators_helpers.py | 27 ++++++++++ .../red-Arrow/helpers/employee_helpers.py | 51 ++++++++++++++++++ .../red-Arrow/helpers/system_helpers.py | 17 ++++++ HW#9Lecture#12/red-Arrow/main.py | 21 ++++++++ 17 files changed, 190 insertions(+) create mode 100644 HW#9Lecture#12/.idea/.gitignore create mode 100644 HW#9Lecture#12/.idea/HW#9.iml create mode 100644 HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 HW#9Lecture#12/.idea/misc.xml create mode 100644 HW#9Lecture#12/.idea/modules.xml create mode 100644 HW#9Lecture#12/.idea/vcs.xml create mode 100644 HW#9Lecture#12/first.py create mode 100644 HW#9Lecture#12/red-Arrow/database/employees.json create mode 100644 HW#9Lecture#12/red-Arrow/helpers/__init__.py create mode 100644 HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc create mode 100644 HW#9Lecture#12/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc create mode 100644 HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc create mode 100644 HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc create mode 100644 HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py create mode 100644 HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py create mode 100644 HW#9Lecture#12/red-Arrow/helpers/system_helpers.py create mode 100644 HW#9Lecture#12/red-Arrow/main.py diff --git a/HW#9Lecture#12/.idea/.gitignore b/HW#9Lecture#12/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/HW#9Lecture#12/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HW#9Lecture#12/.idea/HW#9.iml b/HW#9Lecture#12/.idea/HW#9.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/HW#9Lecture#12/.idea/HW#9.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml b/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/HW#9Lecture#12/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HW#9Lecture#12/.idea/misc.xml b/HW#9Lecture#12/.idea/misc.xml new file mode 100644 index 0000000..4733bd8 --- /dev/null +++ b/HW#9Lecture#12/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW#9Lecture#12/.idea/modules.xml b/HW#9Lecture#12/.idea/modules.xml new file mode 100644 index 0000000..de1b1d1 --- /dev/null +++ b/HW#9Lecture#12/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW#9Lecture#12/.idea/vcs.xml b/HW#9Lecture#12/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HW#9Lecture#12/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW#9Lecture#12/first.py b/HW#9Lecture#12/first.py new file mode 100644 index 0000000..0c779fb --- /dev/null +++ b/HW#9Lecture#12/first.py @@ -0,0 +1,34 @@ +import time + + +def base_decorator(j): + def iterator(func): + def wrapper(x, y): + print(j) + start_time = time.time() + func(x, y) + print(time.time() - start_time) + + return wrapper + return iterator + + +@base_decorator(5) +def suma(x, y): + print(x + y) + + + +@base_decorator(123) +def minus(x, y): + print(x - y) + + +minus(8, 2) +suma(8, 2) + + +class A: + @staticmethod + def hello(): + print("hello") diff --git a/HW#9Lecture#12/red-Arrow/database/employees.json b/HW#9Lecture#12/red-Arrow/database/employees.json new file mode 100644 index 0000000..ec5cd81 --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/database/employees.json @@ -0,0 +1 @@ +[{"id": "1", "first_name": "qwe", "last_name": "qwe", "email": "qwe@qwe.qwe", "phone": "+380681111992"}] \ No newline at end of file diff --git a/HW#9Lecture#12/red-Arrow/helpers/__init__.py b/HW#9Lecture#12/red-Arrow/helpers/__init__.py new file mode 100644 index 0000000..33afd8d --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/helpers/__init__.py @@ -0,0 +1,2 @@ +from .employee_helpers import * +from .system_helpers import * \ No newline at end of file diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..391fd62877da1d36a0cb385bfeb8939675fb3f00 GIT binary patch literal 216 zcmd1j<>g`k0`{j2DYiiRF^GcQUzwU3pOKnVkXlrHi?6t{xFj_f#$U-$#0t~^CVn~SXXNLm>ZhcZ z=_lux78R!!>laj(WaQ`R2BoIxIu;e>m+Ke7Sx^)8Z@bQd7`^1Mkh7d4G8OezR$%a+lFMgKhECVeFSVtS-7^O%k<5 zN-zNz>=P4?aA^loI$|}i1LRsR6YnnM@&OrN*(nGR&PDkQa-ev()$x|mv>SVk{j# z**)xsGUhTFhOrcUBy}&%G#9CUN^7$7cXyK;Z_Oz@HHf7yyaCEY*SrG06kcR17BDU# zEMPK)qI8-iohh4t2zqHh3dR{q8NAL=rFbZ^peuFzBvi7af_KNyUIrM6=dTdcQP7Lx zL4+z0Q76Svr>NSCtHxkltdB4pkl##I8CYf5ge~wL-!sbw))IavpB;rZdKZ%e_#YdPX-3EWJc|TK{D;=V?jCp;scWj(| zu$mG_Nmuv&B=o{z#P?osAqkQq-Y!L;d6hK}*J;B$Mw#K`JyP@#Ou4H$ni1P!+5wxX zT1r0ntCVcQZItk#sbh=X#IurVz2-;3Dyde@v54&9D$@pBH&m4O`>Dv{=)ka2hHDvo F|2OVt;;{e# literal 0 HcmV?d00001 diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/employee_helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..204aafa7aced634dd61392c47be0707f0b55d109 GIT binary patch literal 1510 zcmZ`(-HOvd6rP!6(lnc0*Hsq50Yd^4vxGv7JiNx8Wh5g4EOuK39b`GSk};ltuSO!Ewk zAcE$kphH@)A)~lvxmWl@zu-eoiS#8Gp71}AC0){CAh-xVkYPu3LUt;xJpo-WvATFmLbycNq)@|INlHrad?k zvZvL=LLIv+LZ%K^(50v`oA~FmSo|!{S6S3%2e!>Nn1F^fKKX4?|A#&Yn`qhhGZ-9j_Dgfmx)ul&U2CmCQhj{aY~(uzo6>{YaulsO4`!V&@@DV-?;0Kd=R5^(!x_tI*^=qoj{Vg?*n5I4 zF$3NnvCys#bB6-Gy7z5Pn>= eYnpJcD8($7_pljUuWXZT$~*?D2{*zh-uMMV$w)N- literal 0 HcmV?d00001 diff --git a/HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc b/HW#9Lecture#12/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f4cabe6f0cd4d82e5a2d18c0a461f235eb6e2680 GIT binary patch literal 660 zcmYk3y>8S%5XWcM>pSPTOM#H+fyM=K4MGSMAwiRd0_hsdcsGfW@79`Kb2{nLkUWU5 zq~vwBrGiID#f)=78EZ%L<@tMmc8kRf*na&5^8*2XOY+bXPTukH&)69-*uoNwGRX}r z(P*pAl}XLyMlTbCpCO~#owFaK=V1}<6p1~yvL|(bp-(jwSytq!yd1YBfSTN zooq_ZZl9VeR9`D^3%lxCx3$)veDiJ{k@7TZ*V%Q{V8MG>hq?x z@kq9mZR5jFphql!`>D8eD_d-PYMSD-C-3Nk>5Gddl&sd&zWDg%`KyAgdHJ5mZHi0V zc9wkMw?5cac}P#XZCqT~P>M_`DsoGov76yBW~h-CoJ1|Xn(_WO85Fc5lGhvrxCRD* z14Gy&LQn@pDkOv6A>&DQYDjm9bUB&`C<7xX62cKT`Seb2Qgw{Rkf=~9z0~xp&c}2^ zO|T?im}@$gw)}oNl9~C)sacmobOd$h=3~=W-)$M(cvpewr98pe;h7^n;R0_Jz58o7 ebr{PJw#mCRuFT%7oatNpR>1fPy9~1A@$?@JOP2Wn literal 0 HcmV?d00001 diff --git a/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py new file mode 100644 index 0000000..cfc6af2 --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/helpers/decorators_helpers.py @@ -0,0 +1,27 @@ + +def is_email_valid(func): + def wrapper(x, email, y, a, z): + if "@" in email: + if "." in email.split("@")[1]: + func(x, email, y, a, z) + else: + print("Email invalid without dot!!!!") + else: + print("Email invalid without @ !!!!") + return wrapper + + +def is_phone_valid(func): + def wrapper(x, y, a, z, phone): + if len(phone) == 13: + if phone[0] == '+': + func(x, y, a, z, phone) + else: + print('Phone number is wrong. It must start with +') + else: + print('Wrong phone number length. It must have 12 digits') + return wrapper + + + + diff --git a/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py new file mode 100644 index 0000000..58c2df5 --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/helpers/employee_helpers.py @@ -0,0 +1,51 @@ +from .system_helpers import save_to_file, get_file_data +from .decorators_helpers import is_email_valid, is_phone_valid + + +@is_email_valid +@is_phone_valid +def save(id, email, first_name, last_name, phone): + new_employee = { + "id": id, + "first_name": first_name, + "last_name": last_name, + "email": email, + "phone": phone, + } + save_to_file(new_employee) + + +def get_all_employers(): + employees = get_file_data() + for employee in employees: + print(employee["id"]) + print(employee["email"]) + print(employee["first_name"]) + print(employee["last_name"]) + print(employee["phone"]) + + +def get_employee_by_email(email): + employees = get_file_data() + for employee in employees: + if employee["email"] == email: + print(employee["id"]) + print(employee["email"]) + print(employee["first_name"]) + print(employee["last_name"]) + print(employee["phone"]) + + +def update_employee(id): + employers = get_file_data() + if isinstance(employers, list): + for employee in employers: + if employee['id'] == id: + employee["email"] = input("Employee email: ") + employee["first_name"] = input("Employee first name: ") + employee["last_name"] = input("Employee last Name: ") + employee["phone"] = input("Employee phone: ") + else: + print('No employee with this id') + else: + print('No employers to update') \ No newline at end of file diff --git a/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py b/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py new file mode 100644 index 0000000..377b96c --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/helpers/system_helpers.py @@ -0,0 +1,17 @@ +import json + + +def get_file_data(): + file = open("database/employees.json", "r") + data_list = json.loads(file.read()) + file.close() + return data_list + + +def save_to_file(data: dict): + data_list = get_file_data() + data_list.append(data) + file = open("database/employees.json", "w") + data_in_json = json.dumps(data_list) + file.write(data_in_json) + file.close() \ No newline at end of file diff --git a/HW#9Lecture#12/red-Arrow/main.py b/HW#9Lecture#12/red-Arrow/main.py new file mode 100644 index 0000000..91bd5d1 --- /dev/null +++ b/HW#9Lecture#12/red-Arrow/main.py @@ -0,0 +1,21 @@ +from helpers import save, get_all_employers, get_employee_by_email, update_employee + + +while True: + print("1.Add new Employee\n2.Get all Employees\n3.Get employee by email\n4.Update employee") + flag = input("Choose menu item: ") + if flag == "1": + id = input('id: ') + email = input("Employee email: ") + first_name = input("Employee first name: ") + last_name = input("Employee last name: ") + phone_number = input("Employee phone number: ") + save(id, email, first_name, last_name, phone_number) + elif flag == "2": + get_all_employers() + elif flag == "3": + email_to_find = input("Type email of employee which you want to find: ") + get_employee_by_email(email_to_find) + elif flag == "4": + id_to_update = input("Type employee id to update: ") + update_employee(id_to_update) From 0d82ae1db70a9b6a03f1a94fe1f464122a71b1e1 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Sun, 19 Mar 2023 13:59:10 +0200 Subject: [PATCH 16/18] Add HW#10 Lecture #13 --- HW#10 Lecture#13/.idea/.gitignore | 3 + HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml | 10 ++ .../inspectionProfiles/profiles_settings.xml | 6 + HW#10 Lecture#13/.idea/misc.xml | 4 + HW#10 Lecture#13/.idea/modules.xml | 8 ++ HW#10 Lecture#13/.idea/vcs.xml | 6 + .../red-Arrow/database/employees.json | 1 + .../red-Arrow/database/plants.json | 1 + .../red-Arrow/database/sales_departament.json | 1 + .../red-Arrow/database/salons.json | 1 + .../red-Arrow/helpers/__init__.py | 2 + .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 207 bytes .../decorators_helpers.cpython-310.pyc | Bin 0 -> 588 bytes .../__pycache__/helpers.cpython-310.pyc | Bin 0 -> 2920 bytes .../system_helpers.cpython-310.pyc | Bin 0 -> 1231 bytes .../red-Arrow/helpers/decorators_helpers.py | 12 ++ HW#10 Lecture#13/red-Arrow/helpers/helpers.py | 110 ++++++++++++++++++ .../red-Arrow/helpers/system_helpers.py | 44 +++++++ HW#10 Lecture#13/red-Arrow/main.py | 65 +++++++++++ 19 files changed, 274 insertions(+) create mode 100644 HW#10 Lecture#13/.idea/.gitignore create mode 100644 HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml create mode 100644 HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 HW#10 Lecture#13/.idea/misc.xml create mode 100644 HW#10 Lecture#13/.idea/modules.xml create mode 100644 HW#10 Lecture#13/.idea/vcs.xml create mode 100644 HW#10 Lecture#13/red-Arrow/database/employees.json create mode 100644 HW#10 Lecture#13/red-Arrow/database/plants.json create mode 100644 HW#10 Lecture#13/red-Arrow/database/sales_departament.json create mode 100644 HW#10 Lecture#13/red-Arrow/database/salons.json create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/__init__.py create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/decorators_helpers.py create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/helpers.py create mode 100644 HW#10 Lecture#13/red-Arrow/helpers/system_helpers.py create mode 100644 HW#10 Lecture#13/red-Arrow/main.py diff --git a/HW#10 Lecture#13/.idea/.gitignore b/HW#10 Lecture#13/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/HW#10 Lecture#13/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml b/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/HW#10 Lecture#13/.idea/HW#10 Lecture#13.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml b/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/HW#10 Lecture#13/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HW#10 Lecture#13/.idea/misc.xml b/HW#10 Lecture#13/.idea/misc.xml new file mode 100644 index 0000000..97b8f8e --- /dev/null +++ b/HW#10 Lecture#13/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW#10 Lecture#13/.idea/modules.xml b/HW#10 Lecture#13/.idea/modules.xml new file mode 100644 index 0000000..9bfe4fa --- /dev/null +++ b/HW#10 Lecture#13/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW#10 Lecture#13/.idea/vcs.xml b/HW#10 Lecture#13/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HW#10 Lecture#13/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/database/employees.json b/HW#10 Lecture#13/red-Arrow/database/employees.json new file mode 100644 index 0000000..fb78eb6 --- /dev/null +++ b/HW#10 Lecture#13/red-Arrow/database/employees.json @@ -0,0 +1 @@ +[{"first_name": "test", "last_name": "test", "email": "test@test.com", "phone": "+380971750340", "work_id": "1", "type": "plant", "id": 1}, {"first_name": "test", "last_name": "test", "email": "turupru8@gmail.com", "phone": "+380971750340", "work_id": "1", "type": "plant", "id": 2}, {"first_name": "Roman", "last_name": "Rostotskyi", "email": "roman.rostotskyi@vnv.solutions", "phone": "+380685553001", "work_id": 1, "type": "salon", "id": 3}] \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/database/plants.json b/HW#10 Lecture#13/red-Arrow/database/plants.json new file mode 100644 index 0000000..049ac4a --- /dev/null +++ b/HW#10 Lecture#13/red-Arrow/database/plants.json @@ -0,0 +1 @@ +[{"name": "Azovstal", "address": "Ukraine, Mariupol, st. Address", "id": 1}, {"name": "Silmash", "address": "Ukraine, Ivano-Frankivsk, st. Address 2", "id": 2}] \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/database/sales_departament.json b/HW#10 Lecture#13/red-Arrow/database/sales_departament.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/HW#10 Lecture#13/red-Arrow/database/sales_departament.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/database/salons.json b/HW#10 Lecture#13/red-Arrow/database/salons.json new file mode 100644 index 0000000..dd891c7 --- /dev/null +++ b/HW#10 Lecture#13/red-Arrow/database/salons.json @@ -0,0 +1 @@ +[{"name": "Ford", "address": "Ukraine, Lviv, Doroshenka st.", "id": 1}, {"name": "Mersedes", "address": "Ukraine, Bakhmut, Geroyiv UPA st.", "id": 2}] \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__init__.py b/HW#10 Lecture#13/red-Arrow/helpers/__init__.py new file mode 100644 index 0000000..a040fbd --- /dev/null +++ b/HW#10 Lecture#13/red-Arrow/helpers/__init__.py @@ -0,0 +1,2 @@ +from .helpers import * +from .system_helpers import * \ No newline at end of file diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..443c4b99adbfa35fbce1bd386418562abeeb2649 GIT binary patch literal 207 zcmd1j<>g`kf@D>;6cZr*7{oyaOhAqU5EqL8i4=wu#vFza2+atjnSvQKnO`yjr8F6D zF>3i~GTma&NX;ooEh@gnS6o?KlA0S2<*#HYVg;%L6TckvGxBp&^;1&I^po>Ti;7c= z^$RLXGV=3ugHls;9gB+c%k_)kET{?k@$s2?nI-Y@dIgoYIBatBQ%ZAE?Ld|nvj7PW H1|CKLgfBDa literal 0 HcmV?d00001 diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/decorators_helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d39cb240401c728c61db72a61f01e05cdd31610f GIT binary patch literal 588 zcmZuu%}T>S5T4m4u}JDKh=M=$7{TTRiqwN39&*r|mlCs)2GVZWO{lS43ePYL8>%-1BJ-Fz{S>DVBqd3oabDWhuF)W*0l*c5~ z{r}UQrp*S-xT?sr(zu1p24&zGH?{2yP7KBdrv~o~Ca-9m`{5vYh0m+7C;Dl~(@~g+ zp;V~~iwRvhIK58!>A93*9Lgo?rFoG`Mf60-xD--#7ok=$F)L#k7nHaEs_dHTxP?3D zGoMY5GS#g{=~nM*wR4fgxjJhtYUCR6111}ENV|_JAng|AIvKO}w}IWCa>)4T)a53D cD8TCcF0}2wQB_@U_XQv3>6!gwWs80M0v9WYZvX%Q literal 0 HcmV?d00001 diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..79412e1c2b472ba12bd24810f15c54bdd5e4104d GIT binary patch literal 2920 zcma)8&u$YGh5(h+oQV<7ZRpNk@s&yC7K(?&CW@Zga zUHo3P ztUu^u`myox4T}B^LRf;uR*!A59^c|Ud&_22$784GZn?~ouCRsk(%NTRo^XZt(%LGC zlJKE@Q5F^GvRD#T=!&R`0D4K(#WHkNtcX?Uns`U7K?mZLSck5Q)8Y*Dve*!3p;yG_ zeXDuyPX>3Ic2?ElGucU#&Z8)nS?#e*jnxrh8fGh|F^+Uv^k}jyh;&Ex!YJ-M3*$(1 zJq%PlB^Xq0q38z0h>iHj8rdUfuGJJ?S8GAlh#)RRsmGAG>`$fMKb;lohNmh27UWJgMU`B$Cv518VZxLHy@lp^mG zxunV@C{}6-BCGc0bF3r(^}tefR35ck+euHhc7`g7TDOKuC+fBswjM`m2UA5|-MahW z!qqE{d$OAjmAr8ET1!cB>070e=dEoS52VtCzC75;90JhA$a)!qyPOrTcNF+)1(jV2 zMDY+=92A3J3L^z!_SqgAvG1*)KHnoOx!@bt6Ry5UnXvbPuW)W!uw7$]#H+I?B z6=N?MyK3y3v4fk|Q!nKshIxvZ)Y}S7wlW@x-O_Ce^^Jx>bGLej0@a{Ep^C8GUAl*O zHQIR%0li!Lf#QXBLVUOU0AXuH0^bDwu1C?s2L+*ND_U{pM*YDsRkU(ctx{Ea92%uF zzlf5FQ7#D1%o`3s0=WiTuS59EXVsaPzX-UZrY_3lA%09y{uv)*l&z5klrQeF6nGQL z`-}lu*!Gm|Oxf;~?M>OG+u3EegQKf7R}fY12f&cEs$ z8oLzk;vu?GxrK5_zhXmy`mgvNM`FSvC!4@-AMngEDXA0+p`_MFYm=Nah{JxGCmdD7 zFj&EPDAj<-%9L76kNKcgOhPqHH_-EtSXf~JQx{-#Q6|p}M=zs#hNHn^j^@}lowj-( ze;s?31I;rpcO6-kmN4&NP_QcR^)-gjv~6>QL8aH~V|*^8(jhHthDvKQR61*@biAD= z^clPDj@>32&-7@dNj&dR9&Phy8>6WYNf2ol!lyn#YZD-RMqL+!ka@X3nQQd? z#0Ck|k|S}SM*Eb+6^Q@2_VW|6VN+v{Npd9cwnLf3uf}VJyF*uxr|E YYgUzUyTbec?~-5hUBBe}kSJCEKgZ`r)&Kwi literal 0 HcmV?d00001 diff --git a/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc b/HW#10 Lecture#13/red-Arrow/helpers/__pycache__/system_helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..13ad4dbc9106f86a47d728b090a074851c2935cc GIT binary patch literal 1231 zcmZ`&L2uJA6t*3wOG{e13APD=lnQaE1nUMjG$GKmi38eYpo(3pQoCzdnpC#Cs8Ppd z`yuU-zvL^Y{R1?C;JvgRD+pKqlIQoFSAXBQh3unS7b$EB=*{Gv7`oS4Gs zbkbCRHA~k7e+Ej6LlKKCqWvTUSN7M=)&rCH+84vdNoZQ1+B)p$#@puOo$cVA?3kgFk9S@) zloZe2z#-B`Peuc&bVHA{k^R;@+!~B*`9zu)wrpWXR8(&QFj}IVR%n6xyztYfo6LuZ z{Zgxt>@a}Ez%4hTeSsj`2GM9P8q1z!el8jc=8W0I89P&urb*)JoP2&uEH-hcAYc>B zbcEt9#fxYz-m9Da|B9C?w35QVR$oyrz83(jD~A1nwr;9IBNduk6%p Date: Fri, 24 Mar 2023 18:34:38 +0200 Subject: [PATCH 17/18] Add HW#11 Lecture #14 --- HW#11Lecture#14/.idea/.gitignore | 3 + HW#11Lecture#14/.idea/HW#11Lecture#14.iml | 10 ++ .../inspectionProfiles/profiles_settings.xml | 6 + HW#11Lecture#14/.idea/misc.xml | 4 + HW#11Lecture#14/.idea/modules.xml | 8 + HW#11Lecture#14/.idea/vcs.xml | 6 + .../__pycache__/github.cpython-310.pyc | Bin 0 -> 744 bytes .../__pycache__/writter.cpython-310.pyc | Bin 0 -> 454 bytes HW#11Lecture#14/helpers/github.py | 20 +++ HW#11Lecture#14/helpers/writter.py | 10 ++ HW#11Lecture#14/main.py | 15 ++ HW#11Lecture#14/repositories.csv | 150 ++++++++++++++++++ 12 files changed, 232 insertions(+) create mode 100644 HW#11Lecture#14/.idea/.gitignore create mode 100644 HW#11Lecture#14/.idea/HW#11Lecture#14.iml create mode 100644 HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 HW#11Lecture#14/.idea/misc.xml create mode 100644 HW#11Lecture#14/.idea/modules.xml create mode 100644 HW#11Lecture#14/.idea/vcs.xml create mode 100644 HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc create mode 100644 HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc create mode 100644 HW#11Lecture#14/helpers/github.py create mode 100644 HW#11Lecture#14/helpers/writter.py create mode 100644 HW#11Lecture#14/main.py create mode 100644 HW#11Lecture#14/repositories.csv diff --git a/HW#11Lecture#14/.idea/.gitignore b/HW#11Lecture#14/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/HW#11Lecture#14/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HW#11Lecture#14/.idea/HW#11Lecture#14.iml b/HW#11Lecture#14/.idea/HW#11Lecture#14.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/HW#11Lecture#14/.idea/HW#11Lecture#14.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml b/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/HW#11Lecture#14/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HW#11Lecture#14/.idea/misc.xml b/HW#11Lecture#14/.idea/misc.xml new file mode 100644 index 0000000..b6e0fde --- /dev/null +++ b/HW#11Lecture#14/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW#11Lecture#14/.idea/modules.xml b/HW#11Lecture#14/.idea/modules.xml new file mode 100644 index 0000000..ce30027 --- /dev/null +++ b/HW#11Lecture#14/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW#11Lecture#14/.idea/vcs.xml b/HW#11Lecture#14/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HW#11Lecture#14/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc b/HW#11Lecture#14/helpers/__pycache__/github.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dcc1d6234691cdca7290881d9a2f8680a6cd880e GIT binary patch literal 744 zcmYk4!H&}~5Qc5XNweFQ<$$(Sg3}_T3b9coPKX7>g0u(J3kRf1sB+_>%_@yu+W~cz z-gpcSyGLGz2k?~>7ajm{V4P~DPBgzKlgW(zC92;)BxrwrK9o-wA-}@SzG05MMz@bp zB$2cv)7?s^R5BTTBU2{1jB$-5{Xj;^Z>%JfJiK{p5e6Ln9Nj)Zapamx+K>T}Y(N@1 zAUAZ&8g|LBLo~U1x^zz4=UFCnak?nnvYwyjYL!_KCSPU-w6cX$rU3hDeRh>R)?xu? zqsXTQ)-_mXeY61QJGrVHR1TlSm^T~GLuDwlT2&T)5R>A5{=UhUY6aP*Hbs%0*TyRI zPSzQYp3Q|Va+_UzJQ%-b6u9RHtc9qd=U5jQ=YZ~8&*1UW)McKp(+ z%EzS=()vVb4V4_lp3jv;qEa~Fd;2H$3`(C?@U`X865h!H_VeA)ZKj2>U_!#)Lph|J z_GrQqWQ5nhUc#xlAI5VNekF4^NPyR7_j-o!*Y@%0iX)8}cbhY07%>f5%9* A^8f$< literal 0 HcmV?d00001 diff --git a/HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc b/HW#11Lecture#14/helpers/__pycache__/writter.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6e14bc14579e843e82d61810addeabf94a21c9be GIT binary patch literal 454 zcmYjNu}T9$5Z&3`gd^nC!rH>1a7~T_OA#Ro7Lq1KFd%YfS95T2&)vO*$fb(CzmSx6 zeum$$t(CuE5uA+{nPJ|{o7v$lqr$L3&_0eD;uG_iC)-AmoMV`M1VIGkWIzNJ?3D~a zK#xTH8z-bY1fTw`hB?6KV3+}d#Z5sM^zC2{7M8Sv70hWxF34>-XO>lL$ya0nb6(M9 zt>P;H@*MV2k)tmdVAUfDF~?J!c)!8$y@+*R_OvXN$*j_uH0`08I7p+qdZ>*c%B*S>XS4trE$SuS52du<07@Gg9q*Z?x@Ti(`x!obcp%+C)#a2YMA8+c7@D}(L7o3ijD06w{uWkI>fHc`JY`bZd literal 0 HcmV?d00001 diff --git a/HW#11Lecture#14/helpers/github.py b/HW#11Lecture#14/helpers/github.py new file mode 100644 index 0000000..e4b4aa2 --- /dev/null +++ b/HW#11Lecture#14/helpers/github.py @@ -0,0 +1,20 @@ +import requests +import json + +def get_github_repositories(query, page): + response = requests.get("https://api.github.com/search/repositories?q=" + query + "&page=" + page) + return response.content + + +def json_parser(body): + data = json.loads(body) + repositories = [] + for el in data["items"]: + new_repo = { + "name": el["name"], + "full_name": el["full_name"], + "private": el["private"], + "description": el["description"] + } + repositories.append(new_repo) + return repositories \ No newline at end of file diff --git a/HW#11Lecture#14/helpers/writter.py b/HW#11Lecture#14/helpers/writter.py new file mode 100644 index 0000000..d38fd1a --- /dev/null +++ b/HW#11Lecture#14/helpers/writter.py @@ -0,0 +1,10 @@ +import csv + + +def write(data): + with open('repositories.csv', "a") as f: + writer = csv.writer(f) + for el in data: + row = list(el.values()) + writer.writerow(row) + diff --git a/HW#11Lecture#14/main.py b/HW#11Lecture#14/main.py new file mode 100644 index 0000000..e9a10b9 --- /dev/null +++ b/HW#11Lecture#14/main.py @@ -0,0 +1,15 @@ +import argparse +from helpers.github import get_github_repositories, json_parser +from helpers.writter import write + +parser = argparse.ArgumentParser() + +parser.add_argument("-q", dest="query") +parser.add_argument("-p", dest="page") + +args = parser.parse_args() + +body = get_github_repositories(args.query, args.page) +repositories = json_parser(body) +write(repositories) +print("Done!") diff --git a/HW#11Lecture#14/repositories.csv b/HW#11Lecture#14/repositories.csv new file mode 100644 index 0000000..8c20bfe --- /dev/null +++ b/HW#11Lecture#14/repositories.csv @@ -0,0 +1,150 @@ +django,django/django,False,The Web framework for perfectionists with deadlines. +DjangoBlog,liangliangyy/DjangoBlog,False,🍺基于Django的博客系统 +django-rest-framework,encode/django-rest-framework,False,Web APIs for Django. 🎸 +django-cms,django-cms/django-cms,False,The easy-to-use and developer-friendly enterprise CMS powered by Django +cookiecutter-django,cookiecutter/cookiecutter-django,False,Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. +django-allauth,pennersr/django-allauth,False,"Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication." +django-oscar,django-oscar/django-oscar,False,Domain-driven e-commerce for Django +mezzanine,stephenmcd/mezzanine,False,CMS framework for Django +django-haystack,django-haystack/django-haystack,False,Modular search for Django +django-ex,sclorg/django-ex,False,Django Example +django-extensions,django-extensions/django-extensions,False,This is a repository for collecting global custom management extensions for the Django Framework. +awesome-django,wsvincent/awesome-django,False,A curated list of awesome things related to Django +django-tastypie,django-tastypie/django-tastypie,False,Creating delicious APIs for Django apps since 2010. +django2.0-course,HaddyYang/django2.0-course,False,Django2.0视频教程相关代码(杨仕航) +django-ecommerce,justdjango/django-ecommerce,False,An e-commerce website built with Django +django-shop,awesto/django-shop,False,A Django based shop system +DjangoUeditor,zhangfisher/DjangoUeditor,False,DjangoUeditor +django-sspanel,Ehco1996/django-sspanel,False,用 diango 开发的 shadowsocks 面板 +graphene-django,graphql-python/graphene-django,False,Integrate GraphQL into your Django project. +django-jet,geex-arts/django-jet,False,Modern responsive template for the Django admin interface with improved functionality. We are proud to announce completely new Jet. Please check out Live Demo +django-debug-toolbar,jazzband/django-debug-toolbar,False,A configurable set of panels that display various debug information about the current request/response. +django-filter,carltongibson/django-filter,False,A generic system for filtering Django QuerySets based on user selections +django-ckeditor,django-ckeditor/django-ckeditor,False,Django admin CKEditor integration. +django-taggit,jazzband/django-taggit,False,Simple tagging for django +django-storages,jschneier/django-storages,False,https://django-storages.readthedocs.io/ +channels,django/channels,False,Developer-friendly asynchrony for Django +django-grappelli,sehmaschine/django-grappelli,False,A jazzy skin for the Django Admin-Interface (official repository). +django-DefectDojo,DefectDojo/django-DefectDojo,False,DefectDojo is a DevSecOps and vulnerability management tool. +djangoproject.com,django/djangoproject.com,False,Source code to djangoproject.com +djangorestframework-simplejwt,jazzband/djangorestframework-simplejwt,False,A JSON Web Token authentication plugin for the Django REST Framework. +flask,pallets/flask,False,The Python micro framework for building web applications. +flasky,miguelgrinberg/flasky,False,"Companion code to my O'Reilly book ""Flask Web Development"", second edition." +helloflask,greyli/helloflask,False,"Hello, Flask!" +awesome-flask,humiaozuzu/awesome-flask,False,A curated list of awesome Flask resources and plugins +flask-website,pallets/flask-website,False,"The Flask website, built with Flask!" +flask-admin,flask-admin/flask-admin,False,Simple and extensible administrative interface framework for Flask +flask-restful,flask-restful/flask-restful,False,Simple framework for creating REST APIs +flask-login,maxcountryman/flask-login,False,Flask user session management. +flaskbb,flaskbb/flaskbb,False,A classic Forum Software in Python using Flask. +flask-boilerplate,realpython/flask-boilerplate,False,"Boilerplate template for a Python Flask application with Flask-SQLAlchemy, Flask-WTF, Fabric, Coverage, and Bootstrap" +flask-sqlalchemy,pallets-eco/flask-sqlalchemy,False,Adds SQLAlchemy support to Flask +FlaskIntroduction,jakerieger/FlaskIntroduction,False,Repo for my tutorial on freeCodeCamp.org +discover-flask,realpython/discover-flask,False,Full Stack Web Development with Flask. +cookiecutter-flask,cookiecutter-flask/cookiecutter-flask,False,"A flask template with Bootstrap, asset bundling+minification with webpack, starter templates, and registration/authentication. For use with cookiecutter." +flask,roytuts/flask,False, +Flask-AppBuilder,dpgaspar/Flask-AppBuilder,False,"Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/" +Flask-SocketIO,miguelgrinberg/Flask-SocketIO,False,Socket.IO integration for Flask applications. +flask-bootstrap,mbr/flask-bootstrap,False,Ready-to-use Twitter-bootstrap for use in Flask. +rest-apis-flask-python,tecladocode/rest-apis-flask-python,False,"Projects and e-book for our course, REST APIs with Flask and Python" +flask-restplus,noirbizarre/flask-restplus,False,"Fully featured framework for fast, easy and documented API development with Flask" +FlaskSeries,jimdevops19/FlaskSeries,False,This is the Code from my Flask Series - JimShapedCoding. Each Folder is a checkpoint where we stopped at that particular episode number +flask-base,hack4impact/flask-base,False,"A simple Flask boilerplate app with SQLAlchemy, Redis, User Authentication, and more." +flaskr-tdd,mjhea0/flaskr-tdd,False," Flaskr: Intro to Flask, Test-Driven Development (TDD), and JavaScript" +python-sample-vscode-flask-tutorial,microsoft/python-sample-vscode-flask-tutorial,False,Sample code for the Flask tutorial in the VS Code documentation +flaskSaaS,alectrocute/flaskSaaS,False,"A great starting point to build your SaaS in Flask & Python, with Stripe subscription billing 🚀" +xzceb-flask_eng_fr,ibm-developer-skills-network/xzceb-flask_eng_fr,False,flask_enf_fr +flask-security,mattupstate/flask-security,False,Quick and simple security for Flask applications +flaskex,anfederico/flaskex,False,Simple flask example for quick prototypes and small applications +flask-oauthlib,lepture/flask-oauthlib,False,YOU SHOULD USE https://github.com/lepture/authlib +uwsgi-nginx-flask-docker,tiangolo/uwsgi-nginx-flask-docker,False,Docker image with uWSGI and Nginx for Flask applications in Python running in a single container. Optionally with Alpine Linux. +requests,psf/requests,False,"A simple, yet elegant, HTTP library." +Requests,WordPress/Requests,False,Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries. +requests-html,psf/requests-html,False,Pythonic HTML Parsing for Humans™ +requests-oauthlib,requests/requests-oauthlib,False,OAuthlib support for Python-Requests! +requests-for-research,openai/requests-for-research,False,A living collection of deep learning problems +jsr,mercyblitz/jsr,False,Java Specification Requests +requests,asmcos/requests,False,A golang HTTP client library. Salute to python requests. +request,request/request,False,🏊🏾 Simplified HTTP request client. +read_requests,wangshunping/read_requests,False,python requests 源码阅读,学习更pythonic 的python代码写法。 +cpr,libcpr/cpr,False,"C++ Requests: Curl for People, a spiritual port of Python Requests." +requests-futures,ross/requests-futures,False,Asynchronous Python HTTP Requests for Humans using Futures +robotframework-requests,MarketSquare/robotframework-requests,False,Robot Framework keyword library wrapper for requests +grequests,spyoungtech/grequests,False,Requests + Gevent = <3 +pull-requests,btholt/pull-requests,False,A sample repo for the Intro to Web Dev course for Frontend Masters +reqwest,ded/reqwest,False,browser asynchronous http requests +requests-cache,requests-cache/requests-cache,False,Persistent HTTP cache for python requests +WordPress,WordPress/WordPress,False,"WordPress, Git-ified. This repository is just a mirror of the WordPress subversion repository. Please do not send pull requests. Submit pull requests to https://github.com/WordPress/wordpress-develop and patches to https://core.trac.wordpress.org/ instead." +lazyweb-requests,h5bp/lazyweb-requests,False,Get projects and ideas built by the community +requests3,kennethreitz-archive/requests3,False,"Requests 3.0, for Humans and Machines, alike. 🤖" +semantic-pull-requests,zeke/semantic-pull-requests,False,:robot: Let the robots take care of the semantic versioning +collectd,collectd/collectd,False,The system statistics collection daemon. Please send Pull Requests here! +learn4haskell,kowainik/learn4haskell,False,👩‍🏫 👨‍🏫 Learn Haskell basics in 4 pull requests +HeaderEditor,FirefoxBar/HeaderEditor,False,"Manage browser's requests, include modify the request headers and response headers, redirect requests, cancel requests" +c-ares,c-ares/c-ares,False,A C library for asynchronous DNS requests +requests,wangluozhe/requests,False,用于快速请求HTTP或HTTPS,并支持修改ja3指纹 +vscode-pull-request-github,microsoft/vscode-pull-request-github,False,GitHub Pull Requests for Visual Studio Code +laravel-query-builder,spatie/laravel-query-builder,False,Easily build Eloquent queries from API requests +requests-ip-rotator,Ge0rg3/requests-ip-rotator,False,A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing. +hound,houndci/hound,False,Automated code review for GitHub pull requests. +mention-bot,facebookarchive/mention-bot,False,Automatically mention potential reviewers on pull requests. +LollipopShowcase,mikepenz/LollipopShowcase,False,"A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar" +lolMiner-releases,Lolliedieb/lolMiner-releases,False, +LolliPin,omadahealth/LolliPin,False,A Material design Android pincode library. Supports Fingerprint. +LOLBAS,LOLBAS-Project/LOLBAS,False,Living Off The Land Binaries And Scripts - (LOLBins and LOLScripts) +lolcommits,lolcommits/lolcommits,False,:camera: git-based selfies for software developers +LOLBAS,api0cradle/LOLBAS,False,Living Off The Land Binaries And Scripts - (LOLBins and LOLScripts) +lolcat,busyloop/lolcat,False,Rainbows and unicorns! +LollipopGo,Golangltd/LollipopGo,False,"稳定分支2.9.X 版本已更新,由【Golang语言游戏服务器】维护,全球服游戏服务器及区域服框架,目前协议支持websocket、http、KCP、TCP及RPC,采用状态同步(帧同步内测),愿景:打造MMO多人竞技游戏框架! 功能持续更新中... ..." +LOL,RozDavid/LOL,False,LOL: Lidar-only Odometry and Localization in 3D point cloud maps +ZuAnBot,liuke-wuhan/ZuAnBot,False,祖安助手:英雄联盟(League Of Legends)一键喷人,LOL游戏和客户端中可用。只为反击喷子! +R3nzSkin,R3nzTheCodeGOD/R3nzSkin,False,Skin changer for League of Legends (LOL) +PreLollipopTransition,takahirom/PreLollipopTransition,False,Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices. +primitive.js,ondras/primitive.js,False,JS port of primitive.lol +hh-lol-prophet,real-web-world/hh-lol-prophet,False,"lol 对局先知 上等马 牛马分析程序 选人阶段判断己方大爹 大坑, 明确对局目标 基于lol client api 合法不封号" +LollipopContactsRecyclerViewFastScroller,AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller,False,A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView +lolimeow,baomihuahua/lolimeow,False,wordpress主题 lolimeow +Lol,cpeikert/Lol,False,Λ ⚬ λ: Functional Lattice Cryptography +lol_dba,plentz/lol_dba,False,"lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts." +LoLHuman,LoL-Human/LoLHuman,False,LoL Human APIs +keys-generator,SjorsO/keys-generator,False,Key generator for https://keys.lol +lolviz,parrt/lolviz,False,"A simple Python data-structure visualization tool for lists of lists, lists, dictionaries; primarily for use in Jupyter notebooks / presentations" +Android-Material-Design-for-pre-Lollipop,Suleiman19/Android-Material-Design-for-pre-Lollipop,False,"Various UI implementations, animations & effects based on Material Design compatible with pre Lollipop devices as well. (Work in progess)" +The-LoliBot-MD,elrebelde21/The-LoliBot-MD,False,"𝙃𝙤𝙡𝙖 👋 𝘽𝙞𝙚𝙣𝙫𝙚𝙣𝙞𝙙𝙤 🤗 𝙚𝙨𝙩𝙚 𝙚𝙨 𝙚𝙡 𝙧𝙚𝙥𝙤𝙨𝙞𝙩𝙤𝙧𝙞𝙤 𝙤𝙛𝙞𝙘𝙞𝙖𝙡 𝙙𝙚𝙡 𝙏𝙝𝙚 𝙇𝙤𝙡𝙞𝘽𝙤𝙩-𝙈𝘿. 𝘼𝙦𝙪𝙞 𝙨𝙚 𝙧𝙚𝙖𝙡𝙞𝙯𝙖𝙣 𝙖𝙘𝙩𝙪𝙖𝙡𝙞𝙯𝙖𝙘𝙞𝙤𝙣𝙚𝙨, 𝙎𝙞 𝙩𝙚 𝙖𝙜𝙧𝙖𝙙𝙖 𝙚𝙡 𝙗𝙤𝙩 𝙢𝙚 𝙥𝙪𝙚𝙙𝙚 𝙧𝙚𝙜𝙖𝙡𝙖𝙧 𝙪𝙣𝙖 🌟, 𝙚𝙨𝙥𝙚𝙧𝙤 𝙦𝙪𝙚 𝙜𝙪𝙨𝙩𝙚 𝙚𝙡 𝙗𝙤𝙩 😊" +LOLBAS222,homjxi0e/LOLBAS222,False,"APT || Execution || Launch || APTs || ( Authors harr0ey, bohops )" +lol-html,cloudflare/lol-html,False,Low output latency streaming HTML parser/rewriter with CSS selector-based API +lolcode-spec,justinmeza/lolcode-spec,False,LOLCODE language specification archives and development. +sinatras-hat,nakajima/sinatras-hat,False,lol +lollipops,joiningdata/lollipops,False,Lollipop-style mutation diagrams for annotating genetic variations. +loli_profiler,Tencent/loli_profiler,False,Memory instrumentation tool for android app&game developers. +omg.lol,neatnik/omg.lol,False,Cool stuff for omg.lol +json,nlohmann/json,False,JSON for Modern C++ +json,serde-rs/json,False,Strongly typed JSON library for Rust +json-server,typicode/json-server,False,Get a full fake REST API with zero coding in less than 30 seconds (seriously) +JsonPath,json-path/JsonPath,False,Java JsonPath implementation +json,flori/json,False,JSON implementation for Ruby +jsonschema2pojo,joelittlejohn/jsonschema2pojo,False,"Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc" +jsoncpp,open-source-parsers/jsoncpp,False,A C++ library for interacting with JSON. +SwiftyJSON,SwiftyJSON/SwiftyJSON,False,The better way to deal with JSON data in Swift. +JSON-js,douglascrockford/JSON-js,False,JSON in JavaScript +jsoneditor,josdejong/jsoneditor,False,"A web-based tool to view, edit, format, and validate JSON" +json,konklone/json,False,"A free, in-browser JSON to CSV converter." +json,trentm/json,False,"A ""json"" command for massaging JSON on your Unix command line." +json-tutorial,miloyip/json-tutorial,False,从零开始的 JSON 库教程 +Newtonsoft.Json,JamesNK/Newtonsoft.Json,False,Json.NET is a popular high-performance JSON framework for .NET +JSONKit,johnezang/JSONKit,False,Objective-C JSON +cJSON,DaveGamble/cJSON,False,Ultralightweight JSON parser in ANSI C +json11,dropbox/json11,False,A tiny JSON library for C++11. +jsonmodel,jsonmodel/jsonmodel,False,"Magical Data Modeling Framework for JSON - allows rapid creation of smart data models. You can use it in your iOS, macOS, watchOS and tvOS apps." +jsoncrack.com,AykutSarac/jsoncrack.com,False,⭐️ Transform data chaos into clarity with JSON Crack - the ultimate JSON visualization solution. +JSON-java,stleary/JSON-java,False,A reference implementation of a JSON package in Java. +json,rsanchez/json,False,Output ExpressionEngine data in JSON format. +node-jsonwebtoken,auth0/node-jsonwebtoken,False,JsonWebToken implementation for node.js http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html +JSONExport,Ahmed-Ali/JSONExport,False,"JSONExport is a desktop application for Mac OS X which enables you to export JSON objects as model classes with their associated constructors, utility methods, setters and getters in your favorite language." +react-jsonschema-form,rjsf-team/react-jsonschema-form,False,A React component for building Web forms from JSON Schema. +json,taocpp/json,False,C++ header-only JSON library +json5,json5/json5,False,JSON5 — JSON for Humans +json2csv,zemirco/json2csv,False,Convert json to csv with column titles +json-editor,jdorn/json-editor,False,JSON Schema Based Editor +ArduinoJson,bblanchon/ArduinoJson,False,📟 JSON library for Arduino and embedded C++. Simple and efficient. +jq,stedolan/jq,False,Command-line JSON processor From 65340bc5876bb4778856681af43d702e4f628bc6 Mon Sep 17 00:00:00 2001 From: Yurii Mandrik Date: Sun, 26 Mar 2023 12:46:38 +0300 Subject: [PATCH 18/18] ADD HW#12 Lecture#15 --- HW#12Lecture#15/.idea/.gitignore | 3 ++ HW#12Lecture#15/.idea/HW#12Lecture#15.iml | 10 +++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ HW#12Lecture#15/.idea/misc.xml | 4 ++ HW#12Lecture#15/.idea/modules.xml | 8 ++++ HW#12Lecture#15/.idea/vcs.xml | 6 +++ HW#12Lecture#15/main.py | 43 +++++++++++++++++++ 7 files changed, 80 insertions(+) create mode 100644 HW#12Lecture#15/.idea/.gitignore create mode 100644 HW#12Lecture#15/.idea/HW#12Lecture#15.iml create mode 100644 HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 HW#12Lecture#15/.idea/misc.xml create mode 100644 HW#12Lecture#15/.idea/modules.xml create mode 100644 HW#12Lecture#15/.idea/vcs.xml create mode 100644 HW#12Lecture#15/main.py diff --git a/HW#12Lecture#15/.idea/.gitignore b/HW#12Lecture#15/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/HW#12Lecture#15/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HW#12Lecture#15/.idea/HW#12Lecture#15.iml b/HW#12Lecture#15/.idea/HW#12Lecture#15.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/HW#12Lecture#15/.idea/HW#12Lecture#15.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml b/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/HW#12Lecture#15/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HW#12Lecture#15/.idea/misc.xml b/HW#12Lecture#15/.idea/misc.xml new file mode 100644 index 0000000..1c4cab4 --- /dev/null +++ b/HW#12Lecture#15/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HW#12Lecture#15/.idea/modules.xml b/HW#12Lecture#15/.idea/modules.xml new file mode 100644 index 0000000..e135619 --- /dev/null +++ b/HW#12Lecture#15/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/HW#12Lecture#15/.idea/vcs.xml b/HW#12Lecture#15/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/HW#12Lecture#15/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HW#12Lecture#15/main.py b/HW#12Lecture#15/main.py new file mode 100644 index 0000000..59a7868 --- /dev/null +++ b/HW#12Lecture#15/main.py @@ -0,0 +1,43 @@ +import threading +from urllib.request import urlopen +import json + + +def get_course(url): + response = urlopen(url).read().decode('utf-8') + res = json.loads(response) + return res + + +def get_course_pb(): + url = "https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=5" + res = get_course(url) + #print(res[1]['buy']) + return res[1]['buy'] + + +def get_course_nbu(): + url = 'https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json' + res = get_course(url) + #print(res[24]['rate']) + return res[24]['rate'] + + +def get_best_course(): + + print (f'Best course is {max(float(get_course_pb()), float(get_course_nbu()))}') + return max(float(get_course_pb()), float(get_course_nbu())) + + + +if __name__ == "__main__": + thread1 = threading.Thread(target=get_course_pb) + thread2 = threading.Thread(target=get_course_nbu) + thread3 = threading.Thread(target=get_best_course) + + thread1.start() + thread2.start() + thread1.join() + thread2.join() + thread3.start() +