annotate src/parpg/bGrease/component/field.py @ 144:a6b25c2cedab

Move comment to correct place.
author KarstenBock@gmx.net
date Mon, 03 Oct 2011 13:05:23 +0200
parents 0f659c7675f6
children
rev   line source
92
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
1 #############################################################################
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
2 #
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
3 # Copyright (c) 2010 by Casey Duncan and contributors
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
4 # All Rights Reserved.
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
5 #
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
6 # This software is subject to the provisions of the MIT License
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
7 # A copy of the license should accompany this distribution.
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
8 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
9 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
10 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
11 #
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
12 #############################################################################
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
13
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
14 __version__ = '$Id$'
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
15
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
16 import operator
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
17 from parpg.bGrease.geometry import Vec2d, Vec2dArray, Rect
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
18 from parpg.bGrease import color
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
19
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
20 # Allowed field types -> default values
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
21 types = {int:lambda: 0,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
22 float:lambda: 0.0,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
23 bool:lambda: False,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
24 str:lambda:"",
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
25 object:lambda:None,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
26 Vec2d:lambda: Vec2d(0,0),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
27 Vec2dArray:lambda: Vec2dArray(),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
28 color.RGBA: lambda: color.RGBA(0.0, 0.0, 0.0, 0.0),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
29 Rect: lambda: Rect(0.0, 0.0, 0.0, 0.0),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
30 list: lambda: list(),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
31 dict: lambda: dict(),
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
32 }
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
33
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
34 class Schema(dict):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
35 """Field schema definition for custom components"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
36
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
37 def __init__(self, **fields):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
38 for ftype in fields.values():
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
39 assert ftype in types, fname + " has an illegal field type"
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
40 self.update(fields)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
41
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
42
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
43 class FieldAccessor(object):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
44 """Facade for manipulating a field for a set of entities"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
45
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
46 __field = None
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
47 __entities = None
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
48 __attrs = None
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
49 __getter = None
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
50 __parent_getters = ()
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
51
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
52 def __init__(self, field, entities, attrs=()):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
53 self.__field = field
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
54 self.__entities = entities
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
55 field_getter = operator.attrgetter(field.name)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
56 self.__attrs = attrs
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
57 if attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
58 getters = [field_getter] + [operator.attrgetter(attr) for attr in attrs]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
59 def get(entity):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
60 value = entity
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
61 for getter in getters:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
62 value = getter(value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
63 return value
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
64 self.__getter = get
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
65 self.__parent_getters = getters[:-1]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
66 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
67 self.__getter = field_getter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
68
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
69 def __getattr__(self, name):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
70 """Return a FieldAccessor for the child attribute"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
71 return self.__class__(self.__field, self.__entities, self.__attrs + (name,))
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
72
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
73 def __setattr__(self, name, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
74 if value is self:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
75 return # returned by mutators
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
76 if hasattr(self.__class__, name):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
77 # Set local attr
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
78 self.__dict__[name] = value
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
79 elif not name.startswith('_'):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
80 getattr(self, name).__set__(value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
81 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
82 raise AttributeError("Cannot set field attribute: %s" % name)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
83
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
84 @property
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
85 def __setter(self):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
86 """Return the proper setter function for setting the field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
87 if not self.__attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
88 return setattr
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
89 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
90 parent_getters = self.__parent_getters
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
91 def setter(data, name, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
92 for getter in parent_getters:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
93 data = getter(data)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
94 setattr(data, name, value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
95 self.__setter = setter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
96 return setter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
97
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
98 def __set__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
99 """Set field values en masse"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
100 # Mass set field attr
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
101 setter = self.__setter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
102 component = self.__field.component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
103 if self.__attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
104 name = self.__attrs[-1]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
105 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
106 name = self.__field.name
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
107 if isinstance(value, FieldAccessor):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
108 # Join set between two entity sets
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
109 if not self.__attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
110 cast = self.__field.cast
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
111 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
112 cast = lambda x: x
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
113 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
114 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
115 setter(component[entity], name, cast(value[entity]))
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
116 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
117 pass
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
118 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
119 if not self.__attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
120 value = self.__field.cast(value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
121 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
122 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
123 setter(component[entity], name, value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
124 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
125 pass
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
126
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
127 def __getitem__(self, entity):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
128 """Return the field value for a single entity (used for joins)"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
129 if entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
130 return self.__getter(self.__field.component[entity])
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
131 raise KeyError(entity)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
132
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
133 def __contains__(self, entity):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
134 return entity in self.__entities
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
135
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
136 def __repr__(self):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
137 return '<%s %s @ %x>' % (
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
138 self.__class__.__name__,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
139 '.'.join((self.__field.name,) + self.__attrs), id(self))
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
140
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
141 def __nonzero__(self):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
142 return bool(self.__entities)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
143
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
144 def __iter__(self):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
145 """Return an iterator of all field values in the set"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
146 component = self.__field.component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
147 getter = self.__getter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
148 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
149 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
150 data = component[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
151 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
152 continue
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
153 yield getter(data)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
154
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
155 ## batch comparison operators ##
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
156
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
157 def __match(self, value, op):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
158 component = self.__field.component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
159 getter = self.__getter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
160 matches = set()
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
161 add = matches.add
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
162 if isinstance(value, FieldAccessor):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
163 # Join match between entity sets
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
164 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
165 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
166 data = component[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
167 other = value[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
168 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
169 continue
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
170 if op(getter(data), other):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
171 add(entity)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
172 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
173 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
174 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
175 data = component[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
176 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
177 continue
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
178 if op(getter(data), value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
179 add(entity)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
180 return matches
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
181
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
182 def __eq__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
183 """Return an entity set of all entities with a matching field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
184 return self.__match(value, operator.eq)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
185
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
186 def __ne__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
187 """Return an entity set of all entities not matching field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
188 return self.__match(value, operator.ne)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
189
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
190 def __gt__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
191 """Return an entity set of all entities with a greater field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
192 return self.__match(value, operator.gt)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
193
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
194 def __ge__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
195 """Return an entity set of all entities with a greater or equal field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
196 return self.__match(value, operator.ge)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
197
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
198 def __lt__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
199 """Return an entity set of all entities with a lesser field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
200 return self.__match(value, operator.lt)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
201
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
202 def __le__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
203 """Return an entity set of all entities with a lesser or equal field value"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
204 return self.__match(value, operator.le)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
205
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
206 def _contains(self, values):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
207 """Return an entity set of all entities with a field value contained in values"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
208 return self.__match(values, operator.contains)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
209
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
210 ## Batch in-place mutator methods
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
211
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
212 def __mutate(self, value, op):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
213 component = self.__field.component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
214 if self.__attrs:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
215 name = self.__attrs[-1]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
216 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
217 name = self.__field.name
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
218 getter = self.__getter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
219 setter = self.__setter
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
220 if isinstance(value, FieldAccessor):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
221 # Join between entity sets
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
222 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
223 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
224 data = component[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
225 other = value[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
226 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
227 continue
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
228 setter(data, name, op(getter(data), other))
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
229 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
230 for entity in self.__entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
231 try:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
232 data = component[entity]
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
233 except KeyError:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
234 continue
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
235 setter(data, name, op(getter(data), value))
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
236 return self
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
237
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
238 def __iadd__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
239 return self.__mutate(value, operator.iadd)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
240
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
241 def __isub__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
242 return self.__mutate(value, operator.isub)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
243
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
244 def __imul__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
245 return self.__mutate(value, operator.imul)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
246
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
247 def __idiv__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
248 return self.__mutate(value, operator.idiv)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
249
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
250 def __itruediv__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
251 return self.__mutate(value, operator.itruediv)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
252
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
253 def __ifloordiv__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
254 return self.__mutate(value, operator.ifloordiv)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
255
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
256 def __imod__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
257 return self.__mutate(value, operator.imod)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
258
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
259 def __ipow__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
260 return self.__mutate(value, operator.ipow)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
261
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
262 def __ilshift__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
263 return self.__mutate(value, operator.ilshift)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
264
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
265 def __irshift__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
266 return self.__mutate(value, operator.irshift)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
267
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
268 def __iand__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
269 return self.__mutate(value, operator.iand)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
270
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
271 def __ior__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
272 return self.__mutate(value, operator.ior)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
273
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
274 def __ixor__(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
275 return self.__mutate(value, operator.ixor)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
276
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
277
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
278 class Field(object):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
279 """Component field metadata and accessor interface"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
280
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
281 def __init__(self, component, name, type, accessor_factory=FieldAccessor):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
282 self.component = component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
283 self.name = name
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
284 self.type = type
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
285 self.default = types.get(type)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
286 self.accessor_factory = accessor_factory
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
287
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
288 def cast(self, value):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
289 """Cast value to the appropriate type for thi field"""
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
290 if self.type is not object:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
291 return self.type(value)
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
292 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
293 return value
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
294
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
295 def accessor(self, entities=None):
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
296 """Return the field accessor for the entities in the component,
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
297 or all entities in the set specified that are also in the component
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
298 """
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
299 if entities is None or entities is self.component.entities:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
300 entities = self.component.entities
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
301 else:
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
302 entities = entities & self.component.entities
0f659c7675f6 Changed "import bGrease" to "import parpg.bGrease".
KarstenBock@gmx.net
parents: 66
diff changeset
303 return self.accessor_factory(self, entities)