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 init_main(): doc = '''Usage: oxt-pkg-init [options] <package-path> --help Print this screen. ''' from docopt import docopt args = docopt(doc) logging.basicConfig(level=logging.INFO) package_path = args['<package-path>'] manifest = Manifest() description = Description() with open_storage(package_path, 'w') as stg: with makedirs_to_file(stg, MANIFEST_PATH).open('w') as f: manifest.dump(f) with makedirs_to_file(stg, DESCRIPTION_PATH).open('w') as f: description.write(f)
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)