This is a descriptor, used to define attributes that act differently when accessed through an enum member and through an enum class. Instance access is the same as property(), but access to an attribute through the enum class will instead look in the class' _member_map_ for
| 182 | return "auto(%r)" % self.value |
| 183 | |
| 184 | class property(DynamicClassAttribute): |
| 185 | """ |
| 186 | This is a descriptor, used to define attributes that act differently |
| 187 | when accessed through an enum member and through an enum class. |
| 188 | Instance access is the same as property(), but access to an attribute |
| 189 | through the enum class will instead look in the class' _member_map_ for |
| 190 | a corresponding enum member. |
| 191 | """ |
| 192 | |
| 193 | def __get__(self, instance, ownerclass=None): |
| 194 | if instance is None: |
| 195 | try: |
| 196 | return ownerclass._member_map_[self.name] |
| 197 | except KeyError: |
| 198 | raise AttributeError( |
| 199 | '%r has no attribute %r' % (ownerclass, self.name) |
| 200 | ) |
| 201 | else: |
| 202 | if self.fget is None: |
| 203 | # look for a member by this name. |
| 204 | try: |
| 205 | return ownerclass._member_map_[self.name] |
| 206 | except KeyError: |
| 207 | raise AttributeError( |
| 208 | '%r has no attribute %r' % (ownerclass, self.name) |
| 209 | ) from None |
| 210 | else: |
| 211 | return self.fget(instance) |
| 212 | |
| 213 | def __set__(self, instance, value): |
| 214 | if self.fset is None: |
| 215 | raise AttributeError( |
| 216 | "<enum %r> cannot set attribute %r" % (self.clsname, self.name) |
| 217 | ) |
| 218 | else: |
| 219 | return self.fset(instance, value) |
| 220 | |
| 221 | def __delete__(self, instance): |
| 222 | if self.fdel is None: |
| 223 | raise AttributeError( |
| 224 | "<enum %r> cannot delete attribute %r" % (self.clsname, self.name) |
| 225 | ) |
| 226 | else: |
| 227 | return self.fdel(instance) |
| 228 | |
| 229 | def __set_name__(self, ownerclass, name): |
| 230 | self.name = name |
| 231 | self.clsname = ownerclass.__name__ |
| 232 | |
| 233 | |
| 234 | class _proto_member: |
no outgoing calls
no test coverage detected