/*
Parse a single list-based worksheet, turning it into a Tabletop Model

Used as a callback for the list-based JSON
540951
function(data) {
      var that = this;
      var model = new Tabletop.Model( { data: data, 
                                        parseNumbers: this.parseNumbers,
                                        postProcess: this.postProcess,
                                        tabletop: this,
                                        prettyColumnNames: this.prettyColumnNames,
                                        onReady: function() {
                                          that.sheetReady(this);
                                        } } );
    }
79654
function parse(tokens) {
    var ast = [];

    var current = ast;

    var _line = 0;
    var _char = 0;

    var openCount = 0;
    var closeCount = 0;

    for (var i = 0; i < tokens.length; i++) {
        var token = tokens[i];

        switch (token.type) {
            case TYPES.open:
                // Every time we open a list, we drop into a sub-array
                var child = [];
                child.parent = current;
                current.push(child);
                current = child;
                openCount += 1;
                break;

            case TYPES.open_array:
            case TYPES.quote:
                var child = [];
                var quote = {"'": child };
                child.parent = current;
                current.push(quote);
                current = child;
                openCount += 1;
                break;

            case TYPES.close_array:
            case TYPES.close:
                // If no current, we probably have too many closing parens
                if (!current) _tooManyClosingParensErr(closeCount, openCount);
                // If we close a list, jump back up to the parent list
                current = current.parent;
                closeCount += 1;
                break;

            case TYPES.identifier:
            case TYPES.suffixed_number:
                current.push(token.string);
                break;

            case TYPES.number:
                current.push(Number(token.string));
                break;

            case TYPES.string:
                // We need to strip the quotes off the string entity
                var dequoted = token.string.slice(1).slice(0, token.string.length - 2);
                current.push(dequoted);
                break;

            case TYPES.json:
                try {
                    var deticked = token.string.slice(1).slice(0, token.string.length - 2);
                    current.push(JSON.parse(deticked));
                }
                catch (e) {
                    throw new Error([
                        'Runiq: Couldn\'t parse inlined JSON!',
                        '--- Error occurred at line ' + _line + ', char ' + _char
                    ].join('\n'));
                }
                break;
        }

        // Capture line numbers and columns for future use
        var lines = token.string.split(NEWLINE);
        _line += lines.length - 1;
        if (lines.length > 1) _char = lines[lines.length - 1].length;
        else _char += token.string.length;
    }

    // Raise error if we have a parentheses mismatch
    if (openCount > closeCount) _tooManyOpenParensErr(closeCount, openCount);
    if (openCount < closeCount) _tooManyClosingParensErr(closeCount, openCount);

    // For both safety and to ensure we actually have a JSON-able AST
    return JSON.parse(JSONStableStringify(ast));
}
83640
def _parse_json(self, doc, exactly_one):
        
        places = doc.get('geonames', [])
        self._raise_for_error(doc)
        if not len(places):
            return None

        def parse_code(place):
            """
            Parse each record.
            """
            latitude = place.get('lat', None)
            longitude = place.get('lng', None)
            if latitude and longitude:
                latitude = float(latitude)
                longitude = float(longitude)
            else:
                return None

            placename = place.get('name')
            state = place.get('adminName1', None)
            country = place.get('countryName', None)

            location = ', '.join(
                [x for x in [placename, state, country] if x]
            )

            return Location(location, (latitude, longitude), place)

        if exactly_one:
            return parse_code(places[0])
        else:
            return [parse_code(place) for place in places]
588727
def _parse_json(cls, resources, exactly_one=True):
        
        if not len(resources['features']):  # pragma: no cover
            return None
        if exactly_one:
            return cls.parse_resource(resources['features'][0])
        else:
            return [cls.parse_resource(resource) for resource
                    in resources['features']]
1320747
def parse_properties(parent_index_name, parent_name, nested_path, esProperties):
    
    columns = FlatList()
    for name, property in esProperties.items():
        index_name = parent_index_name
        column_name = concat_field(parent_name, name)
        jx_name = column_name

        if property.type == "nested" and property.properties:
            # NESTED TYPE IS A NEW TYPE DEFINITION
            # MARKUP CHILD COLUMNS WITH THE EXTRA DEPTH
            self_columns = parse_properties(index_name, column_name, [column_name] + nested_path, property.properties)
            columns.extend(self_columns)
            columns.append(Column(
                name=jx_name,
                es_index=index_name,
                es_column=column_name,
                es_type="nested",
                jx_type=NESTED,
                last_updated=Date.now(),
                nested_path=nested_path
            ))

            continue

        if property.properties:
            child_columns = parse_properties(index_name, column_name, nested_path, property.properties)
            columns.extend(child_columns)
            columns.append(Column(
                name=jx_name,
                es_index=index_name,
                es_column=column_name,
                es_type="source" if property.enabled == False else "object",
                jx_type=OBJECT,
                last_updated=Date.now(),
                nested_path=nested_path
            ))

        if property.dynamic:
            continue
        if not property.type:
            continue

        cardinality = 0 if not (property.store or property.enabled) and name != '_id' else None

        if property.fields:
            child_columns = parse_properties(index_name, column_name, nested_path, property.fields)
            if cardinality is None:
                for cc in child_columns:
                    cc.cardinality = None
            columns.extend(child_columns)

        if property.type in es_type_to_json_type.keys():
            columns.append(Column(
                name=jx_name,
                es_index=index_name,
                es_column=column_name,
                es_type=property.type,
                jx_type=es_type_to_json_type[property.type],
                cardinality=cardinality,
                last_updated=Date.now(),
                nested_path=nested_path
            ))
            if property.index_name and name != property.index_name:
                columns.append(Column(
                    name=jx_name,
                    es_index=index_name,
                    es_column=column_name,
                    es_type=property.type,
                    jx_type=es_type_to_json_type[property.type],
                    cardinality=0 if property.store else None,
                    last_updated=Date.now(),
                    nested_path=nested_path
                ))
        elif property.enabled == None or property.enabled == False:
            columns.append(Column(
                name=jx_name,
                es_index=index_name,
                es_column=column_name,
                es_type="source" if property.enabled == False else "object",
                jx_type=OBJECT,
                cardinality=0 if property.store else None,
                last_updated=Date.now(),
                nested_path=nested_path
            ))
        else:
            Log.warning("unknown type {{type}} for property {{path}}", type=property.type, path=parent_name)

    return columns
480251
def from_code_array(self):
        """"""

        worksheets = []
        self._shape2xls(worksheets)

        self._code2xls(worksheets)

        self._row_heights2xls(worksheets)
        self._col_widths2xls(worksheets)

        return self.workbook
445602
function parse_style_json_object(text, options)
{
	// remove multiline comments
	text = text.replace(/\/\*([\s\S]*?)\*\//g, '')

	// ignore curly braces for now.
	// maybe support curly braces along with tabulation in future
	text = text.replace(/[\{\}]/g, '')

	const lines = text.split('\n')

	// helper class for dealing with tabulation
	const tabulator = new Tabulator(Tabulator.determine_tabulation(lines))

	// parse text into JSON object
	let style_json = parse_style_class(tabulator.extract_tabulation(lines), [])

	// expand CSS shorthand properties
	// (e.g. `margin: 1px` -> `margin-left: 1px; ...`)
	if (options.expand)
	{
		style_json = style_builder.build(style_json)
	}

	// expand "modifier" style classes
	// (which can override some of the expanded shorthand CSS properties)
	return expand_modifier_style_classes(style_json)
}
951442
function parseAccountList(resp) {
  return new Promise((resolve, reject) => {
    const $ = cheerio.load(resp.body);
    const accountRows = $('.main_group_account_row');

    if (!accountRows || accountRows.length === 0) {
      return reject(new Error('Cannot find account list.'));
    }

    const accounts = [];
    accountRows.each((index, elem) => {
      try {
        const $$ = cheerio.load(elem);
        const account = {
          name: $$('.NicknameField .left a')
            .text()
            .trim(),
          link: $$('.NicknameField .left a').attr('href'),
          bsb: $$('.BSBField .text')
            .text()
            .replace(/\s+/g, '')
            .trim(),
          account: $$('.AccountNumberField .text')
            .text()
            .replace(/\s+/g, '')
            .trim(),
          balance: parseCurrencyHtml($$('.AccountBalanceField')),
          available: parseCurrencyHtml($$('.AvailableFundsField')),
        };
        //  Assemble the `bsb` and `account` to construct `number`
        account.number = `${account.bsb}${account.account}`;
        account.type = `${/ACCOUNT_PRODUCT_TYPE=(\w+)/.exec(account.link)[1]}`;
        //  push to the final account list if it's valid
        if (account.name && account.link && account.account) {
          accounts.push(account);
        }
      } catch (err) {
        debug(`parseAccountList(): ${err}`);
        debug(`parseAccountList(): elem => ${util.inspect(elem)}`);
      }
    });

    debug(`parseAccountList(): found ${accounts.length} accounts`);
    return resolve(Object.assign({}, resp, { accounts }));
  });
}
168190
def parse_cell(line, world_size):
    
    # Remove "CELL "
    line = line[4:]

    # Extract information
    sline = [i.strip() for i in line.split(":")]
    name = sline[0]
    name = reduce_resource_name_to_task(name)
    cell_components = sline[1].split(",")
    cells = []

    # List all cells
    for i in range(len(cell_components)):
        if ".." in cell_components[i]:
            cell_range = [int(j) for j in cell_components[i].split("..")]
            for j in range(int(cell_range[0]), int(cell_range[1]+1)):
                cells.append(j)
        else:
            cells.append(int(cell_components[i]))

    if cells == [""]:
        return (name, [])

    xy_pairs = [(int(c) % world_size[0], int(c)//world_size[0]) for c in cells]

    return (name, xy_pairs)
302377
function parse_PtgSheet(blob, length, opts) {
	blob.l += 5;
	blob.l += 2;
	blob.l += (opts.biff == 2 ? 1 : 4);
	return ["PTGSHEET"];
}
3144
function fromJson(collection, collectionPath, next) {

  var docsBulk = [];
  var docs = fs.readdirSync(collectionPath);
  var last = ~~docs.length, counter = 0;
  if (last === 0) {
    return next(null);
  }

  docs.forEach(function(docName) {

    var doc, data;
    try {
      data = fs.readFileSync(collectionPath + docName);
    } catch (err) {
      return last === ++counter ? next(null) : null;
    }
    try {
      doc = JSON.parse(data);
    } catch (err) {
      return last === ++counter ? next(err) : error(err);
    }

    docsBulk.push({
      insertOne: {
        document: doc
      }
    });

    return last === ++counter ? collection.bulkWrite(docsBulk, next) : null;
  });
}
261042
def _from_json_list(cls, response_raw, wrapper=None):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        array = obj[cls._FIELD_RESPONSE]
        array_deserialized = []

        for item in array:
            item_unwrapped = item if wrapper is None else item[wrapper]
            item_deserialized = converter.deserialize(cls, item_unwrapped)
            array_deserialized.append(item_deserialized)

        pagination = converter.deserialize(client.Pagination,
                                           obj[cls._FIELD_PAGINATION])

        return client.BunqResponse(array_deserialized, response_raw.headers,
                                   pagination)
713306
def parse(self):
		
		c = Collection()
		while self.index < self.datalen:
			g = self.parseOneGame()
			if g:
				c.append(g)
			else:
				break
		return c
44710
function parse_ws_xml_sheetpr(sheetPr, s, wb, idx) {
	var data = parsexmltag(sheetPr);
	if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
	if(data.codeName) wb.Sheets[idx].CodeName = data.codeName;
}
831056
@Programmatic
    public List<List<?>> fromExcel(
            final Blob excelBlob,
            final List<WorksheetSpec> worksheetSpecs) throws ExcelService.Exception {
        try {
            return newExcelConverter().fromBytes(worksheetSpecs, excelBlob.getBytes());
        } catch (final IOException | InvalidFormatException e) {
            throw new ExcelService.Exception(e);
        }
    }
810309
def _parse_box_list(self, output):
        '''
        
        '''
        # Parse box list output

        boxes = []
        # initialize box values
        name = provider = version = None
        for timestamp, target, kind, data in self._parse_machine_readable_output(output):
            if kind == 'box-name':
                # finish the previous box, if any
                if name is not None:
                    boxes.append(Box(name=name, provider=provider, version=version))

                # start a new box
                name = data # box name
                provider = version = None
            elif kind == 'box-provider':
                provider = data
            elif kind == 'box-version':
                version = data

        # finish the previous box, if any
        if name is not None:
            boxes.append(Box(name=name, provider=provider, version=version))

        return boxes
1288965
private List<Object> getCollectionValue(JsonParser jsonParser) throws IOException {
        LOG.info("Start parsing {} array", jsonParser.getCurrentName());
        List<Object> list = new ArrayList<>();
        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                Object embedded = getEmbeddedObject(jsonParser);
                list.add(embedded);
            }
            if (!"}".equals(jsonParser.getText())) {
                list.add(jsonParser.getText());
            } else {
                LOG.info("Array is over.");
            }
        }
        return list;
    }