Skip to content

Commit

Permalink
Rename getArgumentParser and initArgumentParser methods based on PEP 8.
Browse files Browse the repository at this point in the history
Closes #51
  • Loading branch information
bw2 committed Sep 5, 2016
1 parent 27c1077 commit 975d7cd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions configargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
# global ArgumentParser instances
_parsers = {}

def initArgumentParser(name=None, **kwargs):
def init_argument_parser(name=None, **kwargs):
"""Creates a global ArgumentParser instance with the given name,
passing any args other than "name" to the ArgumentParser constructor.
This instance can then be retrieved using getArgumentParser(..)
This instance can then be retrieved using get_argument_parser(..)
"""

if name is None:
Expand All @@ -43,7 +43,7 @@ def initArgumentParser(name=None, **kwargs):
_parsers[name] = ArgumentParser(**kwargs)


def getArgumentParser(name=None, **kwargs):
def get_argument_parser(name=None, **kwargs):
"""Returns the global ArgumentParser instance with the given name. The 1st
time this function is called, a new ArgumentParser instance will be created
for the given name, and any args other than "name" will be passed on to the
Expand All @@ -53,7 +53,7 @@ def getArgumentParser(name=None, **kwargs):
name = "default"

if len(kwargs) > 0 or name not in _parsers:
initArgumentParser(name, **kwargs)
init_argument_parser(name, **kwargs)

return _parsers[name]

Expand Down Expand Up @@ -931,9 +931,15 @@ def already_on_command_line(existing_args_list, potential_command_line_args):
SUPPRESS = argparse.SUPPRESS
ZERO_OR_MORE = argparse.ZERO_OR_MORE

# deprecated PEP-8 incompatible API names.
initArgumentParser = init_argument_parser
getArgumentParser = get_argument_parser
getArgParser = get_argument_parser
getParser = get_argument_parser

# create shorter aliases for the key methods and class names
getArgParser = getArgumentParser
getParser = getArgumentParser
get_arg_parser = get_argument_parser
get_parser = get_argument_parser

ArgParser = ArgumentParser
Parser = ArgumentParser
Expand Down

0 comments on commit 975d7cd

Please sign in to comment.