Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
definite committed Jun 26, 2018
1 parent 0378d9e commit 23e6c08
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ZanataArgParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ def add_env( # pylint: disable=too-many-arguments
dest=None,
sub_commands=None):
# type: (str, object, bool, type, str, List[str]) -> None
"""Add environment variable"""
"""Add environment variable
env_name: Environment variable name
default: Default value
value_type: type of value e.g. str
dest: attribute name to be return by parse_*
sub_commands: List of subcommands that use this environment"""
if not dest:
dest = env_name.lower()
if env_name in self.env_def:
Expand All @@ -76,7 +81,10 @@ def add_env( # pylint: disable=too-many-arguments

def has_common_argument(self, option_string=None, dest=None):
# type: (str, str) -> bool
"""Whether this parser parses this common argument"""
"""Has the parser defined this argument as a common argument?
Either specify option_string or dest
option_string: option in command line. e.g. -i
dest: attribute name to be return by parse_*"""
for action in self.parent_parser._actions: # pylint: disable=W0212
if option_string:
if option_string in action.option_strings:
Expand Down Expand Up @@ -115,7 +123,7 @@ def parse_args(self, args=None, namespace=None):
return result

@staticmethod
def is_env_valid(env_name, env_value, env_data, args):
def _is_env_valid(env_name, env_value, env_data, args):
# type (str, str, dict, argparse.Namespace) -> bool
"""The invalid env should be skipped or raise error"""
# Skip when the env is NOT in the list of supported sub-commands
Expand All @@ -141,7 +149,7 @@ def parse_env(self, args=None):
env_data = self.env_def[env_name]
env_value = os.environ.get(env_name)
try:
if not ZanataArgParser.is_env_valid(
if not ZanataArgParser._is_env_valid(
env_name, env_value, env_data, args):
continue
except AssertionError as e:
Expand Down

0 comments on commit 23e6c08

Please sign in to comment.