Code cleanup.

This commit is contained in:
Bastian Kleineidam 2013-03-07 18:22:49 +01:00
parent 736d9aa8cf
commit 7d8786c1d2

View file

@ -8,17 +8,18 @@ def queryNamer(paramName, usePageUrl=False):
@classmethod @classmethod
def _namer(cls, imageUrl, pageUrl): def _namer(cls, imageUrl, pageUrl):
"""Get URL query part.""" """Get URL query part."""
url = (imageUrl, pageUrl)[usePageUrl] url = pageUrl if usePageUrl else imageUrl
return getQueryParams(url)[paramName][0] return getQueryParams(url)[paramName][0]
return _namer return _namer
def regexNamer(regex): def regexNamer(regex, usePageUrl=False):
"""Get name from regular expression.""" """Get name from regular expression."""
@classmethod @classmethod
def _namer(cls, imageUrl, pageUrl): def _namer(cls, imageUrl, pageUrl):
"""Get first regular expression group.""" """Get first regular expression group."""
mo = regex.search(imageUrl) url = pageUrl if usePageUrl else imageUrl
mo = regex.search(url)
if mo: if mo:
return mo.group(1) return mo.group(1)
return _namer return _namer