information

class core.information.DumpInfo(d=None)

Bases: dict

Dictionary like object which tracks changes.

>>> d = DumpInfo({'hello': 'world'})
>>> d['foo'] = 'bar'
>>> d.changed
['foo']
class core.information.InfoCache(source=None)

Bases: object

disable_cache()

Turn off static caching.

This makes only sense for callable sources.

enable_cache()

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.

extract_all()
Extract all values, which is usefull for inspector.
extract_others()
Extract all other vars. Does nothing by default. (to be overwritten)
provides(var)

Wether this info (might) provide the var variable.

Returns:if this info should handle this variable
Return type:bool
set_source(source)

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
class core.information.InfoCollection

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
append_info(info)
clear()
dump(*vars)
provides(var)
set_source(d, source=None)

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:
  • d (dict/str) – dictionary {type: source} or type
  • source – source (pil image, filename, ...)
types()
class core.information.InfoFile(source=None)

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']
class core.information.InfoPexif
class core.information.InfoPil(source=None)

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_others()
Extract all other vars
reset_geometry()
exception core.information.UnknownTypeError
Bases: exceptions.Exception
core.information.extract_info_pexif(info, image)
pexif = Pil EXIF
core.information.get_module(var)
core.information.get_modules(vars)
core.information.get_vars(actions)

Extract all used variables from actions.

Parameter:actions (list of dict) – list of actions
core.information.is_string(x)

Previous topic

imageTable

Next topic

message

This Page