Skip to content

Bug: BaseSpaceConfigParser.find_children_w_parents() #836

Description

@bminnix

Environment

  • Python version: 3.12.4
  • netutils version: 1.17.2a0

Expected Behavior

Defining the parent_pattern and child_pattern returns only child lines that are in the parent even if both parent and child are matched.

>>> parsed_object.find_children_w_parents(parent_pattern="context local", child_pattern="  logging", match_type="regex")
['  logging something', '  logging something else']

Observed Behavior

Defining the parent_pattern and child_pattern returns everything under the parent.

parsed_config.find_children_w_parents(parent_pattern="context local", child_pattern="  logging", match_type="regex")
['  something not logging', '  logging something', '  logging something else', '  something else not logging']

Steps to Reproduce

>>> from netutils.config.parser import BaseSpaceConfigParser

>>> config = '''context local
 something not logging
 logging something
 logging something else
 something else not logging
'''

>>> parsed_object = BaseSpaceConfigParser(config)
>>> parsed_config.find_children_w_parents(parent_pattern="context local", child_pattern=" logging", match_type="regex")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions