forked from meicholtz/wordle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_stats.py
More file actions
30 lines (23 loc) · 750 Bytes
/
check_stats.py
File metadata and controls
30 lines (23 loc) · 750 Bytes
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
# check_stats.py
# Simple script to read and display stats from file.
from colorama import init, Fore
import pdb
def main():
init(autoreset=True) # required for colored text
# Read data from stats file
try:
with open("stats.txt", "r") as f:
data = f.read().split('\n') # make list of strings, one per stat line
except IOError:
print(Fore.RED + 'ERROR: stats.txt does not exist. Check files in directory.')
return 0
# Display stats
print("\nSTATISTICS")
print("=" * 10)
for line in data:
stat, value = line.split('=') # expected format is "stat=value"
print(f'{stat.title()}: {value}')
print()
# pdb.set_trace()
if __name__ == "__main__":
main()