selfietorium.libselfietorium package

Submodules

selfietorium.libselfietorium.FakeCamera module

selfietorium.libselfietorium.PicamCamera module

selfietorium.libselfietorium.Printer module

selfietorium.libselfietorium.SendTweet module

selfietorium.libselfietorium.USBCamera module

selfietorium.libselfietorium.configuration module

A library that provides configuration loading and saving for the selfietorium project

This is a python library for handling the configuration for selfietorium.

Notes: Pyxser is a library that aparently also provides object serialisation, but attempts to locate this package in the repos has so far failed. This class therefore provides specific serialisation methods mentioned in: http://www.diveintopython3.net/serializing.html

Example

To Save a configuration file (which will have default values):

import configuration
cfile = ConfigFile("boothsettings.json")
c.Save()
class selfietorium.libselfietorium.configuration.ConfigFile(iniFile)

A Configuration object - this object serialises / deserialises data to JSON format.

Load()

Load data from config file into object.

Save()

Save data to config file.

selfietorium.libselfietorium.pygameTextRectangle module

class selfietorium.libselfietorium.pygameTextRectangle.TextRectException(message=None)

Exception thrown if text is too large to fit within the drawn recatangle

selfietorium.libselfietorium.pygameTextRectangle.render_textrect(string, font, rect, text_color, background_color, justification=0)

Returns a surface containing the passed text string, reformatted to fit within the given rect, word-wrapping as necessary. The text will be anti-aliased.

Parameters:
  • string – the text you wish to render - \n begins a new line.
  • font – Font object
  • rect – A rectstyle giving the size of the surface requested.
  • text_color – a three-byte tuple of the rgb value of the text color.
  • ex (0, 0, 10) = BLACK
  • justification – +-+————————+ |0|(default) left-justified| +-+————————+ |1|horizontally centered | +-+————————+ |2|right-justified | +-+————————+
Returns:

A surface object with the text rendered onto it.

Raises:

1 Raises a TextRectException if the text won’t fit onto the surface.

selfietorium.libselfietorium.template module

A library that provides template functionality for selfietorium project

Templates for selfietorium are stored as SVG graphic files. This library provides functionality for reading and updating templates.

selfietorium.libselfietorium.template.LoadPhotoShoot(templateFile)

Load a template file, and read the PhotoShoot shotlist.

Parameters:templateFile (string) – String containing the template file svg data.
Returns:List of ‘PhotoShoot’ objects

Notes

A shot list consists of the :
  • Image ID associated with the Photo
  • The prompt to the subjects
  • In the order the photos should be taken.

EG:

Shooting instruction ImageID
Ok. Big smiles everyone image3085
That looked amazing.Ok - now everyone wave at the camera. image3087
Wow - and you guys aren’t professional Models? Smile! image3045
Great… last one now.. Got nuts everyone! image3085

This allows the photo program the ability to prompt the subjects appropriately, and makes updating the template easier (straight XPath update). Shot order is determined from the Image ID. Creating an image in Inkscape will increment the image ID. Therefore if you create your images in the order that you want them to be taken, then the photo ordering should work fine.

As the shoot list is ordered by the ImageID, these can be renamed - however the order of these ID’s will determine the shoot order.

class selfietorium.libselfietorium.template.PhotoShoot

Bases: object

Class that describes a photoshoot.

selfietorium.libselfietorium.template.deleteNode(svg_data, xpath)

Deletes a node based on an Xpath. :Parameters: * svg_data (str) – String containing SVG template Data.

  • xpath (str) – XPath of element to find.
Returns:A string containing svg data cleansed of the offending node.
selfietorium.libselfietorium.template.findGeometry(svg_data)

Determines the Geometry (size) of the template. :Parameters: svg_data – String containing template data.

Returns:SVG Geometry data
selfietorium.libselfietorium.template.findNode(svg_data, xpath)

Finds a node based on an Xpath.

Parameters:
  • svg_data – String containing template data
  • xpath – XPath of element to find
Returns:

XmlElement of required node, or None if node does not exist.

selfietorium.libselfietorium.template.get_Element_Styles(element)

Retrieves the style attributes for an element

Parameters:element (xml element) – Element to retrieve the style attribute from.
Returns:Dictionary of style elements, allowing the style information to be queried based on key name.
selfietorium.libselfietorium.template.ns = {'cc': 'http://creativecommons.org/ns#', 'dc': 'http://purl.org/dc/elements/1.1/', 'inkscape': 'http://www.inkscape.org/namespaces/inkscape', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'sodipodi': 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', 'svg': 'http://www.w3.org/2000/svg', 'xlink': 'http://www.w3.org/1999/xlink'}

Namespaces used by SVG files (created by Inkscape).

selfietorium.libselfietorium.template.updateNode(svg_data, element_id, value)

Finds a Text Node based on ID, and sets its value.

Parameters:
  • svg_data – String containing template data
  • element_id – id of element to find
  • value – value to assign.
Returns :
Updated SVG string data.
selfietorium.libselfietorium.template.updateNodeAttrib(svg_data, element_id, attrib, value)

Finds a Text Node based on ID, and sets its value.

Parameters:
  • svg_data – String containing template data
  • element_id – id of element to find
  • value – value to assign.
Returns:

Updated SVG string data.

selfietorium.libselfietorium.utilities module

class selfietorium.libselfietorium.utilities.utilities

Utility functions used throughout selfietorium. These functions may move to a more appropriate module later on.

hex_to_rgb(value)

Convert a colour representation in the form of #RRGGBB to a python tuple.

Parameters:value (string) – string representing the hexadecimal colour to convert.
Returns:Tuple containing the RGB values from the hexadecimal version of the colour.
rgb_to_hex(rgb)

Convert an RGB Tuple to a hexadecimal representation of the colour.

Parameters:rgb (tuple) – tuple containing the rgb value for a colour
Returns:String representing the hexadecimal representation of the colour.

Module contents