diff options
Diffstat (limited to 'megapixels/app/utils')
| -rw-r--r-- | megapixels/app/utils/file_utils.py | 12 | ||||
| -rw-r--r-- | megapixels/app/utils/path_utils.py | 52 |
2 files changed, 9 insertions, 55 deletions
diff --git a/megapixels/app/utils/file_utils.py b/megapixels/app/utils/file_utils.py index 80239fe2..5c7b39d1 100644 --- a/megapixels/app/utils/file_utils.py +++ b/megapixels/app/utils/file_utils.py @@ -40,10 +40,16 @@ log = logging.getLogger(cfg.LOGGER_NAME) # File I/O read/write little helpers # ------------------------------------------ -def glob_multi(dir_in, exts): +def glob_multi(dir_in, exts, recursive=False): files = [] - for e in exts: - files.append(glob(join(dir_in, '*.{}'.format(e)))) + for ext in exts: + if recursive: + fp_glob = join(dir_in, '**/*.{}'.format(ext)) + log.info(f'glob {fp_glob}') + files += glob(fp_glob, recursive=True) + else: + fp_glob = join(dir_in, '*.{}'.format(ext)) + files += glob(fp_glob) return files diff --git a/megapixels/app/utils/path_utils.py b/megapixels/app/utils/path_utils.py deleted file mode 100644 index b0262ea0..00000000 --- a/megapixels/app/utils/path_utils.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -from os.path import join -import logging - -from app.settings import app_cfg as cfg -from app.settings import types - - -# ------------------------------------------------------------------------- -# Metadata and media files -# ------------------------------------------------------------------------- - -class DataStore: - # local data store - def __init__(self, opt_data_store, opt_dataset): - self.data_store = join(f'/data_store_{opt_data_store.name.lower()}') - self.dir_dataset = join(self.data_store, 'datasets', cfg.DIR_PEOPLE, opt_dataset.name.lower()) - self.dir_media = join(self.dir_dataset, 'media') - self.dir_metadata = join(self.dir_dataset, 'metadata') - - def metadata(self, enum_type): - return join(self.dir_metadata, f'{enum_type.name.lower()}.csv') - - def face_image(self, subdir, fn, ext): - return join(self.dir_media, 'original', subdir, f'{fn}.{ext}') - - def face_image_crop(self, subdir, fn, ext): - return join(self.dir_media, 'cropped', subdir, f'{fn}.{ext}') - - -class DataStoreS3: - # S3 server - def __init__(self, opt_dataset): - self._dir_media = join(cfg.S3_HTTP_MEDIA_URL, opt_dataset.name.lower()) - self._dir_metadata = join(cfg.S3_HTTP_METADATA_URL, opt_dataset.name.lower()) - - def metadata(self, opt_metadata_type, ext='csv'): - return join(self._dir_metadata, f'{opt_metadata_type.name.lower()}.{ext}') - - def face_image(self, opt_uuid, ext='jpg'): - #return join(self._dir_media, 'original', f'{opt_uuid}.{ext}') - return join(self._dir_media, f'{opt_uuid}.{ext}') - - def face_image_crop(self, opt_uuid, ext='jpg'): - # not currently using? - return join(self._dir_media, 'cropped', f'{opt_uuid}.{ext}') - - - -# ------------------------------------------------------------------------- -# Models -# -------------------------------------------------------------------------
\ No newline at end of file |
