当前位置: 首页>>代码示例>>Python>>正文


Python MimeTypes.add_type方法代码示例

本文整理汇总了Python中mimetypes.MimeTypes.add_type方法的典型用法代码示例。如果您正苦于以下问题:Python MimeTypes.add_type方法的具体用法?Python MimeTypes.add_type怎么用?Python MimeTypes.add_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mimetypes.MimeTypes的用法示例。


在下文中一共展示了MimeTypes.add_type方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: configure_mimetypes

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
def configure_mimetypes(extra_types):
    """
    Add additional mimetypes to a local MimeTypes instance to avoid polluting
    global registery
    """
    mimetypes = MimeTypes()
    for content_type, extension in extra_types:
        mimetypes.add_type(content_type, extension)
    return mimetypes
开发者ID:Vendetta131,项目名称:Django,代码行数:11,代码来源:base.py

示例2: make_headers

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
 def make_headers(filename):
     mime = MimeTypes()
     mime.add_type('text/plain', '.log')
     mime.add_type('text/x-yaml', '.yaml')
     content_type, encoding = mime.guess_type(filename)
     headers = {"Content-Type": "application/octet-stream"}
     if content_type:
         headers['Content-Type'] = content_type
     if encoding:
         headers['Content-Encoding'] = encoding
     return headers
开发者ID:mjs,项目名称:juju,代码行数:13,代码来源:upload_jenkins_job.py

示例3: mimes

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
    def mimes(self):
        """
        Returns extended MimeTypes.
        """
        _mimes = MimeTypes(strict=False)
        _mimes.suffix_map.update({".tbz2": ".tar.bz2"})
        _mimes.encodings_map.update({".bz2": "bzip2"})

        if cfg["CFG_BIBDOCFILE_ADDITIONAL_KNOWN_MIMETYPES"]:
            for key, value in iteritems(cfg["CFG_BIBDOCFILE_ADDITIONAL_KNOWN_MIMETYPES"]):
                _mimes.add_type(key, value)
                del key, value

        return _mimes
开发者ID:k3njiy,项目名称:invenio,代码行数:16,代码来源:mimetype.py

示例4: write

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
 def write(self, filename, contents, encoding='utf8'):
     """
     Write a file to the data store.
     """
     mime = MimeTypes()
     mime.add_type('text/x-yaml', '.yaml')
     content_type, _ = mime.guess_type(filename)
     key = self.bucket.new_key(self._path(filename))
     key.set_contents_from_string(contents.encode(encoding), {
         'Content-Type': content_type or 'text/plain',
         'Content-Encoding': encoding,
     })
     if self.public:
         key.set_canned_acl('public-read')
开发者ID:seman,项目名称:cloud-weather-report,代码行数:16,代码来源:datastore.py

示例5: exit

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
# Check that all the given paths really exist
if not os.path.exists(moduleLocation):
    print 'ERROR: given module location does not exist'
    exit()

isMissing = False
for f in filenames:
    if not os.path.exists(moduleLocation + os.sep + f):
        print 'ERROR: Cannot find %s' % f
        isMissing = True
if isMissing:
    exit()

# Initialisation of `magic` module
mime = MimeTypes()
mime.add_type('text/plain', '.bsh')
mime.add_type('text/plain', '.properties')

# Make browser
br = mechanize.Browser()

# Initialisation of `mechanize` module (Some stuff I copied from Stack Overflow)
cookiejar = cookielib.LWPCookieJar()
br.set_cookiejar      (cookiejar)
br.set_handle_gzip    (True)
br.set_handle_equiv   (True)
br.set_handle_gzip    (True)
br.set_handle_redirect(True)
br.set_handle_referer (True)
br.set_handle_robots  (False)
开发者ID:FAIMS,项目名称:csiro-crops,代码行数:32,代码来源:upload.py

示例6: QApplication

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
        
        
        
#==============================
#
#==============================
if __name__ == "__main__":


    #log.setLevel(logging.WARNING)

    log.debug("------ start imgimport-------")

    app = QApplication(sys.argv)
    mime = MimeTypes()
    mime.add_type('image/tiff','.arw')
    
    # get global settings
    SourceDir = settings.SourceDir
    #DestDir=settings.DestDir


    exif = ExifTools()
    exif.initArglist()
    
    filemgr = Filemanager()
    #filemgr.readFiles(Filelist, item_list)

    window = ImageWindow()
    window.show()
    sys.exit(app.exec_())
开发者ID:hwahlberg,项目名称:imgimport,代码行数:33,代码来源:main.py

示例7: _init_mimeutils_mime_types

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
def _init_mimeutils_mime_types():
    obj = MimeTypes()
    # this is a special case since the DOT extension is normally mapped to 'application/msword'
    obj.add_type('text/plain', '.dot', True)
    return obj
开发者ID:Justin-W,项目名称:drfunland,代码行数:7,代码来源:utils.py

示例8: parseArguments

# 需要导入模块: from mimetypes import MimeTypes [as 别名]
# 或者: from mimetypes.MimeTypes import add_type [as 别名]
            )
            proc.wait()


if __name__ == "__main__":
    parseArguments()

    checkVerbose()
    print "DestDir is " + DestDir
    print "DoRename is %r" % DoRename
    print "DoMove is %r" % DoMove

    checkCreateDate()

    mime = MimeTypes()
    mime.add_type("image/tiff", ".arw")

    fdnull = os.open("/dev/null", os.O_WRONLY)
    inodlist = []
    for f in Files:
        lista = glob.glob(SourceDir + f)

        for l in lista:
            mt = mime.guess_type(l)
            mtype = mt[0]

            if mtype in acceptedImages:
                st_ino = os.stat(l)[1]
                inodlist.append(st_ino)
                print "{}: mime={}, inode={}".format(l, mtype, st_ino)
开发者ID:hwahlberg,项目名称:binscripts,代码行数:32,代码来源:imgimport.py


注:本文中的mimetypes.MimeTypes.add_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。