2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 06:57:09 +00:00

Start to change dataformat for caves, along with there editing. Start to change survex reader to cope better with equates/tags.

This commit is contained in:
Martin Green
2012-06-10 14:59:21 +01:00
parent 52620ea1c5
commit 9024520184
16 changed files with 388 additions and 136 deletions

View File

@@ -108,14 +108,15 @@ def LoadCaveTab():
addToDefaultArgs(AutogenFile, "url")
if line[Area] == "1626":
if line[KatasterNumber] != "":
args["slug"] = line[Area] + "-" + line[KatasterNumber]
slug = line[Area] + "-" + line[KatasterNumber]
else:
args["slug"] = line[Area] + "-" + line[UnofficialNumber]
slug = line[Area] + "-" + line[UnofficialNumber]
else:
if line[KatasterNumber] != "":
args["slug"] = "1623" + "-" + line[KatasterNumber]
slug = "1623" + "-" + line[KatasterNumber]
else:
args["slug"] = "1623" + "-" + line[UnofficialNumber]
slug = "1623" + "-" + line[UnofficialNumber]
args["filename"] = "%s.html" % slug
#The following adds the legacy_file_path. This is always in either Autogen file or Link file
for header in (AutogenFile,LinkFile):
if line[header]:
@@ -126,8 +127,9 @@ def LoadCaveTab():
#Noinfo was the name of the old password protected directory, so if it has that then we will
#set the non_public field of the model instance to true.
defaultArgs["non_public"]=line[AutogenFile].startswith('noinfo') or line[LinkFile].startswith('noinfo')
newCave, created=save_carefully(models.Cave, lookupAttribs=args, nonLookupAttribs=defaultArgs)
newCave, created = save_carefully(models.Cave, lookupAttribs=args, nonLookupAttribs=defaultArgs)
cs = models.CaveSlug(slug = slug, cave = newCave, primary = True)
cs.save()
logging.info("Added cave "+str(newCave)+"\n")
#If we created a new cave, add the area to it. This does mean that if a cave's identifying features have not changed, areas will not be updated from csv.
@@ -148,8 +150,7 @@ def LoadCaveTab():
newCave.save()
logging.info("Added area "+line[Area]+" to cave "+str(newCave)+"\n")
logging.info("Added area "+line[Area]+" to cave "+str(newCave)+"\n")
if created and line[UnofficialName]:
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName])
newUnofficialName.save()
@@ -161,70 +162,80 @@ def LoadCaveTab():
line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance':
args = {}
if line[Entrances]:
entrance_letter = line[Entrances]
else:
entrance_letter = ''
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = line[CSVname]
def addToArgsViaDict(CSVname, modelName, dictionary):
if line[CSVname]:
args[modelName] = dictionary[line[CSVname]]
addToArgs(EntranceName, 'name')
addToArgs(Explorers, 'explorers')
addToArgs(Map, 'map_description')
addToArgs(Location, 'location_description')
addToArgs(Approach, 'approach')
addToArgs(EntranceDescription, 'entrance_description')
addToArgs(UndergroundDescription, 'underground_description')
addToArgs(PhotoOfLocation, 'photo')
addToArgsViaDict(Marking, 'marking', {"Paint": "P",
"Paint (?)": "P?",
"Tag": "T",
"Tag (?)": "T?",
"Retagged": "R",
"Retag": "R",
"Spit": "S",
"Spit (?)": "S?",
"Unmarked": "U",
"": "?",
})
if line[Entrances]:
entrance_letter = line[Entrances]
else:
entrance_letter = ''
addToArgs(MarkingComment, 'marking_comment')
addToArgsViaDict(Findability, 'findability', {"Surveyed": "S",
"Lost": "L",
"Refindable": "R",
"": "?",
"?": "?",
})
addToArgs(FindabilityComment, 'findability_description')
addToArgs(Easting, 'easting')
addToArgs(Northing, 'northing')
addToArgs(Altitude, 'alt')
addToArgs(DescriptionOfOtherPoint, 'other_description')
addToArgs(TagPoint, 'tag_station')
addToArgs(ExactEntrance, 'exact_station')
addToArgs(OtherPoint, 'other_station')
addToArgs(OtherPoint, 'other_description')
if line[GPSpreSA]:
addToArgs(GPSpreSA, 'other_station')
args['other_description'] = 'pre selective availability GPS'
if line[GPSpostSA]:
addToArgs(GPSpostSA, 'other_station')
args['other_description'] = 'post selective availability GPS'
addToArgs(Bearings, 'bearings')
args['slug'] = newCave.slug + entrance_letter
newEntrance = models.Entrance(**args)
newEntrance.save()
if not line[LinkFile]:
addToArgs(Map, 'map_description')
addToArgs(Location, 'location_description')
addToArgs(Approach, 'approach')
addToArgs(EntranceDescription, 'entrance_description')
if line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance':
addToArgs(UndergroundDescription, 'underground_description')
addToArgs(AutogenFile, 'url')
addToArgs(EntranceName, 'name')
addToArgs(Explorers, 'explorers')
addToArgs(PhotoOfLocation, 'photo')
addToArgsViaDict(Marking, 'marking', {"Paint": "P",
"Paint (?)": "P?",
"Tag": "T",
"Tag (?)": "T?",
"Retagged": "R",
"Retag": "R",
"Spit": "S",
"Spit (?)": "S?",
"Unmarked": "U",
"": "?",
})
logging.info("Added entrance "+str(newEntrance)+"\n")
addToArgs(MarkingComment, 'marking_comment')
addToArgsViaDict(Findability, 'findability', {"Surveyed": "S",
"Lost": "L",
"Refindable": "R",
"": "?",
"?": "?",
})
addToArgs(FindabilityComment, 'findability_description')
addToArgs(Easting, 'easting')
addToArgs(Northing, 'northing')
addToArgs(Altitude, 'alt')
addToArgs(DescriptionOfOtherPoint, 'other_description')
addToArgs(TagPoint, 'tag_station')
addToArgs(ExactEntrance, 'exact_station')
addToArgs(OtherPoint, 'other_station')
addToArgs(OtherPoint, 'other_description')
if line[GPSpreSA]:
addToArgs(GPSpreSA, 'other_station')
args['other_description'] = 'pre selective availability GPS'
if line[GPSpostSA]:
addToArgs(GPSpostSA, 'other_station')
args['other_description'] = 'post selective availability GPS'
addToArgs(Bearings, 'bearings')
args["filename"] = "%s.html" % (slug + entrance_letter)
newEntrance = models.Entrance(**args)
newEntrance.save()
es = models.EntranceSlug(slug = slug + entrance_letter, entrance = newEntrance, primary = True)
es.save()
logging.info("Added entrance "+str(newEntrance)+"\n")
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save()
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave,
entrance = newEntrance,
entrance_letter = entrance_letter)
newCaveAndEntrance.save()
logging.info("Added CaveAndEntrance "+str(newCaveAndEntrance)+"\n")
if line[AutogenFile] != "":