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 31import argparse 32 33epilog = """ 34libexpat is software libre, licensed under the MIT license. 35Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you! 36""" 37 38parser = argparse.ArgumentParser(prog='xmlwf', add_help=False, 39 description='xmlwf - Determines if an XML document is well-formed', 40 formatter_class=argparse.RawTextHelpFormatter, 41 epilog=epilog) 42 43input_related = parser.add_argument_group('input control arguments') 44input_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone') 45input_related.add_argument('-n', action='store_true', help='enable [n]amespace processing') 46input_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities') 47input_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities') 48input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration') 49input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages') 50input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead') 51 52output_related = parser.add_argument_group('output control arguments') 53output_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory') 54output_mode = output_related.add_mutually_exclusive_group() 55output_mode.add_argument('-c', action='store_true', help='write a [c]opy of input XML, not canonical XML') 56output_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not canonical XML') 57output_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing') 58output_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations') 59 60parser.add_argument('files', metavar='FILE', nargs='*', help='files to process (default: STDIN)') 61 62info = parser.add_argument_group('info arguments') 63info = info.add_mutually_exclusive_group() 64info.add_argument('-h', action='store_true', help='show this [h]elp message and exit') 65info.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit') 66 67 68if __name__ == '__main__': 69 parser.print_help() 70