Bauble API Documentation

bauble

The top level module for Bauble.

bauble.main_is_frozen()
Return True if we are running in a py2exe environment, else return False
bauble.save_state()
Save the gui state and preferences.
bauble.quit()
Stop all tasks and quit Bauble.
bauble.set_busy(busy)
Set the interface to appear busy.
bauble.command_handler(cmd, arg)

Call a command handler.

Parameters:
  • cmd (str) – The name of the command to call
  • arg (list) – The arg to pass to the command handler
bauble.main(uri=None)
Initialize Bauble and start the main Bauble interface.

bauble.db

class bauble.db.MapperBase(classname, bases, dict_)

Bases: sqlalchemy.ext.declarative.DeclarativeMeta

MapperBase adds the id, _created and _last_updated columns to all tables.

bauble.db.open(uri, verify=True, show_error_dialogs=False)

Open a database connection. This function sets bauble.db.engine to the opened engined.

Return bauble.db.engine if successful else returns None and bauble.db.engine remains unchanged.

Parameters:
  • uri (str) – The URI of the database to open.
  • verify (bool) – Where the database we connect to should be verified as one created by Bauble. This flag is used mostly for testing.
  • show_error_dialogs (bool) – A flag to indicate whether the error dialogs should be displayed. This is used mostly for testing.
bauble.db.create(import_defaults=True)

Create new Bauble database at the current connection

Parameters:
  • import_defaults (bool) – A flag that is passed to each plugins install() method to indicate where it should import its default data. This is mainly used for testing. The default value is True

bauble.connmgr

The connection manager provides a GUI for creating and opening connections. This is the first thing displayed when Bauble starts.

bauble.editor

bauble.i18n

bauble._gui

bauble.meta

bauble.paths

Access to standard paths used by Bauble.

bauble.paths.main_dir()
Returns the path of the bauble executable.
bauble.paths.lib_dir()
Returns the path of the bauble module.
bauble.paths.locale_dir()
Returns the root path of the locale files
bauble.paths.user_dir()
Returns the path to where Bauble settings should be saved.

bauble.pluginmgr

bauble.pluginmgr.register_command(handler)
Register command handlers. If a command is a duplicate then it will overwrite the old command of the same name.
bauble.pluginmgr.load(path=None)

Search the plugin path for modules that provide a plugin. If path is a directory then search the directory for plugins. If path is None then use the default plugins path, bauble.plugins.

Parameters:
  • path (str) – the path where to look for the plugins
bauble.pluginmgr.init(force=False)

Initialize the plugin manager.

1. Check for and install any plugins in the plugins dict that aren’t in the registry. 2. Call each init() for each plugin the registry in order of dependency 3. Register the command handlers in the plugin’s commands[]

NOTE: This should be called after after Bauble has established a connection to a database with db.open()

bauble.pluginmgr.install(plugins_to_install, import_defaults=True, force=False)
Parameters:
  • plugins_to_install – A list of plugins to install. If the string “all” is passed then install all plugins listed in the bauble.pluginmgr.plugins dict that aren’t already listed in the plugin registry.
  • import_defaults (bool) – Flag passed to the plugin’s install() method to indicate whether it should import its default data.
  • force (book) – Force, don’t ask questions.
class bauble.pluginmgr.RegistryEmptyError
class bauble.pluginmgr.Registry(session=None)

Manipulate the bauble plugin registry. The registry is stored in the bauble meta table in JSON format. This class provides a dict interface to the registry.

add(entry)
Parameters:
create
Create a new empty registry in the current database, if a registry already exists an error will be raised. If session is passed in then we don’t commit the session. If session is passed in then we commit it.
exists
Test if the registry exists
remove(name)
remove entry with name from the registry
class bauble.pluginmgr.RegistryEntry(name, version, **kwargs)

A dict like object for accessing registry values.

The name and version attributes are required

create
Factory method for creating a RegistryEntry from a dct. The dct must have the name and version keys set.
class bauble.pluginmgr.Plugin
tools:
a list of BaubleTool classes that this plugin provides, the tools’ category and label will be used in Bauble’s “Tool” menu
depends:
a list of names classes that inherit from BaublePlugin that this plugin depends on
cmds:
a map of commands this plugin handled with callbacks, e.g dict(‘cmd’, lambda x: handler)
init
init() is run when Bauble is first started
install
install() is run when a new plugin is installed, it is usually only run once for the lifetime of the plugin
class bauble.pluginmgr.Tool
class bauble.pluginmgr.View(*args, **kwargs)
class bauble.pluginmgr.CommandHandler
bauble.pluginmgr.topological_sort(items, partial_order)

Perform topological sort.

Parameters:
  • items – a list of items to be sorted.
  • partial_order – a list of pairs. If pair (a,b) is in it, it means that item a should appear before item b. Returns a list of the items in one of the possible orders, or None if partial_order contains a loop.

bauble.prefs

bauble.task

bauble.task.queue(task, on_quit, on_error, *args)

Queue a new task

Parameters:
  • task – the task to queue
  • callback – the function to call when the task is finished
  • args – the arguments to pass to the task
bauble.task.flush()
Flush out the task queue. This is normally called by bauble.task.queue()
bauble.task.set_message(msg)
A convenience function for setting a message on the statusbar. Returns the message id
bauble.task.clear_messages()
Clear all the messages from the statusbar that were set with bauble.task.set_message()

bauble.types

class bauble.types.Enum(values, empty_to_none=False, strict=True, **kwargs)

Bases: sqlalchemy.types.TypeDecorator

A database independent Enum type. The value is stored in the database as a Unicode string.

class bauble.types.Date(*args, **kwargs)

Bases: sqlalchemy.types.TypeDecorator

A Date type that allows Date strings

class bauble.types.DateTime(*args, **kwargs)

Bases: sqlalchemy.types.TypeDecorator

A DateTime type that allows strings

bauble.utils

A common set of utility functions used throughout Bauble.

bauble.view

bauble.plugins.plants

class bauble.plugins.plants.Family(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

family

Columns:
family:

The name if the family. Required.

qualifier:

The family qualifier.

Possible values:
  • s. lat.: aggregrate family (senso lato)
  • s. str.: segregate family (senso stricto)
  • None: the None value
notes:

Free text notes about the family.

Properties:
synonyms:

An association to _synonyms that will automatically convert a Family object and create the synonym.

Constraints:

The family table has a unique constraint on family/qualifier.

class bauble.plugins.plants.FamilySynonym(synonym=None, **kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

family_synonyms

Columns:

family_id:

synonyms_id:

Properties:

synonyms:

species:

class bauble.plugins.plants.Genus(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

genus

Columns:
genus:

The name of the genus.

hybrid:

Indicates whether the name in genus field refers to an Intergeneric hybrid or an Intergeneric graft chimaera.

Possible values:
  • H: An intergeneric hybrid collective name
  • x: An Intergeneric Hybrid
  • +: An Intergeneric Graft Hybrid or Graft Chimaera
qualifier:

Designates the botanical status of the genus.

Possible values:
  • s. lat.: aggregrate genus (sensu lato)
  • s. str.: segregate genus (sensu stricto)

author:

notes:

Properties:

family:

synonyms:

Contraints:

The combination of genus, hybrid, author, qualifier and family_id must be unique.

class bauble.plugins.plants.GenusSynonym(synonym=None, **kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:genus_synonym
class bauble.plugins.plants.Species(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

species

Columns:
sp_hybrid:

Hybrid flag

Possible values:

H: A hybrid formula for an Interspecific hybrid

x: A Nothotaxon name for an Interspecific hybrid

+: An Interspecific graft hybrid or graft chimaera

sp_qual:

Species qualifier

Possible values:

agg.: An aggregate species

s. lat.: aggregrate species (sensu lato)

s. str.: segregate species (sensu stricto)

infrasp_rank:

The infraspecific rank

Possible values:

subsp.: subspecies

variety.: variety

subvar.: sub variety

f.: form

subf.: subform

cv.: cultivar

Properties:

accessions:

vernacular_names:

default_vernacular_name:

synonyms:

distribution:

Constraints:

The combination of sp, sp_author, sp_hybrid, sp_qual, cv_group, trade_name, infrasp, infrasp_author, infrasp_rank, genus_id

class bauble.plugins.plants.SpeciesSynonym(synonym=None, **kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:species_synonym
class bauble.plugins.plants.VernacularName(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

vernacular_name

Columns:
name:

the vernacular name

language:

language is free text and could include something like UK or US to identify the origin of the name

species_id:

key to the species this vernacular name refers to

Properties:
Constraints:
class bauble.plugins.plants.DefaultVernacularName(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:default_vernacular_name

DefaultVernacularName is not meant to be instantiated directly. Usually the default vernacular name is set on a species by setting the default_vernacular_name property on Species to a VernacularName instance

Columns:
id:

Integer, primary_key

species_id:

foreign key to species.id, nullable=False

vernacular_name_id:

Properties:
Constraints:
class bauble.plugins.plants.SpeciesDistribution(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:species_distribution
Columns:
Properties:
Constraints:
class bauble.plugins.plants.Geography(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Represents a geography unit.

Table name:

geography

Columns:

name:

tdwg_code:

iso_code:

parent_id:

Properties:

children:

Constraints:

bauble.plugins.garden

class bauble.plugins.garden.Accession(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

accession

Columns:
code: sqlalchemy.types.Unicode

the accession code

prov_type: bauble.types.Enum

the provenance type

Possible values:
  • Wild:
  • Propagule of cultivated wild plant
  • Not of wild source
  • Insufficient Data
  • Unknown
wild_prov_status: bauble.types.Enum

wild provenance status, if prov_type is Wild then this column can be used to give more provenance information

Possible values:
  • Wild native
  • Cultivated native
  • Insufficient Data
  • Unknown
date: bauble.types.Date

the date this accession was accessioned

source_type: bauble.types.Enum

The type of the source of this accession

Possible values:

notes: sqlalchemy.types.UnicodeText

Notes relating to this accession.

id_qual: bauble.types.Enum

The id qualifier is used to indicate uncertainty in the identification of this accession

Possible values:
  • aff. - affinity with
  • cf. - compare with
  • forsan - perhaps
  • near - close to
  • ? - questionable
  • incorrect
id_qual_rank: sqlalchemy.types.Unicode

The rank of the species that the id_qaul refers to.

private: sqlalchemy.types.Boolean

Flag to indicate where this information is sensitive and should be kept private

species_id: sqlalchemy.types.ForeignKey

foreign key to the species table

Properties:
species:

the species this accession refers to

_collection:

this relation should never be used directly, use the source property instead

_donation:

this relations should never be used directly, use the source property instead

source:

source cancel either be a Donation, Collection or None depending on the value of the source_type

plants:

a list of plants related to this accession

verifications:

a list of verifications on the identification of this accession

Constraints:
class bauble.plugins.garden.Plant(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

plant

Columns:
code: sqlalchemy.types.Unicode

The plant code

acc_type: bauble.types.Enum

The accession type

Possible values:
  • Plant: Whole plant
  • Seed/Spore: Seed or Spore
  • Vegetative Part: Vegetative Part
  • Tissue Culture: Tissue culture
  • Other: Other, probably see notes for more information
  • None: no information, unknown
acc_status: bauble.types.Enum

The accession status

Possible values:
  • Living accession: Current accession in living collection
  • Dead: Noncurrent accession due to Death
  • Transfered: Noncurrent accession due to Transfer Stored in dormant state: Stored in dormant state
  • Other: Other, possible see notes for more information
  • None: no information, unknown)
notes: sqlalchemy.types.UnicodeText

Notes

accession_id: sqlalchemy.types.ForeignKey

Required.

location_id: sqlalchemy.types.ForeignKey

Required.

Properties:
accession:

The accession for this plant.

location:

The location for this plant.

Constraints:

The combination of code and accession_id must be unique.

static get_delimiter()
Get the plant delimiter from the BaubleMeta table
class bauble.plugins.garden.Location(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

location

Columns:

site:

description:

Relation:

plants:

class bauble.plugins.garden.Collection(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

collection

Columns:

collector: sqlalchemy.types.Unicode(64)

collectors_code: sqlalchemy.types.Unicode(50)

date: sqlalchemy.types.Date

locale: sqlalchemy.types.UnicodeText(nullable=False)

latitude: sqlalchemy.types.Float

longitude: sqlalchemy.types.Float

gps_datum: sqlalchemy.types.Unicode(32)

geo_accy: sqlalchemy.types.Float

elevation: sqlalchemy.types.Float

elevation_accy: sqlalchemy.types.Float

habitat: sqlalchemy.types.UnicodeText

geography_id: sqlalchemy.types.Integer(ForeignKey('geography.id'))

notes: sqlalchemy.types.UnicodeText

accession_id: sqlalchemy.types.Integer(ForeignKey('accession.id'), nullable=False)

Properties:

Also contains an _accession property that was created as a backref from the Accession mapper

Constraints:
class bauble.plugins.garden.Donation(**kwargs)

Bases: sqlalchemy.ext.declarative.Base

Table name:

donation

Columns:

donor_id: sqlalchemy.types.Integer, ForeignKey('donor.id'), nullable=False)

donor_acc: sqlalchemy.types.Unicode(32)

notes: sqlalchemy.types.UnicodeText

date: bauble.types..Date

accession_id: sqlalchemy.types.Integer(ForeignKey('accession.id'), nullable=False)

Properties:
donor:

created as a backref from the Donor mapper

_accession:

created as a backref from the Accession mapper _donation property

class bauble.plugins.garden.Donor(**kwargs)
Bases: sqlalchemy.ext.declarative.Base

bauble.plugins.abcd

bauble.plugins.imex

bauble.plugins.report

bauble.plugins.report.default

The PDF report generator module.

This module takes a list of objects, get all the plants from the objects, converts them to the ABCD XML format, transforms the ABCD data to an XSL formatting stylesheet and uses a XSL-PDF renderer to convert the stylesheet to PDF.

bauble.plugins.report.template

bauble.plugins.tag