changeset e236e6ca4f2e in proteus:default
details: https://hg.tryton.org/proteus?cmd=changeset&node=e236e6ca4f2e
description:
        Add option to remove leading and trailing white spaces from char

        issue7914
        review340511008
diffstat:

 proteus/__init__.py |  7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diffs (17 lines):

diff -r dbabd4cdfb5a -r e236e6ca4f2e proteus/__init__.py
--- a/proteus/__init__.py       Thu Sep 08 13:17:54 2022 +0200
+++ b/proteus/__init__.py       Mon Sep 19 21:25:55 2022 +0200
@@ -145,6 +145,13 @@
 
     def __set__(self, instance, value):
         assert isinstance(value, str) or value is None
+        if self.definition.get('strip') and value:
+            if self.definition['strip'] == 'leading':
+                value = value.lstrip()
+            elif self.definition['strip'] == 'trailing':
+                value = value.rstrip()
+            else:
+                value = value.strip()
         super(CharDescriptor, self).__set__(instance, value or '')
 
 

Reply via email to