Bases: dict
Dictionary like object which tracks changes.
>>> d = DumpInfo({'hello': 'world'})
>>> d['foo'] = 'bar'
>>> d.changed
['foo']
Bases: object
Turn off static caching.
This makes only sense for callable sources.
Enable the static cache so that the expensive :method:_get_source_dynamic does not get called for every var access.
This makes only sense for callable sources.
Wether this info (might) provide the var variable.
Returns: | if this info should handle this variable |
---|---|
Return type: | bool |
Sets the source of this info. This allows reuse of the same info if needed.
Parameter: | source (object or callable) – retrieve source from which to extract data |
---|
Create an info like dictionary which uses a collection of several info instances.
>>> import Image
>>> image1 = Image.new('RGB',(2,1))
>>> image2 = Image.new('L',(1,2))
>>> info = InfoCollection()
>>> info.list.append(InfoPil(image1))
>>> info.types()
['Pil']
>>> info.dump()
{}
>>> info['Pil.Format']
>>> info.dump()
{'Pil.Format': None}
>>> info['width']
2
>>> info.dump()
{'Pil.Format': None, 'width': 2, 'Pil.Size': (2, 1), 'height': 1}
>>> info.set_source('Pil', image2)
>>> info.dump()
{}
>>> d = info.dump('mode','height')
>>> d
{'Pil.Size': (1, 2), 'width': 1, 'mode': 'L', 'height': 2}
>>> type(d) == DumpInfo
True
Set source of an info from the collection. If source is None, d should be a dictionary otherwise a type. Raises an UnknownTypeError in case an unknown type is given.
Parameters: |
|
---|
Bases: core.information.InfoCache
Wraps a lazy file path access around an image filename.
>>> info = InfoFile('/home/phatch/test.png')
>>> info['foldername']
u'phatch'
>>> sorted(info.dict.keys())
['foldername', 'root']
>>> info['type']
u'png'
>>> sorted(info.dict.keys())
['filename', 'foldername', 'root', 'type']
>>> info.set_source('/home/gimp/world.jpg')
>>> info['type']
u'jpg'
>>> sorted(info.dict.keys())
['filename', 'type']
Bases: core.information.InfoCache
Wraps a lazy PIL var access to an image.
Parameter: | image (Pil.Image/function) – Pil.Image or callable to retrieve it |
---|
>>> import pprint
>>> import Image
>>> image = Image.new('L',(1,2))
>>> info = InfoPil(image)
>>> info.provides('Pil.FormatDescription')
True
>>> pprint.pprint(info.vars)
['Pil.Format',
'Pil.FormatDescription',
'Pil.Size',
'compression',
'height',
'mode',
'width']
>>> sorted(info.dict.keys())
[]
>>> info['mode']
'L'
>>> info['height']
2
>>> info['Pil.Format']
>>> sorted(info.dict.keys())
['Pil.Format', 'Pil.Size', 'height', 'mode', 'width']
>>> info.reset_geometry()
>>> sorted(info.dict.keys())
['Pil.Format', 'Pil.Size', 'mode']
>>> info.extract_all()
>>> pprint.pprint(sorted(info.dict.keys()))
['Pil.Format',
'Pil.FormatDescription',
'Pil.Size',
'compression',
'height',
'mode',
'width']
Extract all used variables from actions.
Parameter: | actions (list of dict) – list of actions |
---|