Load a .pyc file from a file-like object.

    Arguments:
        fp(file): The file-like object to read.

    Returns:
        PycFile: The parsed representation of the .pyc file.
426570
def pyc_load(fp):
    

    magic_1 = U16(fp.read(2), target=MARSHAL_TARGET)
    magic_2 = U16(fp.read(2), target=MARSHAL_TARGET)

    internals = MAGIC_MAP.get(magic_1)
    if internals is None:
        raise ValueError('Invalid or unknown magic (%d).' % magic_1)

    if magic_2 != 2573:
        raise ValueError('Invalid secondary magic (%d).' % magic_2)

    timestamp = datetime.datetime.fromtimestamp(U32(fp.read(4), target=MARSHAL_TARGET))

    if internals['version'] >= 33:
        file_size = U32(fp.read(4))
    else:
        file_size = None

    code_object = marshal_load(fp, internals)

    return PycFile(magic_1, internals, timestamp, file_size, code_object)
1373542
def load(self, filename="temp.pkl"):
    
    inputFile = open(filename, 'rb')
    self.tm = cPickle.load(inputFile)
512191
def load(self, fn_):
        '''
        
        '''
        data = fn_.read()
        fn_.close()
        if data:
            if six.PY3:
                return self.loads(data, encoding='utf-8')
            else:
                return self.loads(data)
526045
def parse_file(self, f):
        

        if type(f) is str:
            self.f = open(f, 'rb')
        else:
            self.f = f
        self._parse_header(self.f.read(64))
298532
def open_file(self, fname, external=False):
        
        fname = to_text_string(fname)
        ext = osp.splitext(fname)[1]
        if encoding.is_text_file(fname):
            self.editor.load(fname)
        elif self.variableexplorer is not None and ext in IMPORT_EXT:
            self.variableexplorer.import_data(fname)
        elif not external:
            fname = file_uri(fname)
            programs.start_file(fname)
1051028
def load(self, relpath, rsc=None, mode='r', useFilepath=None):
        
        filepath = self.find(relpath, rsc, useFilepath=useFilepath)
        
        # parse a resource object
        if filepath.startswith(':'):
            return QtCore.QFile(filepath)
        
        # parse a filepath
        elif os.path.isfile(filepath):
            return open(filepath, mode)
        
        # return an unknown object
        else:
            return None
19594
def read_from_file(file_name):
    
    from .docxfile import DOCXFile

    dfile = DOCXFile(file_name)
    dfile.parse()

    return dfile
909726
def load_from_file(self, fname):
        
        with open(fname, 'r') as f:
            for line in f:
                k,v = line.split(' = ')
                self._parse_char_line_to_self(k,v)
1365636
def load(self):
        
        if VERBOSE_PREF:
            print('[pref.load()]')
            #if not os.path.exists(self._intern.fpath):
            #    msg = '[pref] fpath=%r does not exist' % (self._intern.fpath)
            #    return msg
        fpath = self.get_fpath()
        try:
            with open(fpath, 'rb') as f:
                if VERBOSE_PREF:
                    print('load: %r' % fpath)
                pref_dict = pickle.load(f)
        except EOFError as ex1:
            util_dbg.printex(ex1, 'did not load pref fpath=%r correctly' % fpath, iswarning=True)
            #warnings.warn(msg)
            raise
            #return msg
        except ImportError as ex2:
            util_dbg.printex(ex2, 'did not load pref fpath=%r correctly' % fpath, iswarning=True)
            #warnings.warn(msg)
            raise
            #return msg
        if not util_type.is_dict(pref_dict):
            raise Exception('Preference file is corrupted')
        self.add_dict(pref_dict)
        return True
628471
def read(self):
        # type: () -> Optional[str]
        
        with open(self.version_file) as fp:
            content = fp.read()
            m = RE_PY_VERSION.search(content)
            if not m:
                return None
            else:
                return m.group('version')
12596
def load_cache(dpath, fname, cfgstr, ext='.cPkl', verbose=None, enabled=True):
    
    if verbose is None:
        verbose = VERBOSE_CACHE
    if not USE_CACHE or not enabled:
        if verbose > 1:
            print('[util_cache] ... cache disabled: dpath=%s cfgstr=%r' %
                    (basename(dpath), cfgstr,))
        raise IOError(3, 'Cache Loading Is Disabled')
    fpath = _args2_fpath(dpath, fname, cfgstr, ext)
    if not exists(fpath):
        if verbose > 0:
            print('[util_cache] ... cache does not exist: dpath=%r fname=%r cfgstr=%r' % (
                basename(dpath), fname, cfgstr,))
        raise IOError(2, 'No such file or directory: %r' % (fpath,))
    else:
        if verbose > 2:
            print('[util_cache] ... cache exists: dpath=%r fname=%r cfgstr=%r' % (
                basename(dpath), fname, cfgstr,))
        import utool as ut
        nbytes = ut.get_file_nBytes(fpath)
        big_verbose = (nbytes > 1E6 and verbose > 2) or verbose > 2
        if big_verbose:
            print('[util_cache] About to read file of size %s' % (ut.byte_str2(nbytes),))
    try:
        with ut.Timer(fpath, verbose=big_verbose and verbose > 3):
            data = util_io.load_data(fpath, verbose=verbose > 2)
    except (EOFError, IOError, ImportError) as ex:
        print('CORRUPTED? fpath = %s' % (fpath,))
        if verbose > 1:
            print('[util_cache] ... cache miss dpath=%s cfgstr=%r' % (
                basename(dpath), cfgstr,))
        raise IOError(str(ex))
    except Exception:
        print('CORRUPTED? fpath = %s' % (fpath,))
        raise
    else:
        if verbose > 2:
            print('[util_cache] ... cache hit')
    return data
602612
def open(cls, fp):
        
        if hasattr(fp, 'read'):
            self = cls(PSD.read(fp))
        else:
            with open(fp, 'rb') as f:
                self = cls(PSD.read(f))
        return self
50335
def from_file(cls, fn, *args, **kwargs):
        
        return AmiraHeader(get_parsed_data(fn, *args, **kwargs))
271258
def load_file(self, filename):
        
        self._say("Loading file: " + filename)

        fh    = codecs.open(filename, 'r', 'utf-8')
        lines = fh.readlines()
        fh.close()

        self._say("Parsing " + str(len(lines)) + " lines of code from " + filename)
        self._parse(filename, lines)
291405
def load_from_file(filepath):
        
        class_inst = None
        expected_class = "Py3status"
        module_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
        if file_ext.lower() == ".py":
            py_mod = imp.load_source(module_name, filepath)
            if hasattr(py_mod, expected_class):
                class_inst = py_mod.Py3status()
        return class_inst
488461
def pyc_to_py(path_to_file):
    
    stem, ext = os.path.splitext(path_to_file)
    if ext == '.pyc':
        return '%s.py' % stem
    return path_to_file
498019
def from_path_or_file_like(cls, movie_file, mime_type):
        
        if is_string(movie_file):
            # treat movie_file as a path
            with open(movie_file, 'rb') as f:
                blob = f.read()
            filename = os.path.basename(movie_file)
        else:
            # assume movie_file is a file-like object
            blob = movie_file.read()
            filename = None

        return cls.from_blob(blob, mime_type, filename)