pyrekordbox 0.3.2__py3-none-any.whl → 0.4.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 (83) hide show
  1. pyrekordbox/__init__.py +8 -8
  2. pyrekordbox/__main__.py +3 -2
  3. pyrekordbox/_version.py +2 -2
  4. pyrekordbox/anlz/__init__.py +3 -2
  5. pyrekordbox/anlz/file.py +4 -2
  6. pyrekordbox/anlz/tags.py +3 -1
  7. pyrekordbox/config.py +79 -23
  8. pyrekordbox/db6/__init__.py +2 -2
  9. pyrekordbox/db6/aux_files.py +3 -2
  10. pyrekordbox/db6/database.py +101 -111
  11. pyrekordbox/db6/registry.py +1 -0
  12. pyrekordbox/db6/smartlist.py +7 -6
  13. pyrekordbox/db6/tables.py +44 -16
  14. pyrekordbox/logger.py +0 -1
  15. pyrekordbox/mysettings/__init__.py +5 -4
  16. pyrekordbox/mysettings/file.py +3 -1
  17. pyrekordbox/rbxml.py +5 -3
  18. pyrekordbox/utils.py +4 -3
  19. {pyrekordbox-0.3.2.dist-info → pyrekordbox-0.4.0.dist-info}/METADATA +21 -41
  20. pyrekordbox-0.4.0.dist-info/RECORD +25 -0
  21. {pyrekordbox-0.3.2.dist-info → pyrekordbox-0.4.0.dist-info}/WHEEL +1 -1
  22. {pyrekordbox-0.3.2.dist-info → pyrekordbox-0.4.0.dist-info}/top_level.txt +0 -2
  23. docs/Makefile +0 -20
  24. docs/make.bat +0 -35
  25. docs/source/_static/images/anlz_beat.svg +0 -53
  26. docs/source/_static/images/anlz_file.svg +0 -204
  27. docs/source/_static/images/anlz_pco2.svg +0 -138
  28. docs/source/_static/images/anlz_pcob.svg +0 -148
  29. docs/source/_static/images/anlz_pcp2.svg +0 -398
  30. docs/source/_static/images/anlz_pcpt.svg +0 -263
  31. docs/source/_static/images/anlz_ppth.svg +0 -123
  32. docs/source/_static/images/anlz_pqt2.svg +0 -324
  33. docs/source/_static/images/anlz_pqt2_2.svg +0 -253
  34. docs/source/_static/images/anlz_pqtz.svg +0 -140
  35. docs/source/_static/images/anlz_pssi.svg +0 -192
  36. docs/source/_static/images/anlz_pssi_entry.svg +0 -191
  37. docs/source/_static/images/anlz_pvbr.svg +0 -125
  38. docs/source/_static/images/anlz_pwav.svg +0 -130
  39. docs/source/_static/images/anlz_pwv3.svg +0 -139
  40. docs/source/_static/images/anlz_pwv4.svg +0 -139
  41. docs/source/_static/images/anlz_pwv5.svg +0 -139
  42. docs/source/_static/images/anlz_pwv5_entry.svg +0 -100
  43. docs/source/_static/images/anlz_pwv6.svg +0 -130
  44. docs/source/_static/images/anlz_pwv7.svg +0 -139
  45. docs/source/_static/images/anlz_pwvc.svg +0 -125
  46. docs/source/_static/images/anlz_tag.svg +0 -110
  47. docs/source/_static/images/x64dbg_rb_key.png +0 -0
  48. docs/source/_static/logos/dark/logo_primary.svg +0 -75
  49. docs/source/_static/logos/light/logo_primary.svg +0 -75
  50. docs/source/_static/logos/mid/logo_primary.svg +0 -75
  51. docs/source/_templates/apidoc/module.rst_t +0 -8
  52. docs/source/_templates/apidoc/package.rst_t +0 -57
  53. docs/source/_templates/apidoc/toc.rst_t +0 -7
  54. docs/source/_templates/autosummary/class.rst +0 -32
  55. docs/source/_templates/autosummary/module.rst +0 -55
  56. docs/source/api.md +0 -18
  57. docs/source/conf.py +0 -178
  58. docs/source/development/changes.md +0 -3
  59. docs/source/development/contributing.md +0 -3
  60. docs/source/formats/anlz.md +0 -634
  61. docs/source/formats/db6.md +0 -1233
  62. docs/source/formats/mysetting.md +0 -392
  63. docs/source/formats/xml.md +0 -376
  64. docs/source/index.md +0 -103
  65. docs/source/installation.md +0 -271
  66. docs/source/key.md +0 -103
  67. docs/source/quickstart.md +0 -189
  68. docs/source/requirements.txt +0 -7
  69. docs/source/tutorial/anlz.md +0 -7
  70. docs/source/tutorial/configuration.md +0 -66
  71. docs/source/tutorial/db6.md +0 -178
  72. docs/source/tutorial/index.md +0 -20
  73. docs/source/tutorial/mysetting.md +0 -124
  74. docs/source/tutorial/xml.md +0 -140
  75. pyrekordbox/xml.py +0 -8
  76. pyrekordbox-0.3.2.dist-info/RECORD +0 -84
  77. tests/__init__.py +0 -3
  78. tests/test_anlz.py +0 -206
  79. tests/test_config.py +0 -175
  80. tests/test_db6.py +0 -1193
  81. tests/test_mysetting.py +0 -203
  82. tests/test_xml.py +0 -629
  83. {pyrekordbox-0.3.2.dist-info → pyrekordbox-0.4.0.dist-info}/LICENSE +0 -0
tests/test_anlz.py DELETED
@@ -1,206 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Author: Dylan Jones
3
- # Date: 2023-02-01
4
-
5
- import os
6
- import pytest
7
- import numpy as np
8
- from numpy.testing import assert_equal
9
- from pyrekordbox import anlz
10
-
11
- TEST_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".testdata")
12
- ANLZ_ROOT = os.path.join(TEST_ROOT, "export", "PIONEER", "USBANLZ")
13
- ANLZ_DIRS = list(anlz.walk_anlz_paths(ANLZ_ROOT))
14
- ANLZ_FILES = [paths for _, paths in ANLZ_DIRS]
15
-
16
-
17
- def test_parse():
18
- for root, files in ANLZ_DIRS:
19
- for path in files.values():
20
- anlz.AnlzFile.parse_file(path)
21
-
22
-
23
- def test_rebuild():
24
- for root, files in ANLZ_DIRS:
25
- for path in files.values():
26
- file = anlz.AnlzFile.parse_file(path)
27
- data = file.build()
28
- assert len(data) == file.file_header.len_file
29
- _ = anlz.AnlzFile.parse(data)
30
-
31
-
32
- def test_read_anlz_files():
33
- for root, files in ANLZ_DIRS:
34
- anlz_files = anlz.read_anlz_files(root)
35
- assert len(files) == len(anlz_files)
36
-
37
-
38
- # -- Tags ------------------------------------------------------------------------------
39
-
40
-
41
- @pytest.mark.parametrize("paths", ANLZ_FILES)
42
- def test_pqtz_tag_getters(paths):
43
- file = anlz.AnlzFile.parse_file(paths["DAT"])
44
- tag = file.get_tag("PQTZ")
45
- beats, bpms, times = tag.get()
46
- nbeats = len(beats)
47
- # Check that shape of arrays are equal
48
- assert nbeats == len(bpms)
49
- assert nbeats == len(times)
50
- # Check that the beats array only contains the values 1-4
51
- if nbeats:
52
- assert_equal(np.sort(np.unique(beats)), [1, 2, 3, 4])
53
-
54
- # Check other getters
55
- assert_equal(beats, tag.get_beats())
56
- assert_equal(bpms, tag.get_bpms())
57
- assert_equal(times, tag.get_times())
58
-
59
-
60
- def test_pqtz_tag_set_beats():
61
- paths = ANLZ_FILES[0]
62
- file = anlz.AnlzFile.parse_file(paths["DAT"])
63
- tag = file.get_tag("PQTZ")
64
-
65
- beats = np.ones(tag.count)
66
- tag.set_beats(beats)
67
- assert_equal(tag.get_beats(), beats)
68
-
69
-
70
- def test_pqtz_tag_set_bpms():
71
- paths = ANLZ_FILES[0]
72
- file = anlz.AnlzFile.parse_file(paths["DAT"])
73
- tag = file.get_tag("PQTZ")
74
-
75
- bpms = 100 * np.ones(tag.count, dtype=np.float64)
76
- tag.set_bpms(bpms)
77
- assert_equal(tag.get_bpms(), bpms)
78
-
79
-
80
- def test_pqtz_tag_set_times():
81
- paths = ANLZ_FILES[0]
82
- file = anlz.AnlzFile.parse_file(paths["DAT"])
83
- tag = file.get_tag("PQTZ")
84
-
85
- times = 0.5 * np.arange(tag.count)
86
- tag.set_times(times)
87
- assert_equal(tag.get_times(), times)
88
-
89
-
90
- def test_pqtz_tag_set():
91
- paths = ANLZ_FILES[0]
92
- file = anlz.AnlzFile.parse_file(paths["DAT"])
93
- tag = file.get_tag("PQTZ")
94
-
95
- beats = np.ones(tag.count)
96
- bpms = 100 * np.ones(tag.count, dtype=np.float64)
97
- times = 0.5 * np.arange(tag.count)
98
- tag.set(beats, bpms, times)
99
- assert_equal(tag.get_bpms(), bpms)
100
- assert_equal(tag.get_bpms(), bpms)
101
- assert_equal(tag.get_times(), times)
102
-
103
-
104
- @pytest.mark.parametrize("paths", ANLZ_FILES)
105
- def test_ppth_tag_getters(paths):
106
- tmp = ""
107
- for path in paths.values():
108
- file = anlz.AnlzFile.parse_file(path)
109
- tag = file.get_tag("PPTH")
110
- p = tag.get()
111
- if not tmp:
112
- tmp = p
113
- else:
114
- assert tmp == p
115
-
116
-
117
- def test_ppth_tag_setters():
118
- paths = ANLZ_FILES[0]
119
- extected = r"C:/new/path/to/file.mp3"
120
- for path in paths.values():
121
- file = anlz.AnlzFile.parse_file(path)
122
- tag = file.get_tag("PPTH")
123
- tag.set(r"C:\new\path\to\file.mp3")
124
- assert tag.get() == extected
125
-
126
-
127
- @pytest.mark.parametrize("paths", ANLZ_FILES)
128
- def test_pwav_tag_getters(paths):
129
- file = anlz.AnlzFile.parse_file(paths["DAT"])
130
- tag = file.get_tag("PWAV")
131
-
132
- heights, color = tag.get()
133
- assert len(heights) == len(color)
134
- assert np.all(np.logical_and(0 <= heights, heights <= 31))
135
- assert np.all(np.logical_and(0 <= color, color <= 7))
136
-
137
-
138
- @pytest.mark.parametrize("paths", ANLZ_FILES)
139
- def test_pwv2_tag_getters(paths):
140
- file = anlz.AnlzFile.parse_file(paths["DAT"])
141
- tag = file.get_tag("PWV2")
142
-
143
- heights, color = tag.get()
144
- assert len(heights) == len(color)
145
- assert np.all(np.logical_and(0 <= heights, heights <= 31))
146
- assert np.all(np.logical_and(0 <= color, color <= 7))
147
-
148
-
149
- @pytest.mark.parametrize("paths", ANLZ_FILES)
150
- def test_pwv3_tag_getters(paths):
151
- file = anlz.AnlzFile.parse_file(paths["EXT"])
152
- tag = file.get_tag("PWV3")
153
-
154
- heights, color = tag.get()
155
- assert len(heights) == len(color)
156
- assert np.all(np.logical_and(0 <= heights, heights <= 31))
157
- assert np.all(np.logical_and(0 <= color, color <= 7))
158
-
159
-
160
- @pytest.mark.parametrize("paths", ANLZ_FILES)
161
- def test_pwv4_tag_getters(paths):
162
- file = anlz.AnlzFile.parse_file(paths["EXT"])
163
- tag = file.get_tag("PWV4")
164
-
165
- heights, colors, blues = tag.get()
166
- assert len(heights) == len(colors)
167
- assert len(heights) == len(blues)
168
-
169
-
170
- @pytest.mark.parametrize("paths", ANLZ_FILES)
171
- def test_pwv5_tag_getters(paths):
172
- file = anlz.AnlzFile.parse_file(paths["EXT"])
173
- tag = file.get_tag("PWV5")
174
-
175
- heights, colors = tag.get()
176
- assert len(heights) == colors.shape[0]
177
-
178
-
179
- # -- File ------------------------------------------------------------------------------
180
-
181
-
182
- def test_anlzfile_getall_tags():
183
- paths = ANLZ_FILES[0]
184
- file = anlz.AnlzFile.parse_file(paths["DAT"])
185
- key = "PPTH"
186
- tags = file.getall_tags(key)
187
- assert len(tags) == 1
188
- assert tags[0].get() == file.get(key)
189
-
190
-
191
- def test_anlzfile_get():
192
- paths = ANLZ_FILES[0]
193
- file = anlz.AnlzFile.parse_file(paths["DAT"])
194
- key = "PPTH"
195
- tag = file.get_tag(key)
196
- assert file.get(key) == tag.get()
197
-
198
-
199
- def test_anlzfile_getall():
200
- paths = ANLZ_FILES[0]
201
- file = anlz.AnlzFile.parse_file(paths["DAT"])
202
- key = "PPTH"
203
- tag = file.get_tag(key)
204
- values = file.getall(key)
205
- assert len(values) == 1
206
- assert values[0] == tag.get()
tests/test_config.py DELETED
@@ -1,175 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Author: Dylan Jones
3
- # Date: 2023-10-02
4
-
5
- import pytest
6
- import json
7
- from pathlib import Path
8
- from pyrekordbox.config import update_config, get_config
9
-
10
- RB_SETTING = """<?xml version="1.0" encoding="UTF-8"?>
11
- <PROPERTIES><VALUE name="masterDbDirectory" val="{db_dir}"/></PROPERTIES>
12
- """
13
-
14
- RB_OPTIONS = {"options": [["db-path", ""]]}
15
-
16
-
17
- def mock_rekordbox_settings_file(pioneer_app_dir, rb_app_dir):
18
- db_dir = pioneer_app_dir / "rekordbox"
19
- text = RB_SETTING.format(db_dir=db_dir)
20
- file = rb_app_dir / "rekordbox3.settings"
21
- file.write_text(text)
22
-
23
-
24
- def mock_rekordbox_options_file(agent_storage_dir, db_path):
25
- file = agent_storage_dir / "options.json"
26
- options = RB_OPTIONS.copy()
27
- options["options"][0][1] = str(db_path)
28
- with open(file, "w") as fp:
29
- json.dump(options, fp)
30
-
31
-
32
- @pytest.fixture(scope="session")
33
- def pioneer_app_dir(tmp_path_factory):
34
- root = tmp_path_factory.mktemp("Pioneer")
35
- rb_dir = root / "rekordbox"
36
- rb6_dir = root / "rekordbox6"
37
- agent_storage_dir = root / "rekordboxAgent" / "storage"
38
- rb_dir.mkdir(parents=True)
39
- rb6_dir.mkdir(parents=True)
40
- agent_storage_dir.mkdir(parents=True)
41
-
42
- # Mock `rekordbox3.settings` files
43
- mock_rekordbox_settings_file(root, rb_dir)
44
- mock_rekordbox_settings_file(root, rb6_dir)
45
-
46
- # Mock database files
47
- rb5_db = rb_dir / "datafile.edb"
48
- rb6_db = rb_dir / "master.db"
49
- rb5_db.touch()
50
- rb6_db.touch()
51
-
52
- # Mock `options.json` file (RBv6)
53
- mock_rekordbox_options_file(agent_storage_dir, rb6_db)
54
-
55
- return root
56
-
57
-
58
- @pytest.fixture(scope="session")
59
- def pioneer_install_dir(tmp_path_factory):
60
- root = tmp_path_factory.mktemp("Pioneer")
61
- rb5_dir = root / "rekordbox 5.1.1"
62
- rb6_dir = root / "rekordbox 6.1.1"
63
- rb5_dir_alt = root / "rekordbox 5.1.2"
64
- rb6_dir_alt = root / "rekordbox 6.1.2"
65
-
66
- rb5_dir.mkdir(parents=True)
67
- rb6_dir.mkdir(parents=True)
68
- rb5_dir_alt.mkdir(parents=True)
69
- rb6_dir_alt.mkdir(parents=True)
70
- return root
71
-
72
-
73
- def test_pioneer_config(pioneer_install_dir, pioneer_app_dir):
74
- update_config(pioneer_install_dir, pioneer_app_dir)
75
- install_dir = get_config("pioneer", "install_dir")
76
- app_dir = get_config("pioneer", "app_dir")
77
-
78
- assert isinstance(install_dir, Path)
79
- assert isinstance(app_dir, Path)
80
- assert install_dir == pioneer_install_dir
81
- assert app_dir == pioneer_app_dir
82
-
83
-
84
- def test_rb5_config(pioneer_install_dir, pioneer_app_dir):
85
- update_config(pioneer_install_dir, pioneer_app_dir)
86
- expected_version = "5.1.2"
87
-
88
- app_dir = get_config("rekordbox5", "app_dir")
89
- install_dir = get_config("rekordbox5", "install_dir")
90
- db_dir = get_config("rekordbox5", "db_dir")
91
- db_path = get_config("rekordbox5", "db_path")
92
- version = get_config("rekordbox5", "version")
93
-
94
- assert isinstance(install_dir, Path)
95
- assert isinstance(app_dir, Path)
96
- assert isinstance(db_dir, Path)
97
- assert isinstance(db_path, Path)
98
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
99
- assert app_dir == (pioneer_app_dir / "rekordbox")
100
- assert db_dir == (pioneer_app_dir / "rekordbox")
101
- assert db_path == (pioneer_app_dir / "rekordbox" / "datafile.edb")
102
- assert version == expected_version
103
-
104
-
105
- def test_rb6_config(pioneer_install_dir, pioneer_app_dir):
106
- update_config(pioneer_install_dir, pioneer_app_dir)
107
- expected_version = "6.1.2"
108
-
109
- app_dir = get_config("rekordbox6", "app_dir")
110
- install_dir = get_config("rekordbox6", "install_dir")
111
- db_dir = get_config("rekordbox6", "db_dir")
112
- db_path = get_config("rekordbox6", "db_path")
113
- version = get_config("rekordbox6", "version")
114
-
115
- assert isinstance(install_dir, Path)
116
- assert isinstance(app_dir, Path)
117
- assert isinstance(db_dir, Path)
118
- assert isinstance(db_path, Path)
119
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
120
- assert app_dir == (pioneer_app_dir / "rekordbox6")
121
- assert db_dir == (pioneer_app_dir / "rekordbox")
122
- assert db_path == (pioneer_app_dir / "rekordbox" / "master.db")
123
- assert version == expected_version
124
-
125
-
126
- def test_rb5_config_alt(pioneer_install_dir, pioneer_app_dir):
127
- # test default: latest version
128
- update_config(pioneer_install_dir, pioneer_app_dir)
129
- expected_version = "5.1.2"
130
-
131
- app_dir = get_config("rekordbox5", "app_dir")
132
- install_dir = get_config("rekordbox5", "install_dir")
133
- version = get_config("rekordbox5", "version")
134
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
135
- assert app_dir == (pioneer_app_dir / "rekordbox")
136
- assert version == expected_version
137
-
138
- # test alternative version
139
- update_config(
140
- pioneer_install_dir, pioneer_app_dir, rb5_install_dirname="rekordbox 5.1.1"
141
- )
142
- expected_version = "5.1.1"
143
-
144
- app_dir = get_config("rekordbox5", "app_dir")
145
- install_dir = get_config("rekordbox5", "install_dir")
146
- version = get_config("rekordbox5", "version")
147
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
148
- assert app_dir == (pioneer_app_dir / "rekordbox")
149
- assert version == expected_version
150
-
151
-
152
- def test_rb6_config_alt(pioneer_install_dir, pioneer_app_dir):
153
- # test default: latest version
154
- update_config(pioneer_install_dir, pioneer_app_dir)
155
- expected_version = "6.1.2"
156
-
157
- app_dir = get_config("rekordbox6", "app_dir")
158
- install_dir = get_config("rekordbox6", "install_dir")
159
- version = get_config("rekordbox6", "version")
160
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
161
- assert app_dir == (pioneer_app_dir / "rekordbox6")
162
- assert version == expected_version
163
-
164
- # test alternative version
165
- update_config(
166
- pioneer_install_dir, pioneer_app_dir, rb6_install_dirname="rekordbox 6.1.1"
167
- )
168
- expected_version = "6.1.1"
169
-
170
- app_dir = get_config("rekordbox6", "app_dir")
171
- install_dir = get_config("rekordbox6", "install_dir")
172
- version = get_config("rekordbox6", "version")
173
- assert install_dir == (pioneer_install_dir / f"rekordbox {expected_version}")
174
- assert app_dir == (pioneer_app_dir / "rekordbox6")
175
- assert version == expected_version