add encoding arg

dev
7sDream 2017-06-05 01:37:49 +08:00
parent 2bc7a0350a
commit 94e8cd7974
No known key found for this signature in database
GPG Key ID: 72A6D9FCEDDAB75D
1 changed files with 7 additions and 5 deletions

View File

@ -229,6 +229,8 @@ def __main():
parser.add_argument('--ascii', '-a', action='store_true', default=False, parser.add_argument('--ascii', '-a', action='store_true', default=False,
help='ensure output json use ascii char, ' help='ensure output json use ascii char, '
'escape other char use \\u') 'escape other char use \\u')
parser.add_argument('--coding', '-c', default='utf-8',
help='string encoding, default utf-8')
parser.add_argument('--version', '-v', action='store_true', default=False, parser.add_argument('--version', '-v', action='store_true', default=False,
help='print version and exit') help='print version and exit')
args = parser.parse_args() args = parser.parse_args()
@ -249,7 +251,7 @@ def __main():
exit(1) exit(1)
# noinspection PyUnboundLocalVariable # noinspection PyUnboundLocalVariable
data = TorrentFileParser(target_file, not args.dict).parse() data = TorrentFileParser(target_file, not args.dict, args.coding).parse()
data = json.dumps( data = json.dumps(
data, ensure_ascii=args.ascii, data, ensure_ascii=args.ascii,