-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfast_review.py
78 lines (67 loc) · 2.34 KB
/
fast_review.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
import os
from logger import get_logger
file_dict = {}
# for root, _, files in os.walk('data/corrected'):
# files = sorted(files, reverse=True)
# for file in files:
# file = file[:-3]
# name = '-'.join(file.split('-')[:2])
# if name not in file_dict:
# file_dict[name] = {}
# if file.endswith('-corrected'):
# file_dict[name]['corrected'] = f'{file}.md'
# elif file.endswith('-corrected-gemini'):
# file_dict[name]['corrected'] = f'{file}.md'
# elif file.endswith('-reviewed'):
# file_dict[name]['reviewed'] = f'{file}.md'
# else:
# file_dict[name]['original'] = f'{file}.md'
for _, dirs, _ in os.walk('data/contests-extra'):
for dir in dirs:
if 'skip' in dir:
continue
if '_' not in dir:
continue
for root, _, files in os.walk(f'data/contests-extra/{dir}'):
for file in files:
if 'skip' in file:
continue
if 'editorial' in file:
continue
file = file[:-3]
contest = dir.split('_')[0]
problem = file.split('-')[0]
name = f'{contest}-{problem}'
path = f'data/contests-extra/{dir}/{file}.md'
if name not in file_dict:
file_dict[name] = {}
if file.endswith('-corrected'):
file_dict[name]['corrected'] = path
else:
file_dict[name]['original'] = path
files = sorted(list(file_dict.items()), key=lambda x: (int(x[0].split('-')[0]), x[0].split('-')[1]))
for x in files:
if 'reviewed' in x[1]:
continue
print(x[0])
for version, file_name in x[1].items():
if file_name.startswith('data'):
path = file_name
else:
path = f'data/corrected/{file_name}'
with open(path, 'r') as f:
content = f.read()
with open(f'review/{version}.md', 'w') as f:
f.write(content)
while True:
c = input()
if c == 's':
break
elif c == 'q':
exit()
else:
print('Invalid command')
with open(f'review/corrected.md', 'r') as f:
content = f.read()
with open(f'data/corrected/{x[0]}-reviewed.md', 'w') as f:
f.write(content)