Base.DataBase

Name

Base.DataBase -- Represents a bibliographic database

Synopsis

class Base.DataBase:
    self.key
    self.id

    def __init__     (self, url):
    def has_property (self, prop):
    def new_entry    (self, type):
    def add          (self, entry):
    def keys         (self):
    	    return list (Keys)
    def has_key      (self, key):
    	    return boolean
    def __getitem__  (self, key):
    def __setitem__  (self, key, value):
    def get_native   (self, key):
    def set_native   (self, value):
    def __delitem__  (self, key):
    def __len__      (self):
    	    return integer
    def iterator     (self):
    	    return Iterator ()
    def update       (self):

Usage

This class provides access to a full bibliographic database. It basically behaves like a dictionnary: given the key of a entry, this object returns the entry itself.

Warning

The database does not ensure that modifying the returned entry actually modifies the database. It does not ensure the opposite too. So, to commit changes, explicitely set the modified entry in the database. And to avoid unexpected modifications, explicitely copy an entry that has to be modified.

Members

self.key

Holds the URL identifying the database.

self.id

Holds the type of the database, as a string.

Methods

__init__ (self, url)

The database is constructed from a URL object. Usually, the invocation of the constructor is not done directly by the user but rather through a higher level function like bibopen.

new_entry (self, type)

This method returns a new empty entry which is native for the current database. (it is always possible to use a generic Base.Entry instead, but the one returned here can avoid internal conversions)

add (self, entry)

This method inserts a new entry in the database. If the entry has no key yet, a unique key is generated.

keys (self)

Returns a list of entry keys.

has_key (self, key)

Returns true if the database holds the specified key.

__getitem__ (self, key)

entry = database [key]

Returns an entry according to its key, like a dictionnary.

__setitem__ (self, key, entry)

database [key] = entry

Stores an entry under a given key in a database.

get_native (self, key)

Returns a textual representation of the entry in its native format

set_native (self, value)

Parses an entry in its native format, and stores it in the database.

__delitem__ (self, key)

del database [key]

Removes the entry corresponding to the key.

__len__ (self)

l = len (database)

Returns the number of entries stored in the database.

iterator (self)

Returns an iterator that will loop over all the entries of the database. This method should be preferred to an explicit loop over database.keys (), as it can eventually access the entries in a more efficient manner.

update (self)

Updates the URL content so that it reflects the current database.