Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. """Checks a given DocBook XML file for stylistic errors
  4.  
  5. Usage:
  6. sdsc [-h | --help]
  7. sdsc [options] INPUTFILE [OUTPUTFILE]
  8.  
  9. Required arguments:
  10. INPUTFILE the DocBook XML file to check for
  11. OUTPUTFILE optional result file or stdout
  12.  
  13. Options:
  14. -h, --help show this help message and exit
  15. --version show version number and exit
  16. -b, --bookmarklet open Web page that lets you install a bookmarklet to
  17. manage style checker results
  18. -s, --show show final report in $BROWSER, or default browser if
  19. unset; not all browsers open report files correctly and
  20. for some users, a text editor will open; in such cases,
  21. set the BROWSER variable with: export BROWSER=/MY/BROWSER;
  22. Chromium or Firefox will both do the right thing
  23. --module writes name of current check module to stdout
  24. --performance write performance measurements to stdout
  25. --checkpatterns check formal validity of built-in regular expression
  26. patterns
  27. """
  28.  
  29. from docopt import docopt
  30.  
  31. __proc__ = "sdsc"
  32. __version__ = "1.0.0"
  33.  
  34.  
  35. def parsecli(cliargs=None):
  36. """Parse CLI arguments with docopt
  37.  
  38. :param list cliargs: List of commandline arguments
  39. :return: dictionary from docopt
  40. :rtype: dict
  41. """
  42. version = "%s %s" % (__package__, __version__)
  43. args = docopt(__doc__, argv=cliargs, version=version)
  44. return args
  45.  
  46.  
  47. if __name__ == "__main__":
  48. args = parsecli()
  49. print(args)
  50.  
  51. # ./sdsc_docopt.py foo.xml
  52. # {'--bookmarklet': False,
  53. # '--checkpatterns': False,
  54. # '--help': False,
  55. # '--module': False,
  56. # '--performance': False,
  57. # '--show': False,
  58. # '--version': False,
  59. # 'INPUTFILE': 'foo.xml',
  60. # 'OUTPUTFILE': None}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement