-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake_commands.py
38 lines (32 loc) · 1.47 KB
/
make_commands.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
# -*- coding: utf-8 -*-
import argparse
import os
import sys
# input
parser = argparse.ArgumentParser()
parser.add_argument('-in', dest="TEMPLATE_FILE", default="command_template.txt", help="Input template file")
parser.add_argument('-query', dest="QUERY", default="collection:(FedFlix) AND mediatype:(movies) AND creator:(national archives and records administration)", help="Search query for downloading assets from Internet Archive")
parser.add_argument('-uid', dest="UNIQUE_ID", default="ia_fedflixnara", help="Unique identifier")
parser.add_argument('-ddir', dest="DOWNLOAD_DIR", default="D:/landscapes/downloads/", help="Media download directory")
parser.add_argument('-sdir', dest="SHARED_DIR", default="E:/Dropbox/landscapes/", help="For sample data to be saved and synced")
parser.add_argument('-tdir', dest="TEMP_DIR", default="tmp/", help="Directory for temporary files")
parser.add_argument('-odir', dest="OUTPUT_DIR", default="output/", help="Output directory")
a = parser.parse_args()
replacers = {
"uid": a.UNIQUE_ID,
"query": a.QUERY,
"downloadDir": a.DOWNLOAD_DIR,
"sharedDir": a.SHARED_DIR,
"tempDir": a.TEMP_DIR,
"outputDir": a.OUTPUT_DIR
}
fileContents = ""
with open(a.TEMPLATE_FILE, 'r') as f:
fileContents = f.read()
for key in replacers:
findValue = "{"+key+"}"
replaceValue = replacers[key]
fileContents = fileContents.replace(findValue, replaceValue)
print("==================\n")
print(fileContents)
print("==================")