def _check_default (item, value, user): """ If the entries are updated, update the default type with the new entry """ dfl = Config.get ('base/defaulttype').data if dfl is None: return 1 value = value [string.lower (dfl.name)] if dfl == value: Config.set ('base/defaulttype', value) return 1
def _set_entries (entries): desc = Config.get ('base/fields').data ent = {} for e in entries.keys (): d = Types.EntryDescription (e) d.mandatory = \ map (lambda x, desc=desc: desc [x], entries [e] [0]) d.optional = \ map (lambda x, desc=desc: desc [x], entries [e] [1]) ent [string.lower (e)] = d Config.set ('base/entries', ent) return
Config.define ('gnome/native-as-default', """ Should we edit the entries in their native format by default ? """, Config.Boolean ()) Config.define ('gnome/old-confirmation-dialog', """ Should we use the old dialog when closing, and ask for permission to skip saving? """, Config.Boolean ()) Config.define ('gnome/searched', """ List of searchable fields """, Config.List (Config.String ())) Config.define ('gnome/history', """ Size of the history file """, Config.Integer (min = 1)) Config.define ('gnome/paste-key', """ Paste key instead of entry content """, Config.Boolean ()) # -------------------------------------------------- Config.set ('gnome/searched', ['Author', 'Title', 'Abstract', 'Date']) Config.set ('gnome/tooltips', 1) Config.set ('gnome/native-as-default', 0) Config.set ('gnome/old-confirmation-dialog', 0) Config.set ('gnome/columns', ('Author', 'Date', 'Title')) Config.set ('gnome/history', 10) Config.set ('gnome/paste-key', 1)
Config.define ('bibtex/macros', """ A dictionnary defining the BibTeX macros (@String{} macros). Each entry of the dictionnary is a 2-uple : the first field is the expansion of the macro, the second is a boolean indicating if this macro definition has to be saved in the .bib files """, Config.Dict (Config.String (), Config.Tuple ((Config.String (), Config.Boolean ())))) Config.define ('bibtex/datefield', """ A hash table linking a `real' date field to the two bibtex fields that compose it """) Config.define ('bibtex/months', """ A hash table linking month names to their values """) # ================================================== Config.set ('bibtex/keep-preamble', 1) Config.set ('bibtex/strict', 0) Config.set ('bibtex/macros', {'jan' : ("January", 0), 'feb' : ("February", 0), 'mar' : ("March", 0), 'apr' : ("April", 0), 'may' : ("May", 0), 'jun' : ("June", 0), 'jul' : ("July", 0), 'aug' : ("August", 0), 'sep' : ("September", 0), 'oct' : ("October", 0),
from Legacy import Config, Types from Legacy.Format.OvidLike import SimpleField, AuthorField, SourceField, KeywordField def _get_elements (): return [SimpleField, AuthorField, SourceField, KeywordField] Config.define ('ovid/deftype', """ Default type for an Ovid entry """, Config.Element (lambda Config = Config: Config.get ('base/entries').data.values ())) Config.set ('ovid/deftype', Config.get ('base/entries').data ['article']) ## Config.define ('ovid/sourceregexp', ## """A regexp used to parse the source and abbreviated ## source input fields. This is a raw and verbose Python ## regular expression""", ## Config.String()) ## Config.set ('ovid/sourceregexp', ## r""" ## (?P<journal>.*)\.\ + ## (?P<volume>\d+) ## (?:\((?P<number>.*)\))? ## (?::(?P<pages>.*?(?:-+.*?)?) ## (?:;\ *(?P<other>.*))?) ## (?:,\ *(?P<year>\d\d\d\d))\ * ## (?P<month>.*) ## \.\Z ## """)
Config.define ('gnomeui/multiline', """ Fields displayed in a multi-line widget """, Config.Dict (Config.Element (_text_get), Config.Boolean ()), hook = _on_multiline_select) # -------------------------------------------------- Config.set ('gnomeui/monospaced', gtk.gdk.Font ('-*-*-*-r-normal-*-*-*-*-*-c-*-iso8859-1')) h = Config.get ('base/fields').data Fields.AuthorGroup.widget = Editor.AuthorGroup Fields.Text.widget = Editor.Entry Fields.URL.widget = Editor.URL Fields.Reference.widget = Editor.Reference Fields.Date.widget = Editor.Date Fields.Date.justification = gtk.JUSTIFY_RIGHT for f, w in (('author', 150), ('editor', 150),
table, with the entry name (lower case) as key, and a instance of Types.EntryDescription as value. """, hook = _check_default) Config.define ('base/defaulttype', """ Default type for a newly created entry """, vtype = Config.Element (_get_entries)) Config.define ('base/lyxpipe', """ Path to the LyX server """, vtype = Config.String ()) Config.define ('base/keyformat', """ Style of generated keys """, vtype = Config.Element (_get_keytypes)) # -------------------------------------------------- Config.set ('base/keyformat', 'Default') # Available fields fields = [ 'CrossRef', 'Key', 'Author', 'Address_1', 'Address_2', 'Title', 'SpecificTitle', 'Journal', 'Special', 'Type', 'BookTitle', 'Subject', 'Ownership', 'Series', 'Editor', 'Edition', 'Volume', 'Number', 'Chapter', 'Pages', 'School', 'Organization', 'Location', 'Dates', 'Institution', 'Publisher', 'Address', 'Format', 'Date', 'NoSeries', 'ConfPlace', 'Cote', 'IEEECN', 'Annotate', 'Quote', 'LoCN', 'ISBN', 'ISSN', 'Note', 'Language', 'HowPublished', 'To_Appear', 'From', 'Received', 'Owner', 'Keywords', 'Abstract', 'Remarks', 'URL', 'Beigabevermerk' ] entries = { 'Article' : (('author', 'title', 'journal', 'date'),
import os, sys, string from Legacy import Config, Exceptions import locale charset = locale.getlocale () [1] or 'ascii' # check the arguments if len (sys.argv) < 3: print _("usage: pybcheck <file | directory>...").encode (charset) sys.exit (1) # list containing the broken entries broken = [] # set the strictness for bibtex files Config.set ("bibtex/strict", 1) # we go over all the specified files for dir in sys.argv [2:]: # eventually expand directories to their content if os.path.isdir (dir): files = map (lambda x, dir = dir: \ os.path.join (dir, x), os.listdir (dir)) # in the case of a directory, use only .bib extension... files = filter (lambda f: os.path.splitext (f) [1] == '.bib', files) else: files = [dir]
correspondances. The boolean flag specifies if the mapping should be reversible. """, vtype=Config.Dict(Config.String(), Config.Tuple((Config.String(), Config.Boolean()))), ) Config.set( "refer/mapping", { "U": ("url", 1), "A": ("author", 1), "Q": ("author", 0), "T": ("title", 1), "S": ("series", 1), "J": ("journal", 1), "B": ("booktitle", 1), "R": ("type", 1), "V": ("volume", 1), "N": ("number", 1), "E": ("editor", 1), "D": ("date", 1), "P": ("pages", 1), "I": ("publisher", 1), "C": ("address", 1), "K": ("keywords", 1), "X": ("abstract", 1), "W": ("location", 1), "F": ("label", 1), "O": ("note", 1), }, )
return Config.get ('base/fields').data.keys () def _get_url_fields (): fields = Config.get ('base/fields').data return [ k for (k, v) in fields.items() if v.type is Fields.URL] Config.define ('resource/viewable-fields', """A list of fieldnames referring to viewable resources (with URL or otherwise).""", Config.List (Config.Element (_get_fields))) Config.define ('resource/viewers', """A list of mime type, viewer application name tuples. """, Config.List (Config.Tuple ((Config.String(), Config.String ())))) Config.set('resource/viewable-fields', _get_url_fields()) Config.set ('resource/viewers', [['application/pdf', 'acroread'], ['application/pdf', 'evince'], ['application/x-dvi', 'xdvi'], ['application/x-dvi', 'evince'], ['application/postscript', 'evince'], ['application/gzpostscript', 'evince'], ['image/vnd.djvu', 'djview'], ['image/vnd.djvu', 'evince'], ['text/html', 'mozilla'], ['text/html', 'konqueror'], ])
from Legacy import Config Config.define( "medline/mapping", """ A hash table containing field names correspondances """, Config.Dict(Config.String(), Config.String()), ) Config.set( "medline/mapping", { "UI": "medlineref", "AU": "author", "DP": "date", "TI": "title", "LA": "language", "MH": "keywords", "AD": "affiliation", "AB": "abstract", "AD": "authoraddress", "TA": "journal", "CY": "country", "PG": "pages", "IP": "number", "VI": "volume", }, )
Config.define ('bibtex+/braces', """ A boolean specifying if pyblio should use braces (instead of quotes) to limit entries """, Config.Boolean ()) Config.define ('bibtex+/capitalize', """ A flag indicating if pyblio should handle automatic capitalization in the bibtex output """, vtype = Config.Dict (Config.Element (_get_text_ent), Config.Boolean ())) Config.define ('bibtex+/override', """ A boolean indicating if the macro definitions provided here should override the ones given in a file """, Config.Boolean ()) Config.define ('bibtex+/dateformat', """ A template used for date formatting """, Config.String ()) Config.set ('bibtex+/braces', 1) Config.set ('bibtex+/capitalize', { 'title' : 1, 'booktitle' : 1, }) Config.set ('bibtex+/override', 0) Config.set ('bibtex+/dateformat', "{%(day)d } # %(month)s")