Return file-like object for 'name'.
776310
def open(self, name_or_info, mode="r", pwd=None):
        """"""
        # A non-monkey-patched version would contain most of zipfile.py
        ef = super(VerifyingZipFile, self).open(name_or_info, mode, pwd)
        if isinstance(name_or_info, zipfile.ZipInfo):
            name = name_or_info.filename
        else:
            name = name_or_info

        if name in self._expected_hashes and self._expected_hashes[name] is not None:
            expected_hash = self._expected_hashes[name]
            try:
                _update_crc_orig = ef._update_crc
            except AttributeError:
                warnings.warn('Need ZipExtFile._update_crc to implement '
                              'file hash verification (in Python >= 2.7)')
                return ef
            running_hash = self._hash_algorithm()
            if hasattr(ef, '_eof'):  # py33
                def _update_crc(data):
                    _update_crc_orig(data)
                    running_hash.update(data)
                    if ef._eof and running_hash.digest() != expected_hash:
                        raise BadWheelFile("Bad hash for file %r" % ef.name)
            else:
                def _update_crc(data, eof=None):
                    _update_crc_orig(data, eof=eof)
                    running_hash.update(data)
                    if eof and running_hash.digest() != expected_hash:
                        raise BadWheelFile("Bad hash for file %r" % ef.name)
            ef._update_crc = _update_crc
        elif self.strict and name not in self._expected_hashes:
            raise BadWheelFile("No expected hash for file %r" % ef.name)
        return ef
94628
def get_template(self, name):
        """"""
        filename = path.join(self.search_path, *[p for p in name.split('/')
                                                 if p and p[0] != '.'])
        if not path.exists(filename):
            raise TemplateNotFound(name)
        return Template.from_file(filename, self.encoding)
175360
def file_contents(file_name):
    """"""
    curr_dir = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(curr_dir, file_name)) as the_file:
        contents = the_file.read()
    return contents
606500
def file_name(self, resource):
        """"""
        warnings.warn(
            "file_name is deprecated; use resource_name instead",
            DeprecationWarning, stacklevel=2)
        return self.resource_name(resource)
65232
def named(self, name):
        ''''''
        name = self.serialize(name)
        return self.get_by('name', name)
865259
def with_name(self, name):
    """"""
    with self.g.as_default(), scopes.var_and_name_scope((name, None)) as (
        name_scope, var_scope):
      return Layer(copy=self, name=self._name, scope=(name_scope, var_scope))
859635
def name(self):
        """"""
        if self._path:
            # follow h5py convention: add leading slash
            name = self._path
            if name[0] != '/':
                name = '/' + name
            return name
        return '/'
112542
def _readfname(fname):
    """"""
    try:
        if isinstance(fname, (file, StringIO)):
            astr = fname.read()
        else:
            astr = open(fname, 'rb').read()
    except NameError:
        if isinstance(fname, (FileIO, StringIO)):
            astr = fname.read()
        else:
            astr = mylib2.readfile(fname)
    return astr
580322
def get(self, name):
        """"""
        lxc_meta_path = self._service.lxc_path(name,
                constants.LXC_META_FILENAME)
        meta = LXCMeta.load_from_file(lxc_meta_path)
        lxc = self._loader.load(name, meta)
        return lxc
1019485
def read_text(self, name):
        """"""
        with self.open_readable(name) as fp:
            res = fp.read()  # StringIO or file object
            # try:
            #     res = fp.getvalue()  # StringIO returned by FtpTarget
            # except AttributeError:
            #     res = fp.read()  # file object returned by FsTarget
            res = res.decode("utf-8")
            return res
9090
def _get_name_and_version(name, version, for_filename=False):
    """"""
    if for_filename:
        # For both name and version any runs of non-alphanumeric or '.'
        # characters are replaced with a single '-'.  Additionally any
        # spaces in the version string become '.'
        name = _FILESAFE.sub('-', name)
        version = _FILESAFE.sub('-', version.replace(' ', '.'))
    return '%s-%s' % (name, version)
175659
def with_name(self, name):
        """"""
        if not self.name:
            raise ValueError("%r has an empty name" % (self,))
        return self._from_parsed_parts(self._drv, self._root,
                                       self._parts[:-1] + [name])
1072116
def _filename(self_or_cls, filename):
        ""
        if not filename.endswith(self_or_cls.file_ext):
            return '%s.%s' % (filename, self_or_cls.file_ext)
        else:
            return filename
1240397
def get_available_name(self, name, max_length=None):
        """"""
        tempdir = tempfile.mkdtemp(dir=self.base_location)
        name = os.path.join(
            os.path.basename(tempdir),
            os.path.basename(name),
        )
        method = super(TempFileSystemStorage, self).get_available_name
        return method(name, max_length=max_length)
333381
def information(filename):
    """"""
    check_if_this_file_exist(filename)
    filename = os.path.abspath(filename)
    result = get_json(filename)
    result = result[0]
    return result
594058
def get_filelikeobject(filename: str = None,
                       blob: bytes = None) -> BinaryIO:
    
    if not filename and not blob:
        raise ValueError("no filename and no blob")
    if filename and blob:
        raise ValueError("specify either filename or blob")
    if filename:
        return open(filename, 'rb')
    else:
        return io.BytesIO(blob)
171330
def str_(name):
  """"""
  if isinstance(name, bytes) and not isinstance(name, str):
    return name.decode('utf8')
  else:
    return name