ingdiba-pdf-to-text 707 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # PYTHON_ARGCOMPLETE_OK
  3. import sys
  4. import dingguo.parser.ingdiba
  5. def compute(file):
  6. sys.stdout.write(dingguo.parser.ingdiba.ingdiba_pdf_file_to_text(file).encode('utf-8'))
  7. def _init_argparser():
  8. import argparse
  9. argparser = argparse.ArgumentParser(description = None)
  10. argparser.add_argument('file', type = argparse.FileType('rb'))
  11. return argparser
  12. def main(argv):
  13. argparser = _init_argparser()
  14. try:
  15. import argcomplete
  16. argcomplete.autocomplete(argparser)
  17. except ImportError:
  18. pass
  19. args = argparser.parse_args(argv)
  20. compute(**vars(args))
  21. return 0
  22. if __name__ == "__main__":
  23. sys.exit(main(sys.argv[1:]))