summaryrefslogtreecommitdiffstats
path: root/src/python/orcus/__init__.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
commitc484829272cd13a738e35412498e12f2c9a194ac (patch)
treea1f5ec09629ee895bd3963fa8820b45f2f4c574b /src/python/orcus/__init__.py
parentInitial commit. (diff)
downloadliborcus-c484829272cd13a738e35412498e12f2c9a194ac.tar.xz
liborcus-c484829272cd13a738e35412498e12f2c9a194ac.zip
Adding upstream version 0.19.2.upstream/0.19.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/python/orcus/__init__.py')
-rw-r--r--src/python/orcus/__init__.py111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/python/orcus/__init__.py b/src/python/orcus/__init__.py
new file mode 100644
index 0000000..4914d95
--- /dev/null
+++ b/src/python/orcus/__init__.py
@@ -0,0 +1,111 @@
+#######################################################################
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+########################################################################
+
+try:
+ from _orcus import *
+ from _orcus import __version__
+except ModuleNotFoundError:
+ # We do this to enable sphinx to generate documentation without having to
+ # build the C++ part.
+ pass
+
+from enum import Enum
+
+
+class FormatType(Enum):
+ """Collection of file format types currently used in orcus."""
+
+ UNKNOWN = 0
+ ODS = 1
+ XLSX = 2
+ GNUMERIC = 3
+ XLS_XML = 4
+ CSV = 5
+ YAML = 6
+ JSON = 7
+ XML = 8
+ PARQUET = 9
+
+
+class CellType(Enum):
+ """Collection of cell types stored in spreadsheet."""
+
+ UNKNOWN = 0
+ EMPTY = 1
+ BOOLEAN = 2
+ NUMERIC = 3
+ STRING = 4
+ STRING_WITH_ERROR = 5
+ FORMULA = 6
+ FORMULA_WITH_ERROR = 7
+
+
+class FormulaTokenType(Enum):
+ """Collection of formula token types."""
+
+ UNKNOWN = 0
+ REFERENCE = 1
+ VALUE = 2
+ NAME = 3
+ FUNCTION = 4
+ OPERATOR = 5
+ ERROR = 6
+
+
+class FormulaTokenOp(Enum):
+ """Collection of formula token opcodes."""
+
+ UNKNOWN = 0
+ SINGLE_REF = 1
+ RANGE_REF = 2
+ TABLE_REF = 3
+ NAMED_EXPRESSION = 4
+ STRING = 5
+ VALUE = 6
+ FUNCTION = 7
+ PLUS = 8
+ MINUS = 9
+ DIVIDE = 10
+ MULTIPLY = 11
+ EXPONENT = 12
+ CONCAT = 13
+ EQUAL = 14
+ NOT_EQUAL = 15
+ LESS = 16
+ GREATER = 17
+ LESS_EQUAL = 18
+ GREATER_EQUAL = 19
+ OPEN = 20
+ CLOSE = 21
+ SEP = 22
+ ERROR = 23
+
+
+def get_document_loader_module(format_type):
+ """Obtain a document loader module for the specified format type.
+
+ Args:
+ format_type (orcus.FormatType):
+ Format type for which to load a document loader.
+
+ Returns:
+ Document loader module.
+ """
+ m = None
+ if format_type == FormatType.ODS:
+ from . import ods as m
+ elif format_type == FormatType.XLSX:
+ from . import xlsx as m
+ elif format_type == FormatType.XLS_XML:
+ from . import xls_xml as m
+ elif format_type == FormatType.GNUMERIC:
+ from . import gnumeric as m
+ elif format_type == FormatType.CSV:
+ from . import csv as m
+
+ return m