Import a file that will trigger the population of Orca.

    Parameters
    ----------
    filename : str
496144
def import_file(filename):
    
    pathname, filename = os.path.split(filename)
    modname = re.match(
        r'(?P<modname>\w+)\.py', filename).group('modname')
    file, path, desc = imp.find_module(modname, [pathname])

    try:
        imp.load_module(modname, file, path, desc)
    finally:
        file.close()
769812
def from_file(self, filename):
        
        with gzip.open(filename, 'rb') as f:
            self.parse(f.read())
64918
def parseFile(self, filename):
        """"""
        modname = self.filenameToModname(filename)
        module = Module(modname, filename)
        self.modules[modname] = module
        if self.trackUnusedNames:
            module.imported_names, module.unused_names = \
                find_imports_and_track_names(filename,
                                             self.warn_about_duplicates,
                                             self.verbose)
        else:
            module.imported_names = find_imports(filename)
            module.unused_names = None
        dir = os.path.dirname(filename)
        module.imports = set(
            [self.findModuleOfName(imp.name, imp.level, filename, dir)
             for imp in module.imported_names])
352899
def load(cls, filename, format=None):
        
        if format is None:
            # try to derive protocol from file extension
            format = format_from_extension(filename)
        with file(filename, 'rbU') as fp:
            obj = cls.load_from_file_object(fp, format)
            obj.filename = filename
            return obj
1338546
def tofile(self, filename, format = 'ascii'):
        
        if not common.is_string(filename):
            raise TypeError('argument filename must be string but got %s'%(type(filename)))
        if format not in ['ascii','binary']:
            raise TypeError('argument format must be ascii | binary')
        filename = filename.strip()
        if not filename:
            raise ValueError('filename must be non-empty string')
        if filename[-4:]!='.vtk':
            filename += '.vtk'
        f = open(filename,'wb')
        f.write(self.to_string(format))
        f.close()
60169
def load(self, filename):
        """"""
        try:
            with open(filename, 'rb') as fp:
                self.counters = cPickle.load(fp)
        except:
            logging.debug("can't load counter from file: %s", filename)
            return False
        return True
1039104
def add_file(self, filename):
        
        with (open(filename, 'rb')) as f:
            data = f.read()
        # below won't handle the same name files
        # in different paths
        fname = os.path.basename(filename)
        self.files[fname] = base64.b64encode(data)
1113511
def from_file(cls, filename, **kwargs):
        
        filename = os.path.expanduser(filename)
        if not os.path.isfile(filename):
            raise exceptions.PyKubeError("Configuration file {} not found".format(filename))
        with open(filename) as f:
            doc = yaml.safe_load(f.read())
        self = cls(doc, **kwargs)
        self.filename = filename
        return self
190877
def load_migration_file(self, filename):
        """"""
        path = os.path.join(self.directory, filename)
        # spec = spec_from_file_location("migration", path)
        # module = module_from_spec(spec)
        # spec.loader.exec_module(module)
        module = imp.load_source("migration", path)
        return module
1223705
def load(self, filename):
        
        self.filename = filename
        with open(filename) as CFG:
            self.data = yaml.load(CFG.read())

        return self
596519
def new_from_file(self, filename: str, header_data: Optional[Header] = None,
                      mask_data: Optional[np.ndarray] = None):
        """"""
1058470
private void importSingleFile(String file, String toplevelCorpusName,
    long corpusRef)
  {

    BinaryImportHelper preStat = new BinaryImportHelper(file, getRealDataDir(),
      toplevelCorpusName,
      corpusRef, mimeTypeMapping);
    getJdbcTemplate().execute(BinaryImportHelper.SQL, preStat);

  }
965291
def load(cls, filename, schema_only=False):
        
        o = open(filename)
        s = o.read()
        a = cls.parse(s, schema_only=schema_only)
        if not schema_only:
            a._filename = filename
        o.close()
        return a
392275
def filename_to_module(filename):
    
    find = re.compile(r"^[^.|-]*")
    name = re.search(find, filename).group(0)
    return name
141096
def load(self, filename):
        """"""
        if filename[-6:] != ".lcopt":
            filename += ".lcopt"
        try:
            savedInstance = pickle.load(open("{}".format(filename), "rb"))
        except FileNotFoundError:
            savedInstance = pickle.load(open(fix_mac_path_escapes(os.path.join(storage.model_dir, "{}".format(filename))), "rb"))
        
        attributes = ['name',
                      'database',
                      'params',
                      'production_params',
                      'allocation_params',
                      'ext_params',
                      'matrix',
                      'names',
                      'parameter_sets',
                      'model_matrices',
                      'technosphere_matrices',
                      'leontif_matrices',
                      'external_databases',
                      'parameter_map',
                      'sandbox_positions',
                      'ecoinventName',
                      'biosphereName',
                      'forwastName',
                      'analysis_settings',
                      'technosphere_databases',
                      'biosphere_databases',
                      'result_set',
                      'evaluated_parameter_sets',
                      'useForwast',
                      'base_project_name',
                      'save_option',
                      'allow_allocation',
                      'ecoinvent_version',
                      'ecoinvent_system_model',
                      ]

        for attr in attributes:

            if hasattr(savedInstance, attr):
                setattr(self, attr, getattr(savedInstance, attr))
            else:
                pass
                #print ("can't set {}".format(attr))

        # use legacy save option if this is missing from the model
        if not hasattr(savedInstance, 'save_option'):
            setattr(self, 'save_option', LEGACY_SAVE_OPTION)

        # figure out ecoinvent version and system model if these are missing from the model
        if not hasattr(savedInstance, 'ecoinvent_version') or not hasattr(savedInstance, 'ecoinvent_system_model'):
            
            parts = savedInstance.ecoinventName.split("_")
            main_version = parts[0][-1]
            sub_version = parts[1]
            system_model = parts[2]

            #print(parts)

            setattr(self, 'ecoinvent_version', '{}.{}'.format(main_version, sub_version))
            setattr(self, 'ecoinvent_system_model', system_model)
979488
def insert(self, filename):
        
        errors = []
        if os.path.isfile(filename):
            log.info('loading IOC from: {}'.format(filename))
            try:
                self.parse(ioc_api.IOC(filename))
            except ioc_api.IOCParseError:
                log.exception('Parse Error')
                errors.append(filename)
        elif os.path.isdir(filename):
            log.info('loading IOCs from: {}'.format(filename))
            for fn in glob.glob(filename + os.path.sep + '*.ioc'):
                if not os.path.isfile(fn):
                    continue
                else:
                    try:
                        self.parse(ioc_api.IOC(fn))
                    except ioc_api.IOCParseError:
                        log.exception('Parse Error')
                        errors.append(fn)
        else:
            pass
        log.info('Parsed [{}] IOCs'.format(len(self)))
        return errors
559137
def do_file(self, filename):
        
        with open(filename, "r") as infile:
            self._run_cmd(infile.read())