forked from jan/debianmemberportfolio
add support for optional patterns
This commit is contained in:
parent
cce0d82f56
commit
3a28db9439
2 changed files with 12 additions and 8 deletions
|
@ -78,6 +78,7 @@ db.pattern=http://db.debian.org/search.cgi?uid=%(username)s&dosearch=Search
|
||||||
alioth.pattern=http://alioth.debian.org/users/%(aliothusername)s/
|
alioth.pattern=http://alioth.debian.org/users/%(aliothusername)s/
|
||||||
wiki.pattern=http://wiki.debian.org/%(wikihomepage)s
|
wiki.pattern=http://wiki.debian.org/%(wikihomepage)s
|
||||||
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)d
|
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)d
|
||||||
|
forum.optional=true
|
||||||
|
|
||||||
[miscellaneous]
|
[miscellaneous]
|
||||||
urls=debtags,links,website,search
|
urls=debtags,links,website,search
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf8 -*-
|
# -*- coding: utf8 -*-
|
||||||
#
|
#
|
||||||
# DDPortfolio service url builder
|
# DDPortfolio service url builder
|
||||||
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
# Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
||||||
#
|
#
|
||||||
# This file is part of DDPortfolio service.
|
# This file is part of DDPortfolio service.
|
||||||
#
|
#
|
||||||
|
@ -72,12 +72,15 @@ def build_urls(fields):
|
||||||
if my_config.has_option(section, 'urls'):
|
if my_config.has_option(section, 'urls'):
|
||||||
for url in my_config.get(section, 'urls').split(','):
|
for url in my_config.get(section, 'urls').split(','):
|
||||||
if my_config.has_option(section, url + '.pattern'):
|
if my_config.has_option(section, url + '.pattern'):
|
||||||
|
optional = my_config.has_option(section, url + '.optional') \
|
||||||
|
and my_config.getboolean(section, url + '.optional') or False
|
||||||
try:
|
try:
|
||||||
data.append(
|
data.append(
|
||||||
['url', section, url,
|
['url', section, url,
|
||||||
my_config.get(section, url + '.pattern',
|
my_config.get(section, url + '.pattern',
|
||||||
False, qfields)])
|
False, qfields)])
|
||||||
except InterpolationMissingOptionError, e:
|
except InterpolationMissingOptionError, e:
|
||||||
|
if not optional:
|
||||||
if e.reference in _FIELDNAMES_MAP:
|
if e.reference in _FIELDNAMES_MAP:
|
||||||
data.append(['error', section, url,
|
data.append(['error', section, url,
|
||||||
_('Missing input: %s') % \
|
_('Missing input: %s') % \
|
||||||
|
|
Loading…
Reference in a new issue