| |
- Propertied(object)
-
- Enumeration
- EnumerationChoice
- dict(object)
-
- EnumerationSet
- object
-
- EnumerationProperty
class Enumeration(Propertied) |
|
A choice from an enumerated set of data values
This class also operates as the base-type for the
enumeration properties, via the data-type-definition
API. |
|
- Method resolution order:
- Enumeration
- Propertied
- object
Methods defined here:
- __cmp__(self, other)
- Compare this value to another value
- __init__(self, name='', *arguments, **named)
- __repr__(self)
- Return a code-like representation of this object
- choice(self)
- Get the choice object associated with this value or None
- value(self)
- Get the value associated with this choice
Class methods defined here:
- allInstances(cls) from type
- Return cls instances for each of this class's set
- check(cls, value) from type
- Check whether value is of cls type, and has the same set
- coerce(cls, value) from type
- Coerce a value into an Enumeration value
Accepted types:
Enumeration objects
integers/longs
([name,name,name],remainder) tuples
[name,name,name,value] lists (values are |'d together)
- fromValue(cls, value) from type
- Create from an integer value
- parse(cls, value) from type
- Create from a string value
Possible formats:
"coreName"
"23"
"friendlyName"
Data and other attributes defined here:
- dataType = 'enumeration'
- name = <BasicProperty 'name'>
- Data-value choice within one of our sets
- set = None
Methods inherited from Propertied:
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AD1FB0>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class EnumerationChoice(Propertied) |
|
A particular choice within an enumeration set
The enumeration choice is a particular choice
stored within the enumeration set. Its name
is used to index the choice within its set, while
its value is the actual value being enumerated. |
|
- Method resolution order:
- EnumerationChoice
- Propertied
- object
Methods defined here:
- __repr__(self)
- Get a code-like representation of this choice
Data and other attributes defined here:
- friendlyName = <BasicProperty 'friendlyName'>
- Friendly name used to describe this choice to users
- name = <BasicProperty 'name'>
- The internal name/key used to identify the choice
- value = <BasicProperty 'value'>
- The data value associated with this choice
Methods inherited from Propertied:
- __init__(self, *arguments, **namedarguments)
- Propertied object initialisation, allows passing in initial values for properties by name
- __str__(self)
- Get a friendly representation of the object
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01AD1FF0>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
|
class EnumerationProperty(object) |
|
Mix-in for Enumeration properties to return/accept enums |
|
Data and other attributes defined here:
- __dict__ = <dictproxy object at 0x01AD15D0>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'EnumerationProperty' objects>
- list of weak references to the object (if defined)
|
class EnumerationSet(dict) |
|
EnumerationSet classes (set from which values may be chosen)
The struct mimics a C enumeration with
names mapping to integer values.
Note:
name values must be hashable
XXX Needed features:
* ordered sets (e.g. month names)
* multiple input (name -> value) mappings
* preferred name-set (value -> name) mappings
* set-union, difference |
|
- Method resolution order:
- EnumerationSet
- dict
- object
Methods defined here:
- append(self, choice)
- Register a choice with the set
- getName(self, value)
- Get the name of a choice whose value matches value or None
- new(self, **namedarguments)
- Add a new choice to this enumeration
namedarguments -- passed to self.choiceClass initialiser
Class methods defined here:
- check(cls, value) from type
- Check whether item is compatible with this set
- checkSingle(cls, item) from type
- Check whether item is compatible with this set
- coerce(cls, value) from type
- Coerce a value to an enumeration-set value
Accepted value formats:
None # empty dictionary/set
[ stringValue, ... ] # value == name
{ 'name': value, ... }
[ (name,value), ... ]
[ choiceClass(), ... ]
[ { }, ... ] # arguments for choice-class
- coerceSingle(cls, item) from type
- Coerce an individual value/values to an item
This doesn't actually add the item, as the cls
doesn't store such data.
Accepted formats:
'key' # str or unicode only, converted to unicode for key
('key',value)
{'name':'key','value':value,...} # passed directly to the initialiser
choiceClass instance
Data and other attributes defined here:
- __dict__ = <dictproxy object at 0x01AD15D0>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'EnumerationSet' objects>
- list of weak references to the object (if defined)
- choiceClass = <class 'basictypes.enumeration.EnumerationChoice'>
- A particular choice within an enumeration set
The enumeration choice is a particular choice
stored within the enumeration set. Its name
is used to index the choice within its set, while
its value is the actual value being enumerated.
Methods inherited from dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- x.__contains__(y) <==> y in x
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __init__(...)
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- __iter__ = itervalues(...)
- D.itervalues() -> an iterator over the values of D
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- clear(...)
- D.clear() -> None. Remove all items from D.
- copy(...)
- D.copy() -> a shallow copy of D
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
- items(...)
- D.items() -> list of D's (key, value) pairs, as 2-tuples
- iteritems(...)
- D.iteritems() -> an iterator over the (key, value) items of D
- iterkeys(...)
- D.iterkeys() -> an iterator over the keys of D
- itervalues(...)
- D.itervalues() -> an iterator over the values of D
- keys(...)
- D.keys() -> list of D's keys
- pop(...)
- D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem(...)
- D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
- setdefault(...)
- D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(...)
- D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]
- values(...)
- D.values() -> list of D's values
Data and other attributes inherited from dict:
- __new__ = <built-in method __new__ of type object at 0x1E0B5CC8>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
- fromkeys = <built-in method fromkeys of type object at 0x01349550>
- dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
| |