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

docstrings added

This commit is contained in:
Philip Sargent 2022-12-23 00:49:22 +00:00
parent a72c2bd96a
commit 9c39c9dcff

View File

@ -19,7 +19,7 @@ troggle application.
""" """
print(" - settings on loading databaseReset.py", flush=True) print(" - settings on loading databaseReset.py", flush=True)
os.environ['PYTHONPATH'] = settings.PYTHON_PATH os.environ['PYTHONPATH'] = str(settings.PYTHON_PATH)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
print(" - settings on loading databaseReset.py") print(" - settings on loading databaseReset.py")
@ -153,6 +153,8 @@ def reinit_db():
#raise #raise
def memdumpsql(fn): def memdumpsql(fn):
'''Unused option to dump SQL. Aborted attempt to create a cache for loading data
'''
djconn = django.db.connection djconn = django.db.connection
from dump import _iterdump from dump import _iterdump
with open(fn, 'w') as f: with open(fn, 'w') as f:
@ -168,6 +170,9 @@ class JobQueue():
""" """
def __init__(self,run): def __init__(self,run):
'''Initialises the job queue object with a fixed order for reporting
options during a run. Imports the timings from previous runs.
'''
self.runlabel = run self.runlabel = run
self.queue = [] # tuples of (jobname, jobfunction) self.queue = [] # tuples of (jobname, jobfunction)
self.results = {} self.results = {}
@ -180,8 +185,10 @@ class JobQueue():
self.tfile = "import_profile.json" self.tfile = "import_profile.json"
self.htmlfile = "profile.html" # for HTML results table. Not yet done. self.htmlfile = "profile.html" # for HTML results table. Not yet done.
#Adding elements to queue - enqueue
def enq(self,label,func): def enq(self,label,func):
'''Enqueue: Adding elements to queue
'''
self.queue.append((label,func)) self.queue.append((label,func))
return True return True
@ -257,6 +264,8 @@ class JobQueue():
def append_placeholders(self): def append_placeholders(self):
'''Ads a dummy timing for each option, to fix off by one error
'''
for j in self.results_order: for j in self.results_order:
self.results[j].append(None) # append a placeholder self.results[j].append(None) # append a placeholder
@ -326,6 +335,8 @@ class JobQueue():
def usage(): def usage():
'''Prints command line options, can print history of previous runs with timings
'''
print("""Usage is 'python databaseReset.py <command> [runlabel]' print("""Usage is 'python databaseReset.py <command> [runlabel]'
where command is: where command is:
test - testing... imports people and prints profile. Deletes nothing. test - testing... imports people and prints profile. Deletes nothing.