diff --git a/parsers/drawings.py b/parsers/drawings.py
index a6c16be..88a6ca3 100644
--- a/parsers/drawings.py
+++ b/parsers/drawings.py
@@ -21,18 +21,6 @@ for tunnel and therion files
todo='''
'''
-def get_or_create_placeholder(year):
- """ All surveys must be related to a logbookentry. We don't have a way to
- automatically figure out which survey went with which logbookentry,
- so we create a survey placeholder logbook entry for each year. This
- function always returns such a placeholder, and creates it if it doesn't
- exist yet.
- """
- lookupAttribs={'date__year':int(year), 'title':"placeholder for surveys",}
- nonLookupAttribs={'text':"surveys temporarily attached to this should be re-attached to their actual trips", 'date':datetime.date(int(year),1,1)}
- placeholder_logbook_entry, newly_created = save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
- return placeholder_logbook_entry
-
def find_dwg_file(dwgfile, path):
'''Is given a line of text 'path' which may or may not contain a recognisable name of a scanned file
which we have already seen when we imported all the files we could find in the surveyscans direstories
diff --git a/parsers/scans.py b/parsers/scans.py
index d2fcbf7..3d81f13 100644
--- a/parsers/scans.py
+++ b/parsers/scans.py
@@ -55,30 +55,6 @@ wallet_blank_html = '''
Wallet WALLET
'''
-def get_or_create_placeholder(year):
- """ All surveys must be related to a logbookentry. We don't have a way to
- automatically figure out which survey went with which logbookentry,
- so we create a survey placeholder logbook entry for each year. This
- function always returns such a placeholder, and creates it if it doesn't
- exist yet.
- """
- lookupAttribs={'date__year':int(year), 'title':"placeholder for surveys",}
- nonLookupAttribs={'text':"surveys temporarily attached to this should be re-attached to their actual trips", 'date':datetime.date(int(year),1,1)}
- placeholder_logbook_entry, newly_created = save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
- return placeholder_logbook_entry
-
-# def listdir(*directories):
- # '''WHAT is this ?! Some python2 fossil. The only use of settings.SURVEYS
- # local import statement to be avoided, please.
- # '''
- # try:
- # return os.listdir(os.path.join(settings.SURVEYS, *directories))
- # except:
- # import urllib.request, urllib.parse, urllib.error
- # url = settings.SURVEYS + reduce(lambda x, y: x + "/" + y, ["listdir"] + list(directories))
- # folders = urllib.request.urlopen(url.replace("#", "%23")).readlines()
- # return [folder.rstrip(r"/") for folder in folders]
-
def LoadListScansFile(wallet):
gld = [ ]
# flatten out any directories in these wallet folders - should not be any
@@ -107,36 +83,45 @@ def load_all_scans():
SingleScan.objects.all().delete()
Wallet.objects.all().delete()
- print(' - deleting all scansFolder and scansSingle objects')
+ print(' - deleting all Wallet and SingleScan objects')
DataIssue.objects.filter(parser='scans').delete()
# first do the smkhs (large kh survey scans) directory
+ # this seems to be never used ?!
manywallets_smkhs = Wallet(fpath=os.path.join(settings.SCANS_ROOT, "../surveys/smkhs"), walletname="smkhs")
print("smkhs", end=' ')
if os.path.isdir(manywallets_smkhs.fpath):
manywallets_smkhs.save()
LoadListScansFile(manywallets_smkhs)
-
-
+ else:
+ print("smkhs NOT LOADED", end=' ')
+
# iterate into the surveyscans directory
print(' - ', end=' ')
- for f, ff, fisdir in GetListDir(settings.SCANS_ROOT):
+ for walletname, fpath, fisdir in GetListDir(settings.SCANS_ROOT):
if not fisdir:
continue
# do the year folders
- if re.match(r"\d\d\d\d$", f):
- print("%s" % f, end=' ')
- for fy, ffy, fisdiry in GetListDir(ff):
- if fisdiry:
- wallet = Wallet(fpath=ffy, walletname=fy)
+ if re.match(r"\d\d\d\d$", walletname):
+ print(f"{walletname}", end=' ')
+ for walletname, fpath, fisdir in GetListDir(ff):
+ if fisdir:
+ wallet = Wallet(fpath=fpath, walletname=walletname)
+ # this is where we should load the contents.json for people so we can report on them later
+ # this is where we shoudl record the year explicitly
+ # line 347 of view/uploads.py and needs refactoring for loading contentsjson
wallet.save()
LoadListScansFile(wallet)
- # do the
- elif f != "thumbs":
- wallet = Wallet(fpath=ff, walletname=f)
+ # what is this?
+ elif walletname != "thumbs":
+ print(f'\n - Wallet {f} - {ff}')
+ wallet = Wallet(fpath=fpath, walletname=walletname)
wallet.save()
LoadListScansFile(wallet)
+ else:
+ print(f'\n - IGNORE {walletname} - {fpath}')
+
print("", flush=True)