Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
hooks:
- id: ruff
args: [ --exit-zero ]
- id: ruff-format
15 changes: 14 additions & 1 deletion pyneuroml/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Copyright 2024 NeuroML contributors
"""

import re
import logging
import pprint
import typing
Expand Down Expand Up @@ -369,8 +370,20 @@ def create_annotation(
# indent
if indent > 0:
annotation = textwrap.indent(annotation, " " * indent)
# remove xml header

# xml issues
if "xml" in serialization_format:
# replace rdf:_1 etc with rdf:li
# our LEMS definitions only know rdf:li
# https://github.com/RDFLib/rdflib/issues/1374#issuecomment-885656850
rdfli_pattern = re.compile(r"\brdf:_\d+\b")
annotation = rdfli_pattern.sub("rdf:li", annotation)

# remove nodeids for rdflib BNodes: these aren't required
rdfbnode_pattern = re.compile(r' rdf:nodeID="\S+"')
annotation = rdfbnode_pattern.sub("", annotation)

# remove xml header, not used when embedding into other NeuroML files
if xml_header is False:
annotation = annotation[annotation.find(">") + 1 :]

Expand Down