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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import uuid
|
|
3
|
+
from functools import lru_cache
|
|
4
|
+
|
|
5
|
+
from sdata.contrib.timeflake.utils import atoi, itoa
|
|
6
|
+
|
|
7
|
+
BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
8
|
+
HEX = "0123456789abcdef"
|
|
9
|
+
MAX_TIMESTAMP = 281474976710655
|
|
10
|
+
MAX_RANDOM = 1208925819614629174706175
|
|
11
|
+
MAX_TIMEFLAKE = 340282366920938463463374607431768211455
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Timeflake:
|
|
15
|
+
def __init__(self, from_bytes: bytes):
|
|
16
|
+
if from_bytes is None:
|
|
17
|
+
raise ValueError("from_bytes is a required parameter")
|
|
18
|
+
self._bytes = from_bytes
|
|
19
|
+
# Validate flake
|
|
20
|
+
as_int = self.int
|
|
21
|
+
if as_int < 0 or MAX_TIMEFLAKE < as_int:
|
|
22
|
+
raise ValueError("Invalid flake provided")
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def bytes(self) -> bytes:
|
|
26
|
+
return self._bytes
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def uuid(self) -> uuid.UUID:
|
|
30
|
+
return uuid.UUID(bytes=self.bytes)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def int(self) -> int:
|
|
34
|
+
return int.from_bytes(self.bytes, "big", signed=False)
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
@lru_cache(1)
|
|
38
|
+
def hex(self) -> str:
|
|
39
|
+
return itoa(self.int, HEX, padding=32)
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
@lru_cache(1)
|
|
43
|
+
def base62(self) -> str:
|
|
44
|
+
return itoa(self.int, BASE62, padding=22)
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def timestamp(self) -> int:
|
|
48
|
+
return self.int >> 80
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def random(self) -> int:
|
|
52
|
+
return self.int & MAX_RANDOM
|
|
53
|
+
|
|
54
|
+
def __hash__(self) -> int:
|
|
55
|
+
return self.int
|
|
56
|
+
|
|
57
|
+
def __eq__(self, other) -> bool:
|
|
58
|
+
if not isinstance(other, Timeflake):
|
|
59
|
+
return False
|
|
60
|
+
return other.int == self.int
|
|
61
|
+
|
|
62
|
+
def __lt__(self, other) -> bool:
|
|
63
|
+
return self.int < other.int
|
|
64
|
+
|
|
65
|
+
def __repr__(self) -> str:
|
|
66
|
+
return f"Timeflake('{self.hex}')"
|
|
67
|
+
|
|
68
|
+
def __str__(self) -> str:
|
|
69
|
+
return self.base62
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from functools import lru_cache
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@lru_cache(2)
|
|
5
|
+
def _index_alphabet(alphabet):
|
|
6
|
+
return {char: i for i, char in enumerate(alphabet)}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def itoa(value, alphabet, padding=None):
|
|
10
|
+
"""
|
|
11
|
+
Converts an int value to a str, using the given alphabet.
|
|
12
|
+
Padding can be computed as: ceil(log of max_val base alphabet_len)
|
|
13
|
+
"""
|
|
14
|
+
if value < 0:
|
|
15
|
+
raise ValueError("Only positive numbers are allowed")
|
|
16
|
+
elif value == 0:
|
|
17
|
+
return alphabet[0]
|
|
18
|
+
|
|
19
|
+
result = ""
|
|
20
|
+
base = len(alphabet)
|
|
21
|
+
|
|
22
|
+
while value:
|
|
23
|
+
value, rem = divmod(value, base)
|
|
24
|
+
result = alphabet[rem] + result
|
|
25
|
+
|
|
26
|
+
if padding:
|
|
27
|
+
fill = max(padding - len(result), 0)
|
|
28
|
+
result = (alphabet[0] * fill) + result
|
|
29
|
+
|
|
30
|
+
return result
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def atoi(value, alphabet):
|
|
34
|
+
"""
|
|
35
|
+
Converts a str value to an int, using the given alphabet.
|
|
36
|
+
"""
|
|
37
|
+
if value == alphabet[0]:
|
|
38
|
+
return 0
|
|
39
|
+
|
|
40
|
+
index = _index_alphabet(alphabet)
|
|
41
|
+
result = 0
|
|
42
|
+
base = len(alphabet)
|
|
43
|
+
|
|
44
|
+
for char in value:
|
|
45
|
+
result = result * base + index[char]
|
|
46
|
+
|
|
47
|
+
return result
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Deprecated sdata-Module.
|
|
3
|
+
|
|
4
|
+
Hier liegen abgelöste, nicht mehr weiterentwickelte Klassen. ``Data`` wird durch
|
|
5
|
+
:class:`sdata.sclass.dataframe.DataFrame` ersetzt und nur aus
|
|
6
|
+
Kompatibilitätsgründen weiter exportiert.
|
|
7
|
+
|
|
8
|
+
Bewusst ohne ``from sdata import ...`` (Zirkularität) und aus der Coverage
|
|
9
|
+
ausgeblendet.
|
|
10
|
+
"""
|