emxlib.utils module

MODIFICATION ADVICE:

Please, do not generate or distribute a modified version of this file under its original name.

class emxlib.utils.EmxData[source]

Bases: object

Class to group EMX objects

addObject(obj)[source]
clear()[source]
getFirstObject(className)[source]

Return the first object of a given className. This function should be called after read.

getObject(mapPK)[source]

Return an object given its primary key.

iterClasses(className)[source]

Iterate through objects of a particular class.

read(emxFile)[source]

Read data from an emxFile.

readFirstObject(className, emxFile)[source]

Read only the first object of a given className from file.

size()[source]
write(emxFile)[source]

Write data to an emxFile.

class emxlib.utils.EmxImage(fileName=None, index=None)[source]

Bases: emxlib.utils.EmxObject

Base class for EmxMicrograph and EmxParticle. Both share that have FILENAME and INDEX as primary keys.

class emxlib.utils.EmxLabel(type, unit=None)[source]

Bases: object

Auxiliary class to assign data type (i.e.: int, str, etc) and unit to each attribute/label pair.

getType()[source]
getUnit()[source]
hasUnit()[source]
class emxlib.utils.EmxMicrograph(fileName=None, index=None)[source]

Bases: emxlib.utils.EmxImage

Class for Micrographs

class emxlib.utils.EmxObject[source]

Bases: object

Base class for all EMX objects/classes name is the class type so far micrograph or particles

clear()[source]

Generic clean. PK cannot be modified or clean.

get(key, default=None)[source]

Given a key (attribute name) returns the value assigned to it. If not present, the default will be returned.

has(key)[source]
iterAttributes()[source]

Returns list with valid keys (attribute names) and values for this class. Primary keys are ignored

iterForeignKeys()[source]

Returns list with valid primary keys (attribute names) and values for this class

iterPrimaryKeys()[source]

Returns list with valid primary keys (attribute names) and values for this class

set(key, value=None)[source]

Given a key (attribute name) assigns a value to it.

strongEq(other)[source]

true if both objects are truly identical

class emxlib.utils.EmxParticle(fileName=None, index=None)[source]

Bases: emxlib.utils.EmxImage

Class for Particles

getMicrograph()[source]

Return the micrograph associated with this particles.

setMicrograph(micrograph)[source]

Set the micrograph associated with this particle.

class emxlib.utils.EmxXmlMapper(emxData)[source]

Bases: object

Mapper for XML

createObject(elem)[source]
firstObject(classname, fileName)[source]

Iterate over the tags elements and find the first one of type ‘classname’, build the object and return it. The foreing keys will be not updated.

objectToXML(object)[source]

Given an object persist it in XML dataBase. Each object goes to a different element. Much much faster…

readEMXFile(fileName, classElement=None)[source]

create tree from xml file If classElement is not None, the first element of this class will be returned

readObjectPK(elem)[source]

read primary key. So far all entities has the same PK. We may need to specialize or use dictPrimaryKeys in the future

writeEMXFile(fileName)[source]

write xml file and store it in a document

exception emxlib.utils.ValidateError(code, message)[source]

Bases: Exception

getCode()[source]
getMessage()[source]
emxlib.utils.validateSchema(filename, schema_file=None)[source]

Code from astropy project released under BSD licence Validates an XML file against a schema or DTD.

Functions to do XML schema and DTD validation. At the moment, this makes a subprocess call first to xerces then to xmllint. This could use a Python-based library at some point in the future, if something appropriate could be found. lxml is a possibility but has too many dependences if anyone knows about a pure python validator let my know

Parameters:
  • filename (str) – The path to the XML file to validate
  • schema (str) – The path to the XML schema or DTD
Returns:

returncode, stdout, stderr – Returns the returncode from validator and the stdout and stderr as strings

Return type:

int, str, str