Skip to content

Commit 1a36ad5

Browse files
committed
Merge branch 'default_function'
see pull-request #30
2 parents 7ba675f + eb26588 commit 1a36ad5

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

discid/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from discid.disc import read, put, Disc, DiscError, TOCError
3131
from discid.track import Track
32+
from discid.libdiscid import get_default_device
3233
from discid.deprecated import DiscId
3334
import discid.libdiscid
3435
import discid.disc
@@ -43,11 +44,6 @@
4344
For old versions the string is `libdiscid < 0.4.0`.
4445
"""
4546

46-
DEFAULT_DEVICE = discid.libdiscid.DEFAULT_DEVICE
47-
"""The default device to use for :func:`read` on this platform
48-
given as a :obj:`unicode` or :obj:`str <python:str>` object.
49-
"""
50-
5147
FEATURES = discid.libdiscid.FEATURES
5248
"""The features libdiscid supports for the platform as a list of strings.
5349
Some Functions can raise :exc:`NotImplementedError` when a feature

discid/disc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def read(device=None, features=[]):
3838
That string can be either of:
3939
:obj:`str <python:str>`, :obj:`unicode` or :obj:`bytes`.
4040
However, it should in no case contain non-ASCII characters.
41-
If no device is given, the :data:`DEFAULT_DEVICE` is used.
41+
If no device is given, a default, also given by :func:`get_default_device`
42+
is used.
4243
4344
You can optionally add a subset of the features in
4445
:data:`FEATURES` or the whole list to read more than just the TOC.

discid/libdiscid.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ def _get_version_string():
120120

121121
_LIB.discid_get_default_device.argtypes = ()
122122
_LIB.discid_get_default_device.restype = c_char_p
123-
def _get_default_device():
124-
"""Get the default device for the platform
123+
def get_default_device():
124+
"""The default device to use for :func:`read` on this platform
125+
given as a :obj:`unicode` or :obj:`str <python:str>` object.
125126
"""
126127
device = _LIB.discid_get_default_device()
127128
return _decode(device)
@@ -164,8 +165,6 @@ def _get_features():
164165

165166
LIBDISCID_VERSION_STRING = _get_version_string()
166167

167-
DEFAULT_DEVICE = _get_default_device()
168-
169168
FEATURES = _get_features()
170169

171170

doc/discid.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ At the module level there are these constants available:
1010

1111
.. autodata:: LIBDISCID_VERSION_STRING
1212
:annotation:
13-
.. autodata:: DEFAULT_DEVICE
14-
:annotation:
1513
.. autodata:: FEATURES
1614
:annotation:
1715
.. autodata:: FEATURES_IMPLEMENTED
@@ -23,12 +21,15 @@ These functions are used to create a :class:`Disc` object.
2321
.. autofunction:: read
2422
.. autofunction:: put
2523

24+
You can get the device that is used as a default with
25+
26+
.. autofunction:: get_default_device
27+
2628
Disc object
2729
-----------
2830
.. autoclass:: Disc
2931
:undoc-members:
3032

31-
3233
.. autoattribute:: id
3334
.. autoattribute:: freedb_id
3435
.. autoattribute:: submission_url

doc/usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ The basic use case is::
88
# this will load libdiscid
99
import discid
1010

11-
print("device: %s" % discid.DEFAULT_DEVICE)
11+
print("device: %s" % discid.get_default_device())
1212
disc = discid.read() # reads from default device
1313
print("id: %s" % disc.id)
1414
print("submission url:\n%s" % disc.submission_url)
1515

1616
You can also set the device explicitely::
1717

18-
device = discid.DEFAULT_DEVICE
18+
device = discid.get_default_device()
1919
disc = discid.read(device)
2020
id = disc.id
2121

examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def simple_example():
99
disc = discid.read() # use default device
1010
print("id: %s" % disc.id)
11-
print("used %s as device" % discid.DEFAULT_DEVICE)
11+
print("used %s as device" % discid.get_default_device())
1212
print("submit with:\n%s" % disc.submission_url)
1313

1414

test_discid.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_version_string(self):
5151
self.assertTrue(version_string is not None, "No version string given")
5252

5353
def test_default_device(self):
54-
device = discid.DEFAULT_DEVICE
54+
device = discid.get_default_device()
5555
self.assertTrue(device is not None, "No default device given")
5656

5757
def test_features(self):
@@ -131,7 +131,7 @@ class TestDisc(unittest.TestCase):
131131

132132
def test_default_device(self):
133133
# Can't be empty, in contrast to the test in TestModule
134-
device = discid.DEFAULT_DEVICE
134+
device = discid.get_default_device()
135135
self.assertTrue(device, "No default device given")
136136

137137
def test_features(self):

0 commit comments

Comments
 (0)