Dialects¶
This section discusses the concepts of Parser
, Compiler
and
Dialect
The OMI tool handles all metadata in an internal data structure that covers the relevant information needed to describe data. Different metadata formats (e.g. the OEP metadata format) can be parsed into this structure or compiled from it.
Therefore, OMI uses the notion of Parser and Compiler. A
Dialect
combines the functionalities of
Parser
,
Compiler
and adds some convenience methods
to it. Each dialect has an id that can be used to call it via the command line interface
- Available dialects are:
- oep-v1.3
- oep-v1.4
- oep-rdf-v1.4
-
class
omi.dialects.base.dialect.
Parser
[source]¶ A parser is used to transform to read a specific metadata format and transform it into the internal metadata representation.
-
is_file_valid
(file: str, **kwargs)[source]¶ Verify whether the contents of the file under file is parsable by this parser
Parameters: - file (str) – Path to the file to validate
- **kwargs
Returns: bool – Returns True iff the file’s content is parsable
-
is_valid
(inp: str) → bool[source]¶ Verify whether inp is a sting representation that is parsable by this parser
Parameters: inp (str) – String to verify Returns: bool – Indicated whether this object is parsable or not
-
load_string
(string: str, *args, **kwargs)[source]¶ Load a string into the structure represented by the dialect :Parameters: string (str)
Returns: Translates the passed string into the format used as input for this parser
-
-
class
omi.dialects.base.dialect.
Compiler
[source]¶ Compiles
Compilable
objects into the respective metadata format. Every omi compiler should inherit from this class-
visit
(obj, *args, **kwargs)[source]¶ Calls the respective compiler for
Compilable
objects respective toCompilable.__compiler_name__
Parameters: obj – Object to compile Returns: Metadata representation of obj
-
-
class
omi.dialects.base.dialect.
Dialect
[source]¶ -
compile
(obj: omi.structure.OEPMetadata, *args, **kwargs)[source]¶ Compiles the passed
OEPMetadata
-object into the structure fitting for this dialectParameters: obj – The OEPMetadata
-object to compile
-