def gather_results(loader: AssetLoader, path: str, **kwargs) -> Tuple[Set[str], Set[str]]: kwargs.setdefault('extension', ['.txt']) if 'invert' in kwargs: raise ValueError('invert cannot appear in kwargs') normal = set(loader.find_assetnames(path, **kwargs)) inverted = set(loader.find_assetnames(path, **kwargs, invert=True)) return (normal, inverted)
def explore_path(path: str, loader: AssetLoader, excludes: Iterable[str], verbose=False, disable_debug=False): '''Run hierarchy discovery over every matching asset within the given path.''' excludes = set(excludes) logger.info('Discovering hierarchy in path: %s', path) n = 0 with ue_parsing_context(properties=False): asset_iterator = loader.find_assetnames('.*', path, exclude=excludes, extension=asset_extensions, return_extension=True) for (assetname, ext) in asset_iterator: n += 1 if verbose and n % 200 == 0: logger.info(assetname) try: asset = loader.load_asset(assetname, quiet=disable_debug) except AssetLoadException: logger.warning("Failed to load asset: %s", assetname) continue try: _ingest_asset(asset, loader, ext) except AssetLoadException: logger.warning("Failed to check parentage of %s", assetname) except MissingParent as ex: logger.exception("Missing parent for %s", assetname) raise MissingParent from ex # Remove maps from the cache immediately as they are large and cannot be inherited from if ext == '.umap': loader.cache.remove(assetname)