Return list of OSPD common command-line arguments from parser, after
    validating provided values or setting default ones.
187635
def get_common_args(parser, args=None):
    

    options = parser.parse_args(args)
    # TCP Port to listen on.
    port = options.port

    # Network address to bind listener to
    address = options.bind_address

    # Unix file socket to listen on
    unix_socket = options.unix_socket

    # Debug level.
    log_level = options.log_level

    # Server key path.
    keyfile = options.key_file or KEY_FILE

    # Server cert path.
    certfile = options.cert_file or CERT_FILE

    # CA cert path.
    cafile = options.ca_file or CA_FILE

    common_args = dict()
    common_args['port'] = port
    common_args['address'] = address
    common_args['unix_socket'] = unix_socket
    common_args['keyfile'] = keyfile
    common_args['certfile'] = certfile
    common_args['cafile'] = cafile
    common_args['log_level'] = log_level
    common_args['foreground'] = options.foreground
    common_args['log_file'] = options.log_file
    common_args['version'] = options.version

    return common_args
995295
def parse_args():
    """"""
    threshold_choices = docutils.frontend.OptionParser.threshold_choices

    parser = argparse.ArgumentParser(
        description=__doc__ + (' Sphinx is enabled.'
                               if SPHINX_INSTALLED else ''),
        prog='rstcheck')

    parser.add_argument('files', nargs='+', type=decode_filename,
                        help='files to check')
    parser.add_argument('--config', metavar='CONFIG', default=None,
                        help='location of config file')
    parser.add_argument('-r', '--recursive', action='store_true',
                        help='run recursively over directories')
    parser.add_argument('--report', metavar='level',
                        choices=threshold_choices,
                        default='info',
                        help='report system messages at or higher than '
                             'level; ' +
                             ', '.join(choice for choice in threshold_choices
                                       if not choice.isdigit()) +
                             ' (default: %(default)s)')
    parser.add_argument('--ignore-language', '--ignore',
                        metavar='language', default='',
                        help='comma-separated list of languages to ignore')
    parser.add_argument('--ignore-messages',
                        metavar='messages', default='',
                        help='python regex that match the messages to ignore')
    parser.add_argument('--ignore-directives',
                        metavar='directives', default='',
                        help='comma-separated list of directives to ignore')
    parser.add_argument('--ignore-substitutions',
                        metavar='substitutions', default='',
                        help='comma-separated list of substitutions to ignore')
    parser.add_argument('--ignore-roles',
                        metavar='roles', default='',
                        help='comma-separated list of roles to ignore')
    parser.add_argument('--debug', action='store_true',
                        help='show messages helpful for debugging')
    parser.add_argument('--version', action='version',
                        version='%(prog)s ' + __version__)

    args = parser.parse_args()

    if '-' in args.files:
        if len(args.files) > 1:
            parser.error("'-' for standard in can only be checked alone")
    else:
        args.files = list(find_files(filenames=args.files,
                                     recursive=args.recursive))

    return args
225080
def getArguments(parser):
    ""
    args = parser.parse_args()
    if args.width <= 0:
        raise argparse.ArgumentError(args.width, 'The contour width must be a positive number.')
    return args
235282
def _parse_arguments():
        
        parser = get_base_arguments(get_parser())
        parser = get_tc_arguments(parser)
        args, unknown = parser.parse_known_args()
        return args, unknown
376377
def _get_args(self, kwargs):
        '''
        
        '''
        _args = list()
        _kwargs = salt.utils.args.clean_kwargs(**kwargs)

        return _args, _kwargs
251319
def parse_options(self, prog_name, arguments):
        """"""
        # Don't want to load configuration to just print the version,
        # so we handle --version manually here.
        if '--version' in arguments:
            self.exit_status(self.version, fh=sys.stdout)
        parser = self.create_parser(prog_name)
        options, args = parser.parse_args(arguments)
        return options, args
1241666
def parse_options():
    """"""

    server, username, password, auto_update_soa = False, False, False, False

    prs = argparse.ArgumentParser(description='usage')
    prs.add_argument('-v', '--version', action='version',
                     version=__version__)
    if os.environ.get('HOME'):
        config_file = os.environ.get('HOME') + '/.tdclirc'
        if os.path.isfile(config_file):
            (server, username,
             password, auto_update_soa) = check_config(config_file)

    conn = dict(server=server, username=username,
                password=password, auto_update_soa=auto_update_soa)

    subprs = prs.add_subparsers(help='commands')

    # Convert and print JSON
    parse_show(subprs)

    # Retrieve records
    parse_get(subprs, conn)

    # Create record
    parse_create(subprs, conn)

    # Create bulk_records
    parse_bulk_create(subprs, conn)

    # Delete record
    parse_delete(subprs, conn)

    # Delete bulk_records
    parse_bulk_delete(subprs, conn)

    # Update a record
    parse_update(subprs, conn)

    # Update SOA serial
    parse_update_soa(subprs, conn)

    # Create zone
    parse_create_zone(subprs, conn)

    # Delete zone
    parse_delete_zone(subprs, conn)

    # Retrieve template
    parse_get_tmpl(subprs, conn)

    # Delete template
    parse_delete_tmpl(subprs, conn)

    args = prs.parse_args()
    return args
634053
def parse_options(arguments=None):
    
    if arguments is None:
        arguments = sys.argv[1:]
    if isinstance(arguments, str):
        arguments = arguments.split()
    if isinstance(arguments, argparse.Namespace):
        return arguments
    parser = create_args_parser()
    args = parser.parse_args(arguments)
    # pprint(args.__dict__)

    args.dialect = args.dialect.lower()
    if args.dialect not in ['lisp', 'newlisp', 'clojure', 'scheme', 'all', '']:
        parser.error("`{0}' is not a recognized dialect".format(args.dialect))

    args.backup_dir = os.path.expanduser(args.backup_dir)
    if not os.path.exists(args.backup_dir):
        parser.error("Directory `{0}' does not exist".format(args.backup_dir))

    if len(args.files) > 1 and args.output_file:
        parser.error('Cannot use the -o flag when more than one file is specified')

    if not args.files:
        # Indentation from standard input
        if args.modify and not args.output_file:
            args.modify = False
        args.backup = False
        args.warning = False

    if args.output_diff:
        # If someone requests a diff we assume he/she doesn't want the file to be
        # modified
        args.modify = False

    return args
920723
def parseargs(argv):
    ''''''
    args = []
    options = {}
    key = None
    for arg in argv:
        if arg in DEFAULT_OPTION_VALUES:
            key = arg.strip('=').replace('-', '_')
            options[key] = ()
        elif key is None:
            args.append(arg)
        else:
            options[key] += (arg,)

    if set(args) & {'-h', '--help'}:
        print(__doc__, end='')
        exit(0)
    elif set(args) & {'-V', '--version'}:
        print(__version__)
        exit(0)
    elif args:
        exit('invalid option: %s\nTry --help for more information.' % args[0])

    return options
356853
def ParseArguments(args):
  
  try:
    (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=',
                                                 'counting=',
                                                 'filter=',
                                                 'root=',
                                                 'linelength=',
                                                 'extensions='])
  except getopt.GetoptError:
    PrintUsage('Invalid arguments.')

  verbosity = _VerboseLevel()
  output_format = _OutputFormat()
  filters = ''
  counting_style = ''

  for (opt, val) in opts:
    if opt == '--help':
      PrintUsage(None)
    elif opt == '--output':
      if val not in ('emacs', 'vs7', 'eclipse'):
        PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.')
      output_format = val
    elif opt == '--verbose':
      verbosity = int(val)
    elif opt == '--filter':
      filters = val
      if not filters:
        PrintCategories()
    elif opt == '--counting':
      if val not in ('total', 'toplevel', 'detailed'):
        PrintUsage('Valid counting options are total, toplevel, and detailed')
      counting_style = val
    elif opt == '--root':
      global _root
      _root = val
    elif opt == '--linelength':
      global _line_length
      try:
          _line_length = int(val)
      except ValueError:
          PrintUsage('Line length must be digits.')
    elif opt == '--extensions':
      global _valid_extensions
      try:
          _valid_extensions = set(val.split(','))
      except ValueError:
          PrintUsage('Extensions must be comma seperated list.')

  if not filenames:
    PrintUsage('No files were specified.')

  _SetOutputFormat(output_format)
  _SetVerboseLevel(verbosity)
  _SetFilters(filters)
  _SetCountingStyle(counting_style)

  return filenames
476531
def get_arguments():
    """"""
    parser = argparse.ArgumentParser("AbodePy: Command Line Utility")

    parser.add_argument(
        '-u', '--username',
        help='Username',
        required=False)

    parser.add_argument(
        '-p', '--password',
        help='Password',
        required=False)

    parser.add_argument(
        '--cache',
        metavar='pickle_file',
        help='Create/update/use a pickle cache for the username and password.',
        required=False)

    parser.add_argument(
        '--mode',
        help='Output current alarm mode',
        required=False, default=False,
        action="store_true")

    parser.add_argument(
        '--arm',
        metavar='mode',
        help='Arm alarm to mode',
        required=False)

    parser.add_argument(
        '--set',
        metavar='setting=value',
        help='Set setting to a value',
        required=False, action='append')

    parser.add_argument(
        '--devices',
        help='Output all devices',
        required=False, default=False, action="store_true")

    parser.add_argument(
        '--device',
        metavar='device_id',
        help='Output one device for device_id',
        required=False, action='append')

    parser.add_argument(
        '--json',
        metavar='device_id',
        help='Output the json for device_id',
        required=False, action='append')

    parser.add_argument(
        '--on',
        metavar='device_id',
        help='Switch on a given device_id',
        required=False, action='append')

    parser.add_argument(
        '--off',
        metavar='device_id',
        help='Switch off a given device_id',
        required=False, action='append')

    parser.add_argument(
        '--lock',
        metavar='device_id',
        help='Lock a given device_id',
        required=False, action='append')

    parser.add_argument(
        '--unlock',
        metavar='device_id',
        help='Unlock a given device_id',
        required=False, action='append')

    parser.add_argument(
        '--automations',
        help='Output all automations',
        required=False, default=False, action="store_true")

    parser.add_argument(
        '--activate',
        metavar='automation_id',
        help='Activate (enable) an automation by automation_id',
        required=False, action='append')

    parser.add_argument(
        '--deactivate',
        metavar='automation_id',
        help='Deactivate (disable) an automation by automation_id',
        required=False, action='append')

    parser.add_argument(
        '--trigger',
        metavar='automation_id',
        help='Trigger (apply) a manual (quick) automation by automation_id',
        required=False, action='append')

    parser.add_argument(
        '--capture',
        metavar='device_id',
        help='Trigger a new image capture for the given device_id',
        required=False, action='append')

    parser.add_argument(
        '--image',
        metavar='device_id=location/image.jpg',
        help='Save an image from a camera (if available) to the given path',
        required=False, action='append')

    parser.add_argument(
        '--listen',
        help='Block and listen for device_id',
        required=False, default=False, action="store_true")

    parser.add_argument(
        '--debug',
        help='Enable debug logging',
        required=False, default=False, action="store_true")

    parser.add_argument(
        '--quiet',
        help='Output only warnings and errors',
        required=False, default=False, action="store_true")

    return parser.parse_args()
789362
def getArguments(parser):
    ""
    args = parser.parse_args()
    if args.order < 0 or args.order > 5:
        parser.error('The order has to be a number between 0 and 5.')   
    return args
99919
def _get_args(cls, **kwargs):
        
        csl_args = {
            'style': cls._default_style,
            'locale': cls._default_locale
        }

        if has_request_context():
            parser = FlaskParser(locations=('view_args', 'query'))
            csl_args.update(parser.parse(cls._user_args, request))

        csl_args.update({k: kwargs[k]
                         for k in ('style', 'locale') if k in kwargs})

        try:
            csl_args['style'] = get_style_filepath(csl_args['style'].lower())
        except StyleNotFoundError:
            if has_request_context():
                raise StyleNotFoundRESTError(csl_args['style'])
            raise
        return csl_args
325639
def getArguments(parser):
    ""
    args = parser.parse_args()    
    # check output image exists if override not forced
    if not args.force:
        if os.path.exists(args.output + args.image[-4:]):
            raise ArgumentError('The supplied output file {} already exists. Run -f/force flag to override.'.format(args.output))

    return args
203543
def parse_args():
    """"""
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        description='Diagnose script for checking the current system.')
    choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network']
    for choice in choices:
        parser.add_argument('--' + choice, default=1, type=int,
                            help='Diagnose {}.'.format(choice))
    parser.add_argument('--region', default='', type=str,
                        help="Additional sites in which region(s) to test. \
                        Specify 'cn' for example to test mirror sites in China.")
    parser.add_argument('--timeout', default=10, type=int,
                        help="Connection test timeout threshold, 0 to disable.")
    args = parser.parse_args()
    return args
202005
def get_base_arguments(parser):
    
    thisfilepath = os.path.abspath(os.path.dirname(__file__))
    group = parser.add_mutually_exclusive_group(required=False)
    group.add_argument('--list',
                       action='store_true',
                       help='List of available testcases(nothing else)',
                       default=False)
    group.add_argument('--listsuites',
                       action='store_true',
                       help='List of available suites',
                       default=False)
    group.add_argument('--tc',
                       help='execute testcase. Give test index, name, list of indices/'
                            'names, or all to execute all testcases',
                       default=False)
    group.add_argument('--suite',
                       default=False,
                       help='Run tests from suite json file <suite>. Can be absolute path to '
                            'suite file or path relative to --suitedir.')
    group.add_argument('--version',
                       action='store_true',
                       default=False,
                       help='Show version')

    # Filters
    filter_group = parser.add_argument_group("Filter arguments", "Arguments used for filtering "
                                                                 "tc:s")
    filter_group.add_argument('--status', default=False,
                              help='Run all testcases with status <status>')
    filter_group.add_argument('--group',
                              default=False,
                              help='Run all testcases that have all items '
                                   'in <group/subgroup> or <group,group2> in their group path.')
    filter_group.add_argument('--testtype',
                              default=False,
                              help='Run all testcases with type <testtype>')
    filter_group.add_argument('--subtype',
                              default=False,
                              help="Run all testcases with subtype <subtype")
    filter_group.add_argument('--component',
                              default=False,
                              help='Run all testcases with component <component>')
    filter_group.add_argument('--feature',
                              default=False,
                              help='Run all testcases with feature <feature>')
    filter_group.add_argument("--platform_filter",
                              default=False,
                              help="Run all testcases that allow platform <platform_filter>")

    # JobId is BUILD_TAG (from Jenkins job), or generated UUID or command line argument value
    info_group = parser.add_argument_group("Run information", "Information of run, such as job "
                                                              "id and git or build information.")
    info_group.add_argument('--jobId',
                            default=os.environ.get('BUILD_TAG', str(uuid.uuid1())),
                            help='Job Unique ID')
    info_group.add_argument('--gitUrl',
                            default=os.environ.get('ghprbAuthorRepoGitUrl', None),
                            help='Set application used git url for results')
    info_group.add_argument('--branch',
                            default=os.environ.get('GIT_BRANCH', 'master'),
                            help='Set used build branch for results')
    info_group.add_argument('--commitId',
                            default=os.environ.get('ghprbActualCommit', None),
                            help='Set used commit ID for results')
    info_group.add_argument('--buildDate',
                            default=None,
                            help='Set build date')
    info_group.add_argument('--toolchain',
                            default=None,
                            help='Set toolchain for results')
    info_group.add_argument('--buildUrl',
                            default=os.environ.get('BUILD_URL', None),
                            help='Set build url for results')
    info_group.add_argument('--campaign',
                            default=os.environ.get('JOB_NAME', None),
                            help='Set campaign name for results')

    # Directories and paths
    directories = parser.add_argument_group("Paths", "Directory and file paths for various "
                                                     "Icetea features.")
    directories.add_argument('--tcdir',
                             help='Search for testcases in directory <path>',
                             default='./testcases')
    directories.add_argument('--suitedir',
                             help='Search for suites in directory <path>',
                             default='./testcases/suites')
    directories.add_argument("--cfg_file",
                             type=open,
                             default=None,
                             help="Load cli parameters from file. "
                                  "This will overwrite parameters given before --cfg_file, but "
                                  "results of this will be overwritten by "
                                  "parameters given after this one",
                             action=LoadFromFile)

    directories.add_argument('--plugin_path',
                             default=os.path.abspath(
                                 os.path.join(thisfilepath,
                                              "Plugin/plugins/plugins_to_load")),
                             help="location of file called plugins_to_load, "
                                  "where custom plugins are imported from.")

    # Allocator group
    alloc_group = parser.add_argument_group("Allocator", "Control allocation of resources for "
                                                         "tests.")
    alloc_group.add_argument("--allocator",
                             default="LocalAllocator",
                             help="Allocator to be used for allocating resources. "
                                  "Default is LocalAllocator")
    alloc_group.add_argument("--allocator_cfg",
                             help="File that contains configuration for used allocator.",
                             default=None)

    # Other arguments
    parser.add_argument('--env_cfg',
                        help='Use user specific environment configuration file',
                        default='')
    parser.add_argument("--logging_cfg",
                        help="Location of JSON configuration for logging.",
                        default=None)
    parser.add_argument('--repeat',
                        help='Repeat testcases N times',
                        default=1)
    parser.add_argument('--stop_on_failure',
                        help='Stop testruns/repeation on first failed TC',
                        default=False,
                        action="store_true")
    parser.add_argument('--clean',
                        action='store_true',
                        default=False,
                        help='Clean old logs')
    parser.add_argument('--connector',
                        default=None,
                        help='Connector credentials for selecting and/or generating endpoint '
                             'certificates. Format should be domain[:token] where token is '
                             'optional. Eg. --connector this_is_some_domain:this_is_my_token')
    parser.add_argument('--failure_return_value',
                        default=False,
                        action="store_true",
                        help='Sets Icetea to return a failing code to caller if '
                             'one or more tests fail during the run. Default is False')
    parser.add_argument('--color',
                        default=False,
                        action="store_true",
                        help='Indicates if console logs are printed plain'
                             ' or with colours. Default is False for plain'
                             'logs.')
    parser.add_argument("--check_version",
                        default=False,
                        action="store_true",
                        help="Enables version checks for test cases.")
    parser.add_argument('--ignore_invalid_params',
                        default=False,
                        action="store_true",
                        help="Disables checks for invalid parameters.")
    parser.add_argument('--parallel_flash',
                        default=False,
                        action="store_true",
                        help="Enables parallel flash.")
    parser.add_argument('--disable_log_truncate',
                        default=False,
                        action="store_true",
                        help="Disable long log line truncating. Over 10000"
                             "characters long lines are truncated by default.")
    parser.add_argument('--cm',
                        default="opentmi_client",
                        help='name of module that is to be used to send results to a cloud '
                             'service.')
    parser.add_argument("--json", action="store_true", default=False,
                        help="Output results of --list as json instead of a table.")
    parser.add_argument("--export", default=None, metavar="SUITE_FILE_NAME",
                        help="Export list into suite template file.")
    parser.add_argument("--sync_start", default=False, action="store_true",
                        help="Use echo-command to try and make sure duts have "
                             "started before proceeding with test.")
    return parser
1365147
def _get_arg_tokens(cli):
    
    arg = cli.input_processor.arg

    return [
        (Token.Prompt.Arg, '(arg: '),
        (Token.Prompt.Arg.Text, str(arg)),
        (Token.Prompt.Arg, ') '),
    ]