Skip to content

Commit

Permalink
Fix: quotes inside features names with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhorcas committed Jul 25, 2024
1 parent ae3226f commit f369b0e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions flamapy/core/models/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def is_binary_op(self) -> bool:
return not self.is_unique_term() and not self.is_unary_op()

def __str__(self) -> str:
data = self.data.value if self.is_op() else self.data
data = self.data.value if self.is_op() else safename(str(self.data))
if self.left and self.right:
return f'{data}[{self.left}][{self.right}]'
if self.left and not self.right:
Expand All @@ -73,11 +73,11 @@ def _get_pretty_str_node(node: 'Node') -> str:
if node.is_binary_op():
res = f'({res})'
else:
res = str(node)
res = safename(str(node))
return res

def pretty_str(self) -> str:
data = self.data.value if self.is_op() else self.data
data = self.data.value if self.is_op() else safename(str(self.data))
left = Node._get_pretty_str_node(self.left) if self.left is not None else ''
right = Node._get_pretty_str_node(self.right) if self.right is not None else ''

Expand Down Expand Up @@ -302,3 +302,7 @@ def get_clause_from_or_node(node: Node) -> list[Any]:
term = node.right.data if node.right.is_term() else f'-{node.right.left.data}'
clause.append(term)
return clause


def safename(name: str) -> str:
return f'"{name}"' if ' ' in name else name

0 comments on commit f369b0e

Please sign in to comment.