Return content types XML mapping each part in *parts* to the
        appropriate content type and suitable for storage as
        ``[Content_Types].xml`` in an OPC package.
971908
def from_parts(cls, parts):
        
        cti = cls()
        cti._defaults['rels'] = CT.OPC_RELATIONSHIPS
        cti._defaults['xml'] = CT.XML
        for part in parts:
            cti._add_content_type(part.partname, part.content_type)
        return cti
346991
def xml(self):
        
        try:
            from lxml import etree
            return etree.fromstring(self.content)
        except ImportError as ie:
            raise DependencyException(ie)
133186
public static Map<String,Object> toMetaDatas(String contentType, String fileName){
        Map<String,Object> metadatas = new HashMap<String, Object>();
        putMetaDatas(metadatas, contentType, fileName);
        return metadatas;
    }
1294790
def toxml(self):
        

        return '<ComponentReference name="{0}" type="{1}"'.format(self.name, self.type) + \
          (' local = "{0}"'.format(self.local) if self.local else '') + \
            '/>'
917221
def guess_content_type_and_encoding(path):
    
    for ext, content_type in _EXTENSION_TO_MIME_TYPE.items():
        if path.endswith(ext):
            return content_type

    content_type, encoding = mimetypes.guess_type(path)
    content_type = content_type or "application/binary"
    return content_type, encoding
1030468
public Part<T> contentType(String contentType) {
        requireNonNull(contentType);
        return new Part<>(name, fileName, body, contentType, charset, partWriter);
    }
670479
def parse_content_type(header):
    """"""
    typ = subtyp = None; options = {}
    typ, pos = expect_re(re_token, header, 0)
    _, pos = expect_lit('/', header, pos)
    subtyp, pos = expect_re(re_token, header, pos)
    ctype = header[:pos] if subtyp else ''
    while pos < len(header):
        _, pos = accept_ws(header, pos)
        _, pos = expect_lit(';', header, pos)
        _, pos = accept_ws(header, pos)
        name, pos = expect_re(re_token, header, pos)
        _, pos = expect_lit('=', header, pos)
        char = lookahead(header, pos)
        if char == '"':
            value, pos = expect_re(re_qstring, header, pos)
            value = re_qpair.sub('\\1', value)
        elif char:
            value, pos = expect_re(re_token, header, pos)
        if name and value is not None:
            options[name] = value
    return ctype, options
1038802
def parse_opml_bytes(data: bytes) -> OPML:
    """"""
    root = parse_xml(BytesIO(data)).getroot()
    return _parse_opml(root)
365987
def toxml(self):
        

        xmlstr = '<Component id="{0}" type="{1}"'.format(self.id, self.type)

        for (k, v) in self.parameters.items():
            xmlstr += ' {0}="{1}"'.format(k, v)

        if self.children:
            xmlstr += '>'
            for child in self.children:
                xmlstr += child.toxml()
            xmlstr += '</Component>'
        else:
            xmlstr += '/>'

        return xmlstr
69403
def content_children(self):
        
        text_types = {CT_RegularTextRun, CT_TextLineBreak, CT_TextField}
        return tuple(elm for elm in self if type(elm) in text_types)
1182044
def default(cls, package):
        
        partname = PackURI('/word/styles.xml')
        content_type = CT.WML_STYLES
        element = parse_xml(cls._default_styles_xml())
        return cls(partname, content_type, element, package)
509392
def load(cls, partname, content_type, blob, package):
        
        return cls(partname, content_type, blob)
516718
def get_content_type(name, content):
    
    if hasattr(content, "content_type"):
        content_type = content.content_type
    else:
        mime_type, encoding = mimetypes.guess_type(name)
        content_type = mime_type
    return content_type
44200
def get_content_type(*names):
    """"""
    for name in names:
        if name is not None:
            mimetype, encoding = mimetypes.guess_type(name)
            if mimetype is not None:
                if isinstance(mimetype, bytes):
                    return mimetype.decode("ascii")
                else:
                    return mimetype
    else:
        return "application/octet-stream"
774784
def _new_theme_part(cls, package):
        
        partname = package.next_partname('/ppt/theme/theme%d.xml')
        content_type = CT.OFC_THEME
        theme = CT_OfficeStyleSheet.new_default()
        return XmlPart(partname, content_type, theme, package)
142939
def from_xml(content_types_xml):
        
        types_elm = parse_xml(content_types_xml)
        ct_map = _ContentTypeMap()
        for o in types_elm.override_lst:
            ct_map._add_override(o.partName, o.contentType)
        for d in types_elm.default_lst:
            ct_map._add_default(d.extension, d.contentType)
        return ct_map
1235938
def _load_serialized_parts(phys_reader, pkg_srels, content_types):
        
        sparts = []
        part_walker = PackageReader._walk_phys_parts(phys_reader, pkg_srels)
        for partname, blob, srels in part_walker:
            content_type = content_types[partname]
            spart = _SerializedPart(partname, content_type, blob, srels)
            sparts.append(spart)
        return tuple(sparts)