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
@@ -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
+ """