Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit c840c20

Browse files
committed
reformatted
1 parent d776201 commit c840c20

File tree

182 files changed

+5493
-3965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+5493
-3965
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import requests
22

3+
34
class Cryptozor:
45
def __init__(self, currency, cryptocurrency):
56
self.currency = currency.upper()
67
self.cryptocurrency = cryptocurrency.upper()
78

89
def convert(self, amount):
9-
api = requests.get('https://api.coinbase.com/v2/exchange-rates?currency='+self.cryptocurrency)
10+
api = requests.get(
11+
"https://api.coinbase.com/v2/exchange-rates?currency=" + self.cryptocurrency
12+
)
1013
try:
11-
currentPrice = api.json()['data']['rates'][self.currency]
14+
currentPrice = api.json()["data"]["rates"][self.currency]
1215
except KeyError:
1316
pass
1417
# Bitcoin
15-
#if self.cryptocurrency == ('BTC'):
16-
operations = ['BTC','ETH','ETC','BCH','LTC','ZEC','ZRX']
18+
# if self.cryptocurrency == ('BTC'):
19+
operations = ["BTC", "ETH", "ETC", "BCH", "LTC", "ZEC", "ZRX"]
1720
if self.cryptocurrency in operations:
1821
return amount / float(currentPrice)
19-
return'Not Implemented'
20-
21-
22+
return "Not Implemented"

Scripts/API/Cryptocurrency Converter/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
1414
install_requires=[
15-
'requests',
16-
],
17-
py_modules=["cryptozor"]
18-
)
15+
"requests",
16+
],
17+
py_modules=["cryptozor"],
18+
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from cryptozor import Cryptozor
22

3-
Cryptozor = Cryptozor('inr', 'eth') # From INR to ETH
3+
Cryptozor = Cryptozor("inr", "eth") # From INR to ETH
44

5-
value = Cryptozor.convert(2500) # Amount
6-
print(value)
5+
value = Cryptozor.convert(2500) # Amount
6+
print(value)

Scripts/API/Football-Standings/main.py

Lines changed: 65 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,105 @@
33
import sys
44

55
from dotenv import load_dotenv
6+
67
load_dotenv()
78

89
LEAGUE_CODE = {
9-
"BSA": {'code': 2013, 'name': 'Brazilian First Division'},
10-
"BL": {'code': 2002, 'name': 'Bundesliga'}, # Bundesliga
11-
"ECL": {'code': 2016, 'name': 'English Championship'}, # English Championship
12-
"ERD": {'code': 2003, 'name': 'Eredivisie'}, # Eredivisie [Dutch]
13-
"L1": {'code': 2015, 'name': 'Ligue 1'}, # Ligue 1
14-
"SPA": {'code': 2014, 'name': 'La Liga'}, # La Liga
15-
"PPL": {'code': 2017, 'name': 'Portugese first division'}, # Portugese First Dvision
16-
"PL": {'code': 2021, 'name': 'Premier League'}, # Premier League
17-
"SA": {'code': 2019, 'name': 'Serie A'}, # Serie A
10+
"BSA": {"code": 2013, "name": "Brazilian First Division"},
11+
"BL": {"code": 2002, "name": "Bundesliga"}, # Bundesliga
12+
"ECL": {"code": 2016, "name": "English Championship"}, # English Championship
13+
"ERD": {"code": 2003, "name": "Eredivisie"}, # Eredivisie [Dutch]
14+
"L1": {"code": 2015, "name": "Ligue 1"}, # Ligue 1
15+
"SPA": {"code": 2014, "name": "La Liga"}, # La Liga
16+
"PPL": {
17+
"code": 2017,
18+
"name": "Portugese first division",
19+
}, # Portugese First Dvision
20+
"PL": {"code": 2021, "name": "Premier League"}, # Premier League
21+
"SA": {"code": 2019, "name": "Serie A"}, # Serie A
1822
}
1923

20-
API_KEY = os.getenv('API_KEY')
24+
API_KEY = os.getenv("API_KEY")
2125
API_URL = "https://api.football-data.org/v2/"
22-
HEADER = {'X-Auth-Token': str(API_KEY)}
26+
HEADER = {"X-Auth-Token": str(API_KEY)}
27+
2328

2429
def print_standings(league_id):
25-
26-
league_code = league_id.get('code')
30+
31+
league_code = league_id.get("code")
2732
resource = f"competitions/{league_code}/standings"
2833
api_url = API_URL + resource
2934
r = requests.get(api_url, headers=HEADER)
3035
obj = r.json()
3136

32-
str_re = '\nLEAGUE: ' + str(obj['competition']['name']) +\
33-
' ' * (75 - 2 - 8 - 10 - len(str(obj['competition']['name']))) +\
34-
'MATCHDAY: ' + str(obj['season']['currentMatchday']) + '\n'
35-
str_re += '╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n'
36-
str_re += '║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n'
37-
str_re += '╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n'
38-
for team in obj['standings'][0]['table']:
39-
text = '║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n'\
40-
% (team['position'], team['team']['name'][:34], team['playedGames'], team['won'],
41-
team['draw'], team['lost'], team['points'], team['goalDifference'])
37+
str_re = (
38+
"\nLEAGUE: "
39+
+ str(obj["competition"]["name"])
40+
+ " " * (75 - 2 - 8 - 10 - len(str(obj["competition"]["name"])))
41+
+ "MATCHDAY: "
42+
+ str(obj["season"]["currentMatchday"])
43+
+ "\n"
44+
)
45+
str_re += (
46+
"╔════╤════════════════════════════════════╤════╤════╤════╤════╤═════╤═════╗\n"
47+
)
48+
str_re += (
49+
"║ SN │ TEAM │ M │ W │ D │ L │ PTS │ GD ║\n"
50+
)
51+
str_re += (
52+
"╠════╪════════════════════════════════════╪════╪════╪════╪════╪═════╪═════╣\n"
53+
)
54+
for team in obj["standings"][0]["table"]:
55+
text = "║ %-2d │ %-34s │ %-2d │ %-2d │ %-2d │ %-2d │ %-3d │ %+-3d ║\n" % (
56+
team["position"],
57+
team["team"]["name"][:34],
58+
team["playedGames"],
59+
team["won"],
60+
team["draw"],
61+
team["lost"],
62+
team["points"],
63+
team["goalDifference"],
64+
)
4265

4366
str_re += text
4467

45-
str_re += '╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝'
68+
str_re += (
69+
"╚════╧════════════════════════════════════╧════╧════╧════╧════╧═════╧═════╝"
70+
)
4671

4772
print(str_re)
4873

74+
4975
if __name__ == "__main__":
5076
try:
5177

5278
# If API key is not stored
53-
if API_KEY is None or API_KEY == 'YOUR_KEY_HERE':
54-
print('This script requires a free API key from https://www.football-data.org/ for stats!\
55-
\nGet a free API Key and store it in the .env file in place of \"YOUR_KEY_HERE\"')
79+
if API_KEY is None or API_KEY == "YOUR_KEY_HERE":
80+
print(
81+
'This script requires a free API key from https://www.football-data.org/ for stats!\
82+
\nGet a free API Key and store it in the .env file in place of "YOUR_KEY_HERE"'
83+
)
5684
sys.exit(1)
5785

5886
arg = sys.argv[1]
5987

60-
if arg in ['--help', '-h']:
61-
print('List of leagues and the codes: ')
88+
if arg in ["--help", "-h"]:
89+
print("List of leagues and the codes: ")
6290
for sno, key in enumerate(LEAGUE_CODE.keys()):
63-
print('%2d. %-30s %s' % (sno+1, LEAGUE_CODE[key]['name'], key))
91+
print("%2d. %-30s %s" % (sno + 1, LEAGUE_CODE[key]["name"], key))
6492
sys.exit(0)
6593

6694
league_id = LEAGUE_CODE.get(arg)
6795
if league_id is None:
68-
print('Invalid League Code!\nrun: python3 main.py --help | -h to get list of league codes')
96+
print(
97+
"Invalid League Code!\nrun: python3 main.py --help | -h to get list of league codes"
98+
)
6999

70100
print_standings(league_id)
71101

72102
# When no arguments are passed to the script
73103
except IndexError:
74-
print('Invalid Usage!\nrun: python3 main.py [league-code]\
75-
\nrun: python3 main.py --help | -h to get list of league codes')
104+
print(
105+
"Invalid Usage!\nrun: python3 main.py [league-code]\
106+
\nrun: python3 main.py --help | -h to get list of league codes"
107+
)

Scripts/API/GeoCode API/code.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,55 @@
55
import configparser
66

77
config = configparser.ConfigParser()
8-
config.read('config.ini')
8+
config.read("config.ini")
99

10-
api_key = config['keys']['api_key']
11-
serviceurl = config['keys']['service_url']
10+
api_key = config["keys"]["api_key"]
11+
serviceurl = config["keys"]["service_url"]
1212

13-
with open("where.txt") as fh, open("where.js","w",encoding="utf-8") as where:
14-
adrs=[]
15-
parms={}
13+
with open("where.txt") as fh, open("where.js", "w", encoding="utf-8") as where:
14+
adrs = []
15+
parms = {}
1616
for line in fh:
1717

1818
address = line.strip()
1919
parms["address"] = address
20-
parms['key'] = api_key
20+
parms["key"] = api_key
2121
url = serviceurl + urllib.parse.urlencode(parms)
2222

23-
if url.lower().startswith('http'):
23+
if url.lower().startswith("http"):
2424
req = urllib.request.Request(url)
2525
else:
2626
raise ValueError from None
2727

2828
with urllib.request.urlopen(req) as resp:
2929

3030
data = resp.read().decode()
31-
31+
3232
try:
3333
js = json.loads(data)
3434
except:
3535
print(data)
3636
continue
3737

3838
try:
39-
adrs.append([js['results'][0]['geometry']['lat'],js['results'][0]['geometry']['lng'],js['results'][0]['formatted']])
40-
print('Retrieved ', url)
39+
adrs.append(
40+
[
41+
js["results"][0]["geometry"]["lat"],
42+
js["results"][0]["geometry"]["lng"],
43+
js["results"][0]["formatted"],
44+
]
45+
)
46+
print("Retrieved ", url)
4147
except:
4248
print("Not Found " + line.strip())
4349

4450
print("\n\nOpening Webpage")
4551

4652
where.write("myData = [\n")
4753
for item in adrs:
48-
st="[" + str(item[0]) + ", " + str(item[1]) + ", '" + str(item[2]) + "' ], \n"
54+
st = "[" + str(item[0]) + ", " + str(item[1]) + ", '" + str(item[2]) + "' ], \n"
4955
where.write(st)
5056
where.write(",\n")
5157
where.write("];\n")
5258

53-
webbrowser.open('file://' + os.path.realpath("index.html"))
59+
webbrowser.open("file://" + os.path.realpath("index.html"))

Scripts/API/GitHubSizeChecker/Script.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22

33

44
def SizeChecker(username, repository):
5-
response = requests.get(f"https://api.github.com/repos/{username}/{repository}") # Requesting information about the repository
5+
response = requests.get(
6+
f"https://api.github.com/repos/{username}/{repository}"
7+
) # Requesting information about the repository
68
if response.status_code == 200: # The repository exists
7-
print(f"Success! Repository \'{repository}\' found.")
9+
print(f"Success! Repository '{repository}' found.")
810
content = response.json()
9-
size = content['size']
10-
print(f'Size of the repository \'{repository}\': {size} KB.')
11+
size = content["size"]
12+
print(f"Size of the repository '{repository}': {size} KB.")
1113
elif response.status_code == 404:
1214
print("Error 404: Page not found. This could be due to two reasons:")
1315
print("1. You've entered the wrong details.")
1416
print("2. The repository you're looking for is a private repository.")
1517

1618

1719
if __name__ == "__main__":
18-
choice = 'y'
19-
while(choice.lower() == 'y' or choice.lower() == 'yes'):
20+
choice = "y"
21+
while choice.lower() == "y" or choice.lower() == "yes":
2022
username = input("Enter a GitHub username: ")
2123
repository = input("Enter the repository name: ")
2224
SizeChecker(username, repository)
23-
choice = input("Do you want to keep searching for more repositories? (y/yes for yes, any other key for no): ")
25+
choice = input(
26+
"Do you want to keep searching for more repositories? (y/yes for yes, any other key for no): "
27+
)

Scripts/API/Github_information/github_scraper.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,34 @@
55

66

77
def findUserInfo(username):
8-
url = 'https://api.github.com/users/'+username
8+
url = "https://api.github.com/users/" + username
99
html = requests.get(url)
1010
return html.json()
1111

12+
1213
# Some data is not provided by the user, so this error has to be managed
1314

1415

1516
def getField(key, dic):
1617
if dic[key] is None:
17-
return 'Not Available'
18+
return "Not Available"
1819
return dic[key]
1920

2021

2122
if __name__ == "__main__":
22-
username = input('Enter the Username: ')
23+
username = input("Enter the Username: ")
2324
userDetails = findUserInfo(username)
24-
if 'message' in userDetails.keys():
25-
print('Username not Found')
25+
if "message" in userDetails.keys():
26+
print("Username not Found")
2627
sys.exit()
2728
else:
28-
print('** Name **\n'+userDetails['name'], '\n')
29-
print('** About **\n')
30-
print('Bio: ', getField('bio', userDetails))
31-
print('E-mail: ', getField('email', userDetails))
32-
print('Location: ', getField('location', userDetails), '\n')
33-
print('** Profile Details **\n')
34-
print('Public Repositories: ', userDetails['public_repos'])
35-
print('Public Gists: ', userDetails['public_gists'])
36-
print('Followers: ', userDetails['followers'])
37-
print('Following: ', userDetails['following'])
29+
print("** Name **\n" + userDetails["name"], "\n")
30+
print("** About **\n")
31+
print("Bio: ", getField("bio", userDetails))
32+
print("E-mail: ", getField("email", userDetails))
33+
print("Location: ", getField("location", userDetails), "\n")
34+
print("** Profile Details **\n")
35+
print("Public Repositories: ", userDetails["public_repos"])
36+
print("Public Gists: ", userDetails["public_gists"])
37+
print("Followers: ", userDetails["followers"])
38+
print("Following: ", userDetails["following"])

0 commit comments

Comments
 (0)