Implementations

Markdown (basic)

class xettel.impl.markdown.ZettelMD.ZettelMD(parent: Zettelkasten, filename: str)

Example class for markdown-formatted zettels.

Such a Zettel may have a Jekyll-style YAML frontmatter, as compatible with pandoc.

Links are assumed to be of the format ‘[#$UID]’ where $UID is either a 12-char long numering string or a 8-char long alphanumeric string.

Files are expected to end in ‘.md’.

static export(zettel: xettel.base.ZAbstract.ZettelAbstract, force: bool = False) None

Export the Zettel to HTML

get_indexing_function(key: str) Callable[[xapian.Document, xapian.TermGenerator, Any], None]

Returns the function needed to index data from the attributes given a lowered and whitespace-stripped (as in str.strip()) key.

Functions returned by this method must have the following signature: (xapian.Document, xapian.TermGenerator, value) -> None.

Parameters

key (str) – the key to the indexing function

Returns

The indexing function corresponding to the key.

static issue_export_cmd(source: str, dest: str, env: dict[str, str], zinfo: dict[str, str]) None

Execute the command to export Zettels.

The abstract method defined here does nothing.

Parameters
  • source (str) – path of the Zettel

  • dest (str) – where to export the Zettel

  • env (dict[str, str]) – dictionnary of environement variables to pass to the command.

  • zinfo (dict[str,str]) – additional information to feed the command, probably directly among the arguments of the command.

parse_attributes() None

Parses attributes from the file.

Parses links in the file, according to the format specified above.

Keyword Arguments

links (Collection[int]) – unused argument, here so that typechecking passes.

classmethod set_queryparser_prefixes(queryparser: xapian.QueryParser) None

Sets the prefixes for searching the metadata defined by this class into the queryparser.

The method defined here does nothing.

Parameters

queryparser (xapian.QueryParser) – the queryparser to feed information to.

classmethod tag_export(tag: str, filecontents: list[typing.Tuple[str, str]]) None

Exports a page of a list of Zettels having this tag.

The abstract method defined here does nothing.

Parameters
  • tag (str) – the tag

  • filecontents (list[Tuple[str, str]]) – a summary of the contents of the Zettels having this tag. The first component of the tuple is the path of the Zettel, the second may be its title.

Xapian

ZettelX

class xettel.impl.xapian.ZettelX.ZettelX(parent: ZettelkastenX, doc: xapian.Document, id: int)
Parameters
  • parent (ZettelkastenX) – the parent Zettelkasten to this Zettel

  • doc (xapian.Document) – the Xapian document from which Xettel will reconstruct the Zettel

  • id (int) – Xapian id of the document.

__xdata

data retrieved from Xapian

Type

dict[str, Any]

__xapian_id

the id of the Xapian document.

Type

int

parse_attributes() None

Along with setting attributes, this methods also set backlinks

Parse links with the given data

The abstract method defined here just sets the private attribute __links to the ones given by the argument links.

Parameters

links (Collection[int]) – a collection of ints.

ZettelkastenX

class xettel.impl.xapian.ZettelkastenX.ZettelkastenX(folder: str)

Rebuilds a Zettelkasten from a xapian database.

Parameters

folder (str) – path to the folder where Zettel files are stored.

classmethod from_db(db: xapian.Database, folder: str) xettel.impl.xapian.ZettelkastenX.ZettelkastenX

Constructs a Zettelkasten from the whole database.

Parameters
  • db (xapian.Database) – the Xapian database from which xettel will retreive the Zettels.

  • folder (str) – path to the folder where Zettel files are stored.

Returns

A completely reconstructed Zettelkasten

classmethod from_mset(mset: xapian.MSet, folder: str) xettel.impl.xapian.ZettelkastenX.ZettelkastenX

Constructs a partial Zettelkasten with MSet matches.

Parameters
  • mset (xapian.MSet) – a MSET from which xettel will reconstruct a Zettelkasten.

  • folder (str) – path to the folder where Zettel files are stored.

Returns

A partially reconstructed Zettelkasten

initialise_contents(setbacklinks: bool = False) None

Same as parent’s method, but does not initialise backlinks globalwise as it is normally already stored in the xapian database.

Keyword Arguments

setbacklinks (bool) – whether to set backlinks or not