From b2ef6d9d4d056f7eb2fb48b7e822c71d7f167e3d Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Mon, 15 Apr 2024 14:06:52 +0200 Subject: [PATCH] Added skip_strip_code argument --- README.md | 5 +++++ thingsdb/client/client.py | 9 ++++++++- thingsdb/version.py | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 435de4d..3b3dc70 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,7 @@ Client().query( code: str, scope: Optional[str] = None, timeout: Optional[int] = None, + skip_strip_code: bool = False, **kwargs: Any ) -> asyncio.Future ``` @@ -335,6 +336,10 @@ Use this method to run `code` in a scope. Raise a time-out exception if no response is received within X seconds. If no time-out is given, the client will wait forever. Defaults to `None`. +- *skip_strip_code (bool, optional)*: + This can be set to `True` which can be helpful when line numbers + in syntax errors need to match. When `False`, the code will be + stripped from white-space and comments to reduce the code size. - *\*\*kwargs (any, optional)*: Can be used to inject variable into the ThingsDB code. diff --git a/thingsdb/client/client.py b/thingsdb/client/client.py index b770848..ef1189a 100644 --- a/thingsdb/client/client.py +++ b/thingsdb/client/client.py @@ -294,6 +294,7 @@ def query( code: str, scope: Optional[str] = None, timeout: Optional[int] = None, + skip_strip_code: bool = False, **kwargs: Any ) -> asyncio.Future: """Query ThingsDB. @@ -311,6 +312,10 @@ def query( Raise a time-out exception if no response is received within X seconds. If no time-out is given, the client will wait forever. Defaults to `None`. + skip_strip_code (bool, optional): + This can be set to True which can be helpful when line numbers + in syntax errors need to match. When False, the code will be + stripped from white-space and comments to reduce the code size. **kwargs (any, optional): Can be used to inject variable into the ThingsDB code. @@ -337,7 +342,9 @@ def query( if scope is None: scope = self._scope - code = strip_code(code) + if skip_strip_code is False: + code = strip_code(code) + data = [scope, code] if kwargs: data.append(kwargs) diff --git a/thingsdb/version.py b/thingsdb/version.py index 1a72d32..b3ddbc4 100644 --- a/thingsdb/version.py +++ b/thingsdb/version.py @@ -1 +1 @@ -__version__ = '1.1.0' +__version__ = '1.1.1'