Skip to content

Commit

Permalink
Replaced the outdated grako library to parse WKT with TatSu (#1587)
Browse files Browse the repository at this point in the history
* Replaced the outdated grako library to parse WKT with TatSu

* formatted files with isort and black

* added more examples of WKT strings

---------

Co-authored-by: roll <[email protected]>
  • Loading branch information
jze and roll authored Jan 24, 2024
1 parent bb4eeb3 commit 90f717f
Show file tree
Hide file tree
Showing 6 changed files with 400 additions and 309 deletions.
4 changes: 2 additions & 2 deletions frictionless/fields/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def value_reader(cell: Any):

# WKT
elif self.format == "wkt":
parser = platform.wkt.WktParser()
parser = platform.wkt.Parser()

def value_reader(cell: Any):
if not isinstance(cell, str):
return None
try:
parser.parse(cell, rule_name="wkt_representation")
parser.parse(cell)
except Exception:
return None
return cell
Expand Down
3 changes: 0 additions & 3 deletions frictionless/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def inner(*args: Any, **kwargs: Any):
try:
return func(*args, **kwargs)
except Exception:
if name == "wkt" and sys.version_info >= (3, 10):
note = "WKT is not supported in Python3.10+ (grako is unmaintained)"
raise platform.frictionless.FrictionlessException(note)
module = import_module("frictionless.exception")
note = f'Please install "frictionless[{name}]"'
raise module.FrictionlessException(note)
Expand Down
2 changes: 1 addition & 1 deletion frictionless/vendors/wkt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .parser import WktParser
from .parser import Parser
Loading

0 comments on commit 90f717f

Please sign in to comment.