Example #1
0
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'
Example #2
0
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'
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
def print_human_readable(desc, root_stg=None):
    ''' Print summary in human readable form.

    :param desc: an instance of Description
    :param root_stg: root storage of description.xml
    '''
    from storage import resolve_path
    print 'identifier:', desc.identifier
    print 'version:', desc.version
    print 'platform:', desc.platform

    print 'display-name:'
    for lang, name in desc.display_name.items():
        print '  [%s] %s' % (lang, name)

    print 'extension-description:'
    for lang, url in desc.description.items():
        if not root_stg or resolve_path(root_stg, url):
            state = ''
        else:
            state = ' -- MISSING'
        print '  [%s] %s%s' % (lang, url, state)

    print 'publisher:'
    for lang, publisher in desc.publisher.items():
        print '  [%s] %s (%s)' % (lang,
                                       publisher['name'],
                                       publisher['url'])
    if desc.license:
        print 'license: accept-by', desc.license_accept_by
        for lang, url in desc.license.items():
            if not root_stg or resolve_path(root_stg, url):
                state = ''
            else:
                state = ' -- MISSING'
            print '  [%s] %s%s' % (lang, url, state)

    if desc.oo_min_version:
        print 'dependencies:'
        print '  LibreOffice minimal version:', desc.oo_min_version
Example #7
0
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)
Example #8
0
def print_human_readable(desc, root_stg=None):
    ''' Print summary in human readable form.

    :param desc: an instance of Description
    :param root_stg: root storage of description.xml
    '''
    from storage import resolve_path
    print 'identifier:', desc.identifier
    print 'version:', desc.version
    print 'platform:', desc.platform

    print 'display-name:'
    for lang, name in desc.display_name.items():
        print '  [%s] %s' % (lang, name)

    print 'extension-description:'
    for lang, url in desc.description.items():
        if not root_stg or resolve_path(root_stg, url):
            state = ''
        else:
            state = ' -- MISSING'
        print '  [%s] %s%s' % (lang, url, state)

    print 'publisher:'
    for lang, publisher in desc.publisher.items():
        print '  [%s] %s (%s)' % (lang, publisher['name'], publisher['url'])
    if desc.license:
        print 'license: accept-by', desc.license_accept_by
        for lang, url in desc.license.items():
            if not root_stg or resolve_path(root_stg, url):
                state = ''
            else:
                state = ' -- MISSING'
            print '  [%s] %s%s' % (lang, url, state)

    if desc.oo_min_version:
        print 'dependencies:'
        print '  LibreOffice minimal version:', desc.oo_min_version