properly handle edge case when we point collate or manual-collate directly at an extraction directory

This commit is contained in:
xenofem 2024-03-02 18:10:22 -05:00
parent 9fea03c270
commit c042163e85

View file

@ -208,12 +208,15 @@ def fetch(args):
asyncio.run(fetch_async(args)) asyncio.run(fetch_async(args))
def self_and_parents(path):
return [path] + list(path.parents)
def collate(args): def collate(args):
con = sqlite3.connect(args.destdir / 'meta.db') con = sqlite3.connect(args.destdir / 'meta.db')
cur = con.cursor() cur = con.cursor()
extraction_dir = args.destdir / 'extract' extraction_dir = args.destdir / 'extract'
hint_map = {Path(relpath(hint, extraction_dir)).parents[-2].name: hint for hint in args.hints} hint_map = {self_and_parents(Path(relpath(hint, extraction_dir)))[-2].name: hint for hint in args.hints}
collation_staging_area = args.destdir / 'site' / 'images-staging' collation_staging_area = args.destdir / 'site' / 'images-staging'
collation_staging_area.mkdir(parents=True) collation_staging_area.mkdir(parents=True)
@ -697,7 +700,7 @@ def manual_collate(args):
extraction_dir = args.destdir / 'extract' extraction_dir = args.destdir / 'extract'
sample_path = next(path for group in (raw_groups + [raw_exclusions]) for path in group) sample_path = next(path for group in (raw_groups + [raw_exclusions]) for path in group)
work_id = Path(relpath(sample_path, extraction_dir)).parents[-2].name work_id = self_and_parents(Path(relpath(sample_path, extraction_dir)))[-2].name
exclusions = [normalize_to(item, args.destdir) for item in raw_exclusions] exclusions = [normalize_to(item, args.destdir) for item in raw_exclusions]