# HG changeset patch
# User Christian Boos <cboos@neuf.fr>
# Date 1228730009 -3600
# Node ID 082c52be44dd03a5c9416996ce73ec0976f12115
# Parent 6a7faccec71fb2e7d30a74e4f91d8446e5445d20
Turning missing parameter error into a warning, with a sample integration with Babel error reporting.
Currently the 'babel' logger is not registered when the extraction is done from the setuptools, which is the common case when working with Trac. That's why this logger is not used but the distutils one is used.
I've not found a way from the logging API to detect whether one logger was already initialized or not, in order to use the appropriate logger, so the patch is unfinished but ''worksforme'' ;-)
diff -r 6a7faccec71f -r 082c52be44dd genshi/filters/i18n.py
|
a
|
b
|
|
| 948 | 948 | if self.params: |
| 949 | 949 | param = self.params.pop(0) |
| 950 | 950 | else: |
| 951 | | raise IndexError("'%s' parameters given to 'i18n:%s' but more " |
| 952 | | "expressions used in '%s', line %s" % ( |
| 953 | | ', '.join(self.orig_params), |
| 954 | | self.directive.tagname, |
| 955 | | os.path.basename(pos[0]), pos[1])) |
| | 951 | param = 'expr%d' % len(self.values) |
| | 952 | log = logging.getLogger('babel') |
| | 953 | from distutils import log |
| | 954 | log.error("'%s' parameters given to 'i18n:%s' but more " |
| | 955 | "expressions used in '%s', line %s", |
| | 956 | ', '.join(self.orig_params), self.directive.tagname, |
| | 957 | os.path.basename(pos[0]), pos[1]) |
| 956 | 958 | self.string.append('%%(%s)s' % param) |
| 957 | 959 | self.events.setdefault(self.stack[-1], []).append(None) |
| 958 | 960 | self.values[param] = (kind, data, pos) |