:param f: file object with spec data

    spec file is a yaml document that specifies which modules
    can be loaded.

    modules - list of base modules that can be loaded
    pths    - list of .pth files to load
505638
def open_spec(f):
    
    import ruamel.yaml as yaml

    keys = ['modules', 'pths', 'test_import', 'install_hints', 'extra_paths']
    data = yaml.safe_load(f)
    parsed = dict()
    ## pattern = re.compile("^\s+|\s*,\s*|\s+$")
    for k in keys:
        v = data.get(k, [])
        # Items are always lists
        if isinstance(v, basestring):
            parsed[k] = [m for m in re.split(r",| ", v)]
            # parsed[k] = re.split(pattern, v)
        else:
            parsed[k] = v

    return parsed
740649
def _load_file(self, f):
        """"""
        try:
            with open(f, 'r') as _fo:
                _seria_in = seria.load(_fo)
                _y = _seria_in.dump('yaml')
        except IOError:
            raise FiggypyError("could not open configuration file")
        self.values.update(yaml.load(_y))
202779
def requirements(fname):
        
        packages = Setup.read(fname, fail_silently=True).split('\n')
        packages = (p.strip() for p in packages)
        packages = (p for p in packages if p and not p.startswith('#'))
        return list(packages)
873906
def describe_file_set(modules):
    
    descriptor = FileSet()
    file_descriptors = []
    for module in modules:
        file_descriptors.append(describe_file(module))

    if file_descriptors:
        descriptor.files = file_descriptors

    return descriptor
1178004
def _check_file(self, f):
        ''''''
        L.info('File: %s', f)

        full_result = True
        full_summary = OrderedDict()
        try:
            data = load_data(f)
        except Exception as e:  # pylint: disable=W0703
            L.error('Failed to load data... skipping tests for this file')
            L.error(e.args)
            return False, {f: OrderedDict([('ALL', False)])}

        try:
            result, summary = self._check_loop(data, 'structural_checks')
            full_result &= result
            full_summary.update(summary)

            nrn = fst_core.FstNeuron(data)
            result, summary = self._check_loop(nrn, 'neuron_checks')
            full_result &= result
            full_summary.update(summary)
        except Exception as e:  # pylint: disable=W0703
            L.error('Check failed: %s', str(type(e)) + str(e.args))
            full_result = False

        full_summary['ALL'] = full_result

        for m, s in full_summary.items():
            self._log_msg(m, s)

        return full_result, {f: full_summary}
597728
def _spec_from_modpath(modpath, path=None, context=None):
    
    assert modpath
    location = None
    if context is not None:
        try:
            found_spec = spec.find_spec(modpath, [context])
            location = found_spec.location
        except ImportError:
            found_spec = spec.find_spec(modpath, path)
            location = found_spec.location
    else:
        found_spec = spec.find_spec(modpath, path)
    if found_spec.type == spec.ModuleType.PY_COMPILED:
        try:
            location = get_source_file(found_spec.location)
            return found_spec._replace(
                location=location, type=spec.ModuleType.PY_SOURCE
            )
        except NoSourceFile:
            return found_spec._replace(location=location)
    elif found_spec.type == spec.ModuleType.C_BUILTIN:
        # integrated builtin module
        return found_spec._replace(location=None)
    elif found_spec.type == spec.ModuleType.PKG_DIRECTORY:
        location = _has_init(found_spec.location)
        return found_spec._replace(location=location, type=spec.ModuleType.PY_SOURCE)
    return found_spec
721376
def specification(cls, *context_specs):
		
		import_data = []
		for name in context_specs:
			import_data.append((name, None))
		return cls.import_context(import_data)
939815
def parse_model_table_file(path, f):
    

    for line in f:
        line, _, comment = line.partition('#')
        line = line.strip()
        if line == '':
            continue

        yield line
974755
def validate_model_specification_file(file_path: str) -> str:
    """"""
    if not os.path.isfile(file_path):
        raise ConfigurationError('If you provide a model specification file, it must be a file. '
                                 f'You provided {file_path}')

    extension = file_path.split('.')[-1]
    if extension not in ['yaml', 'yml']:
        raise ConfigurationError(f'Model specification files must be in a yaml format. You provided {extension}')
    # Attempt to load
    yaml.full_load(file_path)
    return file_path
411633
def depsOf_of_mirteFile_module_definition(defs):
    
    return lambda x: (list(filter(lambda z: z is not None and z in defs,
                             map(lambda y: y[1].get('type'),
                                 six.iteritems(defs[x]['settings'])
                                 if 'settings' in defs[x] else [])))) + \
        (list(defs[x]['inherits']) if 'inherits' in defs[x] else [])
326413
def evaluate(module_name: str, fname: str, verbose: bool):
    
    if verbose:
        print("Testing {}".format(fname))
    spec = importlib.util.spec_from_file_location(module_name, fname)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)
308571
def parse_requirements(filename):
    

    try:
        with open(filename) as fh_req:
            return [line.strip() for line in fh_req if line.strip() and not line.startswith('#')]
    except FileNotFoundError:
        print('File not found: {}'.format(realpath(filename)), file=stderr)
        raise
675056
def load_yaml_file(file_type, file_name)
      YAML.load_file file_name
    rescue StandardError => error
      @logger.error "Cannot load #{file_type}: #{file_name}"
      raise error
    end
1001176
def get_ft_names(mod, include_inner=False)->List[str]:
    ""
    # If the module has an attribute __all__, it picks those.
    # Otherwise, it returns all the functions defined inside a module.
    fn_names = []
    for elt_name in get_exports(mod):
        elt = getattr(mod,elt_name)
        #This removes the files imported from elsewhere
        try:    fname = inspect.getfile(elt)
        except: continue
        if mod.__file__.endswith('__init__.py'):
            if inspect.ismodule(elt): fn_names.append(elt_name)
            else: continue
        else:
            if (fname != mod.__file__): continue
            if inspect.isclass(elt) or inspect.isfunction(elt): fn_names.append(elt_name)
            else: continue
        if include_inner and inspect.isclass(elt) and not is_enum(elt.__class__):
            fn_names.extend(get_inner_fts(elt))
    return fn_names
514802
def from_yaml_file(f):
    
    return from_json(to_json(yaml.load(f, Loader=yaml.Loader)))
1182424
def core__read_yaml(file_path)
      # return nil if file not exist
      return unless File.exist?(file_path)
      config_file = File.read(file_path)
      # return yaml data
      return YAML.safe_load(config_file).with_indifferent_access
    rescue
      nil
    end
960805
def parse(file_path):
    ''''''

    _, ext = path.splitext(file_path)

    if ext in ('.yaml', '.yml'):
        func = yaml.load

    elif ext == '.json':
        func = json.load

    else:
        raise ValueError("Unrecognized config file type %s" % ext)

    with open(file_path, 'r') as f:
        return func(f)