Exporter
This module contains an “Export extensions” for LOD dictionary SQL model. Add export() function to db object for returning its text string presentation.
- class loglan_core.addons.exporter.Exporter[source]
Bases:
objectThis class serves as a general exporter for various types of objects. The types of objects that can be exported include: BaseAuthor, BaseDefinition, BaseEvent, BaseSetting, BaseSyllable, BaseType, BaseWord, and BaseWordSpell. For each of these types of objects, there’s an associated method that takes the object as an input and returns a formatted string suitable for export.
- export()[source]
The main method that uses a dictionary to map the type of the input object to the respective export method.
- Raises:
ValueError – If the object type is not supported for export.
- FORMAT_DATE_EVENT = '%m/%d/%Y'
- FORMAT_DATE_SETTING = '%d.%m.%Y %H:%M:%S'
- classmethod export(obj, separator='@')[source]
Export the given object using the appropriate exporter function. :type obj: :param obj: The object to be exported. :type separator:
str:param separator: The separator to be used in the exported string.- Return type:
str- Returns:
The exported object.
- Raises:
ValueError – If the object type is not supported.
- static export_author(obj)[source]
Prepare Author data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static export_definition(obj)[source]
Prepare Definition data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- classmethod export_event(obj)[source]
Prepare Event data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- classmethod export_setting(obj)[source]
Prepare Setting data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static export_syllable(obj)[source]
Prepare Syllable data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static export_type(obj)[source]
Prepare Type data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static export_word(obj)[source]
Prepare Word data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static export_word_spell(obj)[source]
Prepare WordSpell data for exporting to text file
- Returns:
elements for export
- Return type:
tuple
- static merge_by(items, separator='@')[source]
Merges a list of items into a single string, separated by the specified separator. :type items:
Iterable:param items: The list of items to merge. :type items: list :type separator:str:param separator: The string to use as a separator, with a defaultvalue.
Returns: str: The resulting string after joining the items.
- Return type:
str