-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* retrofit parser module * fix module-string
- Loading branch information
Showing
4 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
in Python 3.10 the parser module has been removed. some old nodes | ||
(namely: formula.py / formula2.py / profile_mk2.py) make light use of that module. | ||
The main goal of this module is to suppress a startup import exception caused by | ||
the missing parser module, and at the same time offer the basic features of that | ||
module as used by these nodes. | ||
""" | ||
|
||
try: | ||
import parser | ||
|
||
except (ImportError, ModuleNotFoundError) as err: | ||
|
||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class Expr(str): | ||
str_formula: str | ||
def compile(self): | ||
# print('use mock') | ||
return compile(self.str_formula, '<string>', mode='eval') | ||
|
||
parser = lambda: None | ||
parser.expr = lambda str_formula: Expr(str_formula) | ||
|