Retrieve embedded file content by name or by number.
519697
def embeddedFileGet(self, id):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document_embeddedFileGet(self, id)
728891
def _GetUtf8Contents(self, file_name):
    """"""
    contents = self._FileContents(file_name)
    if not contents:  # Missing file
      return

    # Check for errors that will prevent csv.reader from working
    if len(contents) >= 2 and contents[0:2] in (codecs.BOM_UTF16_BE,
        codecs.BOM_UTF16_LE):
      self._problems.FileFormat("appears to be encoded in utf-16", (file_name, ))
      # Convert and continue, so we can find more errors
      contents = codecs.getdecoder('utf-16')(contents)[0].encode('utf-8')

    null_index = contents.find('\0')
    if null_index != -1:
      # It is easier to get some surrounding text than calculate the exact
      # row_num
      m = re.search(r'.{,20}\0.{,20}', contents, re.DOTALL)
      self._problems.FileFormat(
          "contains a null in text \"%s\" at byte %d" %
          (codecs.getencoder('string_escape')(m.group()), null_index + 1),
          (file_name, ))
      return

    # strip out any UTF-8 Byte Order Marker (otherwise it'll be
    # treated as part of the first column name, causing a mis-parse)
    contents = contents.lstrip(codecs.BOM_UTF8)
    return contents
333381
def information(filename):
    """"""
    check_if_this_file_exist(filename)
    filename = os.path.abspath(filename)
    result = get_json(filename)
    result = result[0]
    return result
830479
def _get_contents(self):
        """"""
        def files():
            for value in super(GlobBundle, self)._get_contents():
                for path in glob.glob(value):
                    yield path
        return list(files())
83679
def embeddedFileUpd(self, id, buffer=None, filename=None, ufilename=None, desc=None):
        """"""
        return _fitz.Document_embeddedFileUpd(self, id, buffer, filename, ufilename, desc)
974965
def _get_file_index_str(self):
        """"""
        file_index = str(self.file_index)
        if self.n_digits is not None:
            file_index = file_index.zfill(self.n_digits)
        return file_index
727580
def read(afile):
    """"""
    the_relative_file = os.path.join(HERE, afile)
    with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file:
        content = filter_out_test_code(opened_file)
        content = "".join(list(content))
        return content
594916
def get_content(self, offset, size):
        """"""
        return _bfd.section_get_content(self.bfd, self._ptr, offset, size)
24506
def _get_contents(self):
        """"""
        return [
            str(value) if is_lazy_string(value) else value
            for value in super(LazyNpmBundle, self)._get_contents()
        ]
338175
def read_files(*files):
    """"""
    text = ""
    for single_file in files:
        content = read(single_file)
        text = text + content + "\n"
    return text
940933
def encoded_content(self, path):
        """"""
        if path in self.__class__.asset_contents:
            return self.__class__.asset_contents[path]
        data = self.read_bytes(path)
        self.__class__.asset_contents[path] = force_text(base64.b64encode(data))
        return self.__class__.asset_contents[path]
513903
def file_attribs(location, mode=None, owner=None, group=None, sudo=False):
    """"""
    return dir_attribs(location, mode, owner, group, False, sudo)
935961
def parse_files(self, req, name, field):
        """"""
        files = ((k, v) for k, v in req.POST.items() if hasattr(v, "file"))
        return core.get_value(MultiDict(files), name, field)
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
722549
def read(fname):
    """"""
    content = None
    with open(os.path.join(here, fname)) as f:
        content = f.read()
    return content
613595
def grep(filename, tag, firstOccurrence=False):
    """"""
    import re

    try:
        afile = open(filename, "r")
    except:
        print("Error in utils.grep(): cannot open file", filename)
        exit()
    content = None
    for line in afile:
        if re.search(tag, line):
            content = line.split()
            if firstOccurrence:
                break
    if content:
        if len(content) == 2:
            content = content[1]
        else:
            content = content[1:]
    afile.close()
    return content
687276
def readfile(filename):
    
    with open(path_expand(filename), 'r') as f:
        content = f.read()
    return content