Skip to content

Commit

Permalink
Add artifact path to option pairs and rename option prevalue property
Browse files Browse the repository at this point in the history
  • Loading branch information
simisimon committed Jan 16, 2025
1 parent 73f814d commit 710c025
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cfgnet/conflicts/conflict_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _detect_modified_options(

# check if both values changed equally
if value_a is None and value_b is None:
if option_a.prevalue_node and option_b.prevalue_node:
if option_a.is_prevalue_node and option_b.is_prevalue_node:
if option_a.children[0].name == option_b.children[0].name:
return None

Expand Down
7 changes: 4 additions & 3 deletions src/cfgnet/network/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def get_pairs(self) -> List:
value_nodes = self.get_nodes(node_type=ValueNode)
return [
{
"artifact": self.rel_file_path,
"option": x.get_options(),
"value": x.name,
"line": x.parent.location,
Expand All @@ -197,7 +198,7 @@ class OptionNode(Node):
Option ID for nested options.
location: int
Line number of the option.
prevalue_node: bool
is_prevalue_node: bool
Indicates whether the option is a prevalue node.
config_type: ConfigType
Type of configuration option/value.
Expand All @@ -213,7 +214,7 @@ def __init__(
super().__init__(name)
self.display_option_id: str = name
self.location: str = location
self.prevalue_node: bool = False
self.is_prevalue_node: bool = False
self.config_type = config_type

def __str__(self):
Expand All @@ -237,7 +238,7 @@ def add_child(self, node: Union[OptionNode, ValueNode]) -> None:
)

if isinstance(node, ValueNode):
self.prevalue_node = True
self.is_prevalue_node = True
if node.config_type == ConfigType.UNKNOWN:
node.config_type = ConfigTypeInferer().get_config_type(
option_name=self.name, value=node.name
Expand Down
6 changes: 2 additions & 4 deletions src/cfgnet/utility/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@


def is_in_test_directory(file_path):
"""
Checks if a given file is in a test directory.
"""
"""Check if a given file is in a test directory."""
# Normalize and split the file path
normalized_path = os.path.normpath(file_path)
directories = normalized_path.split(os.sep)

# Check for 'test' in any directory name
for dir_name in directories:
if 'test' in dir_name.lower():
if "test" in dir_name.lower():
return True
return False

Expand Down

0 comments on commit 710c025

Please sign in to comment.