-
Notifications
You must be signed in to change notification settings - Fork 0
/
punch
executable file
·35 lines (29 loc) · 1002 Bytes
/
punch
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
#!/usr/bin/env python
import punchie
import sys
import getopt
punchie.make_yamls()
formats = ','.join(['cdc', 'dec_026', 'dec_029', 'ge_600', 'ibm_024_rept', 'ibm_024_prog', 'ibm_026_fort',
'ibm_026_comm', 'ibm_029_029', 'ibm_029_ibme', 'ibm_029_ebcd', 'ibm_1401', 'univac_1108'])
usage_string = f'Usage ./punch -i <file> -f <format>\nFormats: {formats}'
try:
form = ''
secret = 0
infile = ''
sys.argv.pop(0)
ops, args = getopt.getopt(
sys.argv, 'i:f:h', ['--infile', '--form', '--help'])
for op, arg in ops:
if op in ['-h', '--help']:
print(usage_string)
elif op in ['-f', '--form']:
form = arg
elif op in ['-i', '--infile']:
infile = arg
if (form == '') or (infile == ''):
sys.stderr.write(usage_string)
sys.exit()
collection = punchie.Holder(infile, form, secret)
collection.write_punched()
except getopt.GetoptError:
sys.stderr.write(usage_string)