archive module

class infocards.archive.Archive(**kwargs)

Bases: builtins.object

Database connection.

**kwargs contains the database connection information. Check the documentation on the _create_engine() method for details.

all()

Obtain a list of all the cards stored in the archive.

Returns:list of Card objects
create_archive()

Create the corresponding schemas in the database. Must be used when connecting to an empty database.

get_card(title)

Obtain a card from the archive.

This is a direct search, so the title (or the row id) must be written as in the stored card.

Parameters:title (str) – title of the card to get
Raises NoCardFound:
 raised when the card does not exist
new_card(title='', description='', content='', tags='')

Create a new card for the archive.

Parameters:
  • title (str) – title of the card
  • description (str) – description of the card
  • content (str) – plain text content of the card
  • tags (str) – sequence of tags identifying the card separated by whitespaces
Raises InsertError:
 

raised when a card already exists in the archive

remove_card(title)

Remove a card from the archive.

Parameters:title (str) – title of the card to remove
Raises NoCardFound:
 raised when the card cannot be found
search(query, likelihood=80, relevance=50)

Search for cards using the specified query.

A list of tags is created from the title and tags of the card and then compared with the query. If the percentage of query words present in the card list is greater or equal than relevance, then that card is added to the result.

If the query is empty, then a list of all the cards in the archive is returned.

Parameters:
  • query (str) – search query
  • likelihood (int) – percentage for which two words are considered to be alike (0-100)
  • relevance (int) – percentage for which a search query is considered relevant to the card. (0-100)
Returns:

list of Card

update_card(title, new_card)

Update the information of a card.

Parameters:
  • title (str) – title of the card to update
  • new_card (Card) – Card object with the updated information
Raises NoCardFound:
 

raised when the card to update is not found