-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewday.py
33 lines (25 loc) · 897 Bytes
/
newday.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
import argparse
import os
def copy(src, year, day):
dest = os.path.os.path.basename(src.replace("XX", day))
dest = f"{year}/{dest}"
if os.path.exists(dest):
print(f"Unable to copy over {dest}")
return
x = open(src).read()
x = x.replace('"X"', f'"{day}"')
x = x.replace('"XX"', f'"{day}"')
x = x.replace("YEAR", f"{year}")
open(dest, "w").write(x)
parser = argparse.ArgumentParser(
description="Copy template files for a specific day and year."
)
parser.add_argument("--day", required=True, help="Day of the month")
parser.add_argument("--year", required=True, help="Year")
args = parser.parse_args()
year = args.year
day = args.day
curdir = os.path.dirname(os.path.abspath(__file__))
copy(f"{curdir}/templates/decXX.py", year, day)
# copy(f"{curdir}/templates/decXX.txt", year, day)
copy(f"{curdir}/templates/decXX_test.txt", year, day)