Allow integer value in extension argument
authorThierry Florac <thierry.florac@onf.fr>
Tue, 19 Jun 2018 11:54:53 +0200
changeset 201 8953ed9beeba
parent 200 198b1598bb50
child 202 c3e3a8416bd7
Allow integer value in extension argument
src/pyams_utils/tales.py
--- a/src/pyams_utils/tales.py	Sun Jun 17 16:31:07 2018 +0200
+++ b/src/pyams_utils/tales.py	Tue Jun 19 11:54:53 2018 +0200
@@ -56,11 +56,16 @@
         if arg.startswith('"') or arg.startswith("'"):
             # may be a quoted string...
             return arg[1:-1]
-        args = arg.split('.')
-        result = econtext.get(args.pop(0))
-        for arg in args:
-            result = getattr(result, arg)
-        return result
+        try:
+            arg = int(arg)  # check integer value
+        except ValueError:
+            args = arg.split('.')
+            result = econtext.get(args.pop(0))
+            for arg in args:
+                result = getattr(result, arg)
+            return result
+        else:
+            return arg
 
     name = name.strip()
     context = econtext.get('context')