Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't make DEFAULT_DEVICE a constant #30

Merged
merged 1 commit into from
Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions discid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from discid.disc import read, put, Disc, DiscError, TOCError
from discid.track import Track
from discid.libdiscid import get_default_device
from discid.deprecated import DiscId
import discid.libdiscid
import discid.disc
Expand All @@ -43,11 +44,6 @@
For old versions the string is `libdiscid < 0.4.0`.
"""

DEFAULT_DEVICE = discid.libdiscid.DEFAULT_DEVICE
"""The default device to use for :func:`read` on this platform
given as a :obj:`unicode` or :obj:`str <python:str>` object.
"""

FEATURES = discid.libdiscid.FEATURES
"""The features libdiscid supports for the platform as a list of strings.
Some Functions can raise :exc:`NotImplementedError` when a feature
Expand Down
3 changes: 2 additions & 1 deletion discid/disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def read(device=None, features=[]):
That string can be either of:
:obj:`str <python:str>`, :obj:`unicode` or :obj:`bytes`.
However, it should in no case contain non-ASCII characters.
If no device is given, the :data:`DEFAULT_DEVICE` is used.
If no device is given, a default, also given by :func:`get_default_device`
is used.

You can optionally add a subset of the features in
:data:`FEATURES` or the whole list to read more than just the TOC.
Expand Down
7 changes: 3 additions & 4 deletions discid/libdiscid.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ def _get_version_string():

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

LIBDISCID_VERSION_STRING = _get_version_string()

DEFAULT_DEVICE = _get_default_device()

FEATURES = _get_features()


Expand Down
7 changes: 4 additions & 3 deletions doc/discid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ At the module level there are these constants available:

.. autodata:: LIBDISCID_VERSION_STRING
:annotation:
.. autodata:: DEFAULT_DEVICE
:annotation:
.. autodata:: FEATURES
:annotation:
.. autodata:: FEATURES_IMPLEMENTED
Expand All @@ -23,12 +21,15 @@ These functions are used to create a :class:`Disc` object.
.. autofunction:: read
.. autofunction:: put

You can get the device that is used as a default with

.. autofunction:: get_default_device

Disc object
-----------
.. autoclass:: Disc
:undoc-members:


.. autoattribute:: id
.. autoattribute:: freedb_id
.. autoattribute:: submission_url
Expand Down
4 changes: 2 additions & 2 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ The basic use case is::
# this will load libdiscid
import discid

print("device: %s" % discid.DEFAULT_DEVICE)
print("device: %s" % discid.get_default_device())
disc = discid.read() # reads from default device
print("id: %s" % disc.id)
print("submission url:\n%s" % disc.submission_url)

You can also set the device explicitely::

device = discid.DEFAULT_DEVICE
device = discid.get_default_device()
disc = discid.read(device)
id = disc.id

Expand Down
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def simple_example():
disc = discid.read() # use default device
print("id: %s" % disc.id)
print("used %s as device" % discid.DEFAULT_DEVICE)
print("used %s as device" % discid.get_default_device())
print("submit with:\n%s" % disc.submission_url)


Expand Down
4 changes: 2 additions & 2 deletions test_discid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_version_string(self):
self.assertTrue(version_string is not None, "No version string given")

def test_default_device(self):
device = discid.DEFAULT_DEVICE
device = discid.get_default_device()
self.assertTrue(device is not None, "No default device given")

def test_features(self):
Expand Down Expand Up @@ -129,7 +129,7 @@ class TestDisc(unittest.TestCase):

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

def test_features(self):
Expand Down