-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15.py
149 lines (132 loc) · 7.82 KB
/
15.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import requests
import time
import json
GOLD = '\033[38;5;220m'
CYAN = '\033[96m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
MAGENTA = '\033[95m'
WHITE = '\033[97m'
BLUE = '\033[94m'
BOLD = '\033[1m'
RESET = '\033[0m'
api_url = "https://api.usaspending.gov/api/v2/agency/015/awards/"
def loading_animation(message, duration=3):
"""Creates a smooth loading effect with dots."""
print(f"{GREEN}{message}{RESET}", end="")
for _ in range(duration):
time.sleep(1)
print(".", end="", flush=True)
print("\n")
def format_number(num):
if num is None:
return f"{GREEN}$0.00{RESET}"
if num >= 1_000_000_000:
return f"{GREEN}${num/1_000_000_000:.2f}B{RESET}"
elif num >= 1_000_000:
return f"{GREEN}${num/1_000_000:.2f}M{RESET}"
elif num >= 1_000:
return f"{GREEN}${num/1_000:.1f}K{RESET}"
return f"{GREEN}${num:,.2f}{RESET}"
def format_count(num):
if num is None:
return f"{MAGENTA}0{RESET}"
if num >= 1_000_000:
return f"{MAGENTA}{num/1_000_000:.2f}M{RESET}"
elif num >= 1_000:
return f"{MAGENTA}{num/1_000:.1f}K{RESET}"
return f"{MAGENTA}{num}{RESET}"
loading_animation("Let's find some spending!", 4)
ascii_art = f"""{GOLD}
::::::--===++++===--::::::
:::-=*%%@@@%%#***++***#%%@@@@%*=-:::
:::=#@@@#+-::::::::::::::::::::::-+#@@@#=:::
::-+#@%#=::::--==+****++====++****+==--::::=#%@%+-::
::-*%@#=:::-=+++=-::-=++**######**++=-::-=+++=-:::=#@%*-::
::+%@*=:::=*+=-:-+#%@@@@@@@@@@@@@@@@@@@@@@%#+-:-=+*=:::=*@%+-:
:-#@%=:::=#=::-#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#-::=#=:::=%@#-::
:-#@#:::-#+:-=%@@@@@@@@@@@@@@@***%@@***@@@@@@@@@@@@@@@@@=-:+#-:::#@#-:
::-#@*-::+*-:=#@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@#=:-*+-:-*@#-::
:-*@#-::++--*@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@*--+*::-#@*-:
:-%%=::++-:*@@@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@@@*--++::-%%=:
::+@*-:-*-:+@@@@@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@@@@@*:-*-::*@+::
:-#@+::+*:=%@@@@@@@@@@@@@@@@@@@@@@@%%*:::---:::*%%%@@@@@@@@@@@@@@@@@@@@@@@@=:*+::+@%-:
:-%%-:-*-:*@@@@@@@@@@@@@@@@@@@@@#=::::-:::=+=::::::::::-=++*@@@@@@@@@@@@@@@@@*--*-:-%%-:
:-%%-:-+-:%@@@@@@@@@@@@@@@@@@@#=:::-*%@%:::#@#:::*=:::::::::-@@@@@@@@@@@@@@@@@@%:-*-:-%%-:
:-%%-:-#--@@@@@@@@@@@@@@@@@@@@-::::#@@@@%:::#@#:::%@@*-::::::-@@@@@@@@@@@@@@@@@@@@=-*-:-%%-:
::#@=:-#:=%@@@@@@@@@@@@@@@@@@%-::::*@@@@@%:::#@#:::%@@@@=:::::-@@@@@@@@@@@@@@@@@@@@%=:#-:=%#::
::*@+:-#--%@@@@@@@@@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:-%%-:
:-%%-:-*-:*@@@@@@@@@@@@@@@@@@@@#**+-:::::::::::::::=+*%@@@@@@@@@@@@@@@@@@@@@@*--*-:-%%-:
:-#@+::++:=%@@@@@@@@@@@@@@@@@@@@@@@@@%:::*#*:::%@@@@@@@@@@@@@@@@@@@@@@@@@@@=:++::+@%-:
::+@*-:-*-:*@@@@@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@@@@@*:-*-::*@+::
:=%%-::++-:*@@@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@@@#--++::-%%=:
:-*@#-::*+--*@@@@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@@@@*--+*::-#@*-:
::-#@*-::++-:+#@@@@@@@@@@@@@@@@@%:::#@#:::%@@@@@@@@@@@@@@@@@@%+:-++-:-*@#-::
::-#@#:::=#+:-+%@@@@@@@@@@@@@@@%%%@@@%%%@@@@@@@@@@@@@@@@@+-:+#=:::#@#-::
::-#@%-:::=#=::-#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#-::=#+:::-%@%-::
::+%@*-:::=#+=-:-+#%@@@@@@@@@@@@@@@@@@@@@@%#+-:-=+#=:::-*@%+-:
::-*%@#=:::-=+++=-::-=++**######**++=-::-=+++=-:::=#@%*-::
::-+%@%*=::::--=++****++====++****++==-::::=*%@%+-::
:::-=#@@@#+-::::::::::::::::::::::-+#@@@#+-:::
:::-=*%@@@@%%#**++++**#%%@@@@%*=-:::
::::::--==++++++===-::::::
{RESET}"""
loading_animation("DOGE is handling it", 5)
print(ascii_art)
time.sleep(3)
def fetch_awards_data():
try:
loading_animation("Fetching data from USASpending.gov API", 5)
response = requests.get(api_url, timeout=10)
print(f"{CYAN}Response Status Code:{RESET} {MAGENTA}{response.status_code}{RESET}")
time.sleep(2)
if response.status_code == 200:
data = response.json()
return {
"Fiscal Year": f"{YELLOW}FY {data.get('fiscal_year', 'Unknown')}{RESET}",
"Date": f"{YELLOW}{data.get('latest_action_date', 'Unknown').split('T')[0]}{RESET}",
"Amount": format_number(data.get("obligations", 0)),
"Transactions": format_count(data.get("transaction_count", 0)),
"Agency Code": f"{MAGENTA}{data.get('toptier_code', 'N/A')}{RESET}",
}
else:
print(f"{RED}Error: Received status code {response.status_code}{RESET}")
return None
except requests.exceptions.RequestException as e:
print(f"{RED}Error occurred while fetching data: {e}{RESET}")
return None
api_data = fetch_awards_data()
if api_data:
loading_animation("Processing API data", 4)
time.sleep(2)
print(f"\n{BLUE}{BOLD}╔{'═' * 50}╗{RESET}")
print(f"{BLUE}{BOLD}║{CYAN} DOJ INFORMATION {' ' * 16}{BLUE}║{RESET}")
print(f"{BLUE}{BOLD}╠{'═' * 50}╣{RESET}")
for key, value in api_data.items():
print(f"{BLUE}║{WHITE}{BOLD} {key:<15}:{RESET} {value:<35}{BLUE}║{RESET}")
time.sleep(1)
print(f"{BLUE}{BOLD}╚{'═' * 50}╝{RESET}")
else:
print(f"{RED}No data received from the API. Exiting...{RESET}")