Reads the spec files and extracts the concrete product spec.
        :param spec_path:
        :param product_name:
        :return:
542283
def _read(self, spec_path, product_name):
        
        matches = []
        with codecs.open(spec_path, 'r') as f:
            for entry in json.loads(f.read()):
                if product_name in entry.get('products'):
                    matches.append(entry)
        return matches
292637
def specs_from_names(names)
      names.map do |name|
        spec = available_spec(name)
        fail "#{name} was not found" if spec.nil?
        spec
      end
    end
480565
def load(self):
        
        # If we are given a string, open it up else assume it's something we
        # can call read on.
        if isinstance(self.specfile, str):
            f = open(self.specfile, 'r')
        else:
            f = self.specfile

        for line in f:
            if self.v_regex.match(line):
                self._pkg_version = self.v_regex.match(line).group(1)
            if self.n_regex.match(line):
                self._pkg_name = self.n_regex.match(line).group(1)
        f.close()
        self._loaded = True
855301
def parse_python(spec):  # Ignore PyDocStyleBear
        

        def _extract_op_version(spec):
            # https://www.python.org/dev/peps/pep-0440/#compatible-release
            if spec.operator == "~=":
                version = spec.version.split(".")
                if len(version) in {2, 3, 4}:
                    if len(version) in {3, 4}:
                        del version[-1]  # will increase the last but one in next line
                    version[-1] = str(int(version[-1]) + 1)
                else:
                    raise ValueError("%r must not be used with %r" % (spec.operator, spec.version))
                return [(">=", spec.version), ("<", ".".join(version))]
            # Trailing .* is permitted per
            # https://www.python.org/dev/peps/pep-0440/#version-matching
            elif spec.operator == "==" and spec.version.endswith(".*"):
                try:
                    result = check_output(["/usr/bin/semver-ranger", spec.version], universal_newlines=True).strip()
                    gte, lt = result.split()
                    return [(">=", gte.lstrip(">=")), ("<", lt.lstrip("<"))]
                except ValueError:
                    _LOGGER.warning("couldn't resolve ==%s", spec.version)
                    return spec.operator, spec.version
            # https://www.python.org/dev/peps/pep-0440/#arbitrary-equality
            # Use of this operator is heavily discouraged, so just convert it to 'Version matching'
            elif spec.operator == "===":
                return "==", spec.version
            else:
                return spec.operator, spec.version

        def _get_pip_spec(requirements):
            """There is no `specs` field In Pip 8+, take info from `specifier` field."""
            if hasattr(requirements, "specs"):
                return requirements.specs
            elif hasattr(requirements, "specifier"):
                specs = [_extract_op_version(spec) for spec in requirements.specifier]
                if len(specs) == 0:
                    # TODO: I'm not sure with this one
                    # we should probably return None instead and let pip deal with this
                    specs = [(">=", "0.0.0")]
                return specs

        _LOGGER.info("Parsing dependency %r", spec)
        # create a temporary file and store the spec there since
        # `parse_requirements` requires a file
        with NamedTemporaryFile(mode="w+", suffix="pysolve") as f:
            f.write(spec)
            f.flush()
            parsed = parse_requirements(f.name, session=f.name)
            dependency = [Dependency(x.name, _get_pip_spec(x.req)) for x in parsed].pop()

        return dependency
1145710
def _get_spec(self, spec_file):
        """"""
        spec_file_path = os.path.join(
            pkg_resources.
            resource_filename(
                'reana_commons',
                'openapi_specifications'),
            spec_file)

        with open(spec_file_path) as f:
            json_spec = json.load(f)
        return json_spec
948000
def _get_spec(tree_base, spec, template, saltenv='base'):
    '''
    
    '''
    spec_tgt = os.path.basename(spec)
    dest = os.path.join(tree_base, 'SPECS', spec_tgt)
    return __salt__['cp.get_url'](
        spec,
        dest,
        saltenv=saltenv)
904077
def _import_module_from_path(module_name, plugin_path):
    
    module = None
    try:
        if PY2:
            info = imp.find_module(module_name, [plugin_path])
            if info:
                module = imp.load_module(module_name, *info)
        else:  # Python 3.4+
            spec = importlib.machinery.PathFinder.find_spec(
                module_name,
                [plugin_path])
            if spec:
                module = spec.loader.load_module(module_name)
    except Exception:
        pass

    return module
76336
def _ExtractPath(response, pathspec_attribute=None):
  
  path_specification = response

  if pathspec_attribute is not None:
    if response.HasField(pathspec_attribute):
      path_specification = response.Get(pathspec_attribute)

  if path_specification.HasField("pathspec"):
    path_specification = path_specification.pathspec

  if path_specification.HasField("path"):
    path_specification = path_specification.path

  if isinstance(path_specification, Text):
    return path_specification
  return None
500017
def _parse_glob_spec(self, spec):
        '''
        
        '''
        some_globs = glob.glob(spec['glob'])
        if not some_globs:
            return []
        el_globs = []
        for g in some_globs:
            _spec = copy.copy(spec)
            _spec['file'] = g
            el_globs.append(_spec)
        return el_globs
192121
def get_spec(name, http_client=None, config=None):
    
    http_client = http_client or requests_client.RequestsClient()

    def load_spec():
        loader = Loader(http_client)
        return loader.load_spec(build_spec_url(name))

    spec_dict = cache.get_or_set(build_cache_name(name), load_spec, app_settings.ESI_SPEC_CACHE_DURATION)
    config = dict(CONFIG_DEFAULTS, **(config or {}))
    return Spec.from_dict(spec_dict, build_spec_url(name), http_client, config)
471832
def read_reqs_file(reqs_name):
    
    path_reqs_file = os.path.join(
            "requirements", "reqs-{}.txt".format(reqs_name))
    with open(path_reqs_file, 'r') as reqs_file:
        return [pkg.rstrip() for pkg in reqs_file.readlines()
                if not pkg.startswith("#")]
1026796
def fetch_path(self, name):
        

        with codecs.open(self.lookup_path(name), encoding='utf-8') as fd:
            return fd.read()
684696
def _build_rules(specs):
    
    for spec in specs:
        if "context" in spec:
            yield Context(spec["context"], list(_build_rules(spec.get("routes", []))))
        else:
            rulespec = spec.copy()
            match = rulespec.pop("match")
            name = rulespec.pop("name")
            yield Rule(match, endpoint=name, **rulespec)
1118449
def resource_spec(opts):
    
    resources = _load(opts.resources, opts.output_dir)
    if opts.resource_name not in resources:
        sys.stderr.write('Invalid resource name: {}\n'.format(opts.resource_name))
        return 1
    print(resources[opts.resource_name].spec)
823264
def find_spec(self, fullname, path, target=None):
        
        if fullname.startswith(self.package_prefix):
            for path in self._get_paths(fullname):
                if os.path.exists(path):
                    return ModuleSpec(
                        name=fullname,
                        loader=self.loader_class(fullname, path),
                        origin=path,
                        is_package=(path.endswith('__init__.ipynb') or path.endswith('__init__.py')),
                    )
365373
def get_specs(self,data):
        
    # sort the specimen names
    #
#        print "calling get_specs()"
        speclist=[]
        for rec in data:
          spec=rec["er_specimen_name"]
          if spec not in speclist:speclist.append(spec)
        speclist.sort()
        #print speclist
        return speclist
382740
def import_file(name, path):
    
    spec = importlib.util.spec_from_file_location(name, path)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)
    return mod