Parse source model file and collect information about source ids,
        source types and tectonic region types available in it. That
        information is used then for :meth:`validate_filters` and
        :meth:`validate_uncertainty_value`.
979801
def collect_source_model_data(self, branch_id, source_model):
        
        # using regular expressions is a lot faster than using the
        with self._get_source_model(source_model) as sm:
            xml = sm.read()
        self.tectonic_region_types.update(TRT_REGEX.findall(xml))
        self.source_ids[branch_id].extend(ID_REGEX.findall(xml))
        self.source_types.update(SOURCE_TYPE_REGEX.findall(xml))
603970
def source(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "source", value)
            assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format("source", value)
        self.__source = value
19875
def collect(cls, sources):
        
        source_stats_dict = {}
        for src in sources:
            trt = src['tectonicRegion']
            if trt not in source_stats_dict:
                source_stats_dict[trt] = SourceGroup(trt)
            sg = source_stats_dict[trt]
            if not sg.sources:
                # we append just one source per SourceGroup, so that
                # the memory occupation is insignificant
                sg.sources.append(src)

        # return SourceGroups, ordered by TRT string
        return sorted(source_stats_dict.values())
232117
def _validate_source_data(self):
        

        try:
            jsonschema.validate(self._buffer, self._schema)
        except jsonschema.ValidationError as e:
            raise ValidationError(e)
1166825
def from_shapefile(output, input_shp_files, validate):
    
    input_parser = shapefileparser.ShapefileParser()
    source_model = input_parser.read(input_shp_files[0], validate)
    for f in input_shp_files[1:]:
        source_model.sources.extend(input_parser.read(f, validate).sources)
    if not output:
        output = os.path.splitext(input_shp_files[0])[0]
    shapefileparser.SourceModelParser().write(output + '.xml', source_model)
464811
def extract_source_params(src):
    
    tags = get_taglist(src)
    data = []
    for key, param, vtype in BASE_PARAMS:
        if key in src.attrib:
            if vtype == "c":
                data.append((param, src.attrib[key]))
            elif vtype == "f":
                data.append((param, float(src.attrib[key])))
            else:
                data.append((param, None))
        elif key in tags:
            if vtype == "c":
                data.append((param, src.nodes[tags.index(key)].text))
            elif vtype == "f":
                data.append((param, float(src.nodes[tags.index(key)].text)))
            else:
                data.append((param, None))
        else:
            data.append((param, None))
    return dict(data)
963993
def appraise_source_model(self):
        
        for src in self.sources:
            # source params
            src_taglist = get_taglist(src)
            if "areaSource" in src.tag:
                self.has_area_source = True
                npd_node = src.nodes[src_taglist.index("nodalPlaneDist")]
                npd_size = len(npd_node)
                hdd_node = src.nodes[src_taglist.index("hypoDepthDist")]
                hdd_size = len(hdd_node)
                self.num_np = (npd_size if npd_size > self.num_np
                               else self.num_np)
                self.num_hd = (hdd_size if hdd_size > self.num_hd
                               else self.num_hd)
            elif "pointSource" in src.tag:
                self.has_point_source = True
                npd_node = src.nodes[src_taglist.index("nodalPlaneDist")]
                npd_size = len(npd_node)
                hdd_node = src.nodes[src_taglist.index("hypoDepthDist")]
                hdd_size = len(hdd_node)
                self.num_np = (npd_size if npd_size > self.num_np
                               else self.num_np)
                self.num_hd = (hdd_size if hdd_size > self.num_hd
                               else self.num_hd)
            elif "simpleFaultSource" in src.tag:
                self.has_simple_fault_geometry = True
            elif "complexFaultSource" in src.tag:
                self.has_complex_fault_geometry = True
            elif "characteristicFaultSource" in src.tag:
                # Get the surface node
                surface_node = src.nodes[src_taglist.index("surface")]
                p_size = 0
                for surface in surface_node.nodes:
                    if "simpleFaultGeometry" in surface.tag:
                        self.has_simple_fault_geometry = True
                    elif "complexFaultGeometry" in surface.tag:
                        self.has_complex_fault_geometry = True
                    elif "planarSurface" in surface.tag:
                        self.has_planar_geometry = True
                        p_size += 1
                self.num_p = p_size if p_size > self.num_p else self.num_p
            else:
                pass

            # MFD params
            if "truncGutenbergRichterMFD" in src_taglist:
                self.has_mfd_gr = True
            elif "incrementalMFD" in src_taglist:
                self.has_mfd_incremental = True
                # Get rate size
                mfd_node = src.nodes[src_taglist.index("incrementalMFD")]
                r_size = len(mfd_node.nodes[0].text)
                self.num_r = r_size if r_size > self.num_r else self.num_r
            else:
                pass
341168
def _parse_source_line(self, line):
        
        if '--git' in line:
            regex = self.SRC_FILE_RE
        elif '--cc' in line:
            regex = self.MERGE_CONFLICT_RE
        else:
            msg = "Do not recognize format of source in line '{}'".format(line)
            raise GitDiffError(msg)

        # Parse for the source file path
        groups = regex.findall(line)

        if len(groups) == 1:
            return groups[0]

        else:
            msg = "Could not parse source path in line '{}'".format(line)
            raise GitDiffError(msg)
488922
def parse_tree(self, tree_node, validate):
        
        self.info = collect_info(self.filename)
        self.source_ids = collections.defaultdict(list)
        t0 = time.time()
        for depth, branchinglevel_node in enumerate(tree_node.nodes):
            self.parse_branchinglevel(branchinglevel_node, depth, validate)
        dt = time.time() - t0
        if validate:
            bname = os.path.basename(self.filename)
            logging.info('Validated %s in %.2f seconds', bname, dt)
317520
private void parseFilename() {

    // Add additional filtering to discard empty files, or files ending in .crc
    if ((filename != null) && (filename.length() > 0)
        && (!filename.endsWith(".crc"))) {

      Matcher matcher = PATTERN.matcher(filename);

      if (matcher.matches()) {
    	//  jobTracker = "";
    	  jobid = matcher.group(1);
    	  Matcher confMatcher = CONF_PATTERN.matcher(filename);
    	  if (confMatcher.matches()) {
        	isJobConfFile = true;
        	LOG.debug("Job Conf file  " + filename + " with job id: " + jobid);
        	} else {
        		isJobHistoryFile = true;
        		LOG.debug("Job History file " + filename + " with job id: " + jobid);
        		}
    	  }
      else {
          LOG.info(" file does not match any format: " + filename);
      }
    }
  }
545249
def read_source_models(fnames, converter, monitor):
    
    for fname in fnames:
        if fname.endswith(('.xml', '.nrml')):
            sm = to_python(fname, converter)
        elif fname.endswith('.hdf5'):
            sm = sourceconverter.to_python(fname, converter)
        else:
            raise ValueError('Unrecognized extension in %s' % fname)
        sm.fname = fname
        yield sm
784104
function parseMetadata (source, callback) {
  var i;
  var lines;
  var markerPad = '';

  if (!source) return callback(null, {});
  if (source.length === 0) return callback(null, {});

  try {
    return callback(null, yaml.load(source) || {});
  }
  catch (error) {
    if (error.problem != null && error.problemMark != null) {
      lines = error.problemMark.buffer.split('\n');
      for (i = 0; i < error.problemMark.column; i++) {
        markerPad += ' ';
      }
      error.message = "YAML: " + error.problem + "\n\n"
        + lines[error.problemMark.line] + "\n" + markerPad + "^\n";
    }
    else {
      error.message = "YAML Parsing error " + error.message;
    }
    return callback(error);
  }
}
548654
def source_files(self):
        """"""
        if 'srcs' in self.params and self.params['srcs'] is not None:
            return util.flatten(self.params['srcs'])
349251
def determine_file_type(self, z):
        """"""

        mimetype = z.read('mimetype').decode('utf-8').strip()
        self.type = MIMEMAP[mimetype]
1163896
def load_riskmodel(self):
        # to be called before read_exposure
        # NB: this is called even if there is no risk model
        
        logging.info('Reading the risk model if present')
        self.riskmodel = readinput.get_risk_model(self.oqparam)
        if not self.riskmodel:
            parent = self.datastore.parent
            if 'risk_model' in parent:
                self.riskmodel = riskinput.CompositeRiskModel.read(parent)
            return
        if self.oqparam.ground_motion_fields and not self.oqparam.imtls:
            raise InvalidFile('No intensity_measure_types specified in %s' %
                              self.oqparam.inputs['job_ini'])
        self.save_params()
1331178
def source_filter(method_name, *args, **kwargs):
    

    def source_filter(value, context, **_params):
        method = getattr(context["model"].source, method_name)
        return _filter(method, value, args, kwargs)

    return source_filter
4469
def _parse_model(topology, scope, model, inputs=None, outputs=None):
    '''
    
    '''

    if inputs is None:
        inputs = list()
    if outputs is None:
        outputs = list()

    model_type = model.WhichOneof('Type')
    if model_type in ['pipeline', 'pipelineClassifier', 'pipelineRegressor']:
        _parse_pipeline_model(topology, scope, model, inputs, outputs)
    elif model_type in ['neuralNetworkClassifier', 'neuralNetworkRegressor', 'neuralNetwork']:
        _parse_neural_network_model(topology, scope, model, inputs, outputs)
    else:
        _parse_simple_model(topology, scope, model, inputs, outputs)