python-escpos/src/escpos/codepages.py
Patrick Kanzler fbabd8ed88
Drop Py37, improve typing and docstrings (#544)
Drops Py3.7, improves typing and adds a mypy config, improves the docstrings and isorts the imports.

* configure isort
* sort with isort
* add github action
* enable flake8-docstrings
* fix docstrings
* add mypy env
* no implicit optional
* add type for raw
* add some type hints
2023-08-15 01:03:36 +02:00

33 lines
762 B
Python

"""Helper module for codepage handling."""
from .capabilities import CAPABILITIES
class CodePageManager:
"""Holds information about all the code pages.
Information as defined in escpos-printer-db.
"""
def __init__(self, data):
"""Initialize codepage manager."""
self.data = data
def get_all(self):
"""Get list of all codepages."""
return self.data.values()
@staticmethod
def get_encoding_name(encoding):
"""Get encoding name.
.. todo:: Resolve the encoding alias.
"""
return encoding.upper()
def get_encoding(self, encoding):
"""Return the encoding data."""
return self.data[encoding]
CodePages = CodePageManager(CAPABILITIES["encodings"])