X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=src%2Fpyutils%2Fconfig.py;h=ad97038ed4f4da3f603b84eaedd1d6cde8a77c55;hb=a2cb839d6932060ea00ad9b9d7c198ab310affe4;hp=be11a779507c5ff741c67771b7511fc4b24984b1;hpb=5bbcfd4dfccd411df0afd03f9790f67b4c852b9c;p=pyutils.git diff --git a/src/pyutils/config.py b/src/pyutils/config.py index be11a77..ad97038 100644 --- a/src/pyutils/config.py +++ b/src/pyutils/config.py @@ -7,7 +7,8 @@ optionally, from saved (local or Zookeeper) configuration files... with optional support for dynamic arguments (i.e. that can change during runtime). Let's start with an example of how to use :py:mod:`pyutils.config`. It's -pretty easy for normal commandline arguments because it uses :py:mod:`argparse`: +pretty easy for normal commandline arguments because it wraps :py:mod:`argparse` +(see https://docs.python.org/3/library/argparse.html): In your file.py:: @@ -139,13 +140,15 @@ ORIG_ARGV: List[str] = sys.argv.copy() class OptionalRawFormatter(argparse.HelpFormatter): - """This formatter has the same bahavior as the normal argparse text - formatter except when the help text of an argument begins with - "RAW|". In that case, the line breaks are preserved and the text - is not wrapped. + """This formatter has the same bahavior as the normal argparse + text formatter except when the help text of an argument begins + with "RAW|". In that case, the line breaks are preserved and the + text is not wrapped. It is enabled automatically if you use + :py:mod:`pyutils.config`. - Use this, for example, when you need the helptext of an argument - to have its spacing preserved exactly, e.g.:: + Use this by prepending "RAW|" in your help message to disable + word wrapping and indicate that the help message is already + formatted and should be preserved. Here's an example usage:: args.add_argument( '--mode', @@ -170,6 +173,7 @@ class OptionalRawFormatter(argparse.HelpFormatter): PRECOMPUTE = populate hash table with optimal guesses. ''', ) + """ def _split_lines(self, text, width):