parse resource table file.
169539
public void parse() {
        // read resource file header.
        ResourceTableHeader resourceTableHeader = (ResourceTableHeader) readChunkHeader();

        // read string pool chunk
        stringPool = ParseUtils.readStringPool(buffer, (StringPoolHeader) readChunkHeader());

        resourceTable = new ResourceTable();
        resourceTable.setStringPool(stringPool);

        PackageHeader packageHeader = (PackageHeader) readChunkHeader();
        for (int i = 0; i < resourceTableHeader.getPackageCount(); i++) {
            Pair<ResourcePackage, PackageHeader> pair = readPackage(packageHeader);
            resourceTable.addPackage(pair.getLeft());
            packageHeader = pair.getRight();
        }
    }
299126
def parse(self, resource):
        
        try:
            import polib
        except ImportError as e:
            self.rethrow(
                "You need to install polib to use PoFileLoader or MoFileLoader",
                ImportError)

        self.assert_valid_path(resource)

        messages = {}
        parsed = self._load_contents(polib, resource)

        for item in parsed:
            if item.msgid_plural:
                plurals = sorted(item.msgstr_plural.items())
                if item.msgid and len(plurals) > 1:
                    messages[item.msgid] = plurals[0][1]
                plurals = [msgstr for idx, msgstr in plurals]
                messages[item.msgid_plural] = "|".join(plurals)
            elif item.msgid:
                messages[item.msgid] = item.msgstr

        return messages
237784
def get_python_files(self):
        """"""
        return [resource for resource in self.get_files()
                if self.pycore.is_python_file(resource)]
1269738
def load_data_table(table_name, meta_file, meta):
    
    for table in meta['tables']:
        if table['name'] == table_name:
            prefix = os.path.dirname(meta_file)
            relative_path = os.path.join(prefix, meta['path'], table['path'])
            return pd.read_csv(relative_path), table
1228176
def parse_file(self, sourcepath):
        """"""
        # Get regex objects:
        self.date_regex = re.compile(
                r'{}'.format(self.format_regex))
        if self.backup_format_regex:
            self.backup_date_regex = re.compile(
                    r'{}'.format(self.backup_format_regex))
        data = {}
        data['entries'] = []
        data['parser'] = self.name
        data['source_path'] = sourcepath
        data['source_file'] = sourcepath.split('/')[-1]

        # Set our start year:
        data['source_file_mtime'] = os.path.getmtime(data['source_path'])
        timestamp = datetime.fromtimestamp(data['source_file_mtime'])
        data['source_file_year'] = timestamp.year
        entryyear = timestamp.year
        currentmonth = '99'
        if self.datestamp_type == 'nodate':
            self.datedata = {}
            self.datedata['timestamp'] = timestamp
            self.datedata['entry_time'] = int(timestamp.strftime('%H%M%S'))

        # Set our timezone
        if not self.tzone:
            self.backuptzone = logdissect.utils.get_local_tzone()

        # Parsing works in reverse. This helps with multi-line entries,
        # and logs that span multiple years (December to January shift).

        # Get our lines:
        fparts = sourcepath.split('.')
        if fparts[-1] == 'gz':
            with gzip.open(sourcepath, 'r') as logfile:
                loglines = reversed(logfile.readlines())
        else:
            with open(str(sourcepath), 'r') as logfile:
                loglines = reversed(logfile.readlines())

        # Parse our lines:
        for line in loglines:
            ourline = line.rstrip()

            # Send the line to self.parse_line
            entry = self.parse_line(ourline)

            if entry:
                if 'date_stamp' in self.fields:
                    # Check for Dec-Jan jump and set the year:
                    if self.datestamp_type == 'standard':
                        if int(entry['month']) > int(currentmonth):
                            entryyear = entryyear - 1
                        currentmonth = entry['month']
                    
                        entry['numeric_date_stamp'] = str(entryyear) \
                                + entry['month'] + entry['day'] + \
                                entry['tstamp']
                        entry['year'] = str(entryyear)
                    if self.tzone:
                        entry['tzone'] = self.tzone
                    else:
                        entry['tzone'] = self.backuptzone
                    entry = logdissect.utils.get_utc_date(entry)
                entry['raw_text'] = ourline
                entry['source_path'] = data['source_path']

                # Append current entry
                data['entries'].append(entry)

            else:
                continue

        # Write the entries to the log object
        data['entries'].reverse()
        return data
821541
def _parse_response(response, clazz, is_list=False, resource_name=None):
        """"""
        target = response.json()[
            resource_name] if resource_name else response.json()
        if is_list:
            return [clazz.from_json(resource) for resource in target]
        else:
            return clazz.from_json(target)
901574
def parse_resource_data_entry(self, rva):
        """"""

        try:
            # If the RVA is invalid all would blow up. Some EXEs seem to be
            # specially nasty and have an invalid RVA.
            data = self.get_data(rva, Structure(self.__IMAGE_RESOURCE_DATA_ENTRY_format__).sizeof() )
        except PEFormatError as excp:
            self.__warnings.append(
                'Error parsing a resource directory data entry, '
                'the RVA is invalid: 0x%x' % ( rva ) )
            return None

        data_entry = self.__unpack_data__(
            self.__IMAGE_RESOURCE_DATA_ENTRY_format__, data,
            file_offset = self.get_offset_from_rva(rva) )

        return data_entry
1143825
def get_resource(request):
    """"""
    hash = request.matchdict['hash']

    # Do the file lookup
    with db_connect() as db_connection:
        with db_connection.cursor() as cursor:
            args = dict(hash=hash)
            cursor.execute(SQL['get-resource'], args)
            try:
                mimetype, file = cursor.fetchone()
            except TypeError:  # None returned
                raise httpexceptions.HTTPNotFound()

    resp = request.response
    resp.status = "200 OK"
    resp.content_type = mimetype
    resp.body = file[:]
    return resp
664705
def parse_file(self, sourcepath):
        """"""

        # Open input file and read JSON array:
        with open(sourcepath, 'r') as logfile:
            jsonlist = logfile.readlines()

        # Set our attributes for this entry and add it to data.entries:
        data = {}
        data['entries'] = []
        for line in jsonlist:
            entry = self.parse_line(line)
            data['entries'].append(entry)
        if self.tzone:
            for e in data['entries']:
                e['tzone'] = self.tzone

        # Return the parsed data
        return data
544747
def get_resources(cls):
        """"""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        resources = resource_helper.build_resource_info(my_plurals,
                                                        attr_map,
                                                        constants.A10_DEVICE_INSTANCE)

        return resources
20383
private void parseResources(CloudTrailEventData eventData) throws IOException {
        JsonToken nextToken = jsonParser.nextToken();
        if (nextToken == JsonToken.VALUE_NULL) {
            eventData.add(CloudTrailEventField.resources.name(), null);
            return;
        }

        if (nextToken != JsonToken.START_ARRAY) {
            throw new JsonParseException("Not a list of resources object", jsonParser.getCurrentLocation());
        }

        List<Resource> resources = new ArrayList<Resource>();

        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            resources.add(parseResource());
        }

        eventData.add(CloudTrailEventField.resources.name(), resources);
    }
668920
def parse(data, datafile):
    """"""
    data._last_travel = [0, [0]]  # x and verbs used by section 3

    while True:
        section_number = int(datafile.readline())
        if not section_number:  # no further sections
            break
        store = globals().get('section%d' % section_number)
        while True:
            fields = [ (int(field) if field.lstrip('-').isdigit() else field)
                       for field in datafile.readline().strip().split('\t') ]
            if fields[0] == -1:  # end-of-section marker
                break
            store(data, *fields)

    del data._last_travel  # state used by section 3
    del data._object       # state used by section 5

    data.object_list = sorted(set(data.objects.values()), key=attrgetter('n'))
    #data.room_list = sorted(set(data.rooms.values()), key=attrgetter('n'))
    for obj in data.object_list:
        name = obj.names[0]
        if hasattr(data, name):
            name = name + '2'  # create identifiers like ROD2, PLANT2
        setattr(data, name, obj)

    return data
13377
public void parse() throws NodeFileParserException {
        final ResourceXMLParser resourceXMLParser;
        if(null!=file){
            resourceXMLParser=new ResourceXMLParser(file);
        }else{
            resourceXMLParser = new ResourceXMLParser(input);
        }
        //parse both node and settings
        resourceXMLParser.setReceiver(this);
//        long start = System.currentTimeMillis();
        try {
            resourceXMLParser.parse();
        } catch (ResourceXMLParserException e) {
            throw new NodeFileParserException(e);
        } catch (IOException e) {
            throw new NodeFileParserException(e);
        }
//        System.err.println("parse: " + (System.currentTimeMillis() - start));
    }
443345
def _parse(self):
        """"""
        with open(self.filename, 'r') as fobj:
            lines = fobj.read().split('\n')

        # Create a header object with content at start of file
        self.header = MOPHeader(self.subfmt).parser(lines)

        # Create a data attribute to hold an astropy.table.Table object
        self.data = MOPDataParser(self.header).parse(lines)
1233742
def _Parse(self):
    """"""
    root_file_entry = self._file_system.GetRootFileEntry()

    for sub_file_entry in root_file_entry.sub_file_entries:
      volume = APFSVolume(sub_file_entry)
      self._AddVolume(volume)
515324
function _parse_resource_name(&$params)
	{

		// split tpl_path by the first colon
		$_resource_name_parts = explode(':', $params['resource_name'], 2);

		if (count($_resource_name_parts) == 1) {
			// no resource type given
			$params['resource_type'] = $this->default_resource_type;
			$params['resource_name'] = $_resource_name_parts[0];
		} else {
			if(strlen($_resource_name_parts[0]) == 1) {
				// 1 char is not resource type, but part of filepath
				$params['resource_type'] = $this->default_resource_type;
				$params['resource_name'] = $params['resource_name'];
			} else {
				$params['resource_type'] = $_resource_name_parts[0];
				$params['resource_name'] = $_resource_name_parts[1];
			}
		}

		if ($params['resource_type'] == 'file') {
			if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
				// relative pathname to $params['resource_base_path']
				// use the first directory where the file is found
				foreach ((array)$params['resource_base_path'] as $_curr_path) {
					$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
					if (file_exists($_fullpath) && is_file($_fullpath)) {
						$params['resource_name'] = $_fullpath;
						return true;
					}
					// didn't find the file, try include_path
					$_params = array('file_path' => $_fullpath);
					require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
					if(smarty_core_get_include_path($_params, $this)) {
						$params['resource_name'] = $_params['new_file_path'];
						return true;
					}
				}
				return false;
			} else {
				/* absolute path */
				return file_exists($params['resource_name']);
			}
		} elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
			$_params = array('type' => $params['resource_type']);
			require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
			smarty_core_load_resource_plugin($_params, $this);
		}

		return true;
	}
1117041
def get_data_table(filename):
  """"""
  with get_file_object(filename, "r") as rf:
    return DataTable(list(csv.reader(rf)))