Skip to content

Commit

Permalink
[AutoTimer] fix filter/tags for PY3 #430
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleyel committed Mar 22, 2021
1 parent ec38d0a commit c20907d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions autotimer/src/AutoTimerResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ def get(name, default=None):
ret = req.args.get(name)
return six.ensure_str(ret[0]) if ret else default

def getA(name, default=None):
name = six.ensure_binary(name)
ret = req.args.get(name)
return [six.ensure_str(x) for x in ret] if ret else default

id = get("id")
timer = None
newTimer = True
Expand Down Expand Up @@ -329,10 +334,10 @@ def get(name, default=None):
timer.maxduration = None

# Includes
title = get("title")
shortdescription = get("shortdescription")
description = get("description")
dayofweek = get("dayofweek")
title = getA("title")
shortdescription = getA("shortdescription")
description = getA("description")
dayofweek = getA("dayofweek")
if title or shortdescription or description or dayofweek:
includes = timer.include
title = [unquote(x) for x in title] if title else includes[0]
Expand All @@ -346,10 +351,10 @@ def get(name, default=None):
timer.include = (title, shortdescription, description, dayofweek)

# Excludes
title = get("!title")
shortdescription = get("!shortdescription")
description = get("!description")
dayofweek = get("!dayofweek")
title = getA("!title")
shortdescription = getA("!shortdescription")
description = getA("!description")
dayofweek = getA("!dayofweek")
if title or shortdescription or description or dayofweek:
excludes = timer.exclude
title = [unquote(x) for x in title] if title else excludes[0]
Expand All @@ -362,7 +367,7 @@ def get(name, default=None):
while '' in dayofweek: dayofweek.remove('')
timer.exclude = (title, shortdescription, description, dayofweek)

tags = get("tag")
tags = getA("tag")
if tags:
while '' in tags: tags.remove('')
timer.tags = [unquote(x) for x in tags]
Expand Down

0 comments on commit c20907d

Please sign in to comment.