-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.py
executable file
·87 lines (73 loc) · 1.77 KB
/
template.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
79
80
81
82
83
84
85
86
87
import os
import sys
import getopt
import subprocess
import shutil
import time
from colorama import init, Fore
from pprint import pprint
import ffmpeg
import proclib as p
init()
timestamp = round(time.time())
def showhelp():
"""
Display the help information.
"""
print("help")
rs = '''
-h, --help show help
-Q, --sequence xxx
-f, --x xxx
'''
# print(rs)
# exit()
locationpath = os.getcwd()
dirname = os.getcwd()
basename = False
verbose = False
srcfile = False
testonly = False
# pprint(sys.argv)
# exit()
# print("args:",len(sys.argv))
if len(sys.argv) == 0:
showhelp()
#^ if there is only one argument with no flags, then assume it is a filename
if len(sys.argv) < 3:
print("1args")
pprint(sys.argv)
filename = sys.argv[1]
basename = os.path.basename(locationpath)
dirname = os.path.dirname(locationpath)
fspec = False
else: #^ one or more switches exist
pprint(sys.argv)
argv = sys.argv[1:]
try:
opts, args = getopt.getopt(argv, "hvtQ:y:", [
"help",
"verbose",
"testonly",
])
except Exception as e:
p.errprint(str(e))
for opt, arg in opts:
if opt in ("-h", "--help"):
showhelp()
if opt in ("-v", "--verbose"):
verbose = True
if opt in ("-t", "--testonly"):
testonly = True
if opt in ("-Q", "--sequence"):
sequence = arg
print(sequence)
if opt in ("-y", "--yyy"):
interx = int(arg)
basename, dirname, fspec, srcfile = p.getFnames(locationpath)
srcfile = f"{dirname}/{basename}"
print(f"dirname: {dirname}")
print(f"basename: {basename}")
print(f"srcfile: {srcfile}")
print(f"fspec: {fspec}")
id = p.getID(filename)