Parse command-line arguments.
488966
def get_parser():
    """"""
    parser = ArgumentParser(description='a command-line web scraping tool')
    parser.add_argument('query', metavar='QUERY', type=str, nargs='*',
                        help='URLs/files to scrape')
    parser.add_argument('-a', '--attributes', type=str, nargs='*',
                        help='extract text using tag attributes')
    parser.add_argument('-all', '--crawl-all', help='crawl all pages',
                        action='store_true')
    parser.add_argument('-c', '--crawl', type=str, nargs='*',
                        help='regexp rules for following new pages')
    parser.add_argument('-C', '--clear-cache', help='clear requests cache',
                        action='store_true')
    parser.add_argument('--csv', help='write files as csv',
                        action='store_true')
    parser.add_argument('-cs', '--cache-size', type=int, nargs='?',
                        help='size of page cache (default: 1000)',
                        default=1000)
    parser.add_argument('-f', '--filter', type=str, nargs='*',
                        help='regexp rules for filtering text')
    parser.add_argument('--html', help='write files as HTML',
                        action='store_true')
    parser.add_argument('-i', '--images', action='store_true',
                        help='save page images')
    parser.add_argument('-m', '--multiple', help='save to multiple files',
                        action='store_true')
    parser.add_argument('-max', '--max-crawls', type=int,
                        help='max number of pages to crawl')
    parser.add_argument('-n', '--nonstrict', action='store_true',
                        help='allow crawler to visit any domain')
    parser.add_argument('-ni', '--no-images', action='store_true',
                        help='do not save page images')
    parser.add_argument('-no', '--no-overwrite', action='store_true',
                        help='do not overwrite files if they exist')
    parser.add_argument('-o', '--out', type=str, nargs='*',
                        help='specify outfile names')
    parser.add_argument('-ow', '--overwrite', action='store_true',
                        help='overwrite a file if it exists')
    parser.add_argument('-p', '--pdf', help='write files as pdf',
                        action='store_true')
    parser.add_argument('-pt', '--print', help='print text output',
                        action='store_true')
    parser.add_argument('-q', '--quiet', help='suppress program output',
                        action='store_true')
    parser.add_argument('-s', '--single', help='save to a single file',
                        action='store_true')
    parser.add_argument('-t', '--text', help='write files as text',
                        action='store_true')
    parser.add_argument('-v', '--version', help='display current version',
                        action='store_true')
    parser.add_argument('-x', '--xpath', type=str, nargs='?',
                        help='filter HTML using XPath')
    return parser
1262177
def _parse(args):
    """"""

    ordered = []
    opt_full = dict()
    opt_abbrev = dict()

    args = args + ['']  # Avoid out of range
    i = 0

    while i < len(args) - 1:
        arg = args[i]
        arg_next = args[i+1]
        if arg.startswith('--'):
            if arg_next.startswith('-'):
                raise ValueError('{} lacks value'.format(arg))
            else:
                opt_full[arg[2:]] = arg_next
                i += 2
        elif arg.startswith('-'):
            if arg_next.startswith('-'):
                raise ValueError('{} lacks value'.format(arg))
            else:
                opt_abbrev[arg[1:]] = arg_next
                i += 2
        else:
            ordered.append(arg)
            i += 1
    
    return ordered, opt_full, opt_abbrev
502789
def _parse_arguments(arguments=None):
    """"""
    dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()

    parser = argparse.ArgumentParser(description="""Lint for Polysquare style guide""")
    parser.add_argument("--checks",
                        nargs=0,
                        action=ShowAvailableChecksAction,
                        help="""list available checks""")
    parser.add_argument("files",
                        nargs="*",
                        metavar=("FILE"),
                        help="""read FILE""",
                        type=str)
    parser.add_argument("--whitelist",
                        nargs="*",
                        help="""list of checks that should only be run""",
                        default=None)
    parser.add_argument("--blacklist",
                        nargs="*",
                        help="""list of checks that should never be run""",
                        default=None)
    parser.add_argument("--fix-what-you-can",
                        action="store_const",
                        help="""fix errors automatically""",
                        const=True)
    parser.add_argument("--spellcheck-cache",
                        help="""path to spell-checking cache file""",
                        default=None)
    parser.add_argument("--log-technical-terms-to",
                        help="""path to file to log technical terms to""",
                        default=None)
    parser.add_argument("--stamp-file-path",
                        help="""path to directory to store cached results""",
                        default=os.path.join(tempfile.gettempdir(),
                                             "jobstamps",
                                             "spellcheck_linter",
                                             dir_hash))
    parser.add_argument("--block-regexps",
                        help="""Regular expressions to exclude from all checks.""",
                        nargs="*",
                        default=None)

    return parser.parse_args(arguments)
1108599
def args(parsed_args, name=None):
    """"""
    strings = parsed_args.arg_strings(name)
    files = [s for s in strings if os.path.isfile(s)]
    if files:
        streams = [open(f) for f in files]
    else:
        streams = []
    if getattr(parsed_args, 'paste', not files):
        streams.append(clipboard_stream())
    if getattr(parsed_args, 'stdin', False):
        streams.append(sys.stdin)
    elif not streams:
        streams = [sys.stdin]
    return streams
617983
def parse_args(self, arguments=None):
        
        self._args = self.parser.parse_args(arguments)
        return self.args
1027366
def parse(
        args: typing.List[str] = None,
        arg_parser: ArgumentParser = None
) -> dict:
    """"""

    parser = arg_parser or create_parser()
    return vars(parser.parse_args(args))
692076
def parse_args(args=None):
    """"""
    parser = argparse.ArgumentParser()

    parser.add_argument(
        '-w', '--window',
        default="pyqt5",
        choices=find_window_classes(),
        help='Name for the window type to use',
    )
    parser.add_argument(
        '-fs', '--fullscreen',
        action="store_true",
        help='Open the window in fullscreen mode',
    )
    parser.add_argument(
        '-vs', '--vsync',
        type=str2bool,
        default="1",
        help="Enable or disable vsync",
    )
    parser.add_argument(
        '-s', '--samples',
        type=int,
        default=4,
        help="Specify the desired number of samples to use for multisampling",
    )
    parser.add_argument(
        '-c', '--cursor',
        type=str2bool,
        default="true",
        help="Enable or disable displaying the mouse cursor",
    )

    return parser.parse_args(args or sys.argv[1:])
868130
def _parse_arg(self, arg):
        """"""
        match = self.SPECIAL_RE.search(arg)
        if match:
            raise KatcpSyntaxError("Unescaped special %r." % (match.group(),))
        return self.UNESCAPE_RE.sub(self._unescape_match, arg)
626361
def parse_command_line(self, argv=None):
        
        if self.config:
            parser = argparse.ArgumentParser(add_help=False)
            self.settings['config'].add_argument(parser)
            opts, _ = parser.parse_known_args(argv)
            if opts.config is not None:
                self.set('config', opts.config)

            self.params.update(self.import_from_module())

        parser = self.parser()
        opts = parser.parse_args(argv)
        for k, v in opts.__dict__.items():
            if v is None:
                continue
            self.set(k.lower(), v)
701868
def parse_args(self, *args, **kwargs):
        """"""
        if _debug: ArgumentParser._debug("parse_args")

        # pass along to the parent class
        result_args = _ArgumentParser.parse_args(self, *args, **kwargs)

        # check to dump labels
        if result_args.buggers:
            loggers = sorted(logging.Logger.manager.loggerDict.keys())
            for loggerName in loggers:
                sys.stdout.write(loggerName + '\n')
            sys.exit(0)

        # check for debug
        if result_args.debug is None:
            # --debug not specified
            result_args.debug = []
        elif not result_args.debug:
            # --debug, but no arguments
            result_args.debug = ["__main__"]

        # check for debugging from the environment
        if BACPYPES_DEBUG:
            result_args.debug.extend(BACPYPES_DEBUG.split())
        if BACPYPES_COLOR:
            result_args.color = True

        # keep track of which files are going to be used
        file_handlers = {}

        # loop through the bug list
        for i, debug_name in enumerate(result_args.debug):
            color = (i % 6) + 2 if result_args.color else None

            debug_specs = debug_name.split(':')
            if len(debug_specs) == 1:
                ConsoleLogHandler(debug_name, color=color)
            else:
                # the debugger name is just the first component
                debug_name = debug_specs[0]

                # if the file is already being used, use the already created handler
                file_name = debug_specs[1]
                if file_name in file_handlers:
                    handler = file_handlers[file_name]
                else:
                    if len(debug_specs) >= 3:
                        maxBytes = int(debug_specs[2])
                    else:
                        maxBytes = BACPYPES_MAXBYTES
                    if len(debug_specs) >= 4:
                        backupCount = int(debug_specs[3])
                    else:
                        backupCount = BACPYPES_BACKUPCOUNT

                    # create a handler
                    handler = logging.handlers.RotatingFileHandler(
                        file_name, maxBytes=maxBytes, backupCount=backupCount,
                        )
                    handler.setLevel(logging.DEBUG)

                    # save it for more than one instance
                    file_handlers[file_name] = handler

                # use this handler, no color
                ConsoleLogHandler(debug_name, handler=handler)

        # return what was parsed
        return result_args
167782
def parse_arguments():
    
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-c", dest="count", default=0, type=int,
        help="Number of pings to send"
    )
    parser.add_argument(
        "-i", dest="interval", default=1, type=float, help="Ping interval"
    )
    parser.add_argument(
        "-d", dest="timings", default=False, action="store_true",
        help="Show timings for the entire connection"
    )
    parser.add_argument(
        'destination', nargs='+', help='Destination host or URL'
    )
    args = parser.parse_args()
    return args, args.destination
1275980
def _parse_command_line():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--portserver_static_pool',
        type=str,
        default='15000-24999',
        help='Comma separated N-P Range(s) of ports to manage (inclusive).')
    parser.add_argument(
        '--portserver_unix_socket_address',
        type=str,
        default='@unittest-portserver',
        help='Address of AF_UNIX socket on which to listen (first @ is a NUL).')
    parser.add_argument('--verbose',
                        action='store_true',
                        default=False,
                        help='Enable verbose messages.')
    parser.add_argument('--debug',
                        action='store_true',
                        default=False,
                        help='Enable full debug messages.')
    return parser.parse_args(sys.argv[1:])
1076400
def parse_args(arguments, apply_config=False):
    """"""
    parser = create_parser()
    args = parser.parse_args(arguments)

    if not args.files and not args.list_fixes:
        parser.error('incorrect number of arguments')

    args.files = [decode_filename(name) for name in args.files]

    if apply_config:
        parser = read_config(args, parser)
        args = parser.parse_args(arguments)
        args.files = [decode_filename(name) for name in args.files]

    if '-' in args.files:
        if len(args.files) > 1:
            parser.error('cannot mix stdin and regular files')

        if args.diff:
            parser.error('--diff cannot be used with standard input')

        if args.in_place:
            parser.error('--in-place cannot be used with standard input')

        if args.recursive:
            parser.error('--recursive cannot be used with standard input')

    if len(args.files) > 1 and not (args.in_place or args.diff):
        parser.error('autopep8 only takes one filename as argument '
                     'unless the "--in-place" or "--diff" args are '
                     'used')

    if args.recursive and not (args.in_place or args.diff):
        parser.error('--recursive must be used with --in-place or --diff')

    if args.in_place and args.diff:
        parser.error('--in-place and --diff are mutually exclusive')

    if args.max_line_length <= 0:
        parser.error('--max-line-length must be greater than 0')

    if args.select:
        args.select = _split_comma_separated(args.select)

    if args.ignore:
        args.ignore = _split_comma_separated(args.ignore)
        if not all(
                any(
                    conflicting_code.startswith(ignore_code)
                    for ignore_code in args.ignore
                )
                for conflicting_code in CONFLICTING_CODES
        ):
            args.ignore.update(CONFLICTING_CODES)
    elif not args.select:
        if args.aggressive:
            # Enable everything by default if aggressive.
            args.select = {'E', 'W1', 'W2', 'W3', 'W6'}
        else:
            args.ignore = _split_comma_separated(DEFAULT_IGNORE)

    if args.exclude:
        args.exclude = _split_comma_separated(args.exclude)
    else:
        args.exclude = {}

    if args.jobs < 1:
        # Do not import multiprocessing globally in case it is not supported
        # on the platform.
        import multiprocessing
        args.jobs = multiprocessing.cpu_count()

    if args.jobs > 1 and not args.in_place:
        parser.error('parallel jobs requires --in-place')

    if args.line_range:
        if args.line_range[0] <= 0:
            parser.error('--range must be positive numbers')
        if args.line_range[0] > args.line_range[1]:
            parser.error('First value of --range should be less than or equal '
                         'to the second')

    return args
754425
def _parse_args():
    """"""
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=_CliFormatter)
    parser.add_argument('-v', '--verbose', action='store_true',
                        help='Enable verbose output.')

    fb_group = parser.add_argument_group('FogBugz arguments')
    fb_group.add_argument(
        '-u', '--url', help=(
            'URL for bugzscout requests to be sent. Should be something '
            'like .../scoutSubmit.asp.'))
    fb_group.add_argument(
        '--user', help='User to designate when submitting via bugzscout.')
    fb_group.add_argument(
        '--project', help='Fogbugz project to file cases under.')
    fb_group.add_argument(
        '--area', help='Fogbugz area to file cases under.')

    error_group = parser.add_argument_group('error arguments')
    error_group.add_argument('-e', '--extra',
                             help='Extra data to send with error.')
    error_group.add_argument('--default-message',
                             help='Set default message if case is new.')
    error_group.add_argument('description',
                             help=('Description of error. Will be matched '
                                   'against existing cases.'))

    parser.set_defaults(**_defaults())

    return parser.parse_args()
693035
def _parse_argument(self):
        """"""
        reset = self._head
        try:
            argument = self._parse(contexts.ARGUMENT_NAME)
        except BadRoute:
            self._head = reset
            raise
        self._emit_first(tokens.ArgumentOpen())
        self._emit_all(argument)
        self._emit(tokens.ArgumentClose())
1024014
def parse_args():
  """"""
  parser = argparse.ArgumentParser(
      description='Tool to run attacks and defenses.')
  parser.add_argument('--attacks_dir', required=True,
                      help='Location of all attacks.')
  parser.add_argument('--targeted_attacks_dir', required=True,
                      help='Location of all targeted attacks.')
  parser.add_argument('--defenses_dir', required=True,
                      help='Location of all defenses.')
  parser.add_argument('--dataset_dir', required=True,
                      help='Location of the dataset.')
  parser.add_argument('--dataset_metadata', required=True,
                      help='Location of the dataset metadata.')
  parser.add_argument('--intermediate_results_dir', required=True,
                      help='Directory to store intermediate results.')
  parser.add_argument('--output_dir', required=True,
                      help=('Output directory.'))
  parser.add_argument('--epsilon', required=False, type=int, default=16,
                      help='Maximum allowed size of adversarial perturbation')
  parser.add_argument('--gpu', dest='use_gpu', action='store_true')
  parser.add_argument('--nogpu', dest='use_gpu', action='store_false')
  parser.set_defaults(use_gpu=False)
  parser.add_argument('--save_all_classification',
                      dest='save_all_classification', action='store_true')
  parser.add_argument('--nosave_all_classification',
                      dest='save_all_classification', action='store_false')
  parser.set_defaults(save_all_classification=False)
  return parser.parse_args()
1286547
def parse_args(args=None):
    """"""
    parser = argparse.ArgumentParser(description='afraid.org dyndns client')

    ## positional arguments

    parser.add_argument('user')
    parser.add_argument('password')
    parser.add_argument('hosts',
            nargs='*',
            help='(deafult: all associated hosts)',
            default=None
    )

    ## optional arguments

    # should we fork?
    parser.add_argument('--daemonize', '-d',
        action='store_true',
        default=False,
        help='run in background (default: no)',
    )

    # log to a file or stdout
    parser.add_argument('--log',
        help='log to file (default: log to stdout)',
        type=argparse.FileType('w'),
        default=sys.stdout,
        metavar='file'
    )

    # how long to sleep between updates
    parser.add_argument('--interval',
        help='update interval, in seconds (default: 21600)',
        metavar='seconds',
        default=6 * 60 * 60, # 6 hours
        type=int
    )

    return parser.parse_args(args)