Parse a card from an input string
493475
def parse_card(card, text, default=None):
    
    match = re.search(card.lower() + r"\s*=\s*(\w+)", text.lower())
    return match.group(1) if match else default
130524
def from_string(s):
        """"""

        if not len(s):
            raise ValueError("Invalid parameter string.")

        params = parse_qs(u(s), keep_blank_values=False)
        if not len(params):
            raise ValueError("Invalid parameter string.")

        try:
            key = params['oauth_token'][0]
        except Exception:
            raise ValueError("'oauth_token' not found in OAuth request.")

        try:
            secret = params['oauth_token_secret'][0]
        except Exception:
            raise ValueError("'oauth_token_secret' not found in " 
                "OAuth request.")

        token = Token(key, secret)
        try:
            token.callback_confirmed = params['oauth_callback_confirmed'][0]
        except KeyError:
            pass  # 1.0, no callback confirmed.
        return token
1148047
function (cb) {
                  // card key
                  var url = options.url.replace(/light=true/i, ''),
                    params = {
                      legacyCardKey: Utils.getLegacyCardKey(url, process.env.CARD_SECRET),
                      cardKey: Utils.getCardKey(url, process.env.CARD_SECRET)
                    };

                  // extract input values
                  _.each(_.keys(options.inputValues), function (key) {
                    params[key] = options.inputValues[key];
                  });

                  if (options.inputValues.token) {

                    // retrieve previously saved parameters. Add or replace params
                    DB.unlock(options.packName, options.cardName, options.inputValues.token, process.env.LOCK_KEY, function (err, payload) {
                      if (err) {
                        // Ignore error and just return the params.
                        cb(null, params);
                      }
                      else {
                        if (payload && _.isObject(payload)) {
                          _.each(_.keys(Card.inputs), function (key) {
                            if (payload[key]) {
                              params[key] = Base64.decode(payload[key]);
                            }
                          });
                        }

                        cb(null, params);
                      }
                    });
                  }
                  else {
                    cb(null, params);
                  }
                }
581370
def parse(self, string, all_combos=False):
        
        if not all_combos:
            return self.default_parse(string)
        else:
            return self.all_combinations(string)
311059
def read(file, system):
    """"""
    try:
        fid = open(file, 'r')
        raw_file = fid.readlines()
    except IOError:
        print('* IOError while reading input card file.')
        return

    ret_dict = dict()
    ret_dict['outfile'] = file.split('.')[0].lower() + '.py'
    key, val = None, None
    for idx, line in enumerate(raw_file):
        line = line.strip()
        if not line:
            continue
        if line.startswith('#'):
            continue
        elif '#' in line:
            line = line.split('#')[0]
        if '=' in line:  # defining a field
            key, val = line.split('=')
            key, val = key.strip(), val.strip()
            val = [] if val == '' else val
            ret_dict.update({key: val})
            if val:
                val = val.split(';')
        else:
            val.extend(line.split(';'))
        if val:
            val = de_blank(val)
            ret_dict[key] = val

    ret_dict_ord = dict(ret_dict)

    for key, val in ret_dict.items():
        if not val:
            continue
        if type(val) == list:
            if ':' in val[0]:
                new_val = {}  # return in a dictionary
                new_val_ord = [
                ]  # return in an ordered list with the dict keys at 0
                for item in val:
                    try:
                        m, n = item.split(':')
                    except ValueError:
                        print('* Error: check line <{}>'.format(item))
                        return
                    m, n = m.strip(), n.strip()
                    if ',' in n:
                        n = n.split(',')
                        n = de_blank(n)
                        n = [to_number(i) for i in n]
                    else:
                        n = to_number(n)
                    new_val.update({m.strip(): n})
                    new_val_ord.append([m.strip(), n])
                ret_dict[key] = new_val
                ret_dict_ord[key] = new_val_ord

    ret_dict['name'] = ret_dict['name'][0]
    ret_dict['doc_string'] = ret_dict['doc_string'][0]
    ret_dict['group'] = ret_dict['group'][0]
    ret_dict['service_keys'] = list(ret_dict['service_eq'].keys())
    ret_dict['consts'] = list(ret_dict['data'].keys()) + list(
        ret_dict['service_eq'].keys())
    ret_dict['init1_eq'] = ret_dict_ord['init1_eq']
    ret_dict['service_eq'] = ret_dict_ord['service_eq']
    ret_dict['ctrl'] = ret_dict_ord['ctrl']

    copy_algebs = []
    copy_states = []
    for item in ret_dict['ctrl']:
        key, val = item
        if val[3] == 'y':
            copy_algebs.append(key)
        elif val[3] == 'x':
            copy_states.append(key)
        elif val[3] == 'c':
            ret_dict['consts'].append(key)
    ret_dict['copy_algebs'] = copy_algebs
    ret_dict['copy_states'] = copy_states

    return run(system, **ret_dict)
840511
def parse(scanner, rules, scope = ParserScope.empty)
      p = scanner.pos
      child.parse(scanner, rules, scope) && scanner.string[p...(scanner.pos)]
    end
1104169
function tryParseHexToBytes(hexStr) {
    if ((hexStr.length % 2) !== 0) {
      return null;
    }

    const result = [];
    for (let i = 0; i < hexStr.length; i += 2) {
      const value = parseInt(hexStr.substr(i, 2), 16);
      if (isNaN(value)) {
        return null;
      }
      result.push(value);
    }

    return result;
  }
1263029
def user_parse(data):
        """"""
        yield 'id', data.get('id')
        yield 'username', data.get('username')
        yield 'discriminator', data.get('discriminator')
        yield 'picture', "https://cdn.discordapp.com/avatars/{}/{}.png".format(
            data.get('id'), data.get('avatar'))
1223240
function fromString(string) {
    var parsed = string.match(matrixRegex);
    if (parsed === null || parsed.length < 7) throw new Error('\'' + string + '\' is not a matrix');
    return {
        a: parseFloat(parsed[1]),
        b: parseFloat(parsed[2]),
        c: parseFloat(parsed[3]),
        d: parseFloat(parsed[4]),
        e: parseFloat(parsed[5]),
        f: parseFloat(parsed[6])
    };
}
57896
def parse(str)
      if str.nil? || str == ""
        raise ParserError.new("Empty input",0,"")
      end

      s = StringScanner.new str
      @tokens = []

      until s.eos?
        s.skip(/\s+/) ? nil :
          s.scan(/\A[-+]?[0-9]*\.[0-9]+(e[-+]?[0-9]+)?/i) ? (@tokens << [:FLOAT, s.matched]) :
          s.scan(/\A[-+]?(0|[1-9]\d*)/)      ? (@tokens << [:INTEGER, s.matched]) :
          s.scan(/\A\.(?=\s)/)               ? (@tokens << ['.', '.']) :
          s.scan(/\A[a-z\-.\/_:*<>+=$#][a-z\-.\/_:$*<>+=0-9]*/i) ? (@tokens << [:SYMBOL, s.matched]) :
          s.scan(/\A"(([^\\"]|\\.)*)"/)        ? (@tokens << [:STRING, _unescape_string(s.matched.slice(1...-1))])  :
          s.scan(/\A./)                      ? (a = s.matched; @tokens << [a, a]) :
          (raise ParserError.new("Scanner error",s.pos,s.peek(5)))
      end
      @tokens.push [false, 'END']

      return do_parse.map do |i|
        normalize(i)
      end
    end
9022
public static Card retrieve(String card) throws StripeException {
    return retrieve(card, (Map<String, Object>) null, (RequestOptions) null);
  }
637341
def user_parse(data):
        """"""
        user = data.get('response', {}).get('user', {})
        yield 'id', user.get('id')
        yield 'email', user.get('contact', {}).get('email')
        yield 'first_name', user.get('firstName')
        yield 'last_name', user.get('lastName')
        city, country = user.get('homeCity', ', ').split(', ')
        yield 'city', city
        yield 'country', country
651242
function parse(str, options = {}) {
    let tokens = tokenize(str)
    let data = []

    tokens.forEach((item, idx) => {
        let [ label, token ] = item
        if (renderRules[label]) {
            data.push(renderRules[label](token))
        }else {
            data.push([ RENDER_TYPE_PLAIN, token ])
        }
    })
    return data
}
195006
def user_parse(data):
        """"""
        user_ = data.get('user', {})
        yield 'id', data.get('user_nsid') or user_.get('id')
        yield 'username', user_.get('username', {}).get('_content')
        first_name, _, last_name = data.get(
            'fullname', {}).get('_content', '').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
644354
@SuppressWarnings("unchecked")  // Generic array assignment
  public void readFields(DataInput in) throws IOException {
    int card = WritableUtils.readVInt(in);
    if (splits == null || splits.length != card) {
      splits = new InputSplit[card];
    }
    Class<? extends InputSplit>[] cls = new Class[card];
    try {
      for (int i = 0; i < card; ++i) {
        cls[i] =
          Class.forName(Text.readString(in)).asSubclass(InputSplit.class);
      }
      for (int i = 0; i < card; ++i) {
        splits[i] = ReflectionUtils.newInstance(cls[i], null);
        splits[i].readFields(in);
      }
    } catch (ClassNotFoundException e) {
      throw (IOException)new IOException("Failed split init").initCause(e);
    }
  }
543076
function parse(input, isindex) {
				var sequences = input.split('&');
				if (isindex && sequences[0].indexOf('=') === -1)
					sequences[0] = '=' + sequences[0];
				var pairs = [];
				sequences.forEach(function (bytes) {
					if (bytes.length === 0) return;
					var index = bytes.indexOf('=');
					if (index !== -1) {
						var name = bytes.substring(0, index);
						var value = bytes.substring(index + 1);
					} else {
						name = bytes;
						value = '';
					}
					name = name.replace(/\+/g, ' ');
					value = value.replace(/\+/g, ' ');
					pairs.push({ name: name, value: value });
				});
				var output = [];
				pairs.forEach(function (pair) {
					output.push({
						name: decodeURIComponent(pair.name),
						value: decodeURIComponent(pair.value)
					});
				});
				return output;
			}
1220023
def extract_card(text, config, image_search_path):
    
    card = CardData()
    parser = CardParser(card, config, image_search_path)
    misaka.Markdown(parser, extensions=markdown.ENABLED_EXTENSIONS)(text)

    return card