Skip to content

Commit

Permalink
Fix: error in safename for feature and attributes in Writers
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhorcas committed Aug 22, 2024
1 parent 8b65706 commit 4801497
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def parse_type_value(value: Any) -> str:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def prettify(xml: str) -> bytes:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _get_ctc_info(ast_node: Node) -> dict[str, Any]:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_ctc_info(ast_node: Node) -> Dict[str, Any]:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_constraints(constraints: list[Constraint]) -> list[str]:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def process_attributes(
logging.warning("This attributes are not yet supported in flama.")
else:
# Handle unexpected case
attribute_name = attribute_context.getText().replace('"', '')
raise ValueError(
f"Unknown attribute type for: {attribute_context.getText().replace('"', '')}"
f"Unknown attribute type for: {attribute_name}"
)

attributes_dict[key] = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def serialize_constraint(ctc: Constraint) -> str:


def safename(name: str) -> str:
return f'"{name}"' if any(char in name for char in safecharacters()) else name
return f'"{name}"' if any(char not in safecharacters() for char in name) else name


def safecharacters() -> str:
Expand Down

0 comments on commit 4801497

Please sign in to comment.