# PyGlossary
<p align="center">
<img src="res/pyglossary-256x256.png"></img>
</p>
[![PyPI](https://img.shields.io/pypi/v/pyglossary.svg)](https://pypi.org/project/pyglossary/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyglossary)](https://pypi.org/project/pyglossary/)
[![tests](https://github.com/ilius/pyglossary/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ilius/pyglossary/actions/workflows/test.yml?query=branch%3Amaster)
A tool for converting dictionary files aka glossaries.
The primary purpose is to be able to use our offline glossaries in any Open
Source dictionary we like on any OS/device.
There are countless formats, and my time is limited, so I implement formats that
seem more useful for myself, or for Open Source community. Also diversity of
languages is taken into account. Pull requests are welcome.
## Screenshots
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/44-gtk-txt-stardict-aryanpur-dark.png" width="50%" height="50%"/>
Linux - Gtk3-based interface
______________________________________________________________________
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40b-tk-bgl-epub-es-en-2.png" width="50%" height="50%"/>
Windows - Tkinter-based interface
______________________________________________________________________
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/32-cmd-freedict-mids-de-ru.png" width="50%" height="50%"/>
Linux - command-line interface
______________________________________________________________________
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40-cmdi-termux-zim-slob-en-med.jpg" width="50%" height="50%"/>
Android Termux - interactive command-line interface
______________________________________________________________________
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/50-web-wiktextract-ifo-ar.png" width="50%" height="50%"/>
Web interface
## Supported formats
| Format | | Extension | Read | Write |
| ------------------------------------------------------- | :-: | :-------------: | :--: | :---: |
| [Aard 2 (slob)](./doc/p/aard2_slob.md) | 🔢 | .slob | ✅ | ✅ |
| [AppleDict Binary](./doc/p/appledict_bin.md) | 📁 | .dictionary | ✅ | ❌ |
| [AppleDict Source](./doc/p/appledict.md) | 📁 | | | ✅ |
| [Babylon BGL](./doc/p/babylon_bgl.md) | 🔢 | .bgl | ✅ | ❌ |
| [CSV](./doc/p/csv.md) | 📝 | .csv | ✅ | ✅ |
| [DICT.org / Dictd server](./doc/p/dict_org.md) | 📁 | (📝.index) | ✅ | ✅ |
| [DICT.org / dictfmt source](./doc/p/dict_org_source.md) | 📝 | (.dtxt) | | ✅ |
| [dictunformat output file](./doc/p/dictunformat.md) | 📝 | (.dictunformat) | ✅ | |
| [DictionaryForMIDs](./doc/p/dicformids.md) | 📁 | (📁.mids) | ✅ | ✅ |
| [DIKT JSON](./doc/p/dikt_json.md) | 📝 | (.json) | | ✅ |
| [EPUB-2 E-Book](./doc/p/epub2.md) | 📦 | .epub | ❌ | ✅ |
| [FreeDict](./doc/p/freedict.md) | 📝 | .tei | ✅ | ❌ |
| [Gettext Source](./doc/p/gettext_po.md) | 📝 | .po | ✅ | ✅ |
| [HTML Directory (by file size)](./doc/p/html_dir.md) | 📁 | | ❌ | ✅ |
| [JSON](./doc/p/json.md) | 📝 | .json | | ✅ |
| [Kobo E-Reader Dictionary](./doc/p/kobo.md) | 📦 | .kobo.zip | ❌ | ✅ |
| [Kobo E-Reader Dictfile](./doc/p/kobo_dictfile.md) | 📝 | .df | ✅ | ✅ |
| [Lingoes Source](./doc/p/lingoes_ldf.md) | 📝 | .ldf | ✅ | ✅ |
| [Mobipocket E-Book](./doc/p/mobi.md) | 🔢 | .mobi | ❌ | ✅ |
| [Octopus MDict](./doc/p/octopus_mdict.md) | 🔢 | .mdx | ✅ | ❌ |
| [QuickDic version 6](./doc/p/quickdic6.md) | 🔢 | .quickdic | ✅ | ✅ |
| [SQL](./doc/p/sql.md) | 📝 | .sql | ❌ | ✅ |
| [StarDict](./doc/p/stardict.md) | 📁 | (📝.ifo) | ✅ | ✅ |
| [StarDict Textual File](./doc/p/stardict_textual.md) | 📝 | (.xml) | ✅ | ✅ |
| [Tabfile](./doc/p/tabfile.md) | 📝 | .txt, .tab | ✅ | ✅ |
| [Wiktextract](./doc/p/wiktextract.md) | 📝 | .jsonl | ✅ | ❌ |
| [XDXF](./doc/p/xdxf.md) | 📝 | .xdxf | ✅ | ❌ |
| [Zim (Kiwix)](./doc/p/zim.md) | 🔢 | .zim | ✅ | |
| [ABBYY Lingvo DSL](./doc/p/dsl.md) 🇷🇺 | 📝 | .dsl | ✅ | ❌ |
| [Almaany.com](./doc/p/almaany.md) (Arabic) | 🛢️ | .db | ✅ | ❌ |
| [cc-kedict](./doc/p/cc_kedict.md) 🇰🇷 | 📝 | | ✅ | ❌ |
| [Dict.cc](./doc/p/dict_cc.md) 🇩🇪 | 🛢️ | .db | ✅ | |
| [DigitalNK](./doc/p/digitalnk.md) 🇰🇵 | 🛢️ | .db | ✅ | |
| [EDICT2 (CEDICT)](./doc/p/edict2.md) 🇨🇳 | 📝 | (.u8) | ✅ | ❌ |
| [JMDict](./doc/p/jmdict.md) 🇯🇵 | 📝 | | ✅ | ❌ |
| [JMnedict](./doc/p/jmnedict.md) 🇯🇵 | 📝 | | ✅ | ❌ |
| [WordNet](./doc/p/wordnet.md) 🇬🇧 | 📁 | | ✅ | ❌ |
| [@wordset dictionary](./doc/p/wordset.md) 🇬🇧 | 📁 | | ✅ | |
| [Yomichan / Yomitan](./doc/p/yomichan.md) 🇯🇵 | 📦 | (.zip) | | ✅ |
Legend:
- 📁 Directory
- 📝 Text file
- 📦 Package/archive file
- 🛢️ SQLite file
- 🔢 Binary file
- ✅ Supported
- ❌ Will not be supported
**Note**: SQLite-based formats are not detected by extension (`.db`);
So you need to select the format (with UI or `--read-format` flag).
**Also don't confuse SQLite-based formats with [SQLite mode](#sqlite-mode).**
## Requirements
PyGlossary requires **Python 3.10 or higher**, and works in practically all
modern operating systems. While primarily designed for *GNU/Linux*, it works
on *Windows*, *Mac OS X* and other Unix-based operating systems as well.
As shown in screenshots, there are multiple User Interface types (multiple
ways to use the program).
- **Gtk3-based interface**, uses [PyGI (Python Gobject Introspection)](http://pygobject.readthedocs.io/en/latest/getting_started.html)
You can install it on:
- Debian/Ubuntu: `apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0`
- openSUSE: `zypper install python3-gobject gtk3`
- Fedora: `dnf install pygobject3 python3-gobject gtk3`
- ArchLinux:
- `pacman -S python-gobject gtk3`
- https://aur.archlinux.org/packages/pyglossary/
- Mac OS X: `brew install pygobject3 gtk+3`
- Nix / NixOS: `nix-shell -p pkgs.gobject-introspection python38Packages.pygobject3 python38Packages.pycairo`
- **Tkinter-based interface**, meant to be used in the lack of Gtk. Specially on
Windows where Tkinter library is installed with Python itself.
You can also install it on:
- Debian/Ubuntu: `apt-get install python3-tk tix`
- openSUSE: `zypper install python3-tk tix`
- Fedora: `yum install python3-tkinter tix`
- Mac OS X: read <https://www.python.org/download/mac/tcltk/>
- Nix / NixOS: `nix-shell -p python38Packages.tkinter tix`
- **Command-line interface**, works in all operating systems without
any specific requirements, just type `./main.py --help` or `pyglossary --help`
- **Interactive command-line interface**
- Requires: `pip install prompt_toolkit`
- Perfect for mobile devices (like Termux on Android) where no GUI is available
- Automatically selected if output file argument is not passed **and** one of these:
- On Linux and `$DISPLAY` environment variable is empty or not set
- For example when you are using a remote Linux machine over SSH
- On Mac and no `tkinter` module is found
- Manually select with `--cmd` or `--ui=cmd`
- Minimally: `./main.py --cmd`
- You can still pass input file, or any flag/option
- If both input and output files are passed, non-interactive cmd ui will be default
- If you are writing a script, you can pass `--no-interactive` to force disable interactive ui
- Then you have to pass both input and output file arguments
- Don't forget to use *Up/Down* or *Tab* keys in prompts!
- Up/Down key shows you recent values you have used
- Tab key shows available values/options
- You can press Control+C (on Linux/Windows) at any prompt to exit
## UI (User Interface) selection
When you run PyGlossary without any command-line arguments or options/flags, PyGlossary will try to run the first available interface in this order:
- It tries to find PyGI+Gtk3 and open **Gtk3-based** interface.
- It tries to find PyGI+Gtk4 and open **Gtk4-based** interface.
- It tries to find Tkinter and open **Tkinter-based** interface.
- If it's run in command line (with stdin connected to a terminal) it tries to find `prompt_toolkit` and run **interactive command-line** interface.
- It runs a HTTP server and opens the **web interface** in your browser.
But you can explicitly select user interface type using `--ui`
- `./main.py --ui=gtk`
- `./main.py --ui=gtk4`
- `./main.py --ui=tk`
- `./main.py --ui=web`
- `./main.py --ui=cmd`
## Installation on Windows
- [Download and install Python](https://www.python.org/downloads/windows/) (3.10 or above)
- Open Start -> type Command -> right-click on Command Prompt -> Run as administrator
- To ensure you have `pip`, run: `python -m ensurepip --upgrade`
- To install, run: `pip install --upgrade pyglossary`
- Now you should be able to run `pyglossary` command
- If command was not found, make sure Python environment variables are set up:
<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/windows-python39-env-vars.png" width="50%" height="50%"/>
## Feature-specific requirements
- Using [Sort by Locale](#sorting) feature requires [PyICU](./doc/pyicu.md)
- Using `--remove-html-all` flag requires:
`pip install lxml beautifulsoup4`
Some formats have additional requirements.
If you have trouble with any format, please check the [link given for that format](#supported-formats) to see its documentations.
**Using Termux on Android?** See [doc/termux.md](./doc/termux.md)
## Configuration
See [doc/config.rst](./doc/config.rst).
## Direct and indirect modes
Indirect mode means that input glossary is completely read and loaded into RAM, then converted
into output format. This was the only method available in old versions (before [3.0.0](https://github.com/ilius/pyglossary/releases/tag/3.0.0)).
Direct mode means entries are one-at-a-time read, processed and written into output glossary.
Direct mode was added to limit memory usage for large glossaries; But it may reduce the
conversion time for most cases as well.
Converting glossaries into these formats requires [sorting](#sorting) entries:
- [StarDict](./doc/p/stardict.md)
- [EPUB-2](./doc/p/epub2.md)
- [Mobipocket E-Book](./doc/p/mobi.md)
- [Yomichan](./doc/p/yomichan.md)
- [DictionaryForMIDs](./doc/p/dicformids.md)
That's why direct mode will not work for these formats, and PyGlossary has to
switch to indirect mode (or it previously had to, see [SQLite mode](#sqlite-mode)).
For other formats, direct mode will be default. You may override this by `--indirect` flag.
## SQLite mode
As mentioned above, converting glossaries to some specific formats will
need them to loaded into RAM.
This can be problematic if the glossary is too big to fit into RAM. That's when
you should try adding `--sqlite` flag to your command. Then it uses SQLite3 as intermediate
storage for storing, sorting and then fetching entries. This fixes the memory issue, and may
even reduce running time of conversion (depending on your home directory storage).
The temporary SQLite file is stored in [cache directory](#cache-directory) then
deleted after conversion (unless you pass `--no-cleanup` flag).
SQLite mode is automatically enabled for writing these formats if `auto_sqlite`
[config parameter](./doc/config.rst) is `true` (which is default).
This also applies to when you pass `--sort` flag for any format.
You may use `--no-sqlite` to override this and switch to indirect mode.
Currently you can not disable alternates in SQLite mode (`--no-alts` is ignored).
## Sorting
There are two things than can activate sorting entries:
- Output format requires sorting (as explained [above](#direct-and-indirect-modes))
- You pass `--sort` flag in command line.
In the case of passing `--sort`, you can also pass:
- `--sort-key` to select sort key aka sorting order (including locale), see [doc/sort-key.md](./doc/sort-key.md)
- `--sort-encoding` to change the encoding used for sort
- UTF-8 is the default encoding for all sort keys and all output formats (unless mentioned otherwise)
- This will only effect the order of entries, and will not corrupt words / definition
- Non-encodable characters are replaced with `?` byte (*only for sorting*)
## Cache directory
Cache directory is used for storing temporary files which are either moved or deleted
after conversion. You can pass `--no-cleanup` flag in order to keep them.
The path for cache directory:
- Linux or BSD: `~/.cache/pyglossary/`
- Mac: `~/Library/Caches/PyGlossary/`
- Windows: `C:\Users\USERNAME\AppData\Local\PyGlossary\Cache\`
## User plugins
If you want to add your own plugin without adding it to source code directory,
or you want to use a plugin that has been removed from repository,
you can place it in this directory:
- Linux or BSD: `~/.pyglossary/plugins/`
- Mac: `~/Library/Preferences/PyGlossary/plugins/`
- Windows: `C:\Users\USERNAME\AppData\Roaming\PyGlossary\plugins\`
## Linux packaging status
[![Packaging status](https://repology.org/badge/vertical-allrepos/pyglossary.svg?columns=3&header=PyGlossary)](https://repology.org/project/pyglossary/versions)
## Using PyGlossary as a library
See [doc/lib-usage.md](./doc/lib-usage.md) for how to use PyGlossary as a Python library.
## Internals
See [doc/internals.md](./doc/internals.md) for information about internal glossary structure and entry filters.
Raw data
{
"_id": null,
"home_page": "https://github.com/ilius/pyglossary",
"name": "pyglossary",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10.0",
"maintainer_email": null,
"keywords": "dictionary, glossary",
"author": "Saeed Rasooli",
"author_email": "Saeed Rasooli <saeed.gnu@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ea/8f/6ef502bac5ec911c33f8792193b55dd1f2214d2703107df733b668ce2067/pyglossary-5.0.6.tar.gz",
"platform": null,
"description": "# PyGlossary\n\n<p align=\"center\">\n\t<img src=\"res/pyglossary-256x256.png\"></img>\n</p>\n\n[![PyPI](https://img.shields.io/pypi/v/pyglossary.svg)](https://pypi.org/project/pyglossary/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyglossary)](https://pypi.org/project/pyglossary/)\n[![tests](https://github.com/ilius/pyglossary/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ilius/pyglossary/actions/workflows/test.yml?query=branch%3Amaster)\n\nA tool for converting dictionary files aka glossaries.\n\nThe primary purpose is to be able to use our offline glossaries in any Open\nSource dictionary we like on any OS/device.\n\nThere are countless formats, and my time is limited, so I implement formats that\nseem more useful for myself, or for Open Source community. Also diversity of\nlanguages is taken into account. Pull requests are welcome.\n\n## Screenshots\n\n<img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/44-gtk-txt-stardict-aryanpur-dark.png\" width=\"50%\" height=\"50%\"/>\n\nLinux - Gtk3-based interface\n\n______________________________________________________________________\n\n<img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40b-tk-bgl-epub-es-en-2.png\" width=\"50%\" height=\"50%\"/>\n\nWindows - Tkinter-based interface\n\n______________________________________________________________________\n\n<img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/32-cmd-freedict-mids-de-ru.png\" width=\"50%\" height=\"50%\"/>\n\nLinux - command-line interface\n\n______________________________________________________________________\n\n<img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40-cmdi-termux-zim-slob-en-med.jpg\" width=\"50%\" height=\"50%\"/>\n\nAndroid Termux - interactive command-line interface\n\n______________________________________________________________________\n\n<img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/50-web-wiktextract-ifo-ar.png\" width=\"50%\" height=\"50%\"/>\n\nWeb interface\n\n## Supported formats\n\n| Format | | Extension | Read | Write |\n| ------------------------------------------------------- | :-: | :-------------: | :--: | :---: |\n| [Aard 2 (slob)](./doc/p/aard2_slob.md) | \ud83d\udd22 | .slob | \u2705 | \u2705 |\n| [AppleDict Binary](./doc/p/appledict_bin.md) | \ud83d\udcc1 | .dictionary | \u2705 | \u274c |\n| [AppleDict Source](./doc/p/appledict.md) | \ud83d\udcc1 | | | \u2705 |\n| [Babylon BGL](./doc/p/babylon_bgl.md) | \ud83d\udd22 | .bgl | \u2705 | \u274c |\n| [CSV](./doc/p/csv.md) | \ud83d\udcdd | .csv | \u2705 | \u2705 |\n| [DICT.org / Dictd server](./doc/p/dict_org.md) | \ud83d\udcc1 | (\ud83d\udcdd.index) | \u2705 | \u2705 |\n| [DICT.org / dictfmt source](./doc/p/dict_org_source.md) | \ud83d\udcdd | (.dtxt) | | \u2705 |\n| [dictunformat output file](./doc/p/dictunformat.md) | \ud83d\udcdd | (.dictunformat) | \u2705 | |\n| [DictionaryForMIDs](./doc/p/dicformids.md) | \ud83d\udcc1 | (\ud83d\udcc1.mids) | \u2705 | \u2705 |\n| [DIKT JSON](./doc/p/dikt_json.md) | \ud83d\udcdd | (.json) | | \u2705 |\n| [EPUB-2 E-Book](./doc/p/epub2.md) | \ud83d\udce6 | .epub | \u274c | \u2705 |\n| [FreeDict](./doc/p/freedict.md) | \ud83d\udcdd | .tei | \u2705 | \u274c |\n| [Gettext Source](./doc/p/gettext_po.md) | \ud83d\udcdd | .po | \u2705 | \u2705 |\n| [HTML Directory (by file size)](./doc/p/html_dir.md) | \ud83d\udcc1 | | \u274c | \u2705 |\n| [JSON](./doc/p/json.md) | \ud83d\udcdd | .json | | \u2705 |\n| [Kobo E-Reader Dictionary](./doc/p/kobo.md) | \ud83d\udce6 | .kobo.zip | \u274c | \u2705 |\n| [Kobo E-Reader Dictfile](./doc/p/kobo_dictfile.md) | \ud83d\udcdd | .df | \u2705 | \u2705 |\n| [Lingoes Source](./doc/p/lingoes_ldf.md) | \ud83d\udcdd | .ldf | \u2705 | \u2705 |\n| [Mobipocket E-Book](./doc/p/mobi.md) | \ud83d\udd22 | .mobi | \u274c | \u2705 |\n| [Octopus MDict](./doc/p/octopus_mdict.md) | \ud83d\udd22 | .mdx | \u2705 | \u274c |\n| [QuickDic version 6](./doc/p/quickdic6.md) | \ud83d\udd22 | .quickdic | \u2705 | \u2705 |\n| [SQL](./doc/p/sql.md) | \ud83d\udcdd | .sql | \u274c | \u2705 |\n| [StarDict](./doc/p/stardict.md) | \ud83d\udcc1 | (\ud83d\udcdd.ifo) | \u2705 | \u2705 |\n| [StarDict Textual File](./doc/p/stardict_textual.md) | \ud83d\udcdd | (.xml) | \u2705 | \u2705 |\n| [Tabfile](./doc/p/tabfile.md) | \ud83d\udcdd | .txt, .tab | \u2705 | \u2705 |\n| [Wiktextract](./doc/p/wiktextract.md) | \ud83d\udcdd | .jsonl | \u2705 | \u274c |\n| [XDXF](./doc/p/xdxf.md) | \ud83d\udcdd | .xdxf | \u2705 | \u274c |\n| [Zim (Kiwix)](./doc/p/zim.md) | \ud83d\udd22 | .zim | \u2705 | |\n| [ABBYY Lingvo DSL](./doc/p/dsl.md) \ud83c\uddf7\ud83c\uddfa | \ud83d\udcdd | .dsl | \u2705 | \u274c |\n| [Almaany.com](./doc/p/almaany.md) (Arabic) | \ud83d\udee2\ufe0f | .db | \u2705 | \u274c |\n| [cc-kedict](./doc/p/cc_kedict.md) \ud83c\uddf0\ud83c\uddf7 | \ud83d\udcdd | | \u2705 | \u274c |\n| [Dict.cc](./doc/p/dict_cc.md) \ud83c\udde9\ud83c\uddea | \ud83d\udee2\ufe0f | .db | \u2705 | |\n| [DigitalNK](./doc/p/digitalnk.md) \ud83c\uddf0\ud83c\uddf5 | \ud83d\udee2\ufe0f | .db | \u2705 | |\n| [EDICT2 (CEDICT)](./doc/p/edict2.md) \ud83c\udde8\ud83c\uddf3 | \ud83d\udcdd | (.u8) | \u2705 | \u274c |\n| [JMDict](./doc/p/jmdict.md) \ud83c\uddef\ud83c\uddf5 | \ud83d\udcdd | | \u2705 | \u274c |\n| [JMnedict](./doc/p/jmnedict.md) \ud83c\uddef\ud83c\uddf5 | \ud83d\udcdd | | \u2705 | \u274c |\n| [WordNet](./doc/p/wordnet.md) \ud83c\uddec\ud83c\udde7 | \ud83d\udcc1 | | \u2705 | \u274c |\n| [@wordset dictionary](./doc/p/wordset.md) \ud83c\uddec\ud83c\udde7 | \ud83d\udcc1 | | \u2705 | |\n| [Yomichan / Yomitan](./doc/p/yomichan.md) \ud83c\uddef\ud83c\uddf5 | \ud83d\udce6 | (.zip) | | \u2705 |\n\nLegend:\n\n- \ud83d\udcc1\tDirectory\n- \ud83d\udcdd\tText file\n- \ud83d\udce6\tPackage/archive file\n- \ud83d\udee2\ufe0f\tSQLite file\n- \ud83d\udd22\tBinary file\n- \u2705\tSupported\n- \u274c \tWill not be supported\n\n**Note**: SQLite-based formats are not detected by extension (`.db`);\nSo you need to select the format (with UI or `--read-format` flag).\n**Also don't confuse SQLite-based formats with [SQLite mode](#sqlite-mode).**\n\n## Requirements\n\nPyGlossary requires **Python 3.10 or higher**, and works in practically all\nmodern operating systems. While primarily designed for *GNU/Linux*, it works\non *Windows*, *Mac OS X* and other Unix-based operating systems as well.\n\nAs shown in screenshots, there are multiple User Interface types (multiple\nways to use the program).\n\n- **Gtk3-based interface**, uses [PyGI (Python Gobject Introspection)](http://pygobject.readthedocs.io/en/latest/getting_started.html)\n You can install it on:\n\n - Debian/Ubuntu: `apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0`\n - openSUSE: `zypper install python3-gobject gtk3`\n - Fedora: `dnf install pygobject3 python3-gobject gtk3`\n - ArchLinux:\n - `pacman -S python-gobject gtk3`\n - https://aur.archlinux.org/packages/pyglossary/\n - Mac OS X: `brew install pygobject3 gtk+3`\n - Nix / NixOS: `nix-shell -p pkgs.gobject-introspection python38Packages.pygobject3 python38Packages.pycairo`\n\n- **Tkinter-based interface**, meant to be used in the lack of Gtk. Specially on\n Windows where Tkinter library is installed with Python itself.\n You can also install it on:\n\n - Debian/Ubuntu: `apt-get install python3-tk tix`\n - openSUSE: `zypper install python3-tk tix`\n - Fedora: `yum install python3-tkinter tix`\n - Mac OS X: read <https://www.python.org/download/mac/tcltk/>\n - Nix / NixOS: `nix-shell -p python38Packages.tkinter tix`\n\n- **Command-line interface**, works in all operating systems without\n any specific requirements, just type `./main.py --help` or `pyglossary --help`\n\n - **Interactive command-line interface**\n - Requires: `pip install prompt_toolkit`\n - Perfect for mobile devices (like Termux on Android) where no GUI is available\n - Automatically selected if output file argument is not passed **and** one of these:\n - On Linux and `$DISPLAY` environment variable is empty or not set\n - For example when you are using a remote Linux machine over SSH\n - On Mac and no `tkinter` module is found\n - Manually select with `--cmd` or `--ui=cmd`\n - Minimally: `./main.py --cmd`\n - You can still pass input file, or any flag/option\n - If both input and output files are passed, non-interactive cmd ui will be default\n - If you are writing a script, you can pass `--no-interactive` to force disable interactive ui\n - Then you have to pass both input and output file arguments\n - Don't forget to use *Up/Down* or *Tab* keys in prompts!\n - Up/Down key shows you recent values you have used\n - Tab key shows available values/options\n - You can press Control+C (on Linux/Windows) at any prompt to exit\n\n## UI (User Interface) selection\n\nWhen you run PyGlossary without any command-line arguments or options/flags, PyGlossary will try to run the first available interface in this order:\n\n- It tries to find PyGI+Gtk3 and open **Gtk3-based** interface.\n- It tries to find PyGI+Gtk4 and open **Gtk4-based** interface.\n- It tries to find Tkinter and open **Tkinter-based** interface.\n- If it's run in command line (with stdin connected to a terminal) it tries to find `prompt_toolkit` and run **interactive command-line** interface.\n- It runs a HTTP server and opens the **web interface** in your browser.\n\nBut you can explicitly select user interface type using `--ui`\n\n- `./main.py --ui=gtk`\n- `./main.py --ui=gtk4`\n- `./main.py --ui=tk`\n- `./main.py --ui=web`\n- `./main.py --ui=cmd`\n\n## Installation on Windows\n\n- [Download and install Python](https://www.python.org/downloads/windows/) (3.10 or above)\n- Open Start -> type Command -> right-click on Command Prompt -> Run as administrator\n- To ensure you have `pip`, run: `python -m ensurepip --upgrade`\n- To install, run: `pip install --upgrade pyglossary`\n- Now you should be able to run `pyglossary` command\n- If command was not found, make sure Python environment variables are set up:\n <img src=\"https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/windows-python39-env-vars.png\" width=\"50%\" height=\"50%\"/>\n\n## Feature-specific requirements\n\n- Using [Sort by Locale](#sorting) feature requires [PyICU](./doc/pyicu.md)\n\n- Using `--remove-html-all` flag requires:\n\n `pip install lxml beautifulsoup4`\n\nSome formats have additional requirements.\nIf you have trouble with any format, please check the [link given for that format](#supported-formats) to see its documentations.\n\n**Using Termux on Android?** See [doc/termux.md](./doc/termux.md)\n\n## Configuration\n\nSee [doc/config.rst](./doc/config.rst).\n\n## Direct and indirect modes\n\nIndirect mode means that input glossary is completely read and loaded into RAM, then converted\ninto output format. This was the only method available in old versions (before [3.0.0](https://github.com/ilius/pyglossary/releases/tag/3.0.0)).\n\nDirect mode means entries are one-at-a-time read, processed and written into output glossary.\n\nDirect mode was added to limit memory usage for large glossaries; But it may reduce the\nconversion time for most cases as well.\n\nConverting glossaries into these formats requires [sorting](#sorting) entries:\n\n- [StarDict](./doc/p/stardict.md)\n- [EPUB-2](./doc/p/epub2.md)\n- [Mobipocket E-Book](./doc/p/mobi.md)\n- [Yomichan](./doc/p/yomichan.md)\n- [DictionaryForMIDs](./doc/p/dicformids.md)\n\nThat's why direct mode will not work for these formats, and PyGlossary has to\nswitch to indirect mode (or it previously had to, see [SQLite mode](#sqlite-mode)).\n\nFor other formats, direct mode will be default. You may override this by `--indirect` flag.\n\n## SQLite mode\n\nAs mentioned above, converting glossaries to some specific formats will\nneed them to loaded into RAM.\n\nThis can be problematic if the glossary is too big to fit into RAM. That's when\nyou should try adding `--sqlite` flag to your command. Then it uses SQLite3 as intermediate\nstorage for storing, sorting and then fetching entries. This fixes the memory issue, and may\neven reduce running time of conversion (depending on your home directory storage).\n\nThe temporary SQLite file is stored in [cache directory](#cache-directory) then\ndeleted after conversion (unless you pass `--no-cleanup` flag).\n\nSQLite mode is automatically enabled for writing these formats if `auto_sqlite`\n[config parameter](./doc/config.rst) is `true` (which is default).\nThis also applies to when you pass `--sort` flag for any format.\nYou may use `--no-sqlite` to override this and switch to indirect mode.\n\nCurrently you can not disable alternates in SQLite mode (`--no-alts` is ignored).\n\n## Sorting\n\nThere are two things than can activate sorting entries:\n\n- Output format requires sorting (as explained [above](#direct-and-indirect-modes))\n- You pass `--sort` flag in command line.\n\nIn the case of passing `--sort`, you can also pass:\n\n- `--sort-key` to select sort key aka sorting order (including locale), see [doc/sort-key.md](./doc/sort-key.md)\n\n- `--sort-encoding` to change the encoding used for sort\n\n - UTF-8 is the default encoding for all sort keys and all output formats (unless mentioned otherwise)\n - This will only effect the order of entries, and will not corrupt words / definition\n - Non-encodable characters are replaced with `?` byte (*only for sorting*)\n\n## Cache directory\n\nCache directory is used for storing temporary files which are either moved or deleted\nafter conversion. You can pass `--no-cleanup` flag in order to keep them.\n\nThe path for cache directory:\n\n- Linux or BSD: `~/.cache/pyglossary/`\n- Mac: `~/Library/Caches/PyGlossary/`\n- Windows: `C:\\Users\\USERNAME\\AppData\\Local\\PyGlossary\\Cache\\`\n\n## User plugins\n\nIf you want to add your own plugin without adding it to source code directory,\nor you want to use a plugin that has been removed from repository,\nyou can place it in this directory:\n\n- Linux or BSD: `~/.pyglossary/plugins/`\n- Mac: `~/Library/Preferences/PyGlossary/plugins/`\n- Windows: `C:\\Users\\USERNAME\\AppData\\Roaming\\PyGlossary\\plugins\\`\n\n## Linux packaging status\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/pyglossary.svg?columns=3&header=PyGlossary)](https://repology.org/project/pyglossary/versions)\n\n## Using PyGlossary as a library\n\nSee [doc/lib-usage.md](./doc/lib-usage.md) for how to use PyGlossary as a Python library.\n\n## Internals\n\nSee [doc/internals.md](./doc/internals.md) for information about internal glossary structure and entry filters.\n",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "A tool for converting dictionary files aka glossaries.",
"version": "5.0.6",
"project_urls": {
"Changelog": "https://github.com/ilius/pyglossary/tree/master/doc/releases",
"Homepage": "https://github.com/ilius/pyglossary",
"Issues": "https://github.com/ilius/pyglossary/issues"
},
"split_keywords": [
"dictionary",
" glossary"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fabaad10b30df3f35bad9ba83a565167d89380440e77de96d1ee468d30c5b463",
"md5": "3e6fb45077837d15a7a5ba06ed25a1b4",
"sha256": "70ce16a34d5ed2455fb5027f0ca0577f7bd8de94aa8c8204c1d85d423bcab3b1"
},
"downloads": -1,
"filename": "pyglossary-5.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e6fb45077837d15a7a5ba06ed25a1b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.0",
"size": 644623,
"upload_time": "2025-01-11T04:30:40",
"upload_time_iso_8601": "2025-01-11T04:30:40.818384Z",
"url": "https://files.pythonhosted.org/packages/fa/ba/ad10b30df3f35bad9ba83a565167d89380440e77de96d1ee468d30c5b463/pyglossary-5.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ea8f6ef502bac5ec911c33f8792193b55dd1f2214d2703107df733b668ce2067",
"md5": "2adc27ac9fa9a74ce67f9d71b479959e",
"sha256": "3eb8643875ae071832b7a2e65012206372eb59571e6005983763735a9dc99d20"
},
"downloads": -1,
"filename": "pyglossary-5.0.6.tar.gz",
"has_sig": false,
"md5_digest": "2adc27ac9fa9a74ce67f9d71b479959e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.0",
"size": 484407,
"upload_time": "2025-01-11T04:30:43",
"upload_time_iso_8601": "2025-01-11T04:30:43.270375Z",
"url": "https://files.pythonhosted.org/packages/ea/8f/6ef502bac5ec911c33f8792193b55dd1f2214d2703107df733b668ce2067/pyglossary-5.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-11 04:30:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ilius",
"github_project": "pyglossary",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyglossary"
}