pyrekordbox 0.2.1__py3-none-any.whl → 0.2.2__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.
- docs/source/formats/anlz.md +178 -7
- docs/source/formats/db6.md +1 -1
- docs/source/index.md +2 -6
- docs/source/quickstart.md +68 -45
- docs/source/tutorial/index.md +1 -1
- pyrekordbox/__init__.py +1 -1
- pyrekordbox/_version.py +2 -2
- pyrekordbox/anlz/file.py +39 -0
- pyrekordbox/anlz/structs.py +3 -5
- pyrekordbox/config.py +71 -27
- pyrekordbox/db6/database.py +260 -33
- pyrekordbox/db6/registry.py +22 -0
- pyrekordbox/db6/tables.py +3 -4
- {pyrekordbox-0.2.1.dist-info → pyrekordbox-0.2.2.dist-info}/METADATA +12 -11
- pyrekordbox-0.2.2.dist-info/RECORD +80 -0
- {pyrekordbox-0.2.1.dist-info → pyrekordbox-0.2.2.dist-info}/top_level.txt +0 -2
- tests/test_config.py +175 -0
- tests/test_db6.py +78 -0
- build/lib/build/lib/docs/source/conf.py +0 -178
- build/lib/build/lib/pyrekordbox/__init__.py +0 -22
- build/lib/build/lib/pyrekordbox/__main__.py +0 -204
- build/lib/build/lib/pyrekordbox/_version.py +0 -16
- build/lib/build/lib/pyrekordbox/anlz/__init__.py +0 -127
- build/lib/build/lib/pyrekordbox/anlz/file.py +0 -186
- build/lib/build/lib/pyrekordbox/anlz/structs.py +0 -299
- build/lib/build/lib/pyrekordbox/anlz/tags.py +0 -508
- build/lib/build/lib/pyrekordbox/config.py +0 -596
- build/lib/build/lib/pyrekordbox/db6/__init__.py +0 -45
- build/lib/build/lib/pyrekordbox/db6/aux_files.py +0 -213
- build/lib/build/lib/pyrekordbox/db6/database.py +0 -1808
- build/lib/build/lib/pyrekordbox/db6/registry.py +0 -304
- build/lib/build/lib/pyrekordbox/db6/tables.py +0 -1618
- build/lib/build/lib/pyrekordbox/logger.py +0 -23
- build/lib/build/lib/pyrekordbox/mysettings/__init__.py +0 -32
- build/lib/build/lib/pyrekordbox/mysettings/file.py +0 -369
- build/lib/build/lib/pyrekordbox/mysettings/structs.py +0 -282
- build/lib/build/lib/pyrekordbox/utils.py +0 -162
- build/lib/build/lib/pyrekordbox/xml.py +0 -1294
- build/lib/build/lib/tests/__init__.py +0 -3
- build/lib/build/lib/tests/test_anlz.py +0 -206
- build/lib/build/lib/tests/test_db6.py +0 -1039
- build/lib/build/lib/tests/test_mysetting.py +0 -203
- build/lib/build/lib/tests/test_xml.py +0 -629
- build/lib/docs/source/conf.py +0 -178
- build/lib/pyrekordbox/__init__.py +0 -22
- build/lib/pyrekordbox/__main__.py +0 -204
- build/lib/pyrekordbox/_version.py +0 -16
- build/lib/pyrekordbox/anlz/__init__.py +0 -127
- build/lib/pyrekordbox/anlz/file.py +0 -186
- build/lib/pyrekordbox/anlz/structs.py +0 -299
- build/lib/pyrekordbox/anlz/tags.py +0 -508
- build/lib/pyrekordbox/config.py +0 -596
- build/lib/pyrekordbox/db6/__init__.py +0 -45
- build/lib/pyrekordbox/db6/aux_files.py +0 -213
- build/lib/pyrekordbox/db6/database.py +0 -1808
- build/lib/pyrekordbox/db6/registry.py +0 -304
- build/lib/pyrekordbox/db6/tables.py +0 -1618
- build/lib/pyrekordbox/logger.py +0 -23
- build/lib/pyrekordbox/mysettings/__init__.py +0 -32
- build/lib/pyrekordbox/mysettings/file.py +0 -369
- build/lib/pyrekordbox/mysettings/structs.py +0 -282
- build/lib/pyrekordbox/utils.py +0 -162
- build/lib/pyrekordbox/xml.py +0 -1294
- build/lib/tests/__init__.py +0 -3
- build/lib/tests/test_anlz.py +0 -206
- build/lib/tests/test_db6.py +0 -1039
- build/lib/tests/test_mysetting.py +0 -203
- build/lib/tests/test_xml.py +0 -629
- pyrekordbox-0.2.1.dist-info/RECORD +0 -129
- {pyrekordbox-0.2.1.dist-info → pyrekordbox-0.2.2.dist-info}/LICENSE +0 -0
- {pyrekordbox-0.2.1.dist-info → pyrekordbox-0.2.2.dist-info}/WHEEL +0 -0
@@ -1,304 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Author: Dylan Jones
|
3
|
-
# Date: 2023-08-07
|
4
|
-
|
5
|
-
import logging
|
6
|
-
|
7
|
-
logger = logging.getLogger(__name__)
|
8
|
-
|
9
|
-
|
10
|
-
class RekordboxAgentRegistry:
|
11
|
-
"""Rekordbox Agent Registry handler.
|
12
|
-
|
13
|
-
The Rekordbox Agent Registry handler is responsible for tracking changes to the
|
14
|
-
Rekordbox database. It is used to keep track of changes to the database,
|
15
|
-
provide a history of changes and to update the global and individual
|
16
|
-
USN (unique sequence number) values of the database entries.
|
17
|
-
|
18
|
-
This object should *not* be instantiated directly. It is used by the
|
19
|
-
:class:`RekordboxDatabase` class to track changes to the database.
|
20
|
-
|
21
|
-
Parameters
|
22
|
-
----------
|
23
|
-
db : RekordboxDatabase
|
24
|
-
The Rekordbox database instance.
|
25
|
-
"""
|
26
|
-
|
27
|
-
__update_sequence__ = list()
|
28
|
-
__update_history__ = list()
|
29
|
-
__enabled__ = True
|
30
|
-
|
31
|
-
def __init__(self, db):
|
32
|
-
self.db = db
|
33
|
-
|
34
|
-
@classmethod
|
35
|
-
def on_update(cls, instance, key, value):
|
36
|
-
"""Called when an instance of a database model is updated.
|
37
|
-
|
38
|
-
Parameters
|
39
|
-
----------
|
40
|
-
instance : tables.Base
|
41
|
-
The table entry instance.
|
42
|
-
key : str
|
43
|
-
The name of the updated column.
|
44
|
-
value : Any
|
45
|
-
The new value of the updated column.
|
46
|
-
"""
|
47
|
-
if cls.__enabled__:
|
48
|
-
logger.debug("On update: %s, %s, %s", instance, key, value)
|
49
|
-
cls.__update_sequence__.append((instance, "update", key, value))
|
50
|
-
|
51
|
-
@classmethod
|
52
|
-
def on_create(cls, instance):
|
53
|
-
"""Called when an instance of a database model is created.
|
54
|
-
|
55
|
-
Parameters
|
56
|
-
----------
|
57
|
-
instance : tables.Base
|
58
|
-
The table entry instance.
|
59
|
-
"""
|
60
|
-
if cls.__enabled__:
|
61
|
-
logger.debug("On create: %s", instance)
|
62
|
-
cls.__update_sequence__.append((instance, "create", "", ""))
|
63
|
-
|
64
|
-
@classmethod
|
65
|
-
def on_delete(cls, instance):
|
66
|
-
"""Called when an instance of a database model is deleted.
|
67
|
-
|
68
|
-
Parameters
|
69
|
-
----------
|
70
|
-
instance : tables.Base
|
71
|
-
The table entry instance.
|
72
|
-
"""
|
73
|
-
if cls.__enabled__:
|
74
|
-
logger.debug("On delete: %s", instance)
|
75
|
-
cls.__update_sequence__.append((instance, "delete", "", ""))
|
76
|
-
|
77
|
-
@classmethod
|
78
|
-
def on_move(cls, instances):
|
79
|
-
"""Called when instanced of a database model are moved.
|
80
|
-
|
81
|
-
Parameters
|
82
|
-
----------
|
83
|
-
instances : list[tables.Base]
|
84
|
-
The table entry instance.
|
85
|
-
"""
|
86
|
-
if cls.__enabled__:
|
87
|
-
logger.debug("On move: %s", instances)
|
88
|
-
cls.__update_sequence__.append((instances, "move", "", ""))
|
89
|
-
|
90
|
-
@classmethod
|
91
|
-
def clear_buffer(cls):
|
92
|
-
"""Clears the update buffer and update history."""
|
93
|
-
cls.__update_history__.extend(cls.__update_sequence__)
|
94
|
-
cls.__update_sequence__.clear()
|
95
|
-
|
96
|
-
@classmethod
|
97
|
-
def enable_tracking(cls):
|
98
|
-
"""Enables the tracking of database changes."""
|
99
|
-
cls.__enabled__ = True
|
100
|
-
|
101
|
-
@classmethod
|
102
|
-
def disable_tracking(cls):
|
103
|
-
"""Disables the tracking of database changes."""
|
104
|
-
cls.__enabled__ = False
|
105
|
-
|
106
|
-
def get_registries(self):
|
107
|
-
"""Returns all agent registries.
|
108
|
-
|
109
|
-
Returns
|
110
|
-
-------
|
111
|
-
registries : list[tables.AgentRegistry]
|
112
|
-
"""
|
113
|
-
return self.db.get_agent_registry()
|
114
|
-
|
115
|
-
def get_registry(self, key):
|
116
|
-
"""Returns the agent registry with the given key.
|
117
|
-
|
118
|
-
Parameters
|
119
|
-
----------
|
120
|
-
key : str
|
121
|
-
The registry identifier (`registry_id`).
|
122
|
-
|
123
|
-
Returns
|
124
|
-
-------
|
125
|
-
registry : tables.AgentRegistry
|
126
|
-
"""
|
127
|
-
return self.db.get_agent_registry(registry_id=key)
|
128
|
-
|
129
|
-
def get_string(self, key):
|
130
|
-
"""Returns the string value of the registry with the given key.
|
131
|
-
|
132
|
-
Parameters
|
133
|
-
----------
|
134
|
-
key : str
|
135
|
-
The registry identifier (`registry_id`).
|
136
|
-
|
137
|
-
Returns
|
138
|
-
-------
|
139
|
-
value : str
|
140
|
-
"""
|
141
|
-
return self.db.get_agent_registry(registry_id=key).str_1
|
142
|
-
|
143
|
-
def get_text(self, key):
|
144
|
-
"""Returns the text value of the registry with the given key.
|
145
|
-
|
146
|
-
Parameters
|
147
|
-
----------
|
148
|
-
key : str
|
149
|
-
The registry identifier (`registry_id`).
|
150
|
-
|
151
|
-
Returns
|
152
|
-
-------
|
153
|
-
value : str
|
154
|
-
"""
|
155
|
-
return self.db.get_agent_registry(registry_id=key).text_1
|
156
|
-
|
157
|
-
def get_int(self, key):
|
158
|
-
"""Returns the integer value of the registry with the given key.
|
159
|
-
|
160
|
-
Parameters
|
161
|
-
----------
|
162
|
-
key : str
|
163
|
-
The registry identifier (`registry_id`).
|
164
|
-
|
165
|
-
Returns
|
166
|
-
-------
|
167
|
-
value : int
|
168
|
-
"""
|
169
|
-
return self.db.get_agent_registry(registry_id=key).int_1
|
170
|
-
|
171
|
-
def get_date(self, key):
|
172
|
-
"""Returns the date value of the registry with the given key.
|
173
|
-
|
174
|
-
Parameters
|
175
|
-
----------
|
176
|
-
key : str
|
177
|
-
The registry identifier (`registry_id`).
|
178
|
-
|
179
|
-
Returns
|
180
|
-
-------
|
181
|
-
value : datetime.datetime
|
182
|
-
"""
|
183
|
-
return self.db.get_agent_registry(registry_id=key).date_1
|
184
|
-
|
185
|
-
def set_string(self, key, value):
|
186
|
-
"""Sets the string value of the registry with the given key.
|
187
|
-
|
188
|
-
Parameters
|
189
|
-
----------
|
190
|
-
key : str
|
191
|
-
The registry identifier (`registry_id`).
|
192
|
-
value : str
|
193
|
-
The new value.
|
194
|
-
"""
|
195
|
-
self.db.get_agent_registry(registry_id=key).str_1 = value
|
196
|
-
|
197
|
-
def set_text(self, key, value):
|
198
|
-
"""Sets the text value of the registry with the given key.
|
199
|
-
|
200
|
-
Parameters
|
201
|
-
----------
|
202
|
-
key : str
|
203
|
-
The registry identifier (`registry_id`).
|
204
|
-
value : str
|
205
|
-
The new value.
|
206
|
-
"""
|
207
|
-
self.db.get_agent_registry(registry_id=key).text_1 = value
|
208
|
-
|
209
|
-
def set_int(self, key, value):
|
210
|
-
"""Sets the integer value of the registry with the given key.
|
211
|
-
|
212
|
-
Parameters
|
213
|
-
----------
|
214
|
-
key : str
|
215
|
-
The registry identifier (`registry_id`).
|
216
|
-
value : int
|
217
|
-
The new value.
|
218
|
-
"""
|
219
|
-
self.db.get_agent_registry(registry_id=key).int_1 = value
|
220
|
-
|
221
|
-
def set_date(self, key, value):
|
222
|
-
"""Sets the date value of the registry with the given key.
|
223
|
-
|
224
|
-
Parameters
|
225
|
-
----------
|
226
|
-
key : str
|
227
|
-
The registry identifier (`registry_id`).
|
228
|
-
value : datetime.datetime
|
229
|
-
The new value.
|
230
|
-
"""
|
231
|
-
self.db.get_agent_registry(registry_id=key).date_1 = value
|
232
|
-
|
233
|
-
def get_local_update_count(self):
|
234
|
-
"""Returns the current global local USN (unique sequence number)."""
|
235
|
-
reg = self.db.get_agent_registry(registry_id="localUpdateCount")
|
236
|
-
return reg.int_1
|
237
|
-
|
238
|
-
def set_local_update_count(self, value):
|
239
|
-
"""Sets the global local USN (unique sequence number).
|
240
|
-
|
241
|
-
Parameters
|
242
|
-
----------
|
243
|
-
value : int
|
244
|
-
The new USN value.
|
245
|
-
"""
|
246
|
-
reg = self.db.get_agent_registry(registry_id="localUpdateCount")
|
247
|
-
reg.int_1 = value
|
248
|
-
|
249
|
-
def increment_local_update_count(self, num=1):
|
250
|
-
"""Increments the global local USN (unique sequence number) by the given number.
|
251
|
-
|
252
|
-
Parameters
|
253
|
-
----------
|
254
|
-
num : int, optional
|
255
|
-
The number to increment the USN by. The default is 1.
|
256
|
-
|
257
|
-
Returns
|
258
|
-
-------
|
259
|
-
usn: int
|
260
|
-
The new global local USN.
|
261
|
-
"""
|
262
|
-
if not isinstance(num, int) or num < 1:
|
263
|
-
raise ValueError("The USN can only be increment by a positive integer!")
|
264
|
-
reg = self.db.get_agent_registry(registry_id="localUpdateCount")
|
265
|
-
reg.int_1 = reg.int_1 + num
|
266
|
-
return reg.int_1
|
267
|
-
|
268
|
-
def autoincrement_local_update_count(self, set_row_usn=True):
|
269
|
-
"""Auto-increments the global local USN (unique sequence number).
|
270
|
-
|
271
|
-
The number of changes in the update buffer is used to determine the
|
272
|
-
number to increment the USN by. After the update the buffer is cleared.
|
273
|
-
|
274
|
-
Parameters
|
275
|
-
----------
|
276
|
-
set_row_usn : bool, optional
|
277
|
-
If True the local USN of each database entry is updated with the
|
278
|
-
corresponding value in the order the changes were made.
|
279
|
-
|
280
|
-
Returns
|
281
|
-
-------
|
282
|
-
usn: int
|
283
|
-
The new global local USN.
|
284
|
-
"""
|
285
|
-
reg = self.db.get_agent_registry(registry_id="localUpdateCount")
|
286
|
-
usn = reg.int_1
|
287
|
-
self.disable_tracking()
|
288
|
-
self.db.flush()
|
289
|
-
with self.db.session.no_autoflush:
|
290
|
-
for instances, op, _, _ in self.__update_sequence__.copy():
|
291
|
-
usn += 1
|
292
|
-
if set_row_usn:
|
293
|
-
# All instances in a list get the same USN
|
294
|
-
if not isinstance(instances, list):
|
295
|
-
instances = [instances]
|
296
|
-
for instance in instances:
|
297
|
-
if hasattr(instance, "rb_local_usn"):
|
298
|
-
instance.rb_local_usn = usn
|
299
|
-
reg.int_1 = usn
|
300
|
-
|
301
|
-
self.clear_buffer()
|
302
|
-
self.db.flush()
|
303
|
-
self.enable_tracking()
|
304
|
-
return usn
|