本文整理汇总了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()
示例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
示例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
示例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
示例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)