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)
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)
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'
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'
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)
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)