mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 05:37:14 +00:00
rename scansfolder to wallet
This commit is contained in:
@@ -58,10 +58,10 @@ def GetListDir(sdir):
|
||||
return res
|
||||
|
||||
|
||||
def LoadListScansFile(scansfolder):
|
||||
def LoadListScansFile(wallet):
|
||||
gld = [ ]
|
||||
# flatten out any directories in these wallet folders - should not be any
|
||||
for (fyf, ffyf, fisdiryf) in GetListDir(scansfolder.fpath):
|
||||
for (fyf, ffyf, fisdiryf) in GetListDir(wallet.fpath):
|
||||
if fisdiryf:
|
||||
gld.extend(GetListDir(ffyf))
|
||||
else:
|
||||
@@ -70,7 +70,7 @@ def LoadListScansFile(scansfolder):
|
||||
c=0
|
||||
for (fyf, ffyf, fisdiryf) in gld:
|
||||
if re.search(r"\.(?:png|jpg|jpeg|pdf|svg|gif)(?i)$", fyf):
|
||||
singlescan = SingleScan(ffile=ffyf, name=fyf, scansfolder=scansfolder)
|
||||
singlescan = SingleScan(ffile=ffyf, name=fyf, wallet=wallet)
|
||||
singlescan.save()
|
||||
c+=1
|
||||
if c>=10:
|
||||
@@ -107,35 +107,35 @@ def LoadListScans():
|
||||
print("%s" % f, end=' ')
|
||||
for fy, ffy, fisdiry in GetListDir(ff):
|
||||
if fisdiry:
|
||||
scansfolder = Wallet(fpath=ffy, walletname=fy)
|
||||
scansfolder.save()
|
||||
LoadListScansFile(scansfolder)
|
||||
wallet = Wallet(fpath=ffy, walletname=fy)
|
||||
wallet.save()
|
||||
LoadListScansFile(wallet)
|
||||
|
||||
# do the
|
||||
elif f != "thumbs":
|
||||
scansfolder = Wallet(fpath=ff, walletname=f)
|
||||
scansfolder.save()
|
||||
LoadListScansFile(scansfolder)
|
||||
wallet = Wallet(fpath=ff, walletname=f)
|
||||
wallet.save()
|
||||
LoadListScansFile(wallet)
|
||||
|
||||
|
||||
def find_tunnel_scan(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
|
||||
'''
|
||||
scansfolder, scansfile = None, None
|
||||
wallet, scansfile = None, None
|
||||
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
|
||||
if mscansdir:
|
||||
scansfolderl = Wallet.objects.filter(walletname=mscansdir.group(1))
|
||||
scanswalletl = Wallet.objects.filter(walletname=mscansdir.group(1))
|
||||
# This should properly detect if a list of folders is returned and do something sensible, not just pick the first.
|
||||
if len(scansfolderl):
|
||||
scansfolder = scansfolderl[0]
|
||||
if len(scansfolderl) > 1:
|
||||
if len(scanswalletl):
|
||||
wallet = scanswalletl[0]
|
||||
if len(scanswalletl) > 1:
|
||||
message = "! More than one scan FOLDER matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='Tunnel', message=message)
|
||||
|
||||
if scansfolder:
|
||||
scansfilel = scansfolder.singlescan_set.filter(name=mscansdir.group(2))
|
||||
if wallet:
|
||||
scansfilel = wallet.singlescan_set.filter(name=mscansdir.group(2))
|
||||
if len(scansfilel):
|
||||
if len(scansfilel) > 1:
|
||||
message = "! More than one image FILENAME matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), dwgfile.dwgpath, path)
|
||||
@@ -143,8 +143,8 @@ def find_tunnel_scan(dwgfile, path):
|
||||
DataIssue.objects.create(parser='Tunnel', message=message)
|
||||
scansfile = scansfilel[0]
|
||||
|
||||
if scansfolder:
|
||||
dwgfile.manywallets.add(scansfolder)
|
||||
if wallet:
|
||||
dwgfile.manywallets.add(wallet)
|
||||
if scansfile:
|
||||
dwgfile.scans.add(scansfile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user