Help.register ('searching', """ Searching involves the creation of a Selection () object, that will hold the properties you request from the database. selection = Selection ( constraints ) ...where `constraints' is an arbitrary construction of : - has (field, value) : matches if `field' matches `value' (as a REGEXP) - has_key (key) : matches if the entry matches the key - has_type (typename) : matches if the entry is of the given type - any_has (value) : matches if any of the fields matches the value - before (field, year [, month [, day]]) : matches if the entry is older than the date - after (field, year [, month [, day]]) : matches if the entry is younger than the date - &, | : boolean operators (& = and, | = or) Negation of a constraint is noted `- constraint'. Examples : s = Selection (has ('author', 'me')) s = Selection (has ('author', 'me') & - has ('title', 'failed')) This selection can then create an iterator from a database : it = s.iterator (database.iterator ()) For simple searches, you can use the function `search' See also: search """)
import os, string, sys, tempfile, traceback, urllib, urlparse def url_to_local (url): (file, headers) = urllib.urlretrieve (url.get_url ()) return file Help.register ('bibopen', """ Syntax: database = bibopen (source) bibopen tries several method to open `source' as a bibliographic entry. `source' can be a simple file or even an URL. FTP and HTTP files are automatically fetched. One can even create a specific method for client/server access for example. One can apply the following commands on the output of bibopen : - database.keys () : lists the available entries - database ['key'] : returns a given entry - del database ['key'] : removes an entry from the file - database.where (...) : searches the base (see also `searching') """) def get_by_name (entity, method): ''' returns a specific field of the given entity ''' meth = Autoload.get_by_name ("format", entity) if meth and meth.data.has_key (method):