Skip to content

Commit

Permalink
Refactored mappings to more generic relationships in diff markdow…
Browse files Browse the repository at this point in the history
…n output (#750)

* Refactor diff markdown title

* code clean-up

* formatted

* reverted relationships to mappings

* `mappings` => `relationships`

* addressed B024 error
  • Loading branch information
hrshdhgd authored May 8, 2024
1 parent aef85c6 commit 393cdb6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
3 changes: 3 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ lint.extend-ignore = [
"S607", # Starting a process with a partial executable path
"S608", # Possible SQL injection vector through string-based query construction
"S603", # `subprocess` call: check for execution of untrusted input
"B024", # XXX is an abstract base class, but it has no abstract methods
]
lint.exclude = ["src/oaklib/datamodels/*"]
line-length = 120
Expand Down
1 change: 0 additions & 1 deletion src/oaklib/datamodels/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
OWL_VERSION_INFO = "owl:versionInfo"
OWL_VERSION_IRI = "owl:versionIRI"

MAPPING_EDGE_DELETION = "MappingEdgeDeletion"
CLASS_CREATION = "ClassCreation"
NODE_CREATION = "NodeCreation"
NODE_DELETION = "NodeDeletion"
Expand Down
19 changes: 2 additions & 17 deletions src/oaklib/utilities/writers/change_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def handle_edge_creation(self, value):
header = "| Subject | Predicate | Object|"

# Write the "Edges Created" section as a collapsible markdown table
self.write_markdown_table(f"Mappings added: {len(rows)}", header, rows)
self.write_markdown_table(f"Relationships added: {len(rows)}", header, rows)

def handle_edge_change(self, value):
# Create rows for the table
Expand All @@ -82,21 +82,7 @@ def handle_edge_change(self, value):
header = "| Subject | Predicate | Old Object | New Object |"

# Write the "Edges Changed" section as a collapsible markdown table
self.write_markdown_table(f"Mappings changed: {len(rows)}", header, rows)

def handle_mapping_edge_deletion(self, value):
# Create rows for the table
rows = [
f"| {self._format_entity_labels(change.subject)} | {self._format_entity_labels(change.predicate)} |\
{self._format_entity_labels(change.object)} |"
for change in value
]

# Define the header for the table
header = "| Subject | Predicate | Object |"

# Write the "Edges Deleted" section as a collapsible markdown table
self.write_markdown_table(f"Mappings removed: {len(rows)}", header, rows)
self.write_markdown_table(f"Relationships changed: {len(rows)}", header, rows)

def handle_node_move(self, value):
# Create rows for the table
Expand Down Expand Up @@ -353,7 +339,6 @@ def process_changes(self, curie_or_change: Dict[str, Change]):
"NodeDirectMerge": self.handle_node_direct_merge,
"EdgeCreation": self.handle_edge_creation,
"EdgeChange": self.handle_edge_change,
"MappingEdgeDeletion": self.handle_mapping_edge_deletion,
"AddNodeToSubset": self.handle_add_node_to_subset,
# "DatatypeOrLanguageTagChange": self.handle_datatype_or_language_tag_change,
# "LanguageTagChange": self.handle_language_tag_change,
Expand Down

0 comments on commit 393cdb6

Please sign in to comment.