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


Python AssetResolver.stream方法代码示例

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


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

示例1: _generate_md5

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import stream [as 别名]
def _generate_md5(spec):
    asset = AssetResolver(None).resolve(spec)
    md5 = hashlib.md5()
    with asset.stream() as stream:
        for block in iter(lambda: stream.read(4096), b''):
            md5.update(block)
    return md5.hexdigest()
开发者ID:7924102,项目名称:pyramid,代码行数:9,代码来源:static.py

示例2: _load_manifest

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import stream [as 别名]
    def _load_manifest(self):
        manifest = getattr(self, "_manifest", None)

        if manifest is None:
            manifest = AssetResolver().resolve(self.manifest_asset)
            with manifest.stream() as fp:
                manifest = json.loads(fp.read().decode("utf8"))

            if self.cache:
                self._manifest = manifest

        return manifest
开发者ID:IanLee1521,项目名称:warehouse,代码行数:14,代码来源:static.py

示例3: load_schema

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import stream [as 别名]
def load_schema(filename):
    if isinstance(filename, dict):
        schema = filename
        resolver = NoRemoteResolver.from_schema(schema)
    else:
        utf8 = codecs.getreader("utf-8")
        asset = AssetResolver(caller_package()).resolve(filename)
        schema = json.load(utf8(asset.stream()),
                           object_pairs_hook=collections.OrderedDict)
        resolver = RefResolver('file://' + asset.abspath(), schema)
    schema = mixinProperties(schema, resolver)

    # SchemaValidator is not thread safe for now
    SchemaValidator(schema, resolver=resolver, serialize=True)
    return schema
开发者ID:Kapeel,项目名称:encoded,代码行数:17,代码来源:schema_utils.py

示例4: load_schema

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import stream [as 别名]
def load_schema(filename):
    if isinstance(filename, dict):
        schema = filename
        resolver = NoRemoteResolver.from_schema(schema)
    else:
        utf8 = codecs.getreader("utf-8")
        asset = AssetResolver(caller_package()).resolve(filename)
        schema = json.load(utf8(asset.stream()),
                           object_pairs_hook=collections.OrderedDict)
        resolver = RefResolverOrdered('file://' + asset.abspath(), schema)
    # use mixinProperties, mixinFacets, mixinAggregations, and mixinColumns (if provided)
    schema = mixinSchemas(
        mixinSchemas(
            mixinSchemas( mixinSchemas(schema, resolver, 'properties'), resolver, 'facets' ),
            resolver,
            'aggregations'
        ),
        resolver, 'columns'
    )

    # SchemaValidator is not thread safe for now
    SchemaValidator(schema, resolver=resolver, serialize=True)
    return schema
开发者ID:j1z0,项目名称:snovault,代码行数:25,代码来源:schema_utils.py

示例5: json_asset

# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import stream [as 别名]
def json_asset(spec, **kw):
    utf8 = codecs.getreader("utf-8")
    asset = AssetResolver(caller_package()).resolve(spec)
    return json.load(utf8(asset.stream()), **kw)
开发者ID:lelou6666,项目名称:clincoded,代码行数:6,代码来源:__init__.py


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