python类add_type()的实例源码

website.py 文件源码 项目:hatch 作者: hatch-sh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _upload_artifacts(self, bucket):
        mimetypes.add_type('application/json', '.map')
        mimetypes.add_type('application/woff2', '.woff2')
        for artifact in recursive_glob(self.config.path, '*'):
            mime_type = mimetypes.guess_type(artifact)

            if mime_type is None:
                logger.error('Unknown mime type for %s', artifact)
                sys.exit(1)

            [content_type, _] = mime_type

            if content_type is None:
                logger.error('Unknown content-type for %s', artifact)
                sys.exit(1)

            logger.debug('Uploading %s [%s]', artifact, content_type)
            file_path = artifact.replace('{}/'.format(self.config.path), '')
            bucket.upload_file(artifact, file_path, ExtraArgs={
                'ACL': 'public-read',
                'CacheControl': 'public, max-age=31536000, no-cache',
                'ContentType': content_type
            })
artifacts.py 文件源码 项目:scriptworker 作者: mozilla-releng 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _force_mimetypes_to_plain_text():
    """Populate/Update the mime types database with supported extensions that we want to map to 'text/plain'.

    These extensions can then be open natively read by browsers once they're uploaded on S3. It doesn't affect artifacts
    once they're downloaded from S3.

    """
    for extension in _EXTENSIONS_TO_FORCE_TO_PLAIN_TEXT:
        mimetypes.add_type('text/plain', extension)
        log.debug('Extension "{}" forced to text/plain'.format(extension))
augment_mimetypes.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2')
augment_mimetypes.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2')
plugin.py 文件源码 项目:dati-ckan-docker 作者: italia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update_config(self, config):
        ''' Set up the resource library, public directory and
        template directory for all the spatial extensions
        '''
        p.toolkit.add_public_directory(config, 'public')
        p.toolkit.add_template_directory(config, 'templates')
        p.toolkit.add_resource('public', 'ckanext-spatial')

        # Add media types for common extensions not included in the mimetypes
        # module
        mimetypes.add_type('application/json', '.geojson')
        mimetypes.add_type('application/gml+xml', '.gml')
files.py 文件源码 项目:PeekabooAV 作者: scVENUS 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def guess_mime_type_from_filename(file_path):
    """ Guess the type of a file based on its filename or URL. """
    if not mimetypes.inited:
        mimetypes.init()
        mimetypes.add_type('application/javascript', '.jse')

    mt = mimetypes.guess_type(file_path)[0]
    if mt:
        return mt
products.py 文件源码 项目:fg21sim 作者: liweitianux 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_content_type(self):
        """
        Returns the ``Content-Type`` header to be used for this request.
        """
        # Add MIME types support used here
        mimetypes.add_type("application/fits", ".fits")
        mimetypes.add_type("text/plain", ".conf")
        return super().get_content_type()
augment_mimetypes.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2')
augment_mimetypes.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2')
augment_mimetypes.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2')


问题


面经


文章

微信
公众号

扫码关注公众号