zlmdb 25.12.3__cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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 (78) hide show
  1. zlmdb/__init__.py +416 -0
  2. zlmdb/_database.py +990 -0
  3. zlmdb/_errors.py +31 -0
  4. zlmdb/_flatc/__init__.py +112 -0
  5. zlmdb/_flatc/bin/flatc +0 -0
  6. zlmdb/_lmdb_vendor/__init__.py +37 -0
  7. zlmdb/_lmdb_vendor/__main__.py +25 -0
  8. zlmdb/_lmdb_vendor/_config.py +10 -0
  9. zlmdb/_lmdb_vendor/_lmdb_cffi.cpython-312-aarch64-linux-gnu.so +0 -0
  10. zlmdb/_lmdb_vendor/cffi.py +2606 -0
  11. zlmdb/_lmdb_vendor/tool.py +670 -0
  12. zlmdb/_meta.py +27 -0
  13. zlmdb/_pmap.py +1667 -0
  14. zlmdb/_schema.py +137 -0
  15. zlmdb/_transaction.py +181 -0
  16. zlmdb/_types.py +1596 -0
  17. zlmdb/_version.py +27 -0
  18. zlmdb/cli.py +41 -0
  19. zlmdb/flatbuffers/__init__.py +60 -0
  20. zlmdb/flatbuffers/_git_version.py +24 -0
  21. zlmdb/flatbuffers/_version.py +17 -0
  22. zlmdb/flatbuffers/builder.py +824 -0
  23. zlmdb/flatbuffers/compat.py +89 -0
  24. zlmdb/flatbuffers/encode.py +43 -0
  25. zlmdb/flatbuffers/flexbuffers.py +1570 -0
  26. zlmdb/flatbuffers/number_types.py +182 -0
  27. zlmdb/flatbuffers/packer.py +42 -0
  28. zlmdb/flatbuffers/reflection/AdvancedFeatures.py +10 -0
  29. zlmdb/flatbuffers/reflection/BaseType.py +25 -0
  30. zlmdb/flatbuffers/reflection/Enum.py +252 -0
  31. zlmdb/flatbuffers/reflection/EnumVal.py +144 -0
  32. zlmdb/flatbuffers/reflection/Field.py +325 -0
  33. zlmdb/flatbuffers/reflection/KeyValue.py +84 -0
  34. zlmdb/flatbuffers/reflection/Object.py +260 -0
  35. zlmdb/flatbuffers/reflection/RPCCall.py +195 -0
  36. zlmdb/flatbuffers/reflection/Schema.py +301 -0
  37. zlmdb/flatbuffers/reflection/SchemaFile.py +112 -0
  38. zlmdb/flatbuffers/reflection/Service.py +213 -0
  39. zlmdb/flatbuffers/reflection/Type.py +148 -0
  40. zlmdb/flatbuffers/reflection/__init__.py +0 -0
  41. zlmdb/flatbuffers/reflection.bfbs +0 -0
  42. zlmdb/flatbuffers/reflection.fbs +156 -0
  43. zlmdb/flatbuffers/table.py +129 -0
  44. zlmdb/flatbuffers/util.py +47 -0
  45. zlmdb/py.typed +0 -0
  46. zlmdb/tests/conftest.py +9 -0
  47. zlmdb/tests/lmdb/__init__.py +0 -0
  48. zlmdb/tests/lmdb/address_book.py +287 -0
  49. zlmdb/tests/lmdb/crash_test.py +339 -0
  50. zlmdb/tests/lmdb/cursor_test.py +333 -0
  51. zlmdb/tests/lmdb/env_test.py +919 -0
  52. zlmdb/tests/lmdb/getmulti_test.py +92 -0
  53. zlmdb/tests/lmdb/iteration_test.py +258 -0
  54. zlmdb/tests/lmdb/package_test.py +70 -0
  55. zlmdb/tests/lmdb/test_lmdb.py +188 -0
  56. zlmdb/tests/lmdb/testlib.py +185 -0
  57. zlmdb/tests/lmdb/tool_test.py +60 -0
  58. zlmdb/tests/lmdb/txn_test.py +575 -0
  59. zlmdb/tests/orm/MNodeLog.py +853 -0
  60. zlmdb/tests/orm/__init__.py +0 -0
  61. zlmdb/tests/orm/_schema_fbs.py +215 -0
  62. zlmdb/tests/orm/_schema_mnode_log.py +1202 -0
  63. zlmdb/tests/orm/_schema_py2.py +250 -0
  64. zlmdb/tests/orm/_schema_py3.py +307 -0
  65. zlmdb/tests/orm/_test_flatbuffers.py +144 -0
  66. zlmdb/tests/orm/_test_serialization.py +144 -0
  67. zlmdb/tests/orm/test_basic.py +217 -0
  68. zlmdb/tests/orm/test_etcd.py +275 -0
  69. zlmdb/tests/orm/test_pmap_indexes.py +466 -0
  70. zlmdb/tests/orm/test_pmap_types.py +90 -0
  71. zlmdb/tests/orm/test_pmaps.py +295 -0
  72. zlmdb/tests/orm/test_select.py +619 -0
  73. zlmdb-25.12.3.dist-info/METADATA +277 -0
  74. zlmdb-25.12.3.dist-info/RECORD +78 -0
  75. zlmdb-25.12.3.dist-info/WHEEL +6 -0
  76. zlmdb-25.12.3.dist-info/entry_points.txt +3 -0
  77. zlmdb-25.12.3.dist-info/licenses/LICENSE +167 -0
  78. zlmdb-25.12.3.dist-info/licenses/NOTICE +41 -0
@@ -0,0 +1,185 @@
1
+ #
2
+ # Copyright 2013 The py-lmdb authors, all rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted only as authorized by the OpenLDAP
6
+ # Public License.
7
+ #
8
+ # A copy of this license is available in the file LICENSE in the
9
+ # top-level directory of the distribution or, alternatively, at
10
+ # <http://www.OpenLDAP.org/license.html>.
11
+ #
12
+ # OpenLDAP is a registered trademark of the OpenLDAP Foundation.
13
+ #
14
+ # Individual files and/or contributed packages may be copyright by
15
+ # other parties and/or subject to additional restrictions.
16
+ #
17
+ # This work also contains materials derived from public sources.
18
+ #
19
+ # Additional information about OpenLDAP can be obtained at
20
+ # <http://www.openldap.org/>.
21
+ #
22
+
23
+ from __future__ import absolute_import
24
+ import atexit
25
+ import gc
26
+ import os
27
+ import shutil
28
+ import stat
29
+ import sys
30
+ import tempfile
31
+ import traceback
32
+ import unittest
33
+
34
+ try:
35
+ import __builtin__
36
+ except ImportError:
37
+ import builtins as __builtin__
38
+
39
+ import zlmdb.lmdb as lmdb
40
+
41
+ _cleanups = []
42
+
43
+
44
+ def cleanup():
45
+ while _cleanups:
46
+ func = _cleanups.pop()
47
+ try:
48
+ func()
49
+ except Exception:
50
+ traceback.print_exc()
51
+
52
+
53
+ atexit.register(cleanup)
54
+
55
+
56
+ class LmdbTest(unittest.TestCase):
57
+ def tearDown(self):
58
+ cleanup()
59
+
60
+
61
+ def temp_dir(create=True):
62
+ path = tempfile.mkdtemp(prefix="lmdb_test")
63
+ assert path is not None, "tempfile.mkdtemp failed"
64
+ if not create:
65
+ os.rmdir(path)
66
+ _cleanups.append(lambda: shutil.rmtree(path, ignore_errors=True))
67
+ if hasattr(path, "decode"):
68
+ path = path.decode(sys.getfilesystemencoding())
69
+ return path
70
+
71
+
72
+ def temp_file(create=True):
73
+ fd, path = tempfile.mkstemp(prefix="lmdb_test")
74
+ assert path is not None, "tempfile.mkstemp failed"
75
+ os.close(fd)
76
+ if not create:
77
+ os.unlink(path)
78
+ _cleanups.append(lambda: os.path.exists(path) and os.unlink(path))
79
+ pathlock = path + "-lock"
80
+ _cleanups.append(lambda: os.path.exists(pathlock) and os.unlink(pathlock))
81
+ if hasattr(path, "decode"):
82
+ path = path.decode(sys.getfilesystemencoding())
83
+ return path
84
+
85
+
86
+ def temp_env(path=None, max_dbs=10, **kwargs):
87
+ if not path:
88
+ path = temp_dir()
89
+ env = lmdb.open(path, max_dbs=max_dbs, **kwargs)
90
+ _cleanups.append(env.close)
91
+ return path, env
92
+
93
+
94
+ def path_mode(path):
95
+ return stat.S_IMODE(os.stat(path).st_mode)
96
+
97
+
98
+ def debug_collect():
99
+ if hasattr(gc, "set_debug") and hasattr(gc, "get_debug"):
100
+ old = gc.get_debug()
101
+ gc.set_debug(gc.DEBUG_LEAK)
102
+ gc.collect()
103
+ gc.set_debug(old)
104
+ else:
105
+ for x in range(10):
106
+ # PyPy doesn't collect objects with __del__ on first attempt.
107
+ gc.collect()
108
+
109
+
110
+ UnicodeType = getattr(__builtin__, "unicode", str)
111
+ BytesType = getattr(__builtin__, "bytes", str)
112
+
113
+ try:
114
+ INT_TYPES = (int, long)
115
+ except NameError:
116
+ INT_TYPES = (int,)
117
+
118
+ # B(ascii 'string') -> bytes
119
+ try:
120
+ bytes("") # Python>=2.6, alias for str().
121
+
122
+ def B(s):
123
+ return s
124
+
125
+ except TypeError: # Python3.x, requires encoding parameter.
126
+
127
+ def B(s):
128
+ return bytes(s, "ascii")
129
+
130
+
131
+ # BL('s1', 's2') -> ['bytes1', 'bytes2']
132
+ def BL(*args):
133
+ return list(map(B, args))
134
+
135
+
136
+ # BT('s1', 's2') -> ('bytes1', 'bytes2')
137
+ def BT(*args):
138
+ return tuple(B(s) for s in args)
139
+
140
+
141
+ # byte_chr(int) -> single byte from int (via chr)
142
+ def byte_chr(arg):
143
+ return B(chr(arg))
144
+
145
+
146
+ # OCT(s) -> parse string as octal
147
+ def OCT(s):
148
+ return int(s, 8)
149
+
150
+
151
+ KEYS = BL("a", "b", "baa", "d")
152
+ ITEMS = [(k, B("")) for k in KEYS]
153
+ REV_ITEMS = ITEMS[::-1]
154
+ VALUES = [B("") for k in KEYS]
155
+
156
+ KEYS2 = BL("a", "b", "baa", "d", "e", "f", "g", "h")
157
+ ITEMS2 = [(k, B("")) for k in KEYS2]
158
+ REV_ITEMS2 = ITEMS2[::-1]
159
+ VALUES2 = [B("") for k in KEYS2]
160
+
161
+ KEYSFIXED = BL("a", "b", "c", "d", "e", "f", "g", "h")
162
+ VALUES_MULTI = [(B("r"), B("s")) for k in KEYSFIXED]
163
+ ITEMS_MULTI_FIXEDKEY = [
164
+ (kv[0], v) for kv in list(zip(KEYSFIXED, VALUES_MULTI)) for v in kv[1]
165
+ ]
166
+
167
+
168
+ def _put_items(items, t, db=None):
169
+ for k, v in items:
170
+ if db:
171
+ t.put(k, v, db=db)
172
+ else:
173
+ t.put(k, v)
174
+
175
+
176
+ def putData(t, db=None):
177
+ _put_items(ITEMS, t, db=db)
178
+
179
+
180
+ def putBigData(t, db=None):
181
+ _put_items(ITEMS2, t, db=db)
182
+
183
+
184
+ def putBigDataMultiFixed(t, db=None):
185
+ _put_items(ITEMS_MULTI_FIXEDKEY, t, db=db)
@@ -0,0 +1,60 @@
1
+ #
2
+ # Copyright 2013 The py-lmdb authors, all rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted only as authorized by the OpenLDAP
6
+ # Public License.
7
+ #
8
+ # A copy of this license is available in the file LICENSE in the
9
+ # top-level directory of the distribution or, alternatively, at
10
+ # <http://www.OpenLDAP.org/license.html>.
11
+ #
12
+ # OpenLDAP is a registered trademark of the OpenLDAP Foundation.
13
+ #
14
+ # Individual files and/or contributed packages may be copyright by
15
+ # other parties and/or subject to additional restrictions.
16
+ #
17
+ # This work also contains materials derived from public sources.
18
+ #
19
+ # Additional information about OpenLDAP can be obtained at
20
+ # <http://www.openldap.org/>.
21
+ #
22
+
23
+ from __future__ import absolute_import
24
+
25
+ import sys
26
+ import shlex
27
+ import unittest
28
+
29
+ import zlmdb.lmdb as lmdb
30
+ import zlmdb.lmdb.tool
31
+ from . import testlib
32
+
33
+
34
+ def call_tool(cmdline):
35
+ if sys.platform == "win32":
36
+ args = cmdline.split()
37
+ else:
38
+ args = shlex.split(cmdline)
39
+ return zlmdb.lmdb.tool.main(args)
40
+
41
+
42
+ class ToolTest(testlib.LmdbTest):
43
+ def test_cmd_get(self):
44
+ frompath, env = testlib.temp_env()
45
+ db = env.open_db(b"subdb")
46
+ with env.begin(write=True, db=db) as txn:
47
+ txn.put(b"foo", b"bar", db=db)
48
+ env.close()
49
+ call_tool("-d subdb get --env %s" % (frompath,))
50
+
51
+ def test_cmd_rewrite(self):
52
+ frompath, env = testlib.temp_env()
53
+ env.open_db(b"subdb")
54
+ env.close()
55
+ topath = testlib.temp_dir()
56
+ call_tool("rewrite -e %s -E %s subdb" % (frompath, topath))
57
+
58
+
59
+ if __name__ == "__main__":
60
+ unittest.main()