mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
@@ -163,6 +163,29 @@ class Datastore:
|
||||
# we assume that we are in the middle of a transaction
|
||||
return res
|
||||
|
||||
def set_ntbp(self, path, ntbp, cursor = None):
|
||||
"""
|
||||
Set or remove a sequence's NTBP flag
|
||||
"""
|
||||
if cursor is None:
|
||||
cur = self.conn.cursor()
|
||||
else:
|
||||
cur = cursor
|
||||
|
||||
hash = file_hash(path)
|
||||
qry = """
|
||||
UPDATE raw_lines rl
|
||||
SET ntbp = %s
|
||||
FROM raw_shots rs, files f
|
||||
WHERE rs.hash = f.hash AND rs.sequence = rl.sequence AND f.hash = %s;
|
||||
"""
|
||||
cur.execute(qry, (ntbp, hash))
|
||||
|
||||
if cursor is None:
|
||||
self.maybe_commit()
|
||||
# We do not commit if we've been passed a cursor, instead
|
||||
# we assume that we are in the middle of a transaction
|
||||
|
||||
def save_preplots(self, lines, path, preplot_class, epsg = 0):
|
||||
"""
|
||||
Save preplot data.
|
||||
|
||||
@@ -51,6 +51,11 @@ if __name__ == '__main__':
|
||||
filepath = str(filepath)
|
||||
print(f"Found {filepath}")
|
||||
|
||||
if ntbpRx:
|
||||
ntbp = ntbpRx.search(filepath) is not None
|
||||
else:
|
||||
ntbp = False
|
||||
|
||||
if not db.file_in_db(filepath):
|
||||
print("Importing")
|
||||
|
||||
@@ -62,10 +67,6 @@ if __name__ == '__main__':
|
||||
continue
|
||||
|
||||
file_info = dict(zip(pattern["captures"], match.groups()))
|
||||
if ntbpRx:
|
||||
ntbp = ntbpRx.match(filepath) is not None
|
||||
else:
|
||||
ntbp = False
|
||||
|
||||
p111_data = p111.from_file(filepath)
|
||||
|
||||
@@ -77,5 +78,11 @@ if __name__ == '__main__':
|
||||
else:
|
||||
print("Already in DB")
|
||||
|
||||
# Update the NTBP status to whatever the latest is,
|
||||
# as it might have changed.
|
||||
db.set_ntbp(filepath, ntbp)
|
||||
if ntbp:
|
||||
print("Sequence is NTBP")
|
||||
|
||||
print("Done")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user