From 7d8786c1d2f3416c92ff0d0ae51fca3b2f89f9df Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 7 Mar 2013 18:22:49 +0100 Subject: [PATCH] Code cleanup. --- dosagelib/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dosagelib/helpers.py b/dosagelib/helpers.py index 9a7a5825c..fd0750b12 100644 --- a/dosagelib/helpers.py +++ b/dosagelib/helpers.py @@ -8,17 +8,18 @@ def queryNamer(paramName, usePageUrl=False): @classmethod def _namer(cls, imageUrl, pageUrl): """Get URL query part.""" - url = (imageUrl, pageUrl)[usePageUrl] + url = pageUrl if usePageUrl else imageUrl return getQueryParams(url)[paramName][0] return _namer -def regexNamer(regex): +def regexNamer(regex, usePageUrl=False): """Get name from regular expression.""" @classmethod def _namer(cls, imageUrl, pageUrl): """Get first regular expression group.""" - mo = regex.search(imageUrl) + url = pageUrl if usePageUrl else imageUrl + mo = regex.search(url) if mo: return mo.group(1) return _namer