- commit
- 5e1ad6dd5e2c5fd9e76c4ee8fb5b90e618d14cc0
- parent
- 0b264f21f740e74384056d18587fe88ffec3dc64
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-05-08 20:28
allow to specify per file filetype
Diffstat
| M | cctool.py | 16 | ++++++++++------ |
1 files changed, 10 insertions, 6 deletions
diff --git a/cctool.py b/cctool.py
@@ -498,13 +498,17 @@ def get_outformat(args): 498 498 499 499 def get_informat(filename): 500 500 informats, outformats = formats()501 -1 ext = filename.split(os.path.extsep)[-1]502 501 -1 502 parts = filename.split(':', -1) -1 503 if len(parts) == 2 and parts[1] in informats: -1 504 return parts[1], parts[0] -1 505 -1 506 ext = filename.split(os.path.extsep)[-1] 503 507 if ext in informats:504 -1 return ext505 -1 else:506 -1 print('Missing input format')507 -1 sys.exit(1)-1 508 return ext, filename -1 509 -1 510 print('Missing input format') -1 511 sys.exit(1) 508 512 509 513 510 514 def main(): @@ -518,7 +522,7 @@ def main(): 518 522 if args.informat is not None: 519 523 informat = args.informat 520 524 else:521 -1 informat = get_informat(filename)-1 525 informat, filename = get_informat(filename) 522 526 523 527 infile = sys.stdin if filename == '-' else open(filename, 'rb') 524 528 data += informats[informat]().load(infile)