mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:07:08 +00:00
Initial commit
This commit is contained in:
40
bin/import_preplots.py
Executable file
40
bin/import_preplots.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
"""
|
||||
Import preplot data.
|
||||
|
||||
For each preplot file defined in each survey, check for new
|
||||
or modified preplots and (re-)import them into the database.
|
||||
"""
|
||||
|
||||
from glob import glob
|
||||
import configuration
|
||||
import preplots
|
||||
from datastore import Datastore
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
print("Reading configuration")
|
||||
surveys = configuration.surveys()
|
||||
|
||||
print("Connecting to database")
|
||||
db = Datastore()
|
||||
|
||||
print("Reading surveys")
|
||||
for survey in surveys:
|
||||
print(f'Survey: {survey["id"]} ({survey["schema"]})')
|
||||
db.set_survey(survey["schema"])
|
||||
for file in survey["preplots"]:
|
||||
print(f"Preplot: {file['path']}")
|
||||
if not db.file_in_db(file["path"]):
|
||||
print("Importing")
|
||||
preplot = preplots.from_file(file)
|
||||
if type(preplot) is list:
|
||||
print("Saving to DB")
|
||||
db.save_preplots(preplot, file["path"], file["class"], survey["epsg"])
|
||||
elif type(preplot) is str:
|
||||
print(preplot)
|
||||
else:
|
||||
print("Already in DB")
|
||||
|
||||
print("Done")
|
||||
Reference in New Issue
Block a user