Args:
    args: the command line args, probably passed from main() as sys.argv[1:]
  Returns:
    a populated EFVersionContext object
357590
def handle_args_and_set_context(args):
  
  parser = argparse.ArgumentParser()
  parser.add_argument("service_name", help="name of the service")
  parser.add_argument("key", help="version key to look up for <service_name> such as 'ami-id' (list in EF_Config)")
  parser.add_argument("env", help=", ".join(EFConfig.ENV_LIST))
  group = parser.add_mutually_exclusive_group(required=True)
  group.add_argument("--get", help="get current version", action="store_true")
  group.add_argument("--set", help="set current version of <key> to <value> for <service_name>")
  group.add_argument("--rollback", help="set current version to most recent 'stable' version in history",
                     action="store_true")
  group.add_argument("--rollback-to", help="rollback current version to <ami-id> in history",
                     action="store", metavar='<ami-id>')
  group.add_argument("--history", help="Show version history for env/service/key", choices=['json', 'text'])
  group.add_argument("--show", help="Show keys and values. '*' allowed for <key> and <env>",
                     action="store_true", default=False)
  parser.add_argument("--build",
                      help="On --set, also set the externally defined build number associated with the version entity",
                      default="")
  parser.add_argument("--commit_hash", help="On --set, also set the commit hash associated with the version entity",
                      default="")
  parser.add_argument("--commit", help="Actually --set or --rollback (dry run if omitted)",
                      action="store_true", default=False)
  parser.add_argument("--devel", help="Allow running from branch; don't refresh from origin", action="store_true",
                      default=False)
  parser.add_argument("--force_env_full", help="Override env with env_full for account-scoped environments",
                      action="store_true", default=False)
  parser.add_argument("--limit", help="Limit 'history', 'rollback', 'show' to first N records (default 100, max 1000)",
                      type=int, default=100)
  parser.add_argument("--location", help="On --set, also mark the url location of the static build's version file to"
                      "support dist-hash precheck", default="")
  if EFConfig.ALLOW_EF_VERSION_SKIP_PRECHECK:
    parser.add_argument("--noprecheck", help="--set or --rollback without precheck", action="store_true", default=False)
  parser.add_argument("--sr", help="optional /path/to/service_registry_file.json", default=None)
  parser.add_argument("--stable", help="On --set, also mark the version 'stable'", action="store_true")
  parser.add_argument("--verbose", help="Print additional info", action="store_true", default=False)
  # parse
  parsed_args = vars(parser.parse_args(args))
  context = EFVersionContext()
  # marshall the inherited context values
  context._build_number = parsed_args["build"]
  context._commit_hash = parsed_args["commit_hash"]
  context.commit = parsed_args["commit"]
  context.devel = parsed_args["devel"]
  context._force_env_full = parsed_args["force_env_full"]
  try:
    context.env = parsed_args["env"]
  except ValueError as e:
    fail("Error in env: {}".format(e.message))
  # marshall this module's additional context values
  context._get = parsed_args["get"]
  context._history = parsed_args["history"]
  context._key = parsed_args["key"]
  if EFConfig.ALLOW_EF_VERSION_SKIP_PRECHECK:
    context._noprecheck = parsed_args["noprecheck"]
  if not 1 <= parsed_args["limit"] <= 1000:
    fail("Error in --limit. Valid range: 1..1000")
  context._limit = parsed_args["limit"]
  context._location = parsed_args["location"]
  context._rollback = parsed_args["rollback"]
  context._rollback_to = parsed_args["rollback_to"]
  context._service_name = parsed_args["service_name"]
  context._show = parsed_args["show"]
  context._stable = parsed_args["stable"]
  context._value = parsed_args["set"]
  # Set up service registry and policy template path which depends on it
  context.service_registry = EFServiceRegistry(parsed_args["sr"])

  # VERBOSE is global
  global VERBOSE
  VERBOSE = parsed_args["verbose"]

  validate_context(context)
  return context
294757
def init_args(self):
        """"""
        version = "Glances v" + __version__ + " with psutil v" + psutil_version
        parser = argparse.ArgumentParser(
            prog='glances',
            conflict_handler='resolve',
            formatter_class=argparse.RawDescriptionHelpFormatter,
            epilog=self.example_of_use)
        parser.add_argument(
            '-V', '--version', action='version', version=version)
        parser.add_argument('-d', '--debug', action='store_true', default=False,
                            dest='debug', help='enable debug mode')
        parser.add_argument('-C', '--config', dest='conf_file',
                            help='path to the configuration file')
        # Disable plugin
        parser.add_argument('--modules-list', '--module-list',
                            action='store_true', default=False,
                            dest='modules_list',
                            help='display modules (plugins & exports) list and exit')
        parser.add_argument('--disable-plugin', dest='disable_plugin',
                            help='disable plugin (comma separed list)')
        parser.add_argument('--disable-process', action='store_true', default=False,
                            dest='disable_process', help='disable process module')
        # Enable or disable option
        parser.add_argument('--disable-webui', action='store_true', default=False,
                            dest='disable_webui', help='disable the Web Interface')
        parser.add_argument('--light', '--enable-light', action='store_true',
                            default=False, dest='enable_light',
                            help='light mode for Curses UI (disable all but top menu)')
        parser.add_argument('-0', '--disable-irix', action='store_true', default=False,
                            dest='disable_irix', help='task\'s cpu usage will be divided by the total number of CPUs')
        parser.add_argument('-1', '--percpu', action='store_true', default=False,
                            dest='percpu', help='start Glances in per CPU mode')
        parser.add_argument('-2', '--disable-left-sidebar', action='store_true',
                            default=False, dest='disable_left_sidebar',
                            help='disable network, disk I/O, FS and sensors modules')
        parser.add_argument('-3', '--disable-quicklook', action='store_true', default=False,
                            dest='disable_quicklook', help='disable quick look module')
        parser.add_argument('-4', '--full-quicklook', action='store_true', default=False,
                            dest='full_quicklook', help='disable all but quick look and load')
        parser.add_argument('-5', '--disable-top', action='store_true',
                            default=False, dest='disable_top',
                            help='disable top menu (QL, CPU, MEM, SWAP and LOAD)')
        parser.add_argument('-6', '--meangpu', action='store_true', default=False,
                            dest='meangpu', help='start Glances in mean GPU mode')
        parser.add_argument('--disable-history', action='store_true', default=False,
                            dest='disable_history', help='disable stats history')
        parser.add_argument('--disable-bold', action='store_true', default=False,
                            dest='disable_bold', help='disable bold mode in the terminal')
        parser.add_argument('--disable-bg', action='store_true', default=False,
                            dest='disable_bg', help='disable background colors in the terminal')
        parser.add_argument('--enable-irq', action='store_true', default=False,
                            dest='enable_irq', help='enable IRQ module'),
        parser.add_argument('--enable-process-extended', action='store_true', default=False,
                            dest='enable_process_extended', help='enable extended stats on top process')
        # Export modules feature
        parser.add_argument('--export', dest='export',
                            help='enable export module (comma separed list)')
        parser.add_argument('--export-csv-file',
                            default='./glances.csv',
                            dest='export_csv_file',
                            help='file path for CSV exporter')
        parser.add_argument('--export-json-file',
                            default='./glances.json',
                            dest='export_json_file',
                            help='file path for JSON exporter')
        parser.add_argument('--export-graph-path',
                            default=tempfile.gettempdir(),
                            dest='export_graph_path',
                            help='Folder for Graph exporter')
        # Client/Server option
        parser.add_argument('-c', '--client', dest='client',
                            help='connect to a Glances server by IPv4/IPv6 address or hostname')
        parser.add_argument('-s', '--server', action='store_true', default=False,
                            dest='server', help='run Glances in server mode')
        parser.add_argument('--browser', action='store_true', default=False,
                            dest='browser', help='start the client browser (list of servers)')
        parser.add_argument('--disable-autodiscover', action='store_true', default=False,
                            dest='disable_autodiscover', help='disable autodiscover feature')
        parser.add_argument('-p', '--port', default=None, type=int, dest='port',
                            help='define the client/server TCP port [default: {}]'.format(self.server_port))
        parser.add_argument('-B', '--bind', default='0.0.0.0', dest='bind_address',
                            help='bind server to the given IPv4/IPv6 address or hostname')
        parser.add_argument('--username', action='store_true', default=False, dest='username_prompt',
                            help='define a client/server username')
        parser.add_argument('--password', action='store_true', default=False, dest='password_prompt',
                            help='define a client/server password')
        parser.add_argument('-u', dest='username_used',
                            help='use the given client/server username')
        parser.add_argument('--snmp-community', default='public', dest='snmp_community',
                            help='SNMP community')
        parser.add_argument('--snmp-port', default=161, type=int,
                            dest='snmp_port', help='SNMP port')
        parser.add_argument('--snmp-version', default='2c', dest='snmp_version',
                            help='SNMP version (1, 2c or 3)')
        parser.add_argument('--snmp-user', default='private', dest='snmp_user',
                            help='SNMP username (only for SNMPv3)')
        parser.add_argument('--snmp-auth', default='password', dest='snmp_auth',
                            help='SNMP authentication key (only for SNMPv3)')
        parser.add_argument('--snmp-force', action='store_true', default=False,
                            dest='snmp_force', help='force SNMP mode')
        parser.add_argument('-t', '--time', default=self.refresh_time, type=float,
                            dest='time', help='set refresh time in seconds [default: {} sec]'.format(self.refresh_time))
        parser.add_argument('-w', '--webserver', action='store_true', default=False,
                            dest='webserver', help='run Glances in web server mode (bottle needed)')
        parser.add_argument('--cached-time', default=self.cached_time, type=int,
                            dest='cached_time', help='set the server cache time [default: {} sec]'.format(self.cached_time))
        parser.add_argument('--open-web-browser', action='store_true', default=False,
                            dest='open_web_browser', help='try to open the Web UI in the default Web browser')
        # Display options
        parser.add_argument('-q', '--quiet', default=False, action='store_true',
                            dest='quiet', help='do not display the curses interface')
        parser.add_argument('-f', '--process-filter', default=None, type=str,
                            dest='process_filter', help='set the process filter pattern (regular expression)')
        parser.add_argument('--process-short-name', action='store_true', default=False,
                            dest='process_short_name', help='force short name for processes name')
        parser.add_argument('--stdout', default=None,
                            dest='stdout', help='display stats to stdout, one stat per line (comma separated list of plugins/plugins.attribute)')
        parser.add_argument('--stdout-csv', default=None,
                            dest='stdout_csv', help='display stats to stdout, csv format (comma separated list of plugins/plugins.attribute)')
        if not WINDOWS:
            parser.add_argument('--hide-kernel-threads', action='store_true', default=False,
                                dest='no_kernel_threads', help='hide kernel threads in process list (not available on Windows)')
        parser.add_argument('-b', '--byte', action='store_true', default=False,
                            dest='byte', help='display network rate in byte per second')
        parser.add_argument('--diskio-show-ramfs', action='store_true', default=False,
                            dest='diskio_show_ramfs', help='show RAM Fs in the DiskIO plugin')
        parser.add_argument('--diskio-iops', action='store_true', default=False,
                            dest='diskio_iops', help='show IO per second in the DiskIO plugin')
        parser.add_argument('--fahrenheit', action='store_true', default=False,
                            dest='fahrenheit', help='display temperature in Fahrenheit (default is Celsius)')
        parser.add_argument('--fs-free-space', action='store_true', default=False,
                            dest='fs_free_space', help='display FS free space instead of used')
        parser.add_argument('--sparkline', action='store_true', default=False,
                            dest='sparkline', help='display sparklines instead of bar in the curses interface')
        parser.add_argument('--theme-white', action='store_true', default=False,
                            dest='theme_white', help='optimize display colors for white background')
        # Globals options
        parser.add_argument('--disable-check-update', action='store_true', default=False,
                            dest='disable_check_update', help='disable online Glances version ckeck')
        return parser
91403
def parse_args():
  """"""
  parser = ArgumentParser(description="ModelBase builder")
  subparsers = parser.add_subparsers()

  sql_parser = subparsers.add_parser(
    "get-query",
    description="Usage: e.g. psql -c \"copy ($(python3 lib/generate_models.py get-query)) to " +
                "stdout with csv header\" DB_NAME postgres")
  sql_parser.set_defaults(func=print_sql_query)

  gen_parser = subparsers.add_parser("generate")
  gen_parser.add_argument("filename", nargs="?", help="Read this file for input, or STDIN if not " \
                                                      "given")
  gen_parser.add_argument("-i", "--indent", default="  ")
  gen_parser.add_argument("-c", "--created-at-col-name", default="created_at")
  gen_parser.add_argument("-u", "--updated-at-col-name", default="updated_at")
  gen_parser.set_defaults(func=generate_models)

  args = parser.parse_args()

  if hasattr(args, "func"):
    return args
  else:
    arg_parser.print_help()
    sys.exit(1)
110662
def main(args):
    
    try:
        import __main__
        parser = argparse.ArgumentParser(
            usage='%(prog)s [options] command\n\nVersion\n  %(prog)s version '
            + str(__version__),
            formatter_class=argparse.RawTextHelpFormatter)
        parser.add_argument('--version', action='version',
                            version='%(prog)s ' + str(__version__))
        build_subcommands_parser(parser, __main__)

        if len(args) <= 1:
            parser.print_help()
            return 1

        options = parser.parse_args(args[1:])
        # Filter out options with are not part of the function prototype.
        func_args = filter_subcommand_args(options.func, options)
        options.func(**func_args)

    except RuntimeError as err:
        LOGGER.error(err)
        return err.code
226950
def main():
    
    about_str = "{} version: {}".format(PROJECT_NAME, VERSION)
    parser = argparse.ArgumentParser(description = about_str)

    parser.add_argument('fileNames', metavar='FILE', nargs='*', help='Input files')

    parser.add_argument('-i', '--inspector', dest='inspector',
        help="""The identifier or fullName of the inspector that will be opened at start up.
                E.g. 'Qt/Table'""")

    parser.add_argument('--list-inspectors', dest='list_inspectors', action = 'store_true',
        help="""Prints a list of available inspectors for the -i option""")


    parser.add_argument('-s', '--select', dest='selectPath',
        help="""Full path name of a repository tree item that will be selected at start-up.
                E.g. 'file/var/fieldname'""")

    parser.add_argument('-p', '--profile', dest='profile', default=DEFAULT_PROFILE,
        help="Can be used to have different persistent settings for different use cases.")

    parser.add_argument('--reset', '--reset-profile', dest='reset_profile', action = 'store_true',
        help="If set, persistent settings will be reset for the current profile.")

    parser.add_argument('--reset-all-profiles', dest='reset_all_profiles', action = 'store_true',
        help="If set, persistent settings will be reset for the all profiles.")

    parser.add_argument('--reset-registry', dest='reset_registry', action = 'store_true',
        help="If set, the registry will be reset to contain only the default plugins.")

    parser.add_argument('--version', action = 'store_true',
        help="Prints the program version.")

    parser.add_argument('-l', '--log-level', dest='log_level', default='warning',
        help="Log level. Only log messages with a level higher or equal than this will be printed. "
             "Default: 'warning'",
        choices=('debug', 'info', 'warning', 'error', 'critical'))

    args = parser.parse_args(remove_process_serial_number(sys.argv[1:]))

    if DEBUGGING:
        logger.info("Setting log level to: {}".format(args.log_level.upper()))
    logger.setLevel(args.log_level.upper())

    if DEBUGGING:
        logger.warn("Debugging flag is on!")

    if args.version:
        print(about_str)
        sys.exit(0)

    if args.list_inspectors:
        printInspectors()
        sys.exit(0)

    logger.info('Started {} {}'.format(PROJECT_NAME, VERSION))
    logger.info("Python version: {}".format(sys.version).replace('\n', ''))
    #logger.info('Using: {}'.format('PyQt' if USE_PYQT else 'PySide'))

    # Imported here so this module can be imported without Qt being installed.
    from argos.qt.misc import ABOUT_QT_BINDINGS
    logger.info("Using {}".format(ABOUT_QT_BINDINGS))

    # Browse will create an ArgosApplication with one MainWindow
    browse(fileNames = args.fileNames,
           inspectorFullName=args.inspector,
           select=args.selectPath,
           profile=args.profile,
           resetProfile=args.reset_profile,
           resetAllProfiles=args.reset_all_profiles,
           resetRegistry=args.reset_registry)
    logger.info('Done {}'.format(PROJECT_NAME))
986689
def _get_args(self, *args) -> (Exception, str):
        
        ex = None
        msg = None
        for arg in args:
            if isinstance(arg, str):
                msg = arg
            elif isinstance(arg, Exception):
                ex = arg
        return ex, msg
96585
def get_args(self):
        
        for table in self.tables + self.with_tables:
            if type(table) is QueryTable:
                self._where.args.update(table.query.get_args())

        return self._where.args
1120332
def override_args(**kwargs):
  

  override_kwargs = kwargs

  def custom_getter(getter, *args, **kwargs):
    """Custom getter with certain named arguments overridden.

    Args:
      getter: Underlying variable getter to invoke.
      *args: Arguments, compatible with those of tf.get_variable.
      **kwargs: Keyword arguments, compatible with those of tf.get_variable.

    Returns:
      The result of invoking `getter(*args, **kwargs)` except that certain
      kwargs entries may have been overridden.
    """
    kwargs.update(override_kwargs)
    return getter(*args, **kwargs)

  return custom_getter
109511
public static void main(String args[]) {
        // Associate a new Context with this thread
        Context cx = Context.enter();
        try {
            // Initialize the standard objects (Object, Function, etc.)
            // This must be done before scripts can be executed.
            Shell shell = new Shell();
            cx.initStandardObjects(shell);

            // Define some global functions particular to the shell. Note
            // that these functions are not part of ECMA.
            String[] names = { "print", "quit", "version", "load", "help" };
            shell.defineFunctionProperties(names, Shell.class,
                                           ScriptableObject.DONTENUM);

            args = processOptions(cx, args);

            // Set up "arguments" in the global scope to contain the command
            // line arguments after the name of the script to execute
            Object[] array;
            if (args.length == 0) {
                array = new Object[0];
            } else {
                int length = args.length - 1;
                array = new Object[length];
                System.arraycopy(args, 1, array, 0, length);
            }
            Scriptable argsObj = cx.newArray(shell, array);
            shell.defineProperty("arguments", argsObj,
                                 ScriptableObject.DONTENUM);

            shell.processSource(cx, args.length == 0 ? null : args[0]);
        } finally {
            Context.exit();
        }
    }
416593
def handle_args_and_set_context(args):
  
  parser = argparse.ArgumentParser()
  parser.add_argument("env", help="environment")
  parser.add_argument("path_to_template", help="path to the config template to process")
  parser.add_argument("--no_params", help="disable loading values from params file", action="store_true", default=False)
  parser.add_argument("--verbose", help="Output extra info", action="store_true", default=False)
  parser.add_argument("--lint", help="Test configs for valid JSON/YAML syntax", action="store_true", default=False)
  parser.add_argument("--silent", help="Suppress output of rendered template", action="store_true", default=False)
  parsed = vars(parser.parse_args(args))
  path_to_template = abspath(parsed["path_to_template"])
  service = path_to_template.split('/')[-3]

  return Context(
      get_account_alias(parsed["env"]),
      EFConfig.DEFAULT_REGION,
      parsed["env"],
      service,
      path_to_template,
      parsed["no_params"],
      parsed["verbose"],
      parsed["lint"],
      parsed["silent"]
  )
276050
def do_args(self, arg):
        
        co = self.curframe.f_code
        dict = self.get_locals(self.curframe)
        n = co.co_argcount
        if co.co_flags & 4: n = n+1
        if co.co_flags & 8: n = n+1
        for i in range(n):
            name = co.co_varnames[i]
            if name in dict:
                self.message('%s = %s' % (name, bdb.safe_repr(dict[name])))
            else:
                self.message('%s = *** undefined ***' % (name,))
557925
def run_from_argv(self, argv):
        
        if (len(argv) > 2 and not argv[2].startswith('-') and
                argv[2] in self.subcommands.keys()):
            subcommand = argv[2]
            klass = self.get_subcommand(subcommand)
            parser = OptionParser(
                prog=argv[0],
                usage=klass.usage('{0} {1}'.format(argv[1], subcommand)),
                version=klass.get_version(), option_list=klass.option_list)
            options, args = parser.parse_args(argv[3:])
            args = [subcommand] + args
        else:
            parser = self.create_parser(argv[0], argv[1])
            options, args = parser.parse_args(argv[2:])

        handle_default_options(options)
        self.execute(*args, **options.__dict__)
1250009
def __get_arg(cls, kwds, kwd):
    """"""
    alt_kwd = '_' + kwd
    if alt_kwd in kwds:
      return kwds.pop(alt_kwd)
    if kwd in kwds:
      obj = getattr(cls, kwd, None)
      if not isinstance(obj, Property) or isinstance(obj, ModelKey):
        return kwds.pop(kwd)
    return None
1374662
def parse_args(args, cfg):
    
    prog = pathlib.Path(sys.argv[0]).parts[-1].replace('.py', '')
    prog_version = "%%(prog)s %s" % versionner.__version__

    # pylint: disable=invalid-name
    p = argparse.ArgumentParser(prog=prog, description='Helps manipulating version of the project')
    p.add_argument('--file', '-f', dest='version_file', type=str,
        default=cfg.version_file,
        help="path to file where version is saved")
    p.add_argument('--version', '-v', action="version", version=prog_version)
    p.add_argument('--date-format', type=str,
        default=cfg.date_format,
        help="Date format used in project files")
    p.add_argument('--verbose', action="store_true",
        help="Be more verbose if it's possible")

    sub = p.add_subparsers(dest='command')

    p_init = sub.add_parser('init', aliases=commands.get_aliases_for('init'),
        help="Create new version file")
    p_init.add_argument('value', nargs='?', type=str,
        default=cfg.default_init_version,
        help="Initial version")
    p_init.add_argument('--vcs-engine', type=str,
        default=cfg.vcs_engine,
        help="Select VCS engine (only git is supported currently)", )
    p_init.add_argument('--vcs-commit-message', '-m', type=str,
        default=cfg.vcs_commit_message,
        help="Commit message used when committing changes")
    p_init.add_argument('--commit', '-c', action='store_true',
        help="Commit changes done by `up` command (only if there is no changes in repo before)")

    p_up = sub.add_parser('up', aliases=commands.get_aliases_for('up'),
        help="Increase version")
    p_up.add_argument('--vcs-engine', type=str,
        default=cfg.vcs_engine,
        help="Select VCS engine (only git is supported currently)", )
    p_up.add_argument('--vcs-commit-message', '-m', type=str,
        default=cfg.vcs_commit_message,
        help="Commit message used when committing changes")
    p_up.add_argument('--commit', '-c', action='store_true',
        help="Commit changes done by `up` command (only if there is no changes in repo before)")
    p_up.add_argument('value', nargs='?', type=int,
        default=cfg.default_increase_value,
        help="Increase version by this value (default: %d)" % cfg.default_increase_value)

    p_up_gr = p_up.add_mutually_exclusive_group()
    p_up_gr.add_argument('--major', '-j', action="store_true",
        help="increase major part of version" + (" (project default)" if cfg.up_part == 'major' else ""))
    p_up_gr.add_argument('--minor', '-n', action="store_true",
        help="increase minor part of version" + (" (project default)" if cfg.up_part == 'minor' else ""))
    p_up_gr.add_argument('--patch', '-p', action="store_true",
        help="increase patch part of version" + (" (project default)" if cfg.up_part == 'patch' else ""))

    p_set = sub.add_parser('set', aliases=commands.get_aliases_for('set'),
        help="Set version to specified one")
    p_set.add_argument('--major', '-j', type=int,
        help="set major part of version to MAJOR")
    p_set.add_argument('--minor', '-n', type=int,
        help="set minor part of version to MINOR")
    p_set.add_argument('--patch', '-p', type=int,
        help="set patch part of version to PATCH")
    p_set.add_argument('--prerelease', '-r', type=str,
        help="set prerelease part of version to PRERELEASE")
    p_set.add_argument('--build', '-b', type=str,
        help="set build part of version to BUILD")
    p_set.add_argument('--vcs-engine', type=str,
        default=cfg.vcs_engine,
        help="Select VCS engine (only git is supported currently)", )
    p_set.add_argument('--vcs-commit-message', '-m', type=str,
        default=cfg.vcs_commit_message,
        help="Commit message used when committing changes")
    p_set.add_argument('--commit', '-c', action='store_true',
        help="Commit changes done by `set` command (only if there is no changes in repo before)")
    p_set.add_argument('value', nargs='?', type=str,
        help="set version to this value")

    p_tag = sub.add_parser('tag', aliases=commands.get_aliases_for('tag'),
        help="Create VCS tag with current version")
    p_tag.add_argument('--vcs-tag-param', dest='vcs_tag_params', type=str, action="append",
        help="Additional params for VCS for \"tag\" command")

    sub.add_parser('read', aliases=commands.get_aliases_for('read'),
        help="Read current version")

    args = p.parse_args(args)

    cfg.command = args.command
    cfg.version_file = pathlib.Path(args.version_file).absolute()
    cfg.date_format = args.date_format
    cfg.verbose = args.verbose

    version_file_requirement = 'doesn\'t matter'
    if cfg.command == 'init':
        version_file_requirement = 'none'

        cfg.commit = args.commit
        cfg.vcs_engine = args.vcs_engine
        cfg.vcs_commit_message = args.vcs_commit_message
        cfg.value = args.value

    elif cfg.command == 'up':
        version_file_requirement = 'required'

        cfg.commit = args.commit
        cfg.vcs_engine = args.vcs_engine
        cfg.vcs_commit_message = args.vcs_commit_message
        cfg.value = args.value
        if args.major:
            cfg.up_part = 'major'
        elif args.minor:
            cfg.up_part = 'minor'
        elif args.patch:
            cfg.up_part = 'patch'

    elif cfg.command == 'set':
        version_file_requirement = 'required'

        cfg.commit = args.commit
        cfg.vcs_engine = args.vcs_engine
        cfg.vcs_commit_message = args.vcs_commit_message

        if args.value:
            cfg.value = args.value
        else:
            cfg.value = (
                args.major, args.minor, args.patch,
                args.prerelease, args.build
            )

            if all(value is None for value in cfg.value):
                p.error("Version is not specified")

    elif cfg.command == 'tag':
        version_file_requirement = 'required'

        cfg.vcs_tag_params = args.vcs_tag_params or []

    elif cfg.command is None:
        cfg.command = 'read'
        version_file_requirement = 'required'

    if version_file_requirement == 'required':
        if not cfg.version_file.exists():
            p.error("Version file \"%s\" doesn't exists" % cfg.version_file)
    elif version_file_requirement == 'none':
        if cfg.version_file.exists():
            p.error("Version file \"%s\" already exists" % cfg.version_file)
277417
def get_arguments():
    
    # https://docs.python.org/3/library/argparse.html
    parser = argparse.ArgumentParser(
        description='Handles bumping of the artifact version')
    parser.add_argument('--log-config',
                        '-l',
                        action='store',
                        dest='logger_config',
                        help='The location of the logging config json file',
                        default='')
    parser.add_argument('--log-level',
                        '-L',
                        help='Provide the log level. Defaults to INFO.',
                        dest='log_level',
                        action='store',
                        default='INFO',
                        choices=['DEBUG',
                                 'INFO',
                                 'WARNING',
                                 'ERROR',
                                 'CRITICAL'])
    parser.add_argument('--major',
                        help='Bump the major version',
                        dest='bump_major',
                        action='store_true',
                        default=False)
    parser.add_argument('--minor',
                        help='Bump the minor version',
                        dest='bump_minor',
                        action='store_true',
                        default=False)
    parser.add_argument('--patch',
                        help='Bump the patch version',
                        dest='bump_patch',
                        action='store_true',
                        default=False)
    parser.add_argument('--version',
                        help='Set the version',
                        dest='version',
                        action='store',
                        default=False)
    args = parser.parse_args()
    return args
135243
def run(self, argv):
        
        (opts, args) = self.parser().parse_args(argv)
        func_args = args[args.index(self.__name__) + 1:]
        func_kwds = opts.__dict__

        return self.__call__(*func_args, **func_kwds)
625656
def _arguments(code, module):
  
  arg_parser = CommandParser.create('')
  try:
    # Define our special argument 'types' and add them to the environment.
    builtins = {'source': _table, 'datestring': _datestring}
    env = {}
    env.update(builtins)

    # Execute the cell which should be one or more calls to arg().
    exec(code, env)

    # Iterate through the module dictionary. For any newly defined objects,
    # add args to the parser.
    for key in env:

      # Skip internal/private stuff.
      if key in builtins or key[0] == '_':
        continue
      # If we want to support importing query modules into other query modules, uncomment next 4
      # Skip imports but add them to the module
      # if isinstance(env[key], types.ModuleType):
      #   module.__dict__[key] = env[key]
      #   continue

      val = env[key]
      key = '--%s' % key

      if isinstance(val, bool):
        if val:
          arg_parser.add_argument(key, default=val, action='store_true')
        else:
          arg_parser.add_argument(key, default=val, action='store_false')
      elif isinstance(val, basestring) or isinstance(val, int) or isinstance(val, float) \
              or isinstance(val, int):
        arg_parser.add_argument(key, default=val)
      elif isinstance(val, list):
        arg_parser.add_argument(key, default=val, nargs='+')
      elif isinstance(val, tuple):
        arg_parser.add_argument(key, default=list(val), nargs='+')

      # Is this one of our pseudo-types for dates/tables?
      elif isinstance(val, dict) and 'type' in val:
        if val['type'] == 'datestring':
          arg_parser.add_argument(key, default='',
                                  type=_make_string_formatter(val['format'],
                                                              offset=val['offset']))
        elif val['type'] == 'table':
          if val['format'] is not None:
            arg_parser.add_argument(key, default='',
                                    type=_make_table_formatter(val['format'],
                                                               offset=val['offset']))
          else:
            arg_parser.add_argument(key, default=val['name'], type=_make_table)
        else:
          raise Exception('Cannot generate argument for %s of type %s' % (key, type(val)))
      else:
        raise Exception('Cannot generate argument for %s of type %s' % (key, type(val)))

  except Exception as e:
    print("%%sql arguments: %s from code '%s'" % (str(e), str(code)))
  return arg_parser