Skip to content

Commit

Permalink
Updated the parser to support double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-vd-aardweg committed Apr 17, 2023
1 parent 73979f8 commit 9dc3558
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hydrolib/core/dflowfm/xyn/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ def parse(filepath: Path) -> Dict:
Raises:
ValueError: if a line in the file cannot be parsed
or if the name contains whitespace while not surrounded with
single quotes.
single or double quotes.
"""

def is_surrounded_by_quotes(name: str) -> bool:
def is_surrounded_by_single_quotes(name: str) -> bool:
return name.startswith("'") and name.endswith("'")

def is_surrounded_by_double_quotes(name: str) -> bool:
return name.startswith('"') and name.endswith('"')

def is_surrounded_by_quotes(name: str) -> bool:
return is_surrounded_by_single_quotes(
name
) or is_surrounded_by_double_quotes(name)

def may_contain_whitespace(name: str) -> bool:
return is_surrounded_by_quotes(name)

Expand Down

0 comments on commit 9dc3558

Please sign in to comment.