r13419 - in AGX/agx.io.uml/trunk/src/agx/io/uml: . tests
"johannes raggam" <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.archetypes.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: thet
Date: Tue Jan 18 12:20:35 2011
New Revision: 13419
Modified:
AGX/agx.io.uml/trunk/src/agx/io/uml/core.py
AGX/agx.io.uml/trunk/src/agx/io/uml/interfaces.py
AGX/agx.io.uml/trunk/src/agx/io/uml/tests/test_uml.py
AGX/agx.io.uml/trunk/src/agx/io/uml/utils.py
Log:
remove whitespace
Modified: AGX/agx.io.uml/trunk/src/agx/io/uml/core.py
==============================================================================
--- AGX/agx.io.uml/trunk/src/agx/io/uml/core.py (original)
+++ AGX/agx.io.uml/trunk/src/agx/io/uml/core.py Tue Jan 18 12:20:35 2011
@@ -24,7 +24,7 @@
class UMLElement(Node):
implements(IUMLElement, ICallableNode)
-
+
def __call__(self):
"""Does nothing but fullfill contract.
"""
@@ -41,43 +41,43 @@
@property
def stereotypes(self):
return self.filtereditems(IStereotype)
-
+
def stereotype(self, stereotypename):
for stereotype in self.stereotypes:
if stereotype.name == stereotypename:
return stereotype
return None
-
+
class Profile(UMLElement):
- implements(IProfile)
+ implements(IProfile)
class Stereotype(UMLElement):
implements(IStereotype)
-
+
def __init__(self, name=None):
super(UMLElement, self).__init__(name)
- self._profile = None
+ self._profile = None
def _getprofile(self):
if self._profile is not None:
return self.node(self._profile)
return None
-
+
def _setprofile(self, profileinstance):
self._profile = profileinstance.uuid
-
+
profile = property(_getprofile, _setprofile)
-
+
@property
def taggedvalues(self):
return self.filtereditems(ITaggedValue)
-
+
def taggedvalue(self, taggedvaluename):
for tgv in self.taggedvalues:
if tgv.name == taggedvaluename:
return tgv
- return None
-
+ return None
+
class TaggedValue(UMLElement):
implements(ITaggedValue)
@@ -111,4 +111,4 @@
@property
def datatypes(self):
- return self.filtereditems(IDatatype)
\ No newline at end of file
+ return self.filtereditems(IDatatype)
Modified: AGX/agx.io.uml/trunk/src/agx/io/uml/interfaces.py
==============================================================================
--- AGX/agx.io.uml/trunk/src/agx/io/uml/interfaces.py (original)
+++ AGX/agx.io.uml/trunk/src/agx/io/uml/interfaces.py Tue Jan 18 12:20:35 2011
@@ -4,7 +4,7 @@
"""Literature:
[1] OMG Unified Modeling LanguageTM (OMG UML), Superstructure. Version 2.2.
-[2] The Unified Modeling Language Reference Manual Second Edition.
+[2] The Unified Modeling Language Reference Manual Second Edition.
James Rumbaugh, Ivar Jacobson, Grady Booch. Addison-Wesley, 2005
[3] Unified Modeling Language Specification (version 2.1)
@@ -34,7 +34,7 @@
# convenience
stereotypes = Attribute(u'list of INode filtered contained stereotypes')
-
+
def stereotype(name):
"""returns stereotype by name."""
@@ -43,7 +43,7 @@
###############################################################################
class IProfile(IUMLElement):
- """UML Profile
+ """UML Profile
"""
class IDatatype(IUMLElement, ILeaf):
@@ -53,10 +53,10 @@
class IStereotype(IUMLElement):
"""UML stereotype
"""
- profile = Attribute(u"UID of UML profile this stereotype belongs to.")
+ profile = Attribute(u"UID of UML profile this stereotype belongs to.")
taggedvalue = Attribute(u"List of ITaggedvalue filtered contained tagged"
"values.")
-
+
def taggedvalue(name):
"""returns tagged value by tag name.
"""
@@ -76,7 +76,7 @@
"""An UML Package element.
"""
umlprofile = Attribute(u"list of UML profiles loaded with this package")
-
+
# convenience
packages = Attribute(u'list of INode filtered contained packages')
classes = Attribute(u'list of INode filtered contained classes')
@@ -140,16 +140,16 @@
class IGeneralization(IUMLElement):
"""UML Generalization Element.
-
+
see [3], pg. 71
-
- A generalization is a taxonomic relationship between a more general
- classifier and a more specific classifier. Each instance of the specific
- classifier is also an indirect instance of the general classifier. Thus,
- the specific classifier inherits the features of the more general
+
+ A generalization is a taxonomic relationship between a more general
+ classifier and a more specific classifier. Each instance of the specific
+ classifier is also an indirect instance of the general classifier. Thus,
+ the specific classifier inherits the features of the more general
classifier.
-
- An owned element of of some classifier.
+
+ An owned element of of some classifier.
"""
specific = Attribute(u'References the specializing classifier in the '
'Generalization relationship. Subsets '
@@ -157,14 +157,14 @@
general = Attribute(u'References the general classifier in the '
'Generalization relationship. Subsets '
'DirectedRelationship::target')
-
+
class IInterfaceRealization(IUMLElement):
"""UML InterfaceRealization Element.
-
+
see [3], pg. 89
- An InterfaceRealization is a specialized Realization relationship between a
- Classifier and an Interface. This relationship signifies that the realizing
+ An InterfaceRealization is a specialized Realization relationship between a
+ Classifier and an Interface. This relationship signifies that the realizing
classifier conforms to the contract specified by the Interface.
"""
contract = Attribute(u'References the Interface specifying the conformance '
@@ -175,42 +175,42 @@
'the Interface to which it points). '
'(Subsets Dependency::client, '
'Element::owner.')
-
-
+
+
class IAssociation(IUMLElement):
""" UML Association Element.
-
+
see [3], pg. 39
-
- "An association describes a set of tuples whose values refer to typed
+
+ "An association describes a set of tuples whose values refer to typed
instances. An instance of an association is called a link."
-
- The association itself is very general. It can be a simple association, a
+
+ The association itself is very general. It can be a simple association, a
navigable association, a shared or composite aggregation (and more).
-
- It can be member of a classifier or part of a package, dependend on its
+
+ It can be member of a classifier or part of a package, dependend on its
usage.
"""
-
+
memberEnds = Attribute(u"Each end represents participation of instances of "
"the classifier connected to the end in links of "
"the association. This is an ordered association. "
"Subsets Namespace::member.")
ownedEnds = Attribute(u"The ends that are owned by the association itself. "
- "This is an ordered association. Subsets"
- "Association::memberEnd Classifier::feature, and"
+ "This is an ordered association. Subsets"
+ "Association::memberEnd Classifier::feature, and"
"Namespace::ownedMember.")
class IAssociationEnd(IUMLElement):
- """OwnedElement of Associations or Classes."""
-
+ """OwnedElement of Associations or Classes."""
+
type = Attribute(u'Element this end points to.')
-
+
lowervalue = Attribute(u'Multiplicity lower range')
-
+
uppervalue = Attribute(u'Multiplicity upper range')
-
+
navigable = Attribute(u'Indicates wether the end is navigable or not, bool')
aggregationkind = Attribute(u"see [3], pg. 38: AggregationKind is an "
@@ -223,27 +223,27 @@
"i.e., the composite object has responsibility"
"for the existence and storage of the composed"
"objects (parts).")
-
+
class IDependency(IUMLElement):
""" UML Dependency Element.
-
+
see [3], pg. 62
-
- "A dependency is a relationship that signifies that a single or a set of
- model elements requires other model elements for their specification or
- implementation. This means that the complete semantics of the depending
- elements is either semantically or structurally dependent on the definition
+
+ "A dependency is a relationship that signifies that a single or a set of
+ model elements requires other model elements for their specification or
+ implementation. This means that the complete semantics of the depending
+ elements is either semantically or structurally dependent on the definition
of the supplier element(s).
"""
-
+
client = Attribute(u'The element(s) dependent on the supplier element(s). '
'In some cases (such as a Trace Abstraction) the '
'assignment of direction (that is, the designation of '
'the client element) is at the discretion of the ',
'modeler, and is a stipulation. Subsets '
'DirectedRelationship::source.')
-
+
supplier = Attribute(u'The element(s) independent of the client element(s), '
'in the same respect and the same dependency '
'relationship. In some directed dependency '
@@ -254,4 +254,4 @@
'may stipulate a sense of dependency suitable for '
'their domain, which makes a more abstract element '
'dependent on that which is more specific. Subsets '
- 'DirectedRelationship::target.')
\ No newline at end of file
+ 'DirectedRelationship::target.')
Modified: AGX/agx.io.uml/trunk/src/agx/io/uml/tests/test_uml.py
==============================================================================
--- AGX/agx.io.uml/trunk/src/agx/io/uml/tests/test_uml.py (original)
+++ AGX/agx.io.uml/trunk/src/agx/io/uml/tests/test_uml.py Tue Jan 18 12:20:35 2011
@@ -19,14 +19,14 @@
'../utils.txt',
]
-datadir = os.path.join(os.path.dirname(__file__), '..', '_api', 'data')
+datadir = os.path.join(os.path.dirname(__file__), '..', '_api', 'data')
def test_suite():
XMLConfig('meta.zcml', zope.component)()
-
+
return unittest.TestSuite([
doctest.DocFileSuite(
- file,
+ file,
optionflags=optionflags,
globs={'interact': interact,
'pprint': pprint,
@@ -35,5 +35,5 @@
])
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Modified: AGX/agx.io.uml/trunk/src/agx/io/uml/utils.py
==============================================================================
--- AGX/agx.io.uml/trunk/src/agx/io/uml/utils.py (original)
+++ AGX/agx.io.uml/trunk/src/agx/io/uml/utils.py Tue Jan 18 12:20:35 2011
@@ -11,76 +11,76 @@
class Inheritance(Node):
"""Tree giving the inheritance tree point of view of arbitary UML-elements.
-
- By adapting an UML element this tree shows the generelizations of the
+
+ By adapting an UML element this tree shows the generelizations of the
element as a Node tree.
-
+
On __getitem__ it returns the Inheritance adapter of the more general
element.
"""
-
+
def __init__(self, context):
"""@param context: some UMLElement to get information from."""
super(Inheritance, self).__init__()
self.__name__ = context.uuid
self.context = context
-
+
def _inherited(self):
for generelization in self.context.filtereditems(IGeneralization):
yield generelization.general
-
+
def __iter__(self):
"""iterates over uuids of more general UML-elements."""
for element in self._inherited():
yield element.uuid
-
+
iterkeys = __iter__
-
+
def itervalues(self):
"""iterates over more general UML-elements."""
for key in self.keys():
yield self[key]
-
+
def __getitem__(self, uuid):
"""fetches the more general UML-element by key."""
general = self.context.node(uuid)
item = Inheritance(general)
item.__parent__ = self
return item
-
+
@property
def noderepr(self):
- return '%s on %s' % (super(Inheritance, self).noderepr,
- self.context.__name__)
+ return '%s on %s' % (super(Inheritance, self).noderepr,
+ self.context.__name__)
@property
def all(self):
- """flattend (list) from the traversed tree of more general
+ """flattend (list) from the traversed tree of more general
UML-elements.
@return: list of UMLElements.
"""
- result = list()
+ result = list()
result.append(self)
- for value in self.values():
+ for value in self.values():
subs = value.all
for sub in subs:
if sub.__name__ in [r.__name__ for r in result]:
continue
- result.append(sub)
+ result.append(sub)
return result
class Inheritors(object):
- """Adapter giving the inverse inheritance point of view of arbitary
- UML-elements.
+ """Adapter giving the inverse inheritance point of view of arbitary
+ UML-elements.
"""
-
+
def __init__(self, context):
"""@param context: some UMLElement to get information from."""
self.context = context
-
+
@property
def direct(self):
- """UMLElements which are inheriting diretcly (less general) from the
+ """UMLElements which are inheriting diretcly (less general) from the
given UMLElement
@return: list of UMLElements.
@@ -89,15 +89,15 @@
for node in self.context._index.values():
if IGeneralization.providedBy(node) \
and node.general is self.context:
- result.append(node.specific)
- return result
+ result.append(node.specific)
+ return result
@property
def all(self):
- """UMLElements which are inheriting (less general) from the
- given UMLElement, following the tree down: childs of childs are
+ """UMLElements which are inheriting (less general) from the
+ given UMLElement, following the tree down: childs of childs are
included.
-
+
@return: list of UMLElements.
"""
result = self.direct
@@ -106,17 +106,17 @@
continue
result += Inheritors(node).all
return result
-
+
class Associations(object):
- """Adapter to get information about an UMLElements associations.
+ """Adapter to get information about an UMLElements associations.
"""
-
+
def __init__(self, context):
self.context = context
-
+
def _match_end(self, end):
return IAssociationEnd.providedBy(end)
-
+
def _find_associations_ends(self, partipants):
partuuids = [p.uuid for p in partipants]
result = list()
@@ -127,10 +127,10 @@
@property
def direct(self):
- """All associations which are starting or ending directly at the given
+ """All associations which are starting or ending directly at the given
UML element.
-
- @return: list of AssociationEnd instances.
+
+ @return: list of AssociationEnd instances.
"""
return self._find_associations_ends([self.context])
@@ -138,23 +138,23 @@
def inherited(self):
"""All associations which are inherited from more general UML-Elements,
the direct associations are not included.
-
- @return: list of AssociationEnd instances.
- """
+
+ @return: list of AssociationEnd instances.
+ """
inheritance = Inheritance(self.context)
- subs = [el.context for el in inheritance.all
+ subs = [el.context for el in inheritance.all
if el.context is not self.context]
- return self._find_associations_ends(subs)
-
+ return self._find_associations_ends(subs)
+
@property
- def directlyrealized(self):
- """All associations which are on Interfaces with InterfaceRealizations
- directly on this UMLElement. This includes Associations from more
+ def directlyrealized(self):
+ """All associations which are on Interfaces with InterfaceRealizations
+ directly on this UMLElement. This includes Associations from more
general Interfaces of the contracted Interface (it takes the Inheritance
tree of the Relaized interface into account).
-
- @return: list of AssociationEnd instances.
- """
+
+ @return: list of AssociationEnd instances.
+ """
participatinginterfaces = list()
for directrealization in \
self.context.filtereditems(IInterfaceRealization):
@@ -162,34 +162,34 @@
for inheritance in Inheritance(directrealization.contract).all:
if inheritance.context.uuid not in participatinguuids:
participatinginterfaces.append(inheritance.context)
- return self._find_associations_ends(participatinginterfaces)
-
+ return self._find_associations_ends(participatinginterfaces)
+
@property
def inheritedrealized(self):
- """All associations which are on Interfaces with InterfaceRealizations
- from more general UMLElements of this element. This includes
- Associations from more general Interfaces of the contracted Interface
+ """All associations which are on Interfaces with InterfaceRealizations
+ from more general UMLElements of this element. This includes
+ Associations from more general Interfaces of the contracted Interface
(it takes the Inheritance tree of the Relaized interface into account).
- It does not include directly realized associations.
-
- @return: list of AssociationEnd instances.
- """
- ends = list()
+ It does not include directly realized associations.
+
+ @return: list of AssociationEnd instances.
+ """
+ ends = list()
inherited = [el.context for el in Inheritance(self.context).all]
for node in inherited:
associations = self.__class__(node)
for end in associations.directlyrealized:
if end.uuid not in [e.uuid for e in ends]:
ends.append(end)
- return ends
-
+ return ends
+
@property
def all(self):
- """All associations: direct, directlyrealized, inherited and
+ """All associations: direct, directlyrealized, inherited and
inheritedrealized.
- ``return``
- list of AssociationEnd instances.
+ ``return``
+ list of AssociationEnd instances.
"""
result = self.direct
for end in self.directlyrealized + \
@@ -200,26 +200,26 @@
return result
class Aggregations(Associations):
- """Adapter to get information about an UMLElements aggregations.
+ """Adapter to get information about an UMLElements aggregations.
"""
-
+
def _match_end(self, end):
return super(Aggregations, self)._match_end(end) \
and end.aggregationkind in AssociationEnd.AGGREGATIONS
-
+
class Aggregators(Associations):
- """Adapter to get information about an UMLElements aggregators.
-
+ """Adapter to get information about an UMLElements aggregators.
+
This is done by adding a filter so the inherited methods of this class instances
- are taking onyl aggregations into account.
+ are taking onyl aggregations into account.
"""
-
+
def _oppositeend(self, end):
- oppositeends = [e for e in end.association.memberEnds if e is not end]
+ oppositeends = [e for e in end.association.memberEnds if e is not end]
oppositeends += [e for e in end.association.ownedEnds if e is not end]
assert(len(oppositeends)==1)
return oppositeends[0]
-
+
def _match_end(self, end):
if not super(Aggregators, self)._match_end(end):
return False
@@ -229,13 +229,13 @@
def _find_associations_ends(self, partipants):
ends = super(Aggregators, self)._find_associations_ends(partipants)
return [self._oppositeend(e) for e in ends]
-
+
@property
def allparticipants(self):
"""All UMLElements the AssociationEnds of `all` are pointing to.
-
+
``return``
- list of UMLElements
+ list of UMLElements
"""
results = list()
for end in self.all:
@@ -244,29 +244,29 @@
if inheritor.uuid not in [r.uuid for r in results]:
results.append(inheritor)
return results
-
+
UNSET = object()
-
+
class TaggedValues(object):
"""Adapter to get information about an UMLElements TaggedValues.
"""
-
+
def __init__(self, context):
self.context = context
-
- def direct(self, tag, stereotype=None, default=UNSET):
+
+ def direct(self, tag, stereotype=None, default=UNSET):
"""Access only tgvs directly applied through stereotypes on element.
-
- ``tag``
- The name of the tag to fetch the value from. If no ``stereotype``
+
+ ``tag``
+ The name of the tag to fetch the value from. If no ``stereotype``
argument is given it is expected here in the form: ``STEREOTYPE:TAG``.
-
+
``stereotype``
- Name of the stereotype. Can be omitted if it is part of ``tag``
+ Name of the stereotype. Can be omitted if it is part of ``tag``
argument.
-
+
``return``
- some value
+ some value
"""
if stereotype is None:
stereotype, tag = tag.split(':')
@@ -276,8 +276,8 @@
taggedvalue = stereotypeob.taggedvalue(tag)
if taggedvalue is None:
return default
- return taggedvalue.value
-
+ return taggedvalue.value
+
def _normalized_tgv_pairs(self, tag, stereotype, alternatives):
normalized = list()
if stereotype is None:
@@ -290,39 +290,39 @@
else:
normalized.append(list(reversed(alternative.split(':'))))
return normalized
-
+
def _direct_with_alternatives(self, tag, stereotype, alternatives):
result = list()
- for ltag, lstereotype in self._normalized_tgv_pairs(tag, stereotype,
+ for ltag, lstereotype in self._normalized_tgv_pairs(tag, stereotype,
alternatives):
value = self.direct(ltag, lstereotype)
if value is not UNSET:
- result.append(self.direct(ltag, lstereotype))
+ result.append(self.direct(ltag, lstereotype))
return result
-
+
def inherited(self, tag, stereotype=None, alternatives=[], aggregate=True):
"""Access tgvs on this element and more general elements of element.
-
- ``tag``
- The name of the tag to fetch the value from. If no ``stereotype``
+
+ ``tag``
+ The name of the tag to fetch the value from. If no ``stereotype``
argument is given it is expected here in the form: ``STEREOTYPE:TAG``.
-
+
``stereotype``
- Name of the stereotype. Can be omitted if it is part of ``tag``
+ Name of the stereotype. Can be omitted if it is part of ``tag``
argument.
-
- ``alternatives``
+
+ ``alternatives``
Look in more general elements also for stereotypes/tags in this list.
- Expects either a tuple ``tag, stereotype`` or a tag prefixed with
+ Expects either a tuple ``tag, stereotype`` or a tag prefixed with
stereotyoe as described above. Lookup order: arguments, order of list,
first one hit wins.
-
+
``aggregate``
- When ``True`` a list of all found values is returned. Otherwise it
+ When ``True`` a list of all found values is returned. Otherwise it
stops on the first matching tag and returns its value.
-
+
``return``
- A value, or in case of ``aggregate`` a list of values.
+ A value, or in case of ``aggregate`` a list of values.
"""
result = self._direct_with_alternatives(tag, stereotype, alternatives)
if not aggregate and result:
@@ -337,29 +337,29 @@
if not aggregate:
return UNSET
return result
-
+
def namespaced(self, tag, stereotype=None, alternatives=[], aggregate=True):
"""Access tgvs on this element and elements down in namespace.
-
- ``tag``
- The name of the tag to fetch the value from. If no ``stereotype``
+
+ ``tag``
+ The name of the tag to fetch the value from. If no ``stereotype``
argument is given it is expected here in the form: ``STEREOTYPE:TAG``.
-
+
``stereotype``
- Name of the stereotype. Can be omitted if it is part of ``tag``
+ Name of the stereotype. Can be omitted if it is part of ``tag``
argument.
-
- ``alternatives``
+
+ ``alternatives``
Look in more general elements also for stereotypes/tags in this list.
- Expects either a tuple ``tag, stereotype`` or a tag prefixed with
+ Expects either a tuple ``tag, stereotype`` or a tag prefixed with
stereotyoe as described above.
-
+
``aggregate``
- When ``True`` a list of all found values is returned. Otherwise it
+ When ``True`` a list of all found values is returned. Otherwise it
stops on the first matching tag and returns its value.
-
+
``return``
- A value, or in case of ``aggregate`` a list of values.
+ A value, or in case of ``aggregate`` a list of values.
"""
result = self._direct_with_alternatives(tag, stereotype, alternatives)
if not aggregate and result:
@@ -371,4 +371,4 @@
tgv = TaggedValues(self.context.__parent__)
if not aggregate:
return tgv.namespaced(tag, stereotype, alternatives, aggregate)
- return result + tgv.namespaced(tag, stereotype, alternatives, aggregate)
\ No newline at end of file
+ return result + tgv.namespaced(tag, stereotype, alternatives, aggregate)
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl