Make a file from a TarInfo object with an unknown type
           at targetpath.
433491
def makeunknown(self, tarinfo, targetpath):
        
        self.makefile(tarinfo, targetpath)
        self._dbg(1, "tarfile: Unknown file type %r, " \
                     "extracted as regular file." % tarinfo.type)
1109395
def _load_from_file(self, filename):
        """"""
        if filename in self.fdata:
            return self.fdata[filename]
        else:
            filepath = find_in_tarball(self.tarloc, filename)
            return read_from_tarball(self.tarloc, filepath)
15903
def FromFile(cls, in_path):
        

        with open(in_path, "rb") as infile:
            in_data = json.load(infile)

        if not ('trace', 'selectors') in in_data:
            raise ArgumentError("Invalid trace file format", keys=in_data.keys(), expected=('trace', 'selectors'))

        selectors = [DataStreamSelector.FromString(x) for x in in_data['selectors']]
        readings = [IOTileReading(x['time'], DataStream.FromString(x['stream']).encode(), x['value'], reading_id=x['reading_id']) for x in in_data['trace']]

        return SimulationTrace(readings, selectors=selectors)
930430
def _proc_gnulong(self, tarfile):
        
        buf = tarfile.fileobj.read(self._block(self.size))

        # Fetch the next header and process it.
        try:
            next = self.fromtarfile(tarfile)
        except HeaderError:
            raise SubsequentHeaderError("missing or bad subsequent header")

        # Patch the TarInfo object from the next header with
        # the longname information.
        next.offset = self.offset
        if self.type == GNUTYPE_LONGNAME:
            next.name = nts(buf, tarfile.encoding, tarfile.errors)
        elif self.type == GNUTYPE_LONGLINK:
            next.linkname = nts(buf, tarfile.encoding, tarfile.errors)

        return next
879993
def FromFile(cls, inpath):
        

        with open(inpath, "r") as infile:
            indata = infile.read()

        return cls.FromString(indata)
176536
def from_path(klass, path, header):
        
        path = str(path)
        use_bgzf = False  # we already interpret path
        if path.endswith(".gz"):
            f = bgzf.BgzfWriter(filename=path)
        else:
            f = open(path, "wt")
        return klass.from_stream(f, header, path, use_bgzf=use_bgzf)
912618
def _get_file(self, path, prepend=False):
        ''''''
        if prepend:
            path = os.path.join(self._dirname(), path)
        extracted = self._tar.extractfile(path)
        if extracted:
            return extracted
        raise DapFileError(('Could not read %s from %s, maybe it\'s a directory,' +
            'bad link or the dap file is corrupted') % (path, self.basename))
970364
def resolve_targetfile(self, args, require_sim_name=False):  # x
        """"""
        ttype = args.get('ttype')
        if is_null(ttype):
            sys.stderr.write('Target type must be specified')
            return (None, None)

        sim = args.get('sim')
        if is_null(sim):
            if require_sim_name:
                sys.stderr.write('Simulation scenario must be specified')
                return (None, None)
            else:
                sim = None

        name_keys = dict(target_type=ttype,
                         targetlist='target_list.yaml',
                         sim_name=sim,
                         fullpath=True)
        if sim is None:
            targetfile = self.targetfile(**name_keys)
        else:
            targetfile = self.sim_targetfile(**name_keys)

        targets_override = args.get('targetfile')
        if is_not_null(targets_override):
            targetfile = targets_override

        return (targetfile, sim)
1058285
def from_path(cls, path):
        """"""
        urlparts = urlparse.urlsplit(path)
        site = 'nonlocal'
        if (urlparts.scheme == '' or urlparts.scheme == 'file'):
            if os.path.isfile(urlparts.path):
                path = os.path.abspath(urlparts.path)
                path = urlparse.urljoin('file:',
                                        urllib.pathname2url(path)) 
                site = 'local'

        fil = File(os.path.basename(path))
        fil.PFN(path, site)
        return fil
1260458
def from_filepath(cls, filepath):
        ''''''
        assert(os.path.exists(filepath))
        return cls(read_file(filepath))
355417
def from_path(path):
        '''
        
        '''
        if os.path.isdir(path):
            return DirectoryInfo(path)

        if os.path.isfile(path):
            return FileInfo(path)

        return None
996117
def from_subdir(cls, container, info_obj):
        """"""
        return cls(container,
                   info_obj['subdir'],
                   obj_type=cls.type_cls.SUBDIR)
551434
def from_file(cls, file):
        """"""
        opf_xml = etree.parse(file)
        # Check if ``file`` is file-like.
        if hasattr(file, 'read'):
            name = os.path.basename(file.name)
            root = os.path.abspath(os.path.dirname(file.name))
        else:  # ...a filepath
            name = os.path.basename(file)
            root = os.path.abspath(os.path.dirname(file))
        parser = OPFParser(opf_xml)

        # Roll through the item entries
        manifest = opf_xml.xpath('/opf:package/opf:manifest/opf:item',
                                 namespaces=EPUB_OPF_NAMESPACES)
        pkg_items = []
        for item in manifest:
            absolute_filepath = os.path.join(root, item.get('href'))
            properties = item.get('properties', '').split()
            is_navigation = 'nav' in properties
            media_type = item.get('media-type')
            pkg_items.append(Item.from_file(absolute_filepath,
                                            media_type=media_type,
                                            is_navigation=is_navigation,
                                            properties=properties))
        # Ignore spine ordering, because it is not important
        #   for our use cases.
        return cls(name, pkg_items, parser.metadata)
507959
def from_file(cls, path, **kwargs):
        """"""
        lines = lines_from_file(path)
        if 'meta' not in kwargs:
            kwargs['meta'] = {'from': 'file'}
        kwargs['meta']['filepath'] = path
        return cls(lines, **kwargs)
1153505
def from_path(cls, conn, path):
        """"""
        path = path.strip(SEP)
        full_path = os.path.join(conn.abs_root, path)
        return cls(conn, path, 0, os.path.getsize(full_path))
1096995
def taropen(cls, name, mode="r", fileobj=None, **kwargs):
        
        if len(mode) > 1 or mode not in "raw":
            raise ValueError("mode must be 'r', 'a' or 'w'")
        return cls(name, mode, fileobj, **kwargs)
1177062
def from_file(cls, file_path, compressed=False, encoded=False):
        """"""
        file_id = '.'.join(path.basename(file_path).split('.')[:-1])
        file_format = file_path.split('.')[-1]
        content = cls(file_id, file_format, compressed, encoded)
        content.file_exists = True
        content._location = path.dirname(file_path)
        return content