Source code for cardbuilder.common

from enum import Enum
from iso639 import languages


[docs]class Fieldname(Enum): """An enumeration representing the possible types of data that Cardbuilder data sources can return. This class is primarily useful when constructing data source output or when specifying what data should be resolved to a specific field in the Field class constructor.""" # Always present WORD = 'word' FOUND_FORM = 'form' # Universal PART_OF_SPEECH = 'pos' DEFINITIONS = 'def' PRONUNCIATION_IPA = 'ipa' SYNONYMS = 'syns' ANTONYMS = 'ants' INFLECTIONS = 'infs' EXAMPLE_SENTENCES = 'exst' AUDIO = 'aud' SUPPLEMENTAL = 'supp' LINKS = 'link' # Special BLANK = 'blank' # Japanese specific PITCH_ACCENT = 'acnt' READING = 'read' WRITINGS = 'writ' DETAILED_READING = 'rubi' # English from Japanese specific KATAKANA = 'kana'
[docs]class Language(Enum): """An enumeration representing the languages that Cardbuilder supports. The string corresponding to each language is its ISO 639-1 code (see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).""" JAPANESE = 'jpn' ENGLISH = 'eng' HEBREW = 'heb' ESPERANTO = 'epo' def _to_iso_object(self): return languages.get(part3=self.value)
[docs] def get_name(self): return self._to_iso_object().name
[docs] def get_iso2(self): return self._to_iso_object().part2b