sdata 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sdata/__init__.py +140 -0
- sdata/base.py +684 -0
- sdata/contrib/__init__.py +0 -0
- sdata/contrib/piexif/__init__.py +12 -0
- sdata/contrib/piexif/_common.py +94 -0
- sdata/contrib/piexif/_dump.py +346 -0
- sdata/contrib/piexif/_exceptions.py +2 -0
- sdata/contrib/piexif/_exif.py +638 -0
- sdata/contrib/piexif/_insert.py +60 -0
- sdata/contrib/piexif/_load.py +270 -0
- sdata/contrib/piexif/_remove.py +56 -0
- sdata/contrib/piexif/_transplant.py +45 -0
- sdata/contrib/piexif/_webp.py +240 -0
- sdata/contrib/piexif/helper.py +66 -0
- sdata/contrib/ranger/__init__.py +8 -0
- sdata/contrib/ranger/collections/__init__.py +0 -0
- sdata/contrib/ranger/collections/rangebucketmap.py +346 -0
- sdata/contrib/ranger/collections/rangemap.py +396 -0
- sdata/contrib/ranger/collections/rangeset.py +483 -0
- sdata/contrib/ranger/range/__init__.py +0 -0
- sdata/contrib/ranger/range/cut.py +285 -0
- sdata/contrib/ranger/range/range.py +644 -0
- sdata/contrib/sobol_seq.py +394 -0
- sdata/contrib/sortedcontainers/LICENSE +13 -0
- sdata/contrib/sortedcontainers/__init__.py +74 -0
- sdata/contrib/sortedcontainers/sorteddict.py +789 -0
- sdata/contrib/sortedcontainers/sortedlist.py +2646 -0
- sdata/contrib/sortedcontainers/sortedset.py +733 -0
- sdata/contrib/sqlitedict.py +598 -0
- sdata/contrib/timeflake/__init__.py +40 -0
- sdata/contrib/timeflake/flake.py +69 -0
- sdata/contrib/timeflake/utils.py +47 -0
- sdata/deprecated/__init__.py +10 -0
- sdata/deprecated/data.py +1503 -0
- sdata/did/__init__.py +129 -0
- sdata/did/_http.py +67 -0
- sdata/did/base58btc.py +49 -0
- sdata/did/did_github.py +152 -0
- sdata/did/did_peer4.py +155 -0
- sdata/did/did_web.py +222 -0
- sdata/did/diddoc.py +75 -0
- sdata/did/ed25519.py +225 -0
- sdata/did/eddsa.py +107 -0
- sdata/did/errors.py +40 -0
- sdata/did/issue_vc.py +193 -0
- sdata/did/jose.py +126 -0
- sdata/did/keys.py +104 -0
- sdata/did/utils_didkey.py +161 -0
- sdata/did/verify_vp.py +158 -0
- sdata/doe.py +101 -0
- sdata/dtypes.py +510 -0
- sdata/experiments/__init__.py +331 -0
- sdata/experiments/blob0.py +131 -0
- sdata/experiments/file.py +42 -0
- sdata/experiments/filegroup.py +144 -0
- sdata/experiments/image_old.py +313 -0
- sdata/experiments/ks2.py +15 -0
- sdata/experiments/lapshear.py +8 -0
- sdata/experiments/material.py +7 -0
- sdata/experiments/parameters_deprecated.py +394 -0
- sdata/experiments/workbook.py +226 -0
- sdata/format.py +125 -0
- sdata/imagemeta.py +533 -0
- sdata/interactive.py +118 -0
- sdata/iolib/__init__.py +51 -0
- sdata/iolib/hashtree.py +264 -0
- sdata/iolib/json1sqlitestore.py +554 -0
- sdata/iolib/jsonsqlitestore.py +704 -0
- sdata/iolib/pud.py +242 -0
- sdata/iolib/reader.py +262 -0
- sdata/iolib/writer.py +419 -0
- sdata/metadata.py +882 -0
- sdata/parameter.py +414 -0
- sdata/schema.py +273 -0
- sdata/sclass/__init__.py +111 -0
- sdata/sclass/bfo_classes.py +362 -0
- sdata/sclass/blob.py +362 -0
- sdata/sclass/content.py +87 -0
- sdata/sclass/dataframe.py +1251 -0
- sdata/sclass/dataframegroup.py +187 -0
- sdata/sclass/dependency_graph.py +85 -0
- sdata/sclass/filereference.py +124 -0
- sdata/sclass/image.py +218 -0
- sdata/sclass/lazy_namespace.py +155 -0
- sdata/sclass/process.py +383 -0
- sdata/sclass/process_graph.py +221 -0
- sdata/sclass/zipfile.py +135 -0
- sdata/semantic.py +346 -0
- sdata/suuid.py +136 -0
- sdata/timestamp.py +336 -0
- sdata/tools.py +14 -0
- sdata/units.py +602 -0
- sdata/vocab.py +149 -0
- sdata-1.5.0.dist-info/METADATA +264 -0
- sdata-1.5.0.dist-info/RECORD +98 -0
- sdata-1.5.0.dist-info/WHEEL +5 -0
- sdata-1.5.0.dist-info/licenses/LICENSE-MIT +21 -0
- sdata-1.5.0.dist-info/top_level.txt +1 -0
sdata/__init__.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# -*-coding: utf-8-*-
|
|
2
|
+
from __future__ import division
|
|
3
|
+
|
|
4
|
+
__version__ = '1.5.0'
|
|
5
|
+
__revision__ = None
|
|
6
|
+
__version_info__ = tuple([int(num) for num in __version__.split('.')])
|
|
7
|
+
|
|
8
|
+
'''
|
|
9
|
+
basic sdata types
|
|
10
|
+
'''
|
|
11
|
+
|
|
12
|
+
import sys
|
|
13
|
+
import uuid
|
|
14
|
+
import logging
|
|
15
|
+
import re
|
|
16
|
+
import unicodedata
|
|
17
|
+
|
|
18
|
+
# Bibliothekskonvention: kein basicConfig im Bibliothekscode; die Host-Anwendung
|
|
19
|
+
# konfiguriert das Logging. NullHandler unterdrückt "No handlers could be found".
|
|
20
|
+
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
21
|
+
|
|
22
|
+
# fix "ValueError: unsupported pickle protocol: 5"
|
|
23
|
+
#import pickle
|
|
24
|
+
#pickle.HIGHEST_PROTOCOL = 4
|
|
25
|
+
import pandas
|
|
26
|
+
|
|
27
|
+
from sdata.metadata import Metadata, Attribute
|
|
28
|
+
from sdata.deprecated.data import Data # deprecated: ersetzt durch sdata.sclass.dataframe.DataFrame
|
|
29
|
+
from sdata.base import Base, sdata_factory
|
|
30
|
+
from sdata.sclass.blob import Blob
|
|
31
|
+
from sdata.sclass.dataframe import DataFrame
|
|
32
|
+
from sdata.suuid import SUUID
|
|
33
|
+
from sdata.sclass.image import Image
|
|
34
|
+
|
|
35
|
+
# import sdata.timestamp as timestamp
|
|
36
|
+
from sdata.timestamp import today_str, now_utc_str, now_local_str
|
|
37
|
+
import inspect
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
import openpyxl
|
|
41
|
+
except Exception: # pragma: no cover - optionale Abhängigkeit
|
|
42
|
+
logging.warning("openpyxl is not available -> no xlsx import")
|
|
43
|
+
openpyxl = None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def uuid_from_str(name):
|
|
47
|
+
return uuid.uuid3(uuid.NAMESPACE_DNS, name)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def osname(name, lower=True):
|
|
51
|
+
mapper = [("ä", "ae"), ("ö", "oe"), ("ü", "ue"), ("Ä", "Ae"), ("Ö", "Oe"), ("Ü", "Ue"),
|
|
52
|
+
("ß", "sz"), (" ", "_"), ("/", "_"), ("\\", "_")]
|
|
53
|
+
for k, v in mapper:
|
|
54
|
+
name = name.replace(k, v)
|
|
55
|
+
if lower is True:
|
|
56
|
+
name = name.lower()
|
|
57
|
+
return name.encode('ascii', 'replace').decode("ascii")
|
|
58
|
+
|
|
59
|
+
def generate_safe_name(original_name: str) -> str:
|
|
60
|
+
r"""
|
|
61
|
+
Generiert einen sicheren Dateinamen, der kompatibel mit Linux, Windows, AWS S3 und als Datenbank-Spaltenname oder Index-Name ist.
|
|
62
|
+
|
|
63
|
+
- Konvertiert zu Lowercase.
|
|
64
|
+
- Ersetzt Umlaute und Sonderzeichen durch ASCII-Äquivalente oder Unterstriche.
|
|
65
|
+
- Erlaubt nur alphanumerische Zeichen (a-z, 0-9), Unterstriche (_) und Punkte (.).
|
|
66
|
+
- Entfernt verbotene Zeichen für Windows (z.B. < > : " / \ | ? *).
|
|
67
|
+
- Reduziert multiple Unterstriche zu einem.
|
|
68
|
+
- Entfernt leading/trailing Unterstriche oder Punkte.
|
|
69
|
+
- Stellt sicher, dass der Name mit einem Buchstaben oder Unterstrich beginnt (für DB-Kompatibilität).
|
|
70
|
+
- Begrenzt die Länge auf 255 Zeichen (sichere Grenze für die meisten Dateisysteme).
|
|
71
|
+
|
|
72
|
+
:param original_name: Der ursprüngliche Name (str).
|
|
73
|
+
:return: Der sichere Dateiname (str).
|
|
74
|
+
"""
|
|
75
|
+
if not isinstance(original_name, str):
|
|
76
|
+
original_name = str(original_name)
|
|
77
|
+
|
|
78
|
+
# Ersetze verbotene Zeichen für Windows und allgemeine Sicherheit
|
|
79
|
+
forbidden = r'[<>:"/\\|?*]'
|
|
80
|
+
original_name = re.sub(forbidden, '_', original_name)
|
|
81
|
+
|
|
82
|
+
# Konvertiere Umlaute und andere diakritische Zeichen zu ASCII
|
|
83
|
+
mapper = {
|
|
84
|
+
"ä": "ae", "ö": "oe", "ü": "ue", "Ä": "Ae", "Ö": "Oe", "Ü": "Ue",
|
|
85
|
+
"ß": "ss", " ": "_", "!": "_", "@": "_", "#": "_", "$": "_",
|
|
86
|
+
"%": "_", "^": "_", "&": "_", "*": "_", "(": "_", ")": "_",
|
|
87
|
+
";": "_", ",": "_", "+": "_", "=": "_", "[": "_", "]": "_",
|
|
88
|
+
"{": "_", "}": "_", "`": "_", "~": "_"
|
|
89
|
+
}
|
|
90
|
+
for k, v in mapper.items():
|
|
91
|
+
original_name = original_name.replace(k, v)
|
|
92
|
+
|
|
93
|
+
# Normalisiere zu ASCII und entferne nicht-ASCII-Zeichen
|
|
94
|
+
original_name = unicodedata.normalize('NFKD', original_name).encode('ascii', 'ignore').decode('ascii')
|
|
95
|
+
|
|
96
|
+
# # Zu Lowercase
|
|
97
|
+
# name = original_name.lower()
|
|
98
|
+
|
|
99
|
+
# Ersetze ungültige Zeichen mit _
|
|
100
|
+
# Erlaube nur a-z, 0-9, _, .
|
|
101
|
+
#name = re.sub(r'[^a-z0-9_.]', '_', original_name)
|
|
102
|
+
|
|
103
|
+
# Reduziere multiple _ oder . zu _
|
|
104
|
+
name = re.sub(r'[_.-]+', '_', original_name)
|
|
105
|
+
|
|
106
|
+
# Entferne leading/trailing _ oder .
|
|
107
|
+
name = name.strip('_.')
|
|
108
|
+
|
|
109
|
+
# Stelle sicher, dass es mit einem Buchstaben oder _ beginnt (für DB)
|
|
110
|
+
if name and (name[0].isdigit() or name[0] == '.'):
|
|
111
|
+
name = '_' + name
|
|
112
|
+
|
|
113
|
+
# Begrenze auf 255 Zeichen
|
|
114
|
+
if len(name) > 255:
|
|
115
|
+
name = name[:255]
|
|
116
|
+
|
|
117
|
+
# Falls der Name leer wird, fallback zu einem Standard
|
|
118
|
+
if not name:
|
|
119
|
+
name = 'noname'
|
|
120
|
+
|
|
121
|
+
return name
|
|
122
|
+
|
|
123
|
+
# DataFrame ist die kanonische Klasse (RFC 0012); Data bleibt für die
|
|
124
|
+
# Deserialisierung alter Objekte in SDATACLS auflösbar, führt aber nicht mehr.
|
|
125
|
+
SDATACLS = {"DataFrame": DataFrame,
|
|
126
|
+
"Image": Image,
|
|
127
|
+
"Blob": Blob,
|
|
128
|
+
"SUUID": SUUID,
|
|
129
|
+
"Data": Data,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
__all__ = ["DataFrame", "Image",
|
|
133
|
+
"Blob",
|
|
134
|
+
"SUUID", "Data"]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def print_classes():
|
|
138
|
+
for name, obj in inspect.getmembers(sys.modules[__name__]):
|
|
139
|
+
if inspect.isclass(obj):
|
|
140
|
+
print(obj)
|