2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Tidy formatting prior to adding some new stuff

This commit is contained in:
Philip Sargent 2020-04-14 20:19:41 +01:00
parent 78f8ea2b5b
commit 09bbf81915

View File

@ -55,6 +55,7 @@ def import_logbooks():
try:
settings.LOGFILE.write('\nBegun importing logbooks at ' + time.asctime() +'\n'+'-'*60)
except:
print "EXCEPTION when trying to write to", settings.LOGFILE
pass
import parsers.logbooks
@ -80,16 +81,6 @@ def import_tunnelfiles():
import parsers.surveys
parsers.surveys.LoadTunnelFiles()
def rebuild():
""" Wipe the troggle database and sets up structure but imports nothing
"""
reload_db()
make_dirs()
pageredirects()
def reset():
""" Wipe the troggle database and import everything from legacy data
"""
@ -102,14 +93,10 @@ def reset():
import_logbooks()
import_QMs()
import_survex()
#try:
import_tunnelfiles()
#except:
# print("Tunnel files parser broken.")
import_surveys()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def import_auto_logbooks():
import parsers.logbooks
import os
@ -162,6 +149,7 @@ def dumplogbooks():
output = template.render(context)
f.write(unicode(output).encode( "utf-8" ))
f.close()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def pageredirects():
for oldURL, newURL in [("indxal.htm", reverse("caveindex"))]:
@ -171,22 +159,22 @@ def pageredirects():
def usage():
print("""Usage is 'python databaseReset.py <command>'
where command is:
rebuild - this reloads database and set up directories & redirects only
reset - this is normal usage, clear database and reread everything from files - time-consuming
desc - NOT WORKING: function resetdesc() missing
caves - read in the caves
folklog - read in the people (folk) and then the logbooks
logbooks - read in just the logbooks
reset - this is normal usage, clear database and reread everything from files - time-consuming
caves - read in the caves
logbooks - read in just the logbooks
people - read in the people from folk.csv
QMs - read in the QM files
reload_db - clear database i.e. delete everything
scans - NOT the scanned surveynotes ?!
survex - read in the survex files - all the survex blocks
survexpos - just the Pos out of the survex files
surveys - read in the scanned surveynotes
tunnel - read in the Tunnel files - which scans the surveyscans too
resetend - (archaic?)
writecaves - *disabled* (archaic?)
autologbooks - read in autologbooks (what are these?)
dumplogbooks - write out autologbooks (not working?)
people - read in the people from folk.csv
QMs - read in the QM files
resetend
scans - NOT the scanned surveynotes ?!
survex - read in the survex files - all the survex blocks
survexpos - just the Pos out of the survex files
surveys - read in the scanned surveynotes
tunnel - read in the Tunnel files - which scans the surveyscans too
""")
if __name__ == "__main__":
@ -194,17 +182,12 @@ if __name__ == "__main__":
import sys
import django
django.setup()
if "desc" in sys.argv:
resetdesc()
elif "scans" in sys.argv:
if "scans" in sys.argv:
import_surveyscans()
elif "caves" in sys.argv:
import_caves()
elif "people" in sys.argv:
import_people()
elif "folklogs" in sys.argv:
import_people()
import_logbooks()
elif "QMs" in sys.argv:
import_QMs()
elif "tunnel" in sys.argv:
@ -212,12 +195,11 @@ if __name__ == "__main__":
elif "reset" in sys.argv:
reset()
elif "resetend" in sys.argv:
#import_logbooks()
import_QMs()
import_tunnelfiles()
import_surveys()
import_descriptions()
parse_descriptions()
#import_descriptions() # no longer present
#parse_descriptions() # no longer present
elif "survex" in sys.argv:
# management.call_command('syncdb', interactive=False) # this sets the path so that import settings works in import_survex
import_survex()
@ -232,16 +214,14 @@ if __name__ == "__main__":
import_auto_logbooks()
elif "dumplogbooks" in sys.argv:
dumplogbooks()
elif "writeCaves" in sys.argv:
writeCaves()
# elif "writeCaves" in sys.argv:
# writeCaves() # no longer present
elif "surveys" in sys.argv:
import_surveys()
elif "help" in sys.argv:
usage()
elif "reload_db" in sys.argv:
reload_db()
elif "rebuild" in sys.argv:
rebuild()
else:
print("%s not recognised" % sys.argv)
usage()