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/
|
||||
wiki.pattern=http://wiki.debian.org/%(wikihomepage)s
|
||||
forum.pattern=http://forums.debian.net/memberlist.php?mode=viewprofile&u=%(forumsid)d
|
||||
forum.optional=true
|
||||
|
||||
[miscellaneous]
|
||||
urls=debtags,links,website,search
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf8 -*-
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
@ -72,12 +72,15 @@ def build_urls(fields):
|
|||
if my_config.has_option(section, 'urls'):
|
||||
for url in my_config.get(section, 'urls').split(','):
|
||||
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:
|
||||
data.append(
|
||||
['url', section, url,
|
||||
my_config.get(section, url + '.pattern',
|
||||
False, qfields)])
|
||||
except InterpolationMissingOptionError, e:
|
||||
if not optional:
|
||||
if e.reference in _FIELDNAMES_MAP:
|
||||
data.append(['error', section, url,
|
||||
_('Missing input: %s') % \
|
||||
|
|
Loading…
Reference in a new issue