本文整理汇总了Python中manifest.Manifest.load方法的典型用法代码示例。如果您正苦于以下问题:Python Manifest.load方法的具体用法?Python Manifest.load怎么用?Python Manifest.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类manifest.Manifest
的用法示例。
在下文中一共展示了Manifest.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_main
# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import load [as 别名]
def show_main():
doc = '''Usage: oxt-pkg-show [options] <package-path>
--help Print this screen.
'''
from docopt import docopt
args = docopt(doc)
logging.basicConfig(level=logging.INFO)
package_path = args['<package-path>']
with open_storage(package_path) as pkg:
with resolve_path(pkg, MANIFEST_PATH).open() as f:
manifest = Manifest()
manifest.load(f)
with resolve_path(pkg, DESCRIPTION_PATH).open() as f:
description = Description.parse(f)
from description import print_human_readable
print_human_readable(description, pkg)
for path in manifest:
item = manifest[path]
print path, item['media-type'],
node = resolve_path(pkg, path)
if node:
print '-- OK'
else:
print '-- MISSING'
示例2: build_from
# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import load [as 别名]
def build_from(package_path,
src_folder,
manifest_path=None,
description_path=None,
files=[],
excludes=[],
storage_factory=ZipFileStorage):
if manifest_path:
with file(manifest_path) as f:
manifest = Manifest()
manifest.load(f)
else:
node = resolve_path(src_folder, MANIFEST_PATH)
if node:
with node.open() as f:
manifest = Manifest()
manifest.load(f)
else:
logger.error('%s: not found' % MANIFEST_PATH)
raise IOError('%s: not found' % MANIFEST_PATH)
if description_path:
with file(description_path) as f:
description = Description.parse(f)
else:
node = resolve_path(src_folder, DESCRIPTION_PATH)
if node:
with node.open() as f:
description = Description.parse(f)
else:
raise IOError('%s: not found' % DESCRIPTION_PATH)
package_path = make_output_path(package_path, description)
package_files = dict()
from itertools import chain
required_files = chain(manifest, description.required_files())
for path in required_files:
node = resolve_path(src_folder, path)
if node is None:
raise IOError('%s: not found' % path)
package_files[path] = node
files = ((path, resolve_path(src_folder, path)) for path in files)
files = expand_folders(files)
files = exclude_files(excludes, files)
package_files.update(files)
return build(package_path, manifest, description, package_files,
storage_factory=storage_factory)
示例3: check_main
# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import load [as 别名]
def check_main():
doc = '''Usage: oxt-pkg-show [options] <package-path>
--help Print this screen.
'''
from docopt import docopt
args = docopt(doc)
logging.basicConfig(level=logging.INFO)
package_path = args['<package-path>']
with open_storage(package_path) as pkg:
with resolve_path(pkg, MANIFEST_PATH).open() as f:
manifest = Manifest()
manifest.load(f)
with resolve_path(pkg, DESCRIPTION_PATH).open() as f:
description = Description.parse(f)
missing = dict()
for path in manifest:
node = resolve_path(pkg, path)
if node is None:
missing[path] = MANIFEST_PATH
for path in description.required_files():
node = resolve_path(pkg, path)
if node is None:
missing[path] = DESCRIPTION_PATH
if missing:
for path in sorted(missing):
referer = missing[path]
logger.error('%s: MISSING (refered in %s)',
path, referer)
raise SystemExit(1)
else:
logger.info('%s: OK, identifier=%s, version=%s', package_path,
description.identifier, description.version)
示例4: get_manifest
# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import load [as 别名]
def get_manifest(self):
manifest = Manifest()
manifest.load(self.read('manifest'))
return manifest