parses args json
542404
def parse(self):
        
        data = json.loads(sys.argv[1])
        self.config_path = self.decode(data['config_path'])
        self.subject = self.decode(data['subject'])
        self.text = self.decode(data['text'])
        self.html = self.decode(data['html'])
        self.send_as_one = data['send_as_one']
        if 'files' in data:
            self.parse_files(data['files'])
        self.ccs = data['ccs']
        self.addresses = data['addresses']
        if not self.addresses:
            raise ValueError(
                'Atleast one email address is required to send an email')
625566
def parse_arg_line(fargs):
    

    # Convert to literal dict
    fargs = fargs.strip()
    if fargs == '':
        return {}

    pairs = [s.strip() for s in fargs.split(',')]
    # find first "="
    result = []
    for p in pairs:
        fe = p.find("=")
        if fe == -1:
            # no equal
            raise ValueError("malformed")
        key = p[:fe]
        val = p[fe + 1:]
        tok = "'{}': {}".format(key, val)
        result.append(tok)
    tokj = ','.join(result)
    result = "{{ {0} }}".format(tokj)
    state = ast.literal_eval(result)
    return state
1301360
def _parse_json(self, jstring=None):
        """"""

        # Argument error checking.
        assert jstring is not None

        result = None

        try:
            result = json.loads(jstring)
        except (ValueError) as exception:
            msg = 'Unable to convert JSON string to Python data structure.'
            raise APIDataException(exception, jstring, msg)

        return result
1001456
protected void parse (String arg, Argument argDesc)
        throws YarrgParseException
    {
        Parser<?> parser = parsers.get(argDesc.field);
        if (parser == null) {
            parser = _cmd._factory.createParser(argDesc.field);
            parsers.put(argDesc.field, parser);
        }
        try {
            parser.add(arg);
        } catch (RuntimeException e) {
            throw new YarrgParseException(_usage, e.getMessage(), e);
        }
    }
945141
def _get_args_to_parse(args, sys_argv):
    
    arguments = args if args is not None else sys_argv[1:]
    _LOG.debug("Parsing arguments: %s", arguments)
    return arguments
830637
def parse_args(args):
    
    parser = argparse.ArgumentParser(
        description='Starts the REST API application and connects to a '
        'specified validator.')

    parser.add_argument('-B', '--bind',
                        help='identify host and port for API to run on \
                        default: http://localhost:8008)',
                        action='append')
    parser.add_argument('-C', '--connect',
                        help='specify URL to connect to a running validator')
    parser.add_argument('-t', '--timeout',
                        help='set time (in seconds) to wait for validator \
                        response')
    parser.add_argument('--client-max-size',
                        type=int,
                        help='the max size (in bytes) of a request body')
    parser.add_argument('-v', '--verbose',
                        action='count',
                        default=0,
                        help='enable more verbose output to stderr')
    parser.add_argument('--opentsdb-url',
                        help='specify host and port for Open TSDB database \
                        used for metrics')
    parser.add_argument('--opentsdb-db',
                        help='specify name of database for storing metrics')

    try:
        version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version
    except pkg_resources.DistributionNotFound:
        version = 'UNKNOWN'

    parser.add_argument(
        '-V', '--version',
        action='version',
        version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}')
        .format(version),
        help='display version information')

    return parser.parse_args(args)
1201837
def parse_args(argv):
    
    p = argparse.ArgumentParser(
        description='webhook2lambda2sqs - Generate code and manage '
                    'infrastructure for receiving webhooks with AWS API '
                    'Gateway and pushing to SQS via Lambda - <%s>' % PROJECT_URL
    )
    p.add_argument('-c', '--config', dest='config', type=str,
                   action='store', default='config.json',
                   help='path to config.json (default: ./config.json)')
    p.add_argument('-v', '--verbose', dest='verbose', action='count',
                   default=0,
                   help='verbose output. specify twice for debug-level output.')
    p.add_argument('-V', '--version', action='version',
                   version='webhook2lambda2sqs v%s <%s>' % (
                       VERSION, PROJECT_URL
                   ))
    p.add_argument('-T', '--tf-version', dest='tf_ver', action='store',
                   type=str, default='0.9.0',
                   help='terraform version to generate configurations for')
    subparsers = p.add_subparsers(title='Action (Subcommand)', dest='action',
                                  metavar='ACTION', description='Action to '
                                  'perform; each action may take further '
                                  'parameters. Use ACTION -h for subcommand-'
                                  'specific options and arguments.')
    subparsers.add_parser(
        'generate', help='generate lambda function and terraform configs in ./'
    )
    tf_parsers = [
        ('genapply', 'generate function and terraform configs in ./, then run '
                     'terraform apply'),
        ('plan', 'run terraform plan to show changes which will be made'),
        ('apply', 'run terraform apply to apply changes/create infrastructure'),
        ('destroy',
         'run terraform destroy to completely destroy infrastructure')
    ]
    tf_p_objs = {}
    for cname, chelp in tf_parsers:
        tf_p_objs[cname] = subparsers.add_parser(cname, help=chelp)
        tf_p_objs[cname].add_argument('-t', '--terraform-path', dest='tf_path',
                                      action='store', default='terraform',
                                      type=str, help='path to terraform '
                                                     'binary, if not in PATH')
        tf_p_objs[cname].add_argument('-S', '--no-stream-tf', dest='stream_tf',
                                      action='store_false', default=True,
                                      help='DO NOT stream Terraform output to '
                                           'STDOUT (combined) in realtime')
    apilogparser = subparsers.add_parser('apilogs', help='show last 10 '
                                         'CloudWatch Logs entries for the '
                                         'API Gateway')
    apilogparser.add_argument('-c', '--count', dest='log_count', type=int,
                              default=10, help='number of log entries to show '
                              '(default 10')
    logparser = subparsers.add_parser('logs', help='show last 10 CloudWatch '
                                      'Logs entries for the function')
    logparser.add_argument('-c', '--count', dest='log_count', type=int,
                           default=10, help='number of log entries to show '
                                            '(default 10')
    queueparser = subparsers.add_parser('queuepeek', help='show messages from '
                                        'one or all of the SQS queues')
    queueparser.add_argument('-n', '--name', type=str, dest='queue_name',
                             default=None, help='queue name to read (defaults '
                                                'to None to read all)')
    queueparser.add_argument('-d', '--delete', action='store_true',
                             dest='queue_delete', default=False,
                             help='delete messages after reading')
    queueparser.add_argument('-c', '--count', dest='msg_count', type=int,
                             default=10, help='number of messages to read from '
                                              'each queue (default 10)')
    testparser = subparsers.add_parser('test', help='send test message to '
                                                    'one or more endpoints')
    testparser.add_argument('-t', '--terraform-path', dest='tf_path',
                            action='store', default='terraform',
                            type=str, help='path to terraform '
                            'binary, if not in PATH')
    testparser.add_argument('-n', '--endpoint-name', dest='endpoint_name',
                            type=str, default=None,
                            help='endpoint name (default: None, to send to '
                                 'all endpoints)')
    subparsers.add_parser(
        'example-config', help='write example config to STDOUT and description '
                               'of it to STDERR, then exit'
    )
    args = p.parse_args(argv)
    if args.action is None:
        # for py3, which doesn't raise on this
        sys.stderr.write("ERROR: too few arguments\n")
        raise SystemExit(2)
    return args
1290325
function parse($args = null)
    {
        if ($args === null) {
            $args = array_slice($_SERVER['argv'], 1);
        }

        foreach ($args as $pos => $arg) {
            // reset value
            $value = null;

            if (substr($arg, 0, 1) === '-') {
                if (preg_match('/^(.+)=(.+)$/', $arg, $matches)) {
                    $arg = $matches[1];
                    $value = $matches[2];
                }

                if (!$flag = @$this->flags[$arg]) {
                    throw new ParseException(sprintf('Flag "%s" is not defined.', $arg));
                }

                unset($args[$pos]);

                if ($flag->hasValue) {
                    if (!isset($value)) {
                        $value = $args[$pos + 1];
                        unset($args[$pos + 1]);
                    }
                } else {
                    $value = true;
                }

                if (null !== $flag->callback) {
                    call_user_func_array($flag->callback, array(&$value));
                }

                # Set the reference given as the flag's 'var'.
                $flag->var = $this->parsedFlags[$flag->name] = $value;
            }
        }

        # TODO: Refactor this so this fits into the above foreach
        foreach ($this->flags as $flag) {
            if (!array_key_exists($flag->name, $this->parsedFlags)) {
                $flag->var = $this->parsedFlags[$flag->name] = $flag->defaultValue;
            }
        }

        $this->parsedArgs = $args = array_values($args);

        $pos = 0;

        foreach ($this->args as $arg) {
            if ($arg->required and !isset($args[$pos])) {
                throw new ArgumentException(sprintf(
                    'Missing required argument "%s"', $arg->name
                ));
            }

            if (isset($args[$pos])) {
                if ($arg->vararg) {
                    $value = array_slice($args, $pos);
                    $pos += count($value);
                } else {
                    $value = $args[$pos];
                    $pos++;
                }
            } else {
                $value = $arg->defaultValue;
            }

            $this->parsedNamedArgs[$arg->name] = $value;
        }
    }
598412
def parse_args():
    
    parser = argparse.ArgumentParser(description="Decrypt YubiKey OTPs using YubiHSM",
                                     add_help=True,
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter
                                     )
    parser.add_argument('-D', '--device',
                        dest='device',
                        default=default_device,
                        required=False,
                        help='YubiHSM device'
                        )
    parser.add_argument('-B', '--aead-dir',
                        dest='aead_dir',
                        default=default_dir,
                        required=False,
                        help='AEAD directory - base directory of your AEADs',
                        metavar='DIR',
                        )
    parser.add_argument('-U', '--serve-url',
                        dest='serve_url',
                        default=default_serve_url,
                        required=False,
                        help='Base URL for decrypt web service',
                        metavar='URL',
                        )
    parser.add_argument('-S', '--stats-url',
                        dest='stats_url',
                        required=False,
                        help='URL where statistics can be retrieved',
                        metavar='URL',
                        )
    parser.add_argument('-v', '--verbose',
                        dest='verbose',
                        action='store_true', default=False,
                        help='Enable verbose operation'
                        )
    parser.add_argument('-d', '--daemon',
                        dest='daemon',
                        action='store_true', default=False,
                        help='Run as daemon'
                        )
    parser.add_argument('--debug',
                        dest='debug',
                        action='store_true', default=False,
                        help='Enable debug operation'
                        )
    parser.add_argument('--port',
                        dest='listen_port',
                        type=int, default=default_port,
                        required=False,
                        help='Port to listen on',
                        metavar='PORT',
                        )
    parser.add_argument('--addr',
                        dest='listen_addr',
                        default=default_listen_addr,
                        required=False,
                        help='Address to bind to',
                        metavar='ADDR',
                        )
    parser.add_argument('--reqtimeout',
                        dest='reqtimeout',
                        type=int, default=default_reqtimeout,
                        required=False,
                        help='Request timeout in seconds',
                        metavar='SECONDS',
                        )
    parser.add_argument('--key-handle', '--key-handles',
                        dest='key_handles',
                        nargs='+',
                        required=True,
                        help='Key handle(s) to use to decrypt AEADs on the YHSM.',
                        metavar='HANDLE',
                        )
    parser.add_argument('--pid-file',
                        dest='pid_file',
                        default=default_pid_file,
                        required=False,
                        help='PID file',
                        metavar='FILENAME',
                        )
    parser.add_argument('--db-url',
                        dest='db_url',
                        default=default_db_url,
                        required=False,
                        help='The database url to read the AEADs from, you can '
                        'also use env:YOURENVVAR to instead read the URL from '
                        'the YOURENVVAR environment variable.',
                        metavar='DBURL',
                        )
    parser.add_argument('--proxy', '--proxies',
                        dest='proxies',
                        nargs='+',
                        required=False,
                        default=[],
                        help='IP addresses of proxies where the IP in '
                        'X-Forwarded-For should be used for logging purposes.',
                        metavar='IP',
                        )

    return parser.parse_args()
508782
def parse_args(args=None):
    """"""

    if args is None:
        args = sys.argv

    parser = ArgumentParser(description='Barcode scanner based on GStreamer, '
                            'zbar, and gtk.')
    log_levels = ('critical', 'error', 'warning', 'info', 'debug', 'notset')

    parser.add_argument('-l', '--log-level', type=str, choices=log_levels,
                        default='info')
    parser.add_argument('-d', '--device-name', type=str, help='GStreamer video'
                        ' device name')
    parser.add_argument('-w', '--max-width', type=int,
                        help='Maximum video width')
    parser.add_argument('-f', '--max-fps', type=float, help='Maximum video '
                        'frame rate (frames/second)')
    parser.add_argument('schema', type=str, help='jsonschema schema')

    args = parser.parse_args()
    if hasattr(args, 'log_level'):
        args.log_level = getattr(logging, args.log_level.upper())
    return args
989440
def args_to_dict(args):
    # type: (str) -> DictUpperBound[str,str]
    
    arguments = dict()
    for arg in args.split(','):
        key, value = arg.split('=')
        arguments[key] = value
    return arguments
603675
function parse(str, options) {
  var obj = options.object || 'obj'
    , space = options.pretty ? 2 : 0
    , space = options.spaces ? options.spaces : space
    , js = str;
  
  return ''
    + 'var ' + obj + ' = factory();\n'
    + (options.self
      ? 'var self = locals || {};\n' + js
      : 'with (locals || {}) {\n' + js + '\n}\n')
    + 'return JSON.stringify(' + obj + ', null, ' +  space + ')';
}
253493
def parse(self, argv):
        """"""
        kwargs, args = self.parse_args(argv)
        self.result['args'] += args
        # Annoying that parse_args doesn't just return a dict
        for dest in self.dests:
            value = getattr(kwargs, dest)
            if value is not None:
                self.result['kwargs'][dest] = value
        return self
212452
def __parse_args(cam_c):
    """"""
    user = None
    pswd = None
    name = None
    address = "{address}:{port}".format(**cam_c)
    if "user" in cam_c:
        user = cam_c["user"]
        if "pswd" in cam_c:
            pswd = cam_c["pswd"]
    if "name" in cam_c:
        name = cam_c["name"]
    return {"user": user, "pswd": pswd, "name": name, "address": address}
838974
function parseYargs(yargs, args, callback) {
  // Since yargs doesn't nextTick its callback, this function must be careful
  // that exceptions thrown from callback (which propagate through yargs.parse)
  // are not caught and passed to a second invocation of callback.
  let called = false;
  try {
    yargs.parse(args, function(...cbargs) {
      called = true;
      return callback.apply(this, cbargs);
    });
  } catch (err) {
    if (called) {
      // err was thrown after or by callback.  Let it propagate.
      throw err;
    } else {
      callback(err);
    }
  }
}
617983
def parse_args(self, arguments=None):
        
        self._args = self.parser.parse_args(arguments)
        return self.args
794671
def _parse_create_args(client, args):
    
    data = {}

    if args.get('quantity'):
        data['quantity'] = int(args.get('quantity'))
    if args.get('postinstall'):
        data['provisionScripts'] = [args.get('postinstall')]
    if args.get('complex_type'):
        data['complexType'] = args.get('complex_type')

    if args.get('fqdn'):
        servers = []
        for name in args.get('fqdn'):
            fqdn = name.split(".", 1)
            servers.append({'hostname': fqdn[0], 'domain': fqdn[1]})
        data['hardware'] = servers

    if args.get('image'):
        if args.get('image').isdigit():
            image_mgr = ImageManager(client)
            image_details = image_mgr.get_image(args.get('image'), mask="id,globalIdentifier")
            data['imageTemplateGlobalIdentifier'] = image_details['globalIdentifier']
        else:
            data['imageTemplateGlobalIdentifier'] = args['image']

    userdata = None
    if args.get('userdata'):
        userdata = args['userdata']
    elif args.get('userfile'):
        with open(args['userfile'], 'r') as userfile:
            userdata = userfile.read()
    if userdata:
        for hardware in data['hardware']:
            hardware['userData'] = [{'value': userdata}]

    # Get the SSH keys
    if args.get('key'):
        keys = []
        for key in args.get('key'):
            resolver = SshKeyManager(client).resolve_ids
            key_id = helpers.resolve_id(resolver, key, 'SshKey')
            keys.append(key_id)
        data['sshKeys'] = keys

    return data