def main(rfc_number, trans_mode=None): print('RFC %d:' % rfc_number) try: fetch_rfc(rfc_number) except RFCNotFound as e: print('Exception: RFCNotFound!') filename = "html/rfc%d-not-found.html" % rfc_number with open(filename, "w") as f: f.write('') return except Exception as e: print(e) filename = "html/rfc%d-error.html" % rfc_number with open(filename, "w") as f: f.write('') return res = trans_rfc(rfc_number, mode=trans_mode) if res is False: return False make_html(rfc_number)
RFCs = [int(rfc_number) for rfc_number in args.rfc.split(",")] if args.make_index: make_index() elif args.transtest: from src.trans_rfc import trans_test trans_test() elif args.fetch and args.begin and args.end: numbers = list(diff_remote_and_local_index()) numbers = [x for x in numbers if args.begin <= x <= args.end] for rfc_number in numbers: fetch_rfc(rfc_number) elif args.fetch and RFCs: for rfc in RFCs: fetch_rfc(rfc, args.force) elif args.trans and RFCs: for rfc in RFCs: trans_rfc(rfc) elif args.make and args.begin and args.end: for rfc_number in range(args.begin, args.end): make_html(rfc_number) elif args.make and RFCs: for rfc in RFCs: make_html(rfc) elif RFCs: for rfc in RFCs: main(rfc) else: continuous_main(begin=args.begin, end=args.end)
args = parser.parse_args() if args.make_index: make_index() elif args.transtest: from src.trans_rfc import trans_test trans_test() elif args.fetch and args.begin and args.end: numbers = list(diff_remote_and_local_index()) numbers = [x for x in numbers if args.begin <= x <= args.end] for rfc_number in numbers: fetch_rfc(rfc_number) elif args.fetch and args.rfc: fetch_rfc(args.rfc, args.force) elif args.trans and args.rfc: trans_rfc(args.rfc, mode=args.trans_mode) elif args.make and args.begin and args.end: for rfc_number in range(args.begin, args.end): make_html(rfc_number) elif args.make and args.rfc: make_html(args.rfc) elif args.rfc: main(args.rfc, trans_mode=args.trans_mode) else: continuous_main(begin=args.begin, end=args.end, trans_mode=args.trans_mode)
# 範囲指定でRFCの取得 print("[+] RFC %d - %d のRFCを取得" % (args.begin, args.end)) numbers = list(diff_remote_and_local_index()) numbers = [x for x in numbers if args.begin <= x <= args.end] for rfc_number in numbers: fetch_rfc(rfc_number) elif args.fetch and RFCs: # 指定したRFCの取得 print("[+] RFC %d を取得") for rfc in RFCs: fetch_rfc(rfc, args.force) elif args.trans and RFCs: # RFCの翻訳 print("[+] RFC %d を翻訳") for rfc in RFCs: trans_rfc(rfc, transmode) elif args.make and args.begin and args.end: # 範囲指定でrfcXXXX.htmlの作成 print("[+] RFC %d - %d のHTMLを生成" % (args.begin, args.end)) for rfc_number in range(args.begin, args.end): make_html(rfc_number) elif args.make and RFCs: # 指定したrfcXXXX.htmlの作成 for rfc in RFCs: make_html(rfc) elif RFCs: # 範囲指定でRFCを順番に取得・翻訳・作成 for rfc in RFCs: main(rfc, transmode) else: