[Epydoc-commits] SF.net SVN: epydoc: [1628] trunk/epydoc/src/epydoc/apidoc.py
Brought to you by:
edloper
From: <ed...@us...> - 2007-09-24 00:49:05
|
Revision: 1628 http://epydoc.svn.sourceforge.net/epydoc/?rev=1628&view=rev Author: edloper Date: 2007-09-23 17:48:48 -0700 (Sun, 23 Sep 2007) Log Message: ----------- - Added 'strict' option to DottedName constructor -- if true, then raise an exception if we see an ill-formed name. Modified Paths: -------------- trunk/epydoc/src/epydoc/apidoc.py Modified: trunk/epydoc/src/epydoc/apidoc.py =================================================================== --- trunk/epydoc/src/epydoc/apidoc.py 2007-09-24 00:48:14 UTC (rev 1627) +++ trunk/epydoc/src/epydoc/apidoc.py 2007-09-24 00:48:48 UTC (rev 1628) @@ -83,7 +83,7 @@ """A cache of identifier strings that have been checked against _IDENTIFIER_RE and found to be acceptable.""" - def __init__(self, *pieces): + def __init__(self, *pieces, **options): """ Construct a new dotted name from the given sequence of pieces, each of which can be either a C{string} or a C{DottedName}. @@ -98,6 +98,9 @@ of values. In that case, that tuple will be used as the C{DottedName}'s identifiers; it will I{not} be checked to see if it's valid. + + @kwparam strict: if true, then raise an L{InvalidDottedName} + if the given name is invalid. """ if len(pieces) == 1 and isinstance(pieces[0], tuple): self._identifiers = pieces[0] # Optimization @@ -112,10 +115,14 @@ for subpiece in piece.split('.'): if piece not in self._ok_identifiers: if not self._IDENTIFIER_RE.match(subpiece): - #raise DottedName.InvalidDottedName( - # 'Bad identifier %r' % (piece,)) - log.warning("Identifier %r looks suspicious; " - "using it anyway." % piece) + if options.get('strict'): + raise DottedName.InvalidDottedName( + 'Bad identifier %r' % (piece,)) + else: + raise DottedName.InvalidDottedName( + 'Bad identifier %r' % (piece,)) + log.warning("Identifier %r looks suspicious; " + "using it anyway." % piece) self._ok_identifiers.add(piece) self._identifiers.append(subpiece) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |