hanky


Namehanky JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummarySimple library and command line tool for loading flash cards into anki.
upload_time2024-06-01 00:28:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords anki
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # hanky

[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)

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](#installation)
- [Configuration](#configuration)
    - [Default Configuration](#default-configuration)
- [Application Usage](#usage)
    - [Load Deck From A File](#load-a-deck-from-a-file)
    - [Load Decks From A Folder](#load-decks-from-files-from-a-folder)
    - [Recursively Load Decks From A Folder](#recursively-load-decks-from-files-in-a-folder)
- [Example Hanky Scripts](#examples)


## Installation

Install via pip:

`pip install hanky`

## Configuration

See below an overview of hanky's configuration options or jump to the [default configuration](#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](#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:

```toml
# 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](#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


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hanky",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "anki",
    "author": null,
    "author_email": "HBA <hanky-pypi.8ebs0@simplelogin.com>",
    "download_url": "https://files.pythonhosted.org/packages/94/1b/c9a3123c7c7f9631f339870d22008dde8bd89b4ce58376ca09c8117a5028/hanky-0.0.4.tar.gz",
    "platform": null,
    "description": "# hanky\n\n[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)\n\nHanky is a simple application framework and command line application for loading flash cards into anki. \n\nHanky 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.\n\n> **:information_source: Note:**\n> This project is currently in alpha and is not stable.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Configuration](#configuration)\n    - [Default Configuration](#default-configuration)\n- [Application Usage](#usage)\n    - [Load Deck From A File](#load-a-deck-from-a-file)\n    - [Load Decks From A Folder](#load-decks-from-files-from-a-folder)\n    - [Recursively Load Decks From A Folder](#recursively-load-decks-from-files-in-a-folder)\n- [Example Hanky Scripts](#examples)\n\n\n## Installation\n\nInstall via pip:\n\n`pip install hanky`\n\n## Configuration\n\nSee below an overview of hanky's configuration options or jump to the [default configuration](#default-configuration) section. \n\nHanky 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](#default-configuration).\n\n- `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:\n    - Mac OS: `~/Library/Application Support/Anki2/User 1/collection.anki2`\n    - Linux: `~/.local/share/Anki2/User 1/collection.anki2`\n\n- `database_safety_check`: a boolean which when set to `true` will check for any running processes using the anki collection. Defaults to `true`.\n    > **:warning: Caution:** \n    > Setting this option to false may result in database corruption. Always ensure your anki is backed up.\n\n- `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`.\n\n### Default configuration:\n\n```toml\n# specifies where to find the anki collection (sqlite db where anki stores data)\n# If you are not using the default anki user, 'User 1', this option must be specified\n# DEFAULTS:\n# Mac OS: ~/Library/Application Support/Anki2/User 1/collection.anki2\n# Linux: ~/.local/share/Anki2/User 1/collection.anki2\nanki_database = \"~/.local/share/Anki2/User 1/collection.anki2\"\n\n# whether or not to check for other processes using the anki database\n# DEFAULTS: true\ndatabase_safety_check = true\n\n# whether or not to allow duplicate cards to be added\n# DEFAULTS: false\nallow_duplicates = false\n```\n\n## Usage \n\nHanky can be used as both a command line application and a library. \n\n- 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](#examples)\n\n- If you just want to load flash cards from files, see the examples below\n\nHanky 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`.\n\n**Overview**\n\n```\nusage: hanky [-h] [--config CONFIG] {load,load-dir} ...\n\nSimple program to allow programatic management of anki cards\n\npositional arguments:\n  {load,load-dir}  Type of operation to perform\n    load           Load cards into an anki deck from a file\n    load-dir       Load cards into anki deck(s) from files in a directory, using the filenames as deck names.\n\noptions:\n  -h, --help       show this help message and exit\n  --config CONFIG  Path to hanky toml configuration file\n```\n\n### Load a deck from a file\n\nLoad a single deck using the 'basic' anki model/note type from a file\n\n`hanky load \"basic\" ~/my-folder/countries.csv`\n\nThe following deck will be created:\n- `countries`\n\n### Load decks from files from a folder\n\nLoad 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.\n\n`hanky load-dir \"basic\" \"~/french/\" \"*.csv\"`\n\nFor example, given the following folder structure:\n```\nfrench\n\u251c\u2500\u2500 animals.csv\n\u251c\u2500\u2500 bodies.csv\n\u251c\u2500\u2500 clothing.csv\n\u2514\u2500\u2500 grammar\n    \u2514\u2500\u2500 passe_compose.csv\n```\n\nThe following decks will be created:\n- `french`: top level deck\n- `french::animals`: nested animal vocab deck\n- `french::bodies`: nested bodies vocab deck\n- `french::clothing`: nested clothing vocab deck\n\nThe created anki decks will have the following structure:\n```\nfrench\n\u251c\u2500\u2500 animals\n\u251c\u2500\u2500 bodies\n\u251c\u2500\u2500 clothing\n```\n\n### Recursively load decks from files in a folder\n\nRecursively 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.\n\n`hanky load-dir \"basic\" \"~/french/\" \"*.csv\" -r`\n\nFor example, given the following folder structure:\n```\nfrench\n\u251c\u2500\u2500 animals.csv\n\u251c\u2500\u2500 bodies.csv\n\u251c\u2500\u2500 clothing.csv\n\u2514\u2500\u2500 grammar\n    \u2514\u2500\u2500 passe_compose.csv\n```\n\nThe following decks will be created:\n- `french`: top level deck\n- `french::animals`: nested animal vocab deck\n- `french::bodies`: nested bodies vocab deck\n- `french::clothing`: nested clothing vocab deck\n- `french::grammar`: nested container deck for grammar\n- `french::grammar::passe_compose`: doubly nested deck for passe compose rules\n\nThe created anki decks will have the following structure:\n```\nfrench\n\u251c\u2500\u2500 animals\n\u251c\u2500\u2500 bodies\n\u251c\u2500\u2500 clothing\n\u2514\u2500\u2500 grammar\n    \u2514\u2500\u2500 passe_compose\n```\n\n## Examples\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simple library and command line tool for loading flash cards into anki.",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/Haeata-Ash/hanky",
        "Issues": "https://github.com/Haeata-Ash/hanky/issues"
    },
    "split_keywords": [
        "anki"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "323002032407a5fb1d4e30be86cd1f18cb60d1e9bf2ca4b45b64a97c854bc7b6",
                "md5": "0fa1a24605c57a6fc0a7f9ed6aaea328",
                "sha256": "17dba729141f7440f1774e00c8ef3c70c2b54029d23cf3cec6da6b518028f1cb"
            },
            "downloads": -1,
            "filename": "hanky-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fa1a24605c57a6fc0a7f9ed6aaea328",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13639,
            "upload_time": "2024-06-01T00:28:35",
            "upload_time_iso_8601": "2024-06-01T00:28:35.820328Z",
            "url": "https://files.pythonhosted.org/packages/32/30/02032407a5fb1d4e30be86cd1f18cb60d1e9bf2ca4b45b64a97c854bc7b6/hanky-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "941bc9a3123c7c7f9631f339870d22008dde8bd89b4ce58376ca09c8117a5028",
                "md5": "9f61dac56e11a3b55d74f2f1ebf5f79b",
                "sha256": "5a39acd667d8ab582bf904ad8c7142d2d9fd45df27ba1a7bc842590f9ad96438"
            },
            "downloads": -1,
            "filename": "hanky-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "9f61dac56e11a3b55d74f2f1ebf5f79b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11939,
            "upload_time": "2024-06-01T00:28:33",
            "upload_time_iso_8601": "2024-06-01T00:28:33.088636Z",
            "url": "https://files.pythonhosted.org/packages/94/1b/c9a3123c7c7f9631f339870d22008dde8bd89b4ce58376ca09c8117a5028/hanky-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-01 00:28:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Haeata-Ash",
    "github_project": "hanky",
    "github_not_found": true,
    "lcname": "hanky"
}
        
Elapsed time: 0.29416s