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.
Files changed (98) hide show
  1. sdata/__init__.py +140 -0
  2. sdata/base.py +684 -0
  3. sdata/contrib/__init__.py +0 -0
  4. sdata/contrib/piexif/__init__.py +12 -0
  5. sdata/contrib/piexif/_common.py +94 -0
  6. sdata/contrib/piexif/_dump.py +346 -0
  7. sdata/contrib/piexif/_exceptions.py +2 -0
  8. sdata/contrib/piexif/_exif.py +638 -0
  9. sdata/contrib/piexif/_insert.py +60 -0
  10. sdata/contrib/piexif/_load.py +270 -0
  11. sdata/contrib/piexif/_remove.py +56 -0
  12. sdata/contrib/piexif/_transplant.py +45 -0
  13. sdata/contrib/piexif/_webp.py +240 -0
  14. sdata/contrib/piexif/helper.py +66 -0
  15. sdata/contrib/ranger/__init__.py +8 -0
  16. sdata/contrib/ranger/collections/__init__.py +0 -0
  17. sdata/contrib/ranger/collections/rangebucketmap.py +346 -0
  18. sdata/contrib/ranger/collections/rangemap.py +396 -0
  19. sdata/contrib/ranger/collections/rangeset.py +483 -0
  20. sdata/contrib/ranger/range/__init__.py +0 -0
  21. sdata/contrib/ranger/range/cut.py +285 -0
  22. sdata/contrib/ranger/range/range.py +644 -0
  23. sdata/contrib/sobol_seq.py +394 -0
  24. sdata/contrib/sortedcontainers/LICENSE +13 -0
  25. sdata/contrib/sortedcontainers/__init__.py +74 -0
  26. sdata/contrib/sortedcontainers/sorteddict.py +789 -0
  27. sdata/contrib/sortedcontainers/sortedlist.py +2646 -0
  28. sdata/contrib/sortedcontainers/sortedset.py +733 -0
  29. sdata/contrib/sqlitedict.py +598 -0
  30. sdata/contrib/timeflake/__init__.py +40 -0
  31. sdata/contrib/timeflake/flake.py +69 -0
  32. sdata/contrib/timeflake/utils.py +47 -0
  33. sdata/deprecated/__init__.py +10 -0
  34. sdata/deprecated/data.py +1503 -0
  35. sdata/did/__init__.py +129 -0
  36. sdata/did/_http.py +67 -0
  37. sdata/did/base58btc.py +49 -0
  38. sdata/did/did_github.py +152 -0
  39. sdata/did/did_peer4.py +155 -0
  40. sdata/did/did_web.py +222 -0
  41. sdata/did/diddoc.py +75 -0
  42. sdata/did/ed25519.py +225 -0
  43. sdata/did/eddsa.py +107 -0
  44. sdata/did/errors.py +40 -0
  45. sdata/did/issue_vc.py +193 -0
  46. sdata/did/jose.py +126 -0
  47. sdata/did/keys.py +104 -0
  48. sdata/did/utils_didkey.py +161 -0
  49. sdata/did/verify_vp.py +158 -0
  50. sdata/doe.py +101 -0
  51. sdata/dtypes.py +510 -0
  52. sdata/experiments/__init__.py +331 -0
  53. sdata/experiments/blob0.py +131 -0
  54. sdata/experiments/file.py +42 -0
  55. sdata/experiments/filegroup.py +144 -0
  56. sdata/experiments/image_old.py +313 -0
  57. sdata/experiments/ks2.py +15 -0
  58. sdata/experiments/lapshear.py +8 -0
  59. sdata/experiments/material.py +7 -0
  60. sdata/experiments/parameters_deprecated.py +394 -0
  61. sdata/experiments/workbook.py +226 -0
  62. sdata/format.py +125 -0
  63. sdata/imagemeta.py +533 -0
  64. sdata/interactive.py +118 -0
  65. sdata/iolib/__init__.py +51 -0
  66. sdata/iolib/hashtree.py +264 -0
  67. sdata/iolib/json1sqlitestore.py +554 -0
  68. sdata/iolib/jsonsqlitestore.py +704 -0
  69. sdata/iolib/pud.py +242 -0
  70. sdata/iolib/reader.py +262 -0
  71. sdata/iolib/writer.py +419 -0
  72. sdata/metadata.py +882 -0
  73. sdata/parameter.py +414 -0
  74. sdata/schema.py +273 -0
  75. sdata/sclass/__init__.py +111 -0
  76. sdata/sclass/bfo_classes.py +362 -0
  77. sdata/sclass/blob.py +362 -0
  78. sdata/sclass/content.py +87 -0
  79. sdata/sclass/dataframe.py +1251 -0
  80. sdata/sclass/dataframegroup.py +187 -0
  81. sdata/sclass/dependency_graph.py +85 -0
  82. sdata/sclass/filereference.py +124 -0
  83. sdata/sclass/image.py +218 -0
  84. sdata/sclass/lazy_namespace.py +155 -0
  85. sdata/sclass/process.py +383 -0
  86. sdata/sclass/process_graph.py +221 -0
  87. sdata/sclass/zipfile.py +135 -0
  88. sdata/semantic.py +346 -0
  89. sdata/suuid.py +136 -0
  90. sdata/timestamp.py +336 -0
  91. sdata/tools.py +14 -0
  92. sdata/units.py +602 -0
  93. sdata/vocab.py +149 -0
  94. sdata-1.5.0.dist-info/METADATA +264 -0
  95. sdata-1.5.0.dist-info/RECORD +98 -0
  96. sdata-1.5.0.dist-info/WHEEL +5 -0
  97. sdata-1.5.0.dist-info/licenses/LICENSE-MIT +21 -0
  98. 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)