Interfacee to xapian

Common interface for IO

class xettel.zxapian.basic.ZX(folder: str, db: Optional[xapian.Database] = None)

Common interface for reading and writing the Xapian database

Reader Class

class xettel.zxapian.reader.ZXReader(folder: str)

Class for reading the Xapian database

add_prefix(db_prefix: str, user_prefix: str) None

Add a synonym for a prefix

db_to_zk() xettel.impl.xapian.ZettelkastenX.ZettelkastenX

Export the database to a Zettelkasten

search(querystring: str, sort: bool = False, n: Optional[int] = None) xapian.MSet

Search the database (with limitations) Basically no wrapper around Xapian

The method also implements a different way of querying the full database when querystring is '*' than ZXReader.db_to_zk. Instead of rebuilding the Zettelkasten, this returns a xapian.MSet. This allows for an efficient sorting which is done by xapian, as well as a limited subset of the results.

search_zk(querystring: str, sort: bool = False, n: Optional[int] = None) xettel.impl.xapian.ZettelkastenX.ZettelkastenX

Search the database and returns a Zettelkasten with only the matching zettels.

tag_map() Iterator[Tuple[str, list[typing.Tuple[str, str]]]]

Returns a list [(tagname, [filenames_with_that_tag])]. Uses the resources module to determine the tag prefix.

Writer Class

class xettel.zxapian.writer.ZXWriter(folder: str)
delete_in_database(zettelkasten: Zettelkasten[ZFT], stored_zk: Optional[ZettelkastenX[ZFT]] = None) int

Delete Zettels not present in provided Zettelkasten from the db

Returns the number of deleted zettels

index_zettel(zettel: xettel.zxapian.writer.ZFT) None

Indexes a single zettel into the xapian database.

Given that the indexing strategy is to map ZK UIDs, this eventually overwrites a previous zettel indexed with the same UID.

update_database(zettelkasten: Zettelkasten[ZFT], delete: bool = True) Tuple[int, int, int]

Given a Zettelkasten, replace index zettels whose timestamp is older. Optionally deletes zettels not present in provided Zettelkasten (defaults to True).

Returns a 3-uple of ints (updated, added, deleted)

zk_to_db(zettelkasten: Zettelkasten, delete: bool = True) int

Indexes a whole Zettelkasten into the xapian database, overwriting everything.

Optionally deletes zettels that don’t exist anymore (defaults to True)

Returns the number of deleted documents.

Misc.