Exemple #1
0
 def __dir__(cls):
     """
     Return the names of the factory methods that are synthesized for each of
     standard error types in addition to the name of the attributes in the
     base class (object).
     """
     #pylint: disable=R0201
     method_names = [
         'new_' + Converter.capwords_to_underscore(name)
         for name in enumerate_standard_error_names()
     ]
     return sorted(dir(object) + method_names)
Exemple #2
0
    def visit(self, value):
        """
        Dispatch the call to the appropriate method based
        on the type of the input argument

        :type  value: :class:`object`
        :param value: The object to be used for dispatch
        """
        class_name = value.__class__.__name__
        method = self._cache.get(class_name)
        if not method:
            type_name = class_name
            if self._suffix and type_name.endswith(self._suffix):
                type_name = type_name[:-len(self._suffix)]
            type_name = Converter.capwords_to_underscore(type_name)
            method = getattr(self, 'visit_' + type_name)
            self._cache[class_name] = method
        return method(value)