Changeset 17:323bb4ed1810 in stamper for bin/stamp2json
- Timestamp:
- Jul 19, 2014, 9:51:02 AM (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/stamp2json
r16 r17 2 2 3 3 import json 4 import sys 4 5 from argparse import ArgumentParser 5 from os.path import expanduser 6 from os.path import expanduser, isfile, isdir 6 7 7 8 … … 59 60 'action': action, 60 61 }) 62 63 if isfile(args.output): 64 print('[warning] %(out)s already exist' 65 % {'out': args.output}) 66 confirm = raw_input('overwrite? (y/n) ') 67 while confirm not in ['y','n','Y','N']: 68 confirm = raw_input('overwrite? (y/n) ') 69 if confirm in ['n', 'N']: 70 print('[warning] exiting without converting') 71 sys.exit() 72 73 elif isdir(args.output): 74 print('[error] %(out)s is a directory, remove it first' 75 % {'out': args.output}) 76 sys.exit(1) 77 61 78 with open(args.output, 'w') as stamps_file: 62 79 json.dump(stamps, stamps_file, indent=4)
Note:
See TracChangeset
for help on using the changeset viewer.