Lib

rdf

This module provides functionality for handling our data as rdf.

class clld.lib.rdf.ClldGraph(*args, **kw)[source]

Augmented rdflib.Graph.

Augment the standard rdflib.Graph by making sure our standard ns prefixes are always bound.

clld.lib.rdf.expand_prefix(p)[source]

Expand default prefixes if possible.

Parameters:

p – a qualified name in prefix:localname notation or a URL.

Returns:

a string URL or a URIRef

clld.lib.rdf.properties_as_xml_snippet(subject, props)[source]

Serialize props of subject as RDF-XML snippet.

clld.lib.rdf.url_for_qname(qname)[source]

Expand qname to full URL respecting our default prefixes.

bibtex

Functionality to handle bibligraphical data in the BibTeX format.

class clld.lib.bibtex.Database(records)[source]

Represents a bibtex databases, i.e. a container class for Record instances.

classmethod from_file(bibFile, encoding='utf8', lowercase=False)[source]

Create bibtex database from a bib-file.

@param bibFile: path of the bibtex-database-file to be read.

property keymap

Map bibtex record ids to list index.

class clld.lib.bibtex.EntryType[source]

Bibtext entry types.

article

An article from a journal or magazine. Required fields: author, title, journal, year Optional fields: volume, number, pages, month, note, key

book

A book with an explicit publisher. Required fields: author/editor, title, publisher, year Optional fields: volume/number, series, address, edition, month, note, key

booklet

A work that is printed and bound, but without a named publisher or sponsoring institution. Required fields: title Optional fields: author, howpublished, address, month, year, note, key

conference

The same as inproceedings, included for Scribe compatibility.

inbook

A part of a book, usually untitled. May be a chapter (or section or whatever) and/or a range of pages. Required fields: author/editor, title, chapter/pages, publisher, year Optional fields: volume/number, series, type, address, edition, month, note, key

incollection

A part of a book having its own title. Required fields: author, title, booktitle, publisher, year Optional fields: editor, volume/number, series, type, chapter, pages, address, edition, month, note, key

inproceedings

An article in a conference proceedings. Required fields: author, title, booktitle, year Optional fields: editor, volume/number, series, pages, address, month, organization, publisher, note, key

manual

Technical documentation. Required fields: title Optional fields: author, organization, address, edition, month, year, note, key

mastersthesis

A Master’s thesis. Required fields: author, title, school, year Optional fields: type, address, month, note, key

misc

For use when nothing else fits. Required fields: none Optional fields: author, title, howpublished, month, year, note, key

phdthesis

A Ph.D. thesis. Required fields: author, title, school, year Optional fields: type, address, month, note, key

proceedings

The proceedings of a conference. Required fields: title, year Optional fields: editor, volume/number, series, address, month, publisher, organization, note, key

techreport

A report published by a school or other institution, usually numbered within a series. Required fields: author, title, institution, year Optional fields: type, number, address, month, note, key

unpublished

A document having an author and title, but not formally published. Required fields: author, title, note Optional fields: month, year, key

class clld.lib.bibtex.Record(genre, id_, *args, **kw)[source]

A BibTeX record is an ordered dict with two special properties - id and genre.

To overcome the limitation of single values per field in BibTeX, we allow fields, i.e. values of the dict to be iterables of strings as well. Note that to support this use case comprehensively, various methods of retrieving values will behave differently. I.e. values will be

  • joined to a string in __getitem__,

  • retrievable as assigned with get (i.e. only use get if you know how a value was assigned),

  • retrievable as list with getall

Note

Unknown genres are converted to “misc”.

get(key, default=None)[source]

Return the value for key if key is in the dictionary, else default.

getall(key)[source]

Get list of all values for key.

Returns:

list of strings representing the values of the record for field ‘key’.

clld.lib.bibtex.u_unescape(s)[source]

Unencode Unicode escape sequences.

Match all 3-5-digit sequences with unicode character replace all ‘?[u….]’ with corresponding unicode

There are some decimal/octal mismatches in unicode encodings in bibtex

clld.lib.bibtex.unescape(string)[source]

Transform latex escape sequences of type `ae into unicode.

Parameters:

string – str or binary

Returns:

str

coins

Functionality to create Coins, i.e. context objects in spans.

class clld.lib.coins.ContextObject(sid, mtx, *data)[source]

A Context Object which knows how to render it’s metadata as HTML span tags.