Commit 780ffa98 authored by Romain Bignon's avatar Romain Bignon

Revert "Allow ResultsCondition to compare timedelta"

This reverts commit bd7891f2.
parent 95246ba2
......@@ -173,7 +173,7 @@ def analyze_application(app, script_name):
script_name, app.VERSION.replace('.', '\\&.'))
name = ".SH NAME\n%s \- %s" % (script_name, application.SHORT_DESCRIPTION)
condition = """.SH CONDITION
The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted.
The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format.
The syntax of one expression is "\\fBfield operator value\\fR". The field to test is always the left member of the expression.
.LP
The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields.
......
......@@ -100,8 +100,7 @@ class ResultsCondition(IResultsCondition):
def is_valid(self, obj):
import weboob.tools.date as date_utils
import re
from datetime import date, datetime, timedelta
from datetime import date, datetime
d = obj.to_dict()
# We evaluate all member of a list at each iteration.
for _or in self.condition:
......@@ -124,12 +123,6 @@ class ResultsCondition(IResultsCondition):
splitted_datetime = condition.right.split(' ')
tocompare = datetime(*([int(x) for x in splitted_datetime[0].split('-')] +
[int(x) for x in splitted_datetime[1].split(':')]))
elif isinstance(d[condition.left], timedelta):
time_dict = re.match('^\s*((?P<hours>\d+)\s*h)?\s*((?P<minutes>\d+)\s*m)?\s*((?P<seconds>\d+)\s*s)?\s*$',
condition.right).groupdict()
tocompare = timedelta(seconds=int(time_dict['seconds'] or "0"),
minutes=int(time_dict['minutes'] or "0"),
hours=int(time_dict['hours'] or "0"))
else:
tocompare = typed(condition.right)
myeval = functions[condition.op](tocompare, d[condition.left])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment