def migrate(db): log.info('Processing Datasets.') datasets = Dataset.objects().no_cache().timeout(False) count = 0 for dataset in datasets: save_dataset = False for resource in [res for res in dataset.resources if res.fs_filename]: detected_format = extension(resource.fs_filename) if detected_format != resource.format: save_dataset = True resource.format = detected_format count += 1 if save_dataset: dataset.save(signal_kwargs={'ignores': ['post_save']}) log.info(f'Modified {count} resource objects') log.info('Done')
def test_extension_compound(self): assert utils.extension('test.tar.gz') == 'tar.gz' assert utils.extension('prefix.with.dot/test.tar.gz') == 'tar.gz'
def test_no_extension(self): assert utils.extension('test') is None assert utils.extension('prefix/test') is None
def test_extension_default(self): assert utils.extension('test.txt') == 'txt' assert utils.extension('prefix/test.txt') == 'txt' assert utils.extension('prefix.with.dot/test.txt') == 'txt'
def test_no_extension(self): assert utils.extension('test') is None assert utils.extension('prefix/test') is None
def test_extension_compound(self): assert utils.extension('test.tar.gz') == 'tar.gz' assert utils.extension('prefix.with.dot/test.tar.gz') == 'tar.gz'
def test_extension_default(self): assert utils.extension('test.txt') == 'txt' assert utils.extension('prefix/test.txt') == 'txt' assert utils.extension('prefix.with.dot/test.txt') == 'txt'
def test_extension_compound_without_allowed_extension(self, app): assert utils.extension('test.2022.tar.gz') == 'tar.gz' assert utils.extension('prefix.with.dot/test.2022.tar.gz') == 'tar.gz'