-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.py
More file actions
38 lines (27 loc) · 694 Bytes
/
create.py
File metadata and controls
38 lines (27 loc) · 694 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
31
32
33
34
35
36
37
38
import sys
import re
from pathlib import Path
num = re.compile(
r'[0-9]+'
)
text = r'''
use std::fs;
fn main() {{
let text = fs::read_to_string("{}.txt").unwrap();
let text = text
.strip_suffix('\n')
.unwrap_or(&text);
}}
'''
here = Path()
if len(sys.argv) > 1:
new_yearnum = int(sys.argv[1])
else:
years = (year for year in here.iterdir() if num.match(year.name))
new_yearnum = max(int(year.name) for year in years) + 1
new_year = here / str(new_yearnum)
new_year.mkdir()
for i in range(1, 26):
(new_year / f'{i}a.rs').write_text(text.format(i))
(new_year / f'{i}b.rs').write_text(text.format(i))
print(f'Created {new_year}')