xmlwf_helpgen.py 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #! /usr/bin/env python3
  2. # __ __ _
  3. # ___\ \/ /_ __ __ _| |_
  4. # / _ \\ /| '_ \ / _` | __|
  5. # | __// \| |_) | (_| | |_
  6. # \___/_/\_\ .__/ \__,_|\__|
  7. # |_| XML parser
  8. #
  9. # Copyright (c) 2019 Expat development team
  10. # Licensed under the MIT license:
  11. #
  12. # Permission is hereby granted, free of charge, to any person obtaining
  13. # a copy of this software and associated documentation files (the
  14. # "Software"), to deal in the Software without restriction, including
  15. # without limitation the rights to use, copy, modify, merge, publish,
  16. # distribute, sublicense, and/or sell copies of the Software, and to permit
  17. # persons to whom the Software is furnished to do so, subject to the
  18. # following conditions:
  19. #
  20. # The above copyright notice and this permission notice shall be included
  21. # in all copies or substantial portions of the Software.
  22. #
  23. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26. # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  27. # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28. # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29. # USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. import argparse
  31. epilog = """
  32. exit status:
  33. 0 the input files are well-formed and the output (if requested) was written successfully
  34. 1 could not allocate data structures, signals a serious problem with execution environment
  35. 2 one or more input files were not well-formed
  36. 3 could not create an output file
  37. 4 command-line argument error
  38. xmlwf of libexpat is software libre, licensed under the MIT license.
  39. Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you!
  40. """
  41. parser = argparse.ArgumentParser(prog='xmlwf', add_help=False,
  42. description='xmlwf - Determines if an XML document is well-formed',
  43. formatter_class=argparse.RawTextHelpFormatter,
  44. epilog=epilog)
  45. input_related = parser.add_argument_group('input control arguments')
  46. input_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone')
  47. input_related.add_argument('-n', action='store_true', help='enable [n]amespace processing')
  48. input_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities')
  49. input_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities')
  50. input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration')
  51. input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages')
  52. input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead')
  53. input_related.add_argument('-k', action='store_true', help='when processing multiple files, [k]eep processing after first file with error')
  54. output_related = parser.add_argument_group('output control arguments')
  55. output_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory')
  56. output_mode = output_related.add_mutually_exclusive_group()
  57. output_mode.add_argument('-c', action='store_true', help='write a [c]opy of input XML, not canonical XML')
  58. output_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not canonical XML')
  59. output_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing')
  60. output_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations')
  61. parser.add_argument('files', metavar='FILE', nargs='*', help='file to process (default: STDIN)')
  62. info = parser.add_argument_group('info arguments')
  63. info = info.add_mutually_exclusive_group()
  64. info.add_argument('-h', action='store_true', help='show this [h]elp message and exit')
  65. info.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit')
  66. if __name__ == '__main__':
  67. parser.print_help()