Changeset 36:b78fa8f898ea in stamper


Ignore:
Timestamp:
Aug 11, 2014, 8:24:13 AM (10 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

If a provided date-based filter is not valid, show a warning message
and ignore the filtering, instead of raising an error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stamper/stamper.py

    r32 r36  
    128128        else:
    129129            # maybe they are giving us a fixed date
    130             filter_from = datetime.strptime(stamp_filter, DATE_FORMAT)
    131             filter_from = filter_from.replace(hour=0, minute=0, second=0)
    132             filter_to = filter_from + timedelta(days=1)
     130            try:
     131                filter_from = datetime.strptime(stamp_filter, DATE_FORMAT)
     132            except:
     133                # nothing to be used as a filter, go on, printing a warning
     134                print('[warning] invalid date filter: ' + stamp_filter)
     135            else:
     136                filter_from = filter_from.replace(hour=0, minute=0, second=0)
     137                filter_to = filter_from + timedelta(days=1)
    133138
    134139        return filter_from, filter_to
Note: See TracChangeset for help on using the changeset viewer.