nope/py-helpers/prepare_code/post_processor.py
Martin Karkowski 90783572b4 # 1.4.1
- Fixes:
    - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
      - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth`
    - Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value`
      - `lib\helpers\mapMethods.ts` has been adapted
    - `lib\pubSub\nopePubSubSystem.ts` contains the following fixes:
      - fixing typo of method `updateMatching`
  - Modified:
    - `lib\pubSub\nopePubSubSystem.ts`:
      - throws error if `register` method doest not contain a topic.
      - Adapted the behavior of `_patternbasedPullData`. If no default default value is present -> the function returns an empty array.
2022-10-08 07:15:33 +02:00

44 lines
1015 B
Python

replacers = {
"console.log": "print",
"console.error": "print",
"Error(": "Exception(",
"true": "True",
"false": "False",
"JSON.stringify": "json.dumps",
"JSON.parse": "json.loads",
"const _this = this;": "",
"_this": "self",
"this": "self",
" Set": " set",
" Map": " dict",
"toLowerCase": "lower",
"toUpperCase": "upper",
".push(": ".append(",
".indexOf(": ".index(",
"Array.from": "list",
"null": "None",
'"null"': "None",
'"undefined"': "None",
'undefined': "None",
'self = self': "",
"__definition_of__": "",
"@property()": "@property",
}
def post_process(code: str) -> str:
""" Post processes the code. This results in adapting the code by replacing default
elements like console.log
Args:
code (str): The code that have to be adapted
Returns:
str: The adapted code
"""
for org, new in replacers.items():
code = code.replace(org, new)
return code