comparison babel/messages/catalog.py @ 352:20d10066a42a

The builtin checkers don't require setuptools any longer, validate_format and python_format from the checkers module are merged into one now.
author aronacher
date Tue, 17 Jun 2008 19:54:34 +0000
parents 7215876bdf89
children 1355e4014496
comparison
equal deleted inserted replaced
351:7215876bdf89 352:20d10066a42a
566 566
567 For every message which fails validation, this method yield a 567 For every message which fails validation, this method yield a
568 ``(message, errors)`` tuple, where ``message`` is the `Message` object 568 ``(message, errors)`` tuple, where ``message`` is the `Message` object
569 and ``errors`` is a sequence of `TranslationError` objects. 569 and ``errors`` is a sequence of `TranslationError` objects.
570 570
571 :note: this feature requires ``setuptools``/``pkg_resources`` to be
572 installed; if it is not, this method will simply return an empty
573 iterator
574 :rtype: ``iterator`` 571 :rtype: ``iterator``
575 """ 572 """
576 checkers = [] 573 checkers = []
577 try: 574 try:
578 from pkg_resources import working_set 575 from pkg_resources import working_set
579 except ImportError: 576 except ImportError:
580 return 577 from babel.messages.checkers import builtin_checkers
578 checkers.extend(builtin_checkers)
581 else: 579 else:
582 for entry_point in working_set.iter_entry_points('babel.checkers'): 580 for entry_point in working_set.iter_entry_points('babel.checkers'):
583 checkers.append(entry_point.load()) 581 checkers.append(entry_point.load())
584 for message in self._messages.values(): 582 for message in self._messages.values():
585 errors = [] 583 errors = []
586 for checker in checkers: 584 for checker in checkers:
587 try: 585 try:
588 checker(self, message) 586 checker(self, message)
589 except TranslationError, e: 587 except TranslationError, e:
590 errors.append(e) 588 errors.append(e)
591 if errors: 589 if errors:
592 yield message, errors 590 yield message, errors
593 591
594 def get(self, id, context=None): 592 def get(self, id, context=None):
595 """Return the message with the specified ID and context. 593 """Return the message with the specified ID and context.
596 594
597 :param id: the message ID 595 :param id: the message ID
Copyright (C) 2012-2017 Edgewall Software