tweaked LeaseFilter to allow lists instead of tuples for clip and alive
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 6 Feb 2024 10:46:32 +0000 (11:46 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 6 Feb 2024 10:46:32 +0000 (11:46 +0100)
PLC/LeaseFilter.py

index 84f84b7..c7e31bc 100644 (file)
@@ -28,11 +28,13 @@ class LeaseFilter(Filter):
         'alive': Mixed(
             Parameter(int, "int_timestamp: leases alive at that time"),
             Parameter(str, "str_timestamp: leases alive at that time"),
-            Parameter(tuple, "timeslot: the leases alive during this timeslot")),
-        'clip':  Mixed(
+            Parameter(list, "timeslot: the leases alive during this timeslot"),
+            ),
+        'clip': Mixed(
             Parameter(int, "int_timestamp: leases alive after that time"),
             Parameter(str, "str_timestamp: leases alive after that time"),
-            Parameter(tuple, "timeslot: the leases alive during this timeslot")),
+            Parameter(list, "timeslot: the leases alive during this timeslot"),
+            ),
         ########## macros
         # {'day' : 0} : all leases from today and on
         # {'day' : 1} : all leases today (localtime at the myplc)
@@ -92,7 +94,7 @@ class LeaseFilter(Filter):
             # the lease is alive at that time if from <= alive <= until
             alive = LeaseFilter.quote(alive)
             return LeaseFilter.sql_time_in_range(alive, 't_from', 't_until')
-        elif isinstance(alive, tuple):
+        elif isinstance(alive, (tuple, list)):
             (f, u) = alive
             f = LeaseFilter.quote(f)
             u = LeaseFilter.quote(u)
@@ -105,7 +107,7 @@ class LeaseFilter(Filter):
         if isinstance(clip, int) or isinstance(clip, str):
             start = LeaseFilter.quote(clip)
             return LeaseFilter.sql_timeslot_after('t_from', 't_until', start)
-        elif isinstance(clip, tuple):
+        elif isinstance(clip, (tuple, list)):
             (f, u) = clip
             f = LeaseFilter.quote(f)
             u = LeaseFilter.quote(u)