Skip to content

Commit

Permalink
Remove comments when parsing pom.xml files
Browse files Browse the repository at this point in the history
  • Loading branch information
simisimon committed Nov 19, 2024
1 parent 2a190b2 commit ce5c316
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/cfgnet/plugins/concept/maven_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from typing import Optional, Tuple, List
from lxml import etree as ET
from lxml.etree import _Element
from lxml.etree import _Element, _Comment

from cfgnet.config_types.config_types import ConfigType
from cfgnet.network.nodes import (
Expand Down Expand Up @@ -63,10 +63,14 @@ def _parse_config_file(
maven_tree = ET.parse(abs_file_path)
tree_root = maven_tree.getroot()

# Remove namespace prefixes
# Remove namespace prefixes and comments
for elem in tree_root.getiterator():
if elem.tag is not ET.Comment:
elem.tag = ET.QName(elem).localname
for child in list(elem):
if isinstance(child, _Comment):
elem.remove(child)

# Remove unused namespace declarations
ET.cleanup_namespaces(tree_root)

Expand Down Expand Up @@ -322,7 +326,7 @@ def get_config_type(self, option_name: str, value: str = "") -> ConfigType:
if option_name in ("includes", "excludes", "filter", "file"):
return ConfigType.PATH

if any(x in option_name for x in ["directory", "Directory", "Path"]):
if option_name in ("directory", "Directory", "Path"):
return ConfigType.PATH

if option_name in ("url", "organizationUrl", "picUrl", "downloadUrl"):
Expand Down

0 comments on commit ce5c316

Please sign in to comment.