Commit 052fcb37 authored by Jgiannelos's avatar Jgiannelos
Browse files

Merge branch 'serialize-elements' into 'main'

Serialize OSM element when logging

See merge request !18
parents 44d0a9c6 63efcde4
Pipeline #1483 passed with stages
in 2 minutes and 30 seconds
......@@ -15,6 +15,18 @@ class ElementHandler:
self.failfast = failfast
self.inconsistencies = []
def serialize(self, change):
tags = {}
for tag in change.tags:
tags[tag.k] = tag.v
return {
"id": change.id,
"changeset": change.changeset,
"version": change.version,
"tags": tags,
}
def exists(self, table, osm_id):
query = f"SELECT * FROM {table} WHERE osm_id = {osm_id}"
cursor = self.conn.cursor()
......@@ -29,7 +41,7 @@ class ElementHandler:
f"Element with id:{change.id} shouldn't exist"
)
self.inconsistencies.append(
{"type": "should be deleted", "id": change.id}
{"type": "should be deleted", "element": self.serialize(change)}
)
break
......@@ -45,7 +57,9 @@ class ElementHandler:
raise InconsistentChangeException(
f"Element with id:{change.id} should exist"
)
self.inconsistencies.append({"type": "should exist", "id": change.id})
self.inconsistencies.append(
{"type": "should exist", "element": self.serialize(change)}
)
def log_inconsistencies(self):
for elem in self.inconsistencies:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment