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
build/lib/pyrekordbox/utils.py
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Author: Dylan Jones
|
3
|
-
# Date: 2022-04-10
|
4
|
-
|
5
|
-
"""This module contains common constants and methods used in other modules."""
|
6
|
-
|
7
|
-
import os
|
8
|
-
import warnings
|
9
|
-
import psutil
|
10
|
-
from xml.dom import minidom
|
11
|
-
import xml.etree.cElementTree as xml
|
12
|
-
|
13
|
-
warnings.simplefilter("always", DeprecationWarning)
|
14
|
-
|
15
|
-
|
16
|
-
def warn_deprecated(name, new_name="", hint="", remove_in=""):
|
17
|
-
s = f"'{name}' is deprecated"
|
18
|
-
if remove_in:
|
19
|
-
s += f" and will be removed in version '{remove_in}'"
|
20
|
-
|
21
|
-
if new_name:
|
22
|
-
s += f", use '{new_name}' instead!"
|
23
|
-
else:
|
24
|
-
s += "!"
|
25
|
-
|
26
|
-
if hint:
|
27
|
-
s += "\n" + hint
|
28
|
-
|
29
|
-
warnings.warn(s, DeprecationWarning, stacklevel=3)
|
30
|
-
|
31
|
-
|
32
|
-
def get_process_id(name: str, raise_exec=False) -> int:
|
33
|
-
"""Returns the ID of a process if it exists.
|
34
|
-
|
35
|
-
Parameters
|
36
|
-
----------
|
37
|
-
name : str
|
38
|
-
The name of the process, for example 'rekordbox'.
|
39
|
-
raise_exec : bool, optional
|
40
|
-
Raise an exception if the process can not be found.
|
41
|
-
|
42
|
-
Returns
|
43
|
-
-------
|
44
|
-
pid : int
|
45
|
-
The ID of the process if it exists, otherwise zero.
|
46
|
-
|
47
|
-
Raises
|
48
|
-
------
|
49
|
-
RuntimeError: If ``raise_exec=True``, raises a runtime error if the application
|
50
|
-
is not running.
|
51
|
-
|
52
|
-
Examples
|
53
|
-
--------
|
54
|
-
>>> get_process_id("rekordbox")
|
55
|
-
12345
|
56
|
-
|
57
|
-
>>> get_process_id("rekordboxAgent")
|
58
|
-
23456
|
59
|
-
"""
|
60
|
-
for proc in psutil.process_iter():
|
61
|
-
try:
|
62
|
-
proc_name = os.path.splitext(proc.name())[0] # needed on Windows (.exe)
|
63
|
-
if proc_name == name:
|
64
|
-
return proc.pid
|
65
|
-
except (psutil.AccessDenied, psutil.NoSuchProcess):
|
66
|
-
pass
|
67
|
-
if raise_exec:
|
68
|
-
raise RuntimeError("No process with name 'rekordbox' found!")
|
69
|
-
return 0
|
70
|
-
|
71
|
-
|
72
|
-
def get_rekordbox_pid(raise_exec=False):
|
73
|
-
"""Returns the process ID of the Rekordbox application.
|
74
|
-
|
75
|
-
Parameters
|
76
|
-
----------
|
77
|
-
raise_exec : bool, optional
|
78
|
-
Raise an exception if the Rekordbox process can not be found.
|
79
|
-
|
80
|
-
Returns
|
81
|
-
-------
|
82
|
-
pid : int
|
83
|
-
The ID of the Rekordbox process if it exists, otherwise zero.
|
84
|
-
|
85
|
-
Raises
|
86
|
-
------
|
87
|
-
RuntimeError: If ``raise_exec=True``, raises a runtime error if the Rekordbox
|
88
|
-
application is not running.
|
89
|
-
|
90
|
-
Examples
|
91
|
-
--------
|
92
|
-
>>> get_rekordbox_pid()
|
93
|
-
12345
|
94
|
-
"""
|
95
|
-
return get_process_id("rekordbox", raise_exec)
|
96
|
-
|
97
|
-
|
98
|
-
def get_rekordbox_agent_pid(raise_exec=False):
|
99
|
-
"""Returns the process ID of the RekordboxAgent application.
|
100
|
-
|
101
|
-
Parameters
|
102
|
-
----------
|
103
|
-
raise_exec : bool, optional
|
104
|
-
Raise an exception if the RekordboxAgent process can not be found.
|
105
|
-
|
106
|
-
Returns
|
107
|
-
-------
|
108
|
-
pid : int
|
109
|
-
The ID of the RekordboxAgent process if it exists, otherwise zero.
|
110
|
-
|
111
|
-
Raises
|
112
|
-
------
|
113
|
-
RuntimeError: If ``raise_exec=True``, raises a runtime error if the RekordboxAgent
|
114
|
-
application is not running.
|
115
|
-
|
116
|
-
Examples
|
117
|
-
--------
|
118
|
-
>>> get_rekordbox_agent_pid()
|
119
|
-
23456
|
120
|
-
"""
|
121
|
-
return get_process_id("rekordboxAgent", raise_exec)
|
122
|
-
|
123
|
-
|
124
|
-
def pretty_xml(element, indent=None, encoding="utf-8"):
|
125
|
-
"""Generates a formatted string of an XML element.
|
126
|
-
|
127
|
-
Parameters
|
128
|
-
----------
|
129
|
-
element : xml.etree.cElementTree.Element
|
130
|
-
The input XML element.
|
131
|
-
indent : str, optional
|
132
|
-
The indentation used for formatting the XML element. The default is 3 spaces.
|
133
|
-
encoding : str, optional
|
134
|
-
The encoding used for formatting the XML element. The default is 'utf-8'.
|
135
|
-
|
136
|
-
Returns
|
137
|
-
-------
|
138
|
-
xml_string : str
|
139
|
-
The formatted string of the XML element.
|
140
|
-
|
141
|
-
Notes
|
142
|
-
-----
|
143
|
-
This method is needed for Python 3.8 and below. Starting with Python 3.9 the XML
|
144
|
-
module has a built-in pretty-print function:
|
145
|
-
|
146
|
-
>>> tree = xml.ElementTree(root) # noqa
|
147
|
-
>>> xml.indent(tree, space="\t", level=0)
|
148
|
-
>>> tree.write(path, encoding="utf-8", xml_declaration=True) # noqa
|
149
|
-
|
150
|
-
This method will be used as soon support for Python 3.8 and below is dropped.
|
151
|
-
"""
|
152
|
-
# Build pretty xml-string
|
153
|
-
if indent is None:
|
154
|
-
indent = " "
|
155
|
-
if encoding is None:
|
156
|
-
encoding = "utf-8"
|
157
|
-
rough_string = xml.tostring(element, encoding)
|
158
|
-
reparsed = minidom.parseString(rough_string)
|
159
|
-
string = reparsed.toprettyxml(indent=indent, encoding=encoding).decode()
|
160
|
-
# Remove annoying empty lines
|
161
|
-
string = "\n".join([line for line in string.splitlines() if line.strip()])
|
162
|
-
return string
|