From b5640954c1a3e7844db7f20ab3d223efcb5a48ca Mon Sep 17 00:00:00 2001 From: tobes Date: Tue, 2 Apr 2013 15:03:09 +0100 Subject: [PATCH] [#708] Minor refactor --- ckan/lib/helpers.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 93f0cb68ac2..ad6ec7fd04e 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -1401,19 +1401,19 @@ def html_auto_link(data): group:... converted to a group link http://... converted to a link ''' + + LINK_FNS = { + 'tag': tag_link, + 'group': group_link, + 'dataset': dataset_link, + 'package': dataset_link, + } + def makelink(matchobj): obj = matchobj.group(1) name = matchobj.group(2) title = '%s:%s' % (obj, name) - if obj == 'tag': - return tag_link({'name': name.strip('"'), - 'title': title}) - elif obj == 'group': - return group_link({'name': name, - 'title': title}) - elif obj in ['dataset', 'package']: - return dataset_link({'name': name, - 'title': title}) + return LINK_FNS[obj]({'name': name.strip('"'), 'title': title}) def link(matchobj): return '%s' \