forked from expo/troggle
rename Tunnel files to Drawings files - phase 1
This commit is contained in:
@@ -15,6 +15,8 @@ import settings
|
||||
#from troggle.core.models import *
|
||||
#from troggle.core.models_caves import *
|
||||
from troggle.core.models_survex import SingleScan, ScansFolder, TunnelFile
|
||||
from troggle.core.models import DataIssue
|
||||
|
||||
|
||||
def get_or_create_placeholder(year):
|
||||
""" All surveys must be related to a logbookentry. We don't have a way to
|
||||
@@ -177,22 +179,24 @@ def SetTunnelfileInfo(tunnelfile):
|
||||
tunnelfile.save()
|
||||
|
||||
|
||||
def LoadTunnelFiles():
|
||||
tunneldatadir = settings.TUNNEL_DATA
|
||||
def LoadDrawingFiles():
|
||||
drawdatadir = settings.TUNNEL_DATA
|
||||
TunnelFile.objects.all().delete()
|
||||
tunneldirs = [ "" ]
|
||||
while tunneldirs:
|
||||
tunneldir = tunneldirs.pop()
|
||||
for f in os.listdir(os.path.join(tunneldatadir, tunneldir)):
|
||||
DataIssue.objects.filter(parser='drawings').delete()
|
||||
|
||||
drawingsdirs = [ "" ]
|
||||
while drawingsdirs:
|
||||
drawdir = drawingsdirs.pop()
|
||||
for f in os.listdir(os.path.join(drawdatadir, drawdir)):
|
||||
if f[0] == "." or f[-1] == "~":
|
||||
continue
|
||||
lf = os.path.join(tunneldir, f)
|
||||
ff = os.path.join(tunneldatadir, lf)
|
||||
lf = os.path.join(drawdir, f)
|
||||
ff = os.path.join(drawdatadir, lf)
|
||||
if os.path.isdir(ff):
|
||||
tunneldirs.append(lf)
|
||||
drawingsdirs.append(lf)
|
||||
elif f[-4:] == ".xml":
|
||||
tunnelfile = TunnelFile(tunnelpath=lf, tunnelname=os.path.split(f[:-4])[1])
|
||||
tunnelfile.save()
|
||||
|
||||
for tunnelfile in TunnelFile.objects.all():
|
||||
SetTunnelfileInfo(tunnelfile)
|
||||
for drawfile in TunnelFile.objects.all():
|
||||
SetTunnelfileInfo(drawfile)
|
||||
|
||||
Reference in New Issue
Block a user