\
    Returns the cable's header as text.
    
    `file_content`
        The HTML file content, c.f. `get_file_content`.
183458
def get_header_as_text(file_content, reference_id):
    
    res = _CONTENT_PATTERN.findall(file_content)
    if len(res) == 2:
        content = res[0]
    elif len(res) == 1:
        return ''
    else:
        raise ValueError('Unexpected <code><pre> sections: "%r"' % res)
    return _clean_html(content)
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
220104
def generate_text_files(in_dir, out_dir, include_header=False):
    
    for cable in cables_from_source(in_dir):
        out = codecs.open(out_dir + '/' + cable.reference_id + '.txt', 'wb', encoding='utf-8')
        out.write(cable_to_text(cable, include_header))
        out.close()
651641
def header(self, content):
        
        header = Element("Header", ns=envns)
        header.append(content)
        return header
122657
def cable_from_file(filename):
    
    html = codecs.open(filename, 'rb', 'utf-8').read()
    return cable_from_html(html, reader.reference_id_from_filename(filename))
505178
def as_txt(self):
        
        s = "IIIF Image Server Error\n\n"
        s += self.text if (self.text) else 'UNKNOWN_ERROR'
        s += "\n\n"
        if (self.parameter):
            s += "parameter=%s\n" % self.parameter
        if (self.code):
            s += "code=%d\n\n" % self.code
        for header in sorted(self.headers):
            s += "header %s=%s\n" % (header, self.headers[header])
        return s
647765
def get_http_header(self) -> Response:
        '''
        '''
        with wpull.util.reset_file_offset(self.block_file):
            data = self.block_file.read(4096)

        match = re.match(br'(.*?\r?\n\r?\n)', data)

        if not match:
            return

        status_line, dummy, field_str = match.group(1).partition(b'\n')

        try:
            version, code, reason = Response.parse_status_line(status_line)
        except ValueError:
            return

        response = Response(status_code=code, reason=reason, version=version)

        try:
            response.fields.parse(field_str, strict=False)
        except ValueError:
            return

        return response
639000
def contents(self):
        
        if not hasattr(self, "_content"):
            self._content = self.get_content()
        return self._content
940283
def _get_file_content(source):
    
    filepath = os.path.join('siglists', source + '.txt')

    lines = []
    with resource_stream(__name__, filepath) as f:
        for i, line in enumerate(f):
            line = line.decode('utf-8', 'strict').strip()
            if not line or line.startswith('#'):
                continue

            try:
                re.compile(line)
            except Exception as ex:
                raise BadRegularExpressionLineError(
                    'Regex error: {} in file {} at line {}'.format(
                        str(ex),
                        filepath,
                        i
                    )
                )

            lines.append(line)

    if source in _SPECIAL_EXTENDED_VALUES:
        lines = lines + _SPECIAL_EXTENDED_VALUES[source]

    return tuple(lines)
135318
def _get_file_content(self, path):
        """"""
        with open(path, 'r') as file_:
            content = file_.read()
        return content
1267391
def extract_content(image_path, member_name, return_hash=False):
    '''
    '''
    if member_name.startswith('./'):
        member_name = member_name.replace('.','',1)
    if return_hash:
        hashy = hashlib.md5()

    try:
        content = Client.execute(image_path,'cat %s' %(member_name))
    except:
        return None

    if not isinstance(content,bytes):
        content = content.encode('utf-8')
        content = bytes(content)

    # If permissions don't allow read, return None
    if len(content) == 0:
        return None
    if return_hash:
        hashy.update(content)
        return hashy.hexdigest()
    return content
524532
def html_footer():
    
    file_path = resources_path('footer.html')
    with open(file_path) as header_file:
        content = header_file.read()
    return content
116099
def _get_header(self):
        """"""
        fh = self._src
        obj = _make_object("Header")

        # first part of the header
        obj.Signature = sign = "".join(chr(unpack_ui8(fh)) for _ in range(3))
        obj.Version = self._version = unpack_ui8(fh)
        obj.FileLength = file_length = unpack_ui32(fh)

        # deal with compressed content
        if sign[0] == 'C':
            uncompressed = zlib.decompress(fh.read())
            if len(uncompressed) + 8 != file_length:
                raise ValueError("Problems dealing with compressed content")
            fh = self._src = io.BytesIO(uncompressed)

        # second part of the header
        obj.FrameSize = self._get_struct_rect()
        obj.FrameRate = unpack_ui16(fh)
        obj.FrameCount = unpack_ui16(fh)
        return obj
202584
public String getContent() {

        if ((m_content.length() == 0) && (getFile() != null)) {
            m_content = new String(getFile().getContents());
        }
        return m_content;
    }
1371511
def text_result(text: str,
                extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None,
                filename: str = None) -> WSGI_TUPLE_TYPE:
    
    extraheaders = extraheaders or []
    if filename:
        extraheaders.append(
            ('content-disposition', 'inline; filename="{}"'.format(filename))
        )
    contenttype = 'text/plain; charset=utf-8'
    if filename:
        contenttype += '; filename="{}"'.format(filename)
    return contenttype, extraheaders, text.encode("utf-8")
995132
def _get_text(self):
        
        boxes = self.boxes
        txt = []
        for line in boxes:
            txt_line = u""
            for box in line.word_boxes:
                txt_line += u" " + box.content
            txt.append(txt_line)
        return txt
676271
def cable_from_html(html, reference_id=None):
    
    if not html:
        raise ValueError('The HTML page of the cable must be provided, got: "%r"' % html)
    if not reference_id:
        reference_id = reader.reference_id_from_html(html)
    cable = Cable(reference_id)
    reader.parse_meta(html, cable)
    cable.header = reader.get_header_as_text(html, reference_id)
    cable.content = reader.get_content_as_text(html, reference_id)
    return cable