Skip to content
Permalink
Browse files

Handle ConstantsContainer inputs properly.

  • Loading branch information
wsanchez committed Jan 31, 2014
1 parent 769a2d6 commit 8c8746783110528588b6646124305407a96be279
Showing with 8 additions and 2 deletions.
  1. +8 −2 twext/who/util.py
@@ -26,6 +26,8 @@
"iterFlags",
]

from inspect import isclass

from twisted.python.constants import (
Names, Values, Flags, NamedConstant, ValueConstant, FlagConstant,
)
@@ -43,7 +45,7 @@ def __init__(self, sources):
self._methods = {}

for source in sources:
if issubclass(type(source), type):
if isclass(source):
if issubclass(source, CONTAINER_CLASSES):
self._addConstants(source.iterconstants())
self._addMethods(source)
@@ -52,6 +54,10 @@ def __init__(self, sources):
"Unknown constants type: {0}".format(source)
)

elif isinstance(source, ConstantsContainer):
self._addConstants(source.iterconstants())
self._addMethods(source)

elif isinstance(source, CONSTANT_CLASSES):
self._addConstants((source,))

@@ -144,5 +150,5 @@ def iterFlags(flags):



CONTAINER_CLASSES = (ConstantsContainer, Names, Values, Flags)
CONTAINER_CLASSES = (Names, Values, Flags)
CONSTANT_CLASSES = (NamedConstant, ValueConstant, FlagConstant)

0 comments on commit 8c87467

Please sign in to comment.
You can’t perform that action at this time.