Skip to main content

Simple library and command line tool for loading flash cards into anki.

Project description

hanky

Hatch project

Hanky is a simple application framework and command line application for loading flash cards into anki.

Hanky allows you to easily write your own python code which enriches or transforms your flash card data before adding them to Anki, for example by generating text to speech audio or quering an api for extra data at runtime.

:information_source: Note: This project is currently in alpha and is not stable.

Table of Contents

Installation

Install via pip:

pip install hanky

Configuration

See below an overview of hanky's configuration options or jump to the default configuration section.

Hanky automatically looks for a configuration file in ~/.config/hanky/hanki.toml. Alternatively, provide a path to a config file with the --config option. If no configuration file is provided, hanky will attempt to use the default configuration.

  • anki_database: tells hanky where to find the anki collection (an sqlite database where anki stores flash cards and other data). Defaults to the following locations:

    • Mac OS: ~/Library/Application Support/Anki2/User 1/collection.anki2
    • Linux: ~/.local/share/Anki2/User 1/collection.anki2
  • database_safety_check: a boolean which when set to true will check for any running processes using the anki collection. Defaults to true.

    :warning: Caution: Setting this option to false may result in database corruption. Always ensure your anki is backed up.

  • allow_duplicates: a boolean which when set to true allows duplicate cards to be added. A duplicate card is a card whose field values match another cards field values already in anki. Defaults to false.

Default configuration:

# specifies where to find the anki collection (sqlite db where anki stores data)
# If you are not using the default anki user, 'User 1', this option must be specified
# DEFAULTS:
# Mac OS: ~/Library/Application Support/Anki2/User 1/collection.anki2
# Linux: ~/.local/share/Anki2/User 1/collection.anki2
anki_database = "~/.local/share/Anki2/User 1/collection.anki2"

# whether or not to check for other processes using the anki database
# DEFAULTS: true
database_safety_check = true

# whether or not to allow duplicate cards to be added
# DEFAULTS: false
allow_duplicates = false

Usage

Hanky can be used as both a command line application and a library.

  • If you want to do something more complex than simply adding cards directly from files, such as generating audio using text to speech, querying an api or performing other operations at runtime, see the examples

  • If you just want to load flash cards from files, see the examples below

Hanky can be used out of the box as a command line application. If running your own hanky script, replace hanky with python3 my_script.py.

Overview

usage: hanky [-h] [--config CONFIG] {load,load-dir} ...

Simple program to allow programatic management of anki cards

positional arguments:
  {load,load-dir}  Type of operation to perform
    load           Load cards into an anki deck from a file
    load-dir       Load cards into anki deck(s) from files in a directory, using the filenames as deck names.

options:
  -h, --help       show this help message and exit
  --config CONFIG  Path to hanky toml configuration file

Load a deck from a file

Load a single deck using the 'basic' anki model/note type from a file

hanky load "basic" ~/my-folder/countries.csv

The following deck will be created:

  • countries

Load decks from files from a folder

Load all csv files in a folder as decks of cards using the 'basic' anki model/note type. The relative path from the specified folder will be used as the deck name.

hanky load-dir "basic" "~/french/" "*.csv"

For example, given the following folder structure:

french
├── animals.csv
├── bodies.csv
├── clothing.csv
└── grammar
    └── passe_compose.csv

The following decks will be created:

  • french: top level deck
  • french::animals: nested animal vocab deck
  • french::bodies: nested bodies vocab deck
  • french::clothing: nested clothing vocab deck

The created anki decks will have the following structure:

french
├── animals
├── bodies
├── clothing

Recursively load decks from files in a folder

Recursively load all csv files as decks of cards using the 'basic' anki model/note type. The relative path from the specified folder will be used as the deck name.

hanky load-dir "basic" "~/french/" "*.csv" -r

For example, given the following folder structure:

french
├── animals.csv
├── bodies.csv
├── clothing.csv
└── grammar
    └── passe_compose.csv

The following decks will be created:

  • french: top level deck
  • french::animals: nested animal vocab deck
  • french::bodies: nested bodies vocab deck
  • french::clothing: nested clothing vocab deck
  • french::grammar: nested container deck for grammar
  • french::grammar::passe_compose: doubly nested deck for passe compose rules

The created anki decks will have the following structure:

french
├── animals
├── bodies
├── clothing
└── grammar
    └── passe_compose

Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hanky-0.0.4.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hanky-0.0.4-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file hanky-0.0.4.tar.gz.

File metadata

  • Download URL: hanky-0.0.4.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for hanky-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5a39acd667d8ab582bf904ad8c7142d2d9fd45df27ba1a7bc842590f9ad96438
MD5 9f61dac56e11a3b55d74f2f1ebf5f79b
BLAKE2b-256 941bc9a3123c7c7f9631f339870d22008dde8bd89b4ce58376ca09c8117a5028

See more details on using hashes here.

File details

Details for the file hanky-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: hanky-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for hanky-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 17dba729141f7440f1774e00c8ef3c70c2b54029d23cf3cec6da6b518028f1cb
MD5 0fa1a24605c57a6fc0a7f9ed6aaea328
BLAKE2b-256 323002032407a5fb1d4e30be86cd1f18cb60d1e9bf2ca4b45b64a97c854bc7b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page