def _extract(self, resource: ExtractPath) -> promise.Promise[ReadOnlyPath]: """Extract a single archive, returns Promise->path to extraction result.""" if isinstance(resource, type_utils.PathLikeCls): resource = resource_lib.Resource(path=resource) path = resource.path extract_method = resource.extract_method if extract_method == resource_lib.ExtractMethod.NO_EXTRACT: logging.info('Skipping extraction for %s (method=NO_EXTRACT).', path) return promise.Promise.resolve(path) method_name = resource_lib.ExtractMethod(extract_method).name extract_path = self._extract_dir / f'{method_name}.{path.name}' if not self._force_extraction and extract_path.exists(): logging.info('Reusing extraction of %s at %s.', path, extract_path) return promise.Promise.resolve(extract_path) return self._extractor.extract(path, extract_method, extract_path)
def _extract(self, resource): """Extract a single archive, returns Promise->path to extraction result.""" if isinstance(resource, six.string_types): resource = resource_lib.Resource(path=resource) path = resource.path extract_method = resource.extract_method if extract_method == resource_lib.ExtractMethod.NO_EXTRACT: logging.info('Skipping extraction for %s (method=NO_EXTRACT).', path) return promise.Promise.resolve(path) method_name = resource_lib.ExtractMethod(extract_method).name extract_path = os.path.join(self._extract_dir, '%s.%s' % (method_name, os.path.basename(path))) if not self._force_extraction and tf.io.gfile.exists(extract_path): logging.info('Reusing extraction of %s at %s.', path, extract_path) return promise.Promise.resolve(extract_path) return self._extractor.extract(path, extract_method, extract_path)