-
Notifications
You must be signed in to change notification settings - Fork 0
/
best.py
executable file
·67 lines (56 loc) · 1.58 KB
/
best.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
#!/usr/bin/env python3
import random
import datetime
MONTHS = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']
class Show:
def __init__(self, score, date, review):
self.score = score
self.date = date
self.review = review
def __repr__(self):
if self.date[0] < 10:
day = f'0{self.date[0]}'
else:
day = str(self.date[0])
if self.date[1] < 10:
month = f'0{self.date[1]}'
else:
month = str(self.date[1])
sc_txt = str(self.score)
size = len(sc_txt)
if size == 3:
final = sc_txt
elif size == 2:
final = f' {sc_txt}'
else:
final = f' {sc_txt}'
text_date = f'{day}-{month}-{self.date[2]}'
return f'{text_date} {final} {self.review}'
def getScores():
reviews = open('dead_reviews.txt').readlines()
shows = []
for i in reviews:
data = i.split()
if len(data) <= 2:
continue
date = data[0]
score = data[1]
try:
review = ' '.join(data[2:])
except:
review = ''
try:
dates = date.split('-')
day = int(dates[0])
month = int(dates[1])
year = int(dates[2])
if float(score) >= 3.6:
shows.append(Show(score, [day, month, year], review))
except:
continue
return shows
if __name__ == '__main__':
scores = getScores()
random.shuffle(scores)
for i in scores:
print(i)