def main(): args = arg_parser.parse_args() file_path = args.pptx_path g.file_prefix = ''.join(os.path.basename(file_path).split('.')[:-1]) if args.title: g.use_custom_title prepare_titles(args.title) g.use_custom_title = True if args.wiki: out_path = 'out.tid' else: out_path = 'out.md' if args.output: out_path = args.output if args.image_dir: g.img_path = args.image_dir if args.image_width: g.max_img_width = args.image_width if args.min_block_size: g.text_block_threshold = args.min_block_size if args.disable_image: g.disable_image = True else: g.disable_image = False if args.disable_wmf: g.disable_wmf = True else: g.disable_wmf = False prs = Presentation(file_path) if args.wiki: out = outputter.wiki_outputter(out_path) elif args.mdk: out = outputter.madoko_outputter(out_path) else: out = outputter.md_outputter(out_path) parse(prs, out)
def main(): args = arg_parser.parse_args() file_path = args.pptx_path g.file_prefix = ''.join(os.path.basename(file_path).split('.')[:-1]) if args.title: g.use_custom_title prepare_titles(args.title) g.use_custom_title = True if args.wiki: out_path = 'out.tid' else: out_path = 'out.md' if args.output: out_path = args.output if args.image_dir: g.img_path = args.image_dir if args.image_width: g.max_img_width = args.image_width if args.min_block_size: g.text_block_threshold = args.min_block_size if args.disable_image: g.disable_image = True else: g.disable_image = False if args.disable_wmf: g.disable_wmf = True else: g.disable_wmf = False if not os.path.exists(file_path): print(f'source file {file_path} not exist!') print(f'(absolute path: {os.path.abspath(file_path)})') exit(0) try: prs = Presentation(file_path) except KeyError as err: if len(err.args) > 0 and re.match( r'There is no item named .*NULL.* in the archive', str(err.args[0])): print('corrupted links found, trying to purge...') try: res_path = fix_null_rels(file_path) print(f'purged file saved to {res_path}.') prs = Presentation(res_path) except: print( 'failed, please report this bug at https://github.com/ssine/pptx2md/issues' ) exit(0) else: print( 'unknown error, please report this bug at https://github.com/ssine/pptx2md/issues' ) exit(0) if args.wiki: out = outputter.wiki_outputter(out_path) elif args.mdk: out = outputter.madoko_outputter(out_path) else: out = outputter.md_outputter(out_path) parse(prs, out)