Fixing more bugs in dl_pictures

This commit is contained in:
spbeach46 2021-04-27 22:42:55 -07:00
parent 545bc78421
commit 6cfa798902

View File

@ -278,12 +278,16 @@ class CurateData:
temp_pics_source_list = list(set(expanded_class.PictureURL.to_list())) # prolly need to create set long before df... immediately after Shopping or trading call
# defined in the download function
with open('temp_pics_source_list.txt', 'a+') as f: # Temp iterable for use w/executor
try:
try:
with open('temp_pics_source_list.txt') as f:
temp_pics_source_list = json.load(f)
temp_pics_source_list.append(temp_pics_source_list)
json.dump(temp_pics_source_list, f) # TODO This creates duplicates incorrectly
except ValueError:
temp_pics_source_list = list(set(temp_pics_source_list))
with open('temp_pics_source_list.txt', 'w') as f:
json.dump(temp_pics_source_list, f)
except (ValueError, FileNotFoundError):
with open('temp_pics_source_list.txt', 'w') as f:
json.dump(temp_pics_source_list, f)
return expanded_class, expanded_dropd
@ -298,17 +302,17 @@ class CurateData:
with open('target_dirs.txt', 'r+') as f: # TODO you can add option to change directory here, too. Look up how to have optional arguments
target_dir = json.load(f)
except (ValueError, FileNotFoundError): # TODO doesn't seem to create target_dir from cwd. I think it's because ValueError should be FileNotFoundError?
except (ValueError, FileNotFoundError):
target_dir = input('No target dirctory found. Create One? [y] or [n]:')
if target_dir == ('y' or 'Y'):
target_dir = input('Please provide full URL to destination folder:')
with open('target_dirs.txt','w+') as f:
json.dump(target_dir, f)
else:
target_dir = os.getcwd()
target_dir = os.mkdir(os.getcwd()+os.sep+'training_images')
with open('target_dirs.txt','w+') as f:
json.dump(target_dir, f)
print('Creating default folder in current directory, ' + target_dir) # TODO does not concat correctly. Fix this
print('Creating default folder in current directory @ ' + target_dir)
with open('temp_pics_source_list.txt') as f:
try:
@ -316,7 +320,7 @@ class CurateData:
temp_pics_source_list = args[0]
else:
temp_pics_source_list = json.load(f)
except ValueError:
except (ValueError, FileNotFoundError):
if args:
temp_pics_sources_list = args[0]
else: