def execute(self, args): filters = {} if args.name: filters['name'] = args.name ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) results = ext_loader.list_extensions(args.kind[:-1]) if filters or args.platform: filtered_results = [] for result in results: passed = True for k, v in filters.iteritems(): if getattr(result, k) != v: passed = False break if passed and args.platform: passed = check_platform(result, args.platform) if passed: filtered_results.append(result) else: # no filters specified filtered_results = results if filtered_results: output = DescriptionListFormatter() for result in sorted(filtered_results, key=lambda x: x.name): output.add_item(get_summary(result), result.name) print output.format_data()
def execute(self, args): filters = {} if args.name: filters["name"] = args.name ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) results = ext_loader.list_extensions(args.kind[:-1]) if filters or args.platform: filtered_results = [] for result in results: passed = True for k, v in filters.iteritems(): if getattr(result, k) != v: passed = False break if passed and args.platform: passed = check_platform(result, args.platform) if passed: filtered_results.append(result) else: # no filters specified filtered_results = results if filtered_results: output = DescriptionListFormatter() for result in sorted(filtered_results, key=lambda x: x.name): output.add_item(get_summary(result), result.name) print output.format_data()
def generate_extension_documentation(source_dir, outdir, ignore_paths): loader = ExtensionLoader(keep_going=True) loader.clear() loader.update(paths=[source_dir], ignore_paths=ignore_paths) for ext_type in loader.extension_kinds: if not ext_type in GENERATE_FOR: continue outfile = os.path.join(outdir, '{}s.rst'.format(ext_type)) with open(outfile, 'w') as wfh: wfh.write('.. _{}s:\n\n'.format(ext_type)) wfh.write(underline(capitalize('{}s'.format(ext_type)))) exts = loader.list_extensions(ext_type) for ext in sorted(exts, key=lambda x: x.name): wfh.write(get_rst_from_extension(ext))
def generate_extension_documentation(source_dir, outdir, ignore_paths): loader = ExtensionLoader(keep_going=True) loader.clear() loader.update(paths=[source_dir], ignore_paths=ignore_paths) for ext_type in loader.extension_kinds: if not ext_type in GENERATE_FOR: continue outfile = os.path.join(outdir, '{}s.rst'.format(ext_type)) with open(outfile, 'w') as wfh: wfh.write('.. _{}s:\n\n'.format(ext_type)) wfh.write(underline(capitalize('{}s'.format(ext_type)))) exts = loader.list_extensions(ext_type) for ext in sorted(exts, key=lambda x: x.name): wfh.write(get_rst_from_extension(ext))
def execute(self, args): self.logger.debug('Program arguments: {}'.format(vars(args))) if args.force: self.logger.info('Force-download of assets requested') if not args.url: self.logger.debug('URL not provided, falling back to default setting in config') self.logger.info('Downloading external assets from {}'.format(args.url)) # Get file index of assets ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) getter = ext_loader.get_resource_getter('http_assets', None, url=args.url, always_fetch=args.force) try: getter.index = getter.fetch_index() except (ConnectionError, RequestException) as e: self.exit_with_error(str(e)) all_assets = dict() for k, v in getter.index.iteritems(): all_assets[str(k)] = [str(asset['path']) for asset in v] # Here we get a list of all extensions present in the current WA installation, # and cross-check that against the list of extensions whose assets are requested. # The aim is to avoid downloading assets for extensions that do not exist, since # WA extensions and asset index can be updated independently and go out of sync. all_extensions = [ext.name for ext in ext_loader.list_extensions()] assets_to_get = set(all_assets).intersection(all_extensions) if args.exts: assets_to_get = assets_to_get.intersection(args.exts) # Check list is not empty if not assets_to_get: if args.all: self.exit_with_error('Could not find extensions: {}'.format(', '.join(all_assets.keys()))) else: # args.exts self.exit_with_error('Asset index has no entries for: {}'.format(', '.join(args.exts))) # Check out of sync extensions i.e. do not exist in both WA and assets index missing = set(all_assets).difference(all_extensions) | set(args.exts or []).difference(all_assets) if missing: self.logger.warning('Not getting assets for missing extensions: {}'.format(', '.join(missing))) # Ideally the extension loader would be used to instantiate, but it does full # validation of the extension, like checking connected devices or supported # platform(s). This info might be unavailable and is not required to download # assets, since they are classified by extension name alone. So instead we use # a simple subclass of ``Extension`` providing a valid ``name`` attribute. for ext_name in assets_to_get: owner = _instantiate(NamedExtension, ext_name) self.logger.info('Getting assets for: {}'.format(ext_name)) for asset in all_assets[ext_name]: getter.get(File(owner, asset)) # Download the files
def execute(self, args): self.logger.debug('Program arguments: {}'.format(vars(args))) if args.force: self.logger.info('Force-download of assets requested') if not args.url: self.logger.debug( 'URL not provided, falling back to default setting in config') self.logger.info('Downloading external assets from {}'.format( args.url)) # Get file index of assets ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) getter = ext_loader.get_resource_getter('http_assets', None, url=args.url, always_fetch=args.force) try: getter.index = getter.fetch_index() except (ConnectionError, RequestException) as e: self.exit_with_error(str(e)) all_assets = dict() for k, v in getter.index.iteritems(): all_assets[str(k)] = [str(asset['path']) for asset in v] # Here we get a list of all extensions present in the current WA installation, # and cross-check that against the list of extensions whose assets are requested. # The aim is to avoid downloading assets for extensions that do not exist, since # WA extensions and asset index can be updated independently and go out of sync. all_extensions = [ext.name for ext in ext_loader.list_extensions()] assets_to_get = set(all_assets).intersection(all_extensions) if args.exts: assets_to_get = assets_to_get.intersection(args.exts) # Check list is not empty if not assets_to_get: if args.all: self.exit_with_error('Could not find extensions: {}'.format( ', '.join(all_assets.keys()))) else: # args.exts self.exit_with_error( 'Asset index has no entries for: {}'.format(', '.join( args.exts))) # Check out of sync extensions i.e. do not exist in both WA and assets index missing = set(all_assets).difference(all_extensions) | set( args.exts or []).difference(all_assets) if missing: self.logger.warning( 'Not getting assets for missing extensions: {}'.format( ', '.join(missing))) # Ideally the extension loader would be used to instantiate, but it does full # validation of the extension, like checking connected devices or supported # platform(s). This info might be unavailable and is not required to download # assets, since they are classified by extension name alone. So instead we use # a simple subclass of ``Extension`` providing a valid ``name`` attribute. for ext_name in assets_to_get: owner = _instantiate(NamedExtension, ext_name) self.logger.info('Getting assets for: {}'.format(ext_name)) for asset in all_assets[ext_name]: getter.get(File(owner, asset)) # Download the files