Package glue :: Package ligolw :: Module ligolw :: Class LLWNameAttr
[hide private]
[frames] | no frames]

Class LLWNameAttr

source code

object --+        
basestring --+    
       unicode --+
Known Subclasses:

Baseclass to hide pattern-matching of various element names. Subclasses must provide a .dec_pattern compiled regular expression defining a group "Name" that identifies the meaningful portion of the string, and a .enc_pattern that gives a format string to be used with "%" to reconstrct the full string.

This is intended to be used to provide the enc and dec functions for an attributeproxy instance.


>>> import re
>>> class Test(Element):
...     class TestName(LLWNameAttr):
...             dec_pattern = re.compile(r"(?P<Name>[a-z0-9_]+):test\Z")
...             enc_pattern = u"%s:test"
...     Name = attributeproxy(u"Name", enc = TestName.enc, dec = TestName)
>>> x = Test()
>>> x.Name = u"blah"
>>> # internally, suffix has been appended
>>> x.getAttribute("Name")
>>> # but attributeproxy reports original value
>>> x.Name
Instance Methods [hide private]

Inherited from unicode: __add__, __contains__, __eq__, __format__, __ge__, __getattribute__, __getitem__, __getnewargs__, __getslice__, __gt__, __hash__, __le__, __len__, __lt__, __mod__, __mul__, __ne__, __repr__, __rmod__, __rmul__, __sizeof__, __str__, capitalize, center, count, decode, encode, endswith, expandtabs, find, format, index, isalnum, isalpha, isdecimal, isdigit, islower, isnumeric, isspace, istitle, isupper, join, ljust, lower, lstrip, partition, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

Inherited from unicode (private): _formatter_field_name_split, _formatter_parser

Inherited from object: __delattr__, __init__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

Class Methods [hide private]
enc(cls, name) source code
Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, name) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, name)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)