[Zope3-checkins] CVS: Zope3/src/zope/interface - declarations.py:1.5
Steve Alexander
steve@cat-box.net
Wed, 7 May 2003 11:48:58 -0400
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv5127/src/zope/interface
Modified Files:
declarations.py
Log Message:
minor formatting cleanup
=== Zope3/src/zope/interface/declarations.py 1.4 => 1.5 ===
--- Zope3/src/zope/interface/declarations.py:1.4 Tue May 6 07:08:00 2003
+++ Zope3/src/zope/interface/declarations.py Wed May 7 11:48:57 2003
@@ -85,14 +85,10 @@
... I2.__identifier__, I1.__identifier__,
... Interface.__identifier__))
1
-
+
"""
-
self.__signature__ = '\t'.join([iface.__identifier__ for iface in iro])
-
-
-
def __contains__(self, interface):
"""Test whether an interface is in the specification
@@ -294,8 +290,7 @@
>>> [iface.__name__ for iface
... in spec - InterfaceSpecification(I3, I4)]
['I2']
-
-
+
"""
if other is None:
other = _empty
@@ -311,7 +306,7 @@
break
else:
ifaces.append(iface)
-
+
return self.__class__(*ifaces)
@@ -344,7 +339,7 @@
>>> directlyProvides(b, I4)
>>> [i.__name__ for i in b.__implements__]
['I3', 'I2']
-
+
"""
return InterfaceSpecification(_gatherSpecs(cls, []))
@@ -356,7 +351,7 @@
def __init__(self, *interfaces):
ImplementsSpecification.__init__(self, *interfaces)
self.__signature__ = "only(%s)" % self.__signature__
-
+
class ProvidesSpecification(InterfaceSpecification):
@@ -407,9 +402,9 @@
['IFooFactory']
>>> [i.__name__ for i in C().__providedBy__]
['IFoo']
-
+
"""
-
+
# Get an ObjectSpecification bound to either an instance or a class,
# depending on how we were accessed.
if inst is None:
@@ -492,7 +487,7 @@
def __signature__(self):
ob = self.ob
-
+
provides = getattr(ob, '__provides__', None)
if provides is not None:
result = [provides.__signature__]
@@ -513,7 +508,7 @@
for c in mro:
try: flags = c.__flags__
except AttributeError: flags = heap
-
+
if flags & heap:
try:
dict = c.__dict__
@@ -538,11 +533,11 @@
implements.__class__.__mro__)
)
result.append(`implements`)
-
+
else:
# Normal case
-
+
implements = dict.get('__implements__')
if implements is not None:
@@ -847,10 +842,10 @@
# Try to make sure we were called from a class def
if (locals is frame.f_globals) or ('__module__' not in locals):
- raise TypeError(name+" can only be used from a class definition.")
+ raise TypeError(name+" can be used only from a class definition.")
if '__providedBy__' in locals:
- raise TypeError( name+" can only be used once in a class definition.")
+ raise TypeError(name+" can be used only once in a class definition.")
locals["__implements__"] = spec
locals["__providedBy__"] = _objectSpecificationDescriptor
@@ -1119,14 +1114,14 @@
implements = getattr(cls, '__implements__', None)
if implements is not None:
implements = OnlyImplementsSpecification(implements)
-
+
return implements
k = '__implements__'
else:
d = _implements_reg
k = cls
-
+
return d.get(k)
def _setImplements(cls, v):
@@ -1152,7 +1147,7 @@
>>> r = _flattenSpecs((I3, spec), [])
>>> int(r == [I3, I1, I2])
1
-
+
"""
try:
# catch bad spec by seeing if we can iterate over it
@@ -1160,7 +1155,7 @@
except TypeError:
# Must be a bad spec
raise exceptions.BadImplements(specs)
-
+
for spec in ispecs:
# We do this rather than isinstance because it works w proxies classes
if InterfaceClass in spec.__class__.__mro__:
@@ -1191,11 +1186,11 @@
_flattenSpecs([implements], []))
stop = 1
_setImplements(cls, implements)
-
+
result.append(implements)
else:
stop = 0
-
+
if not stop:
for b in cls.__bases__:
_gatherSpecs(b, result)