Merge lp:~rockstar/entertainer/storage-branch into lp:entertainer

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/entertainer/storage-branch
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~rockstar/entertainer/storage-branch
Reviewer Review Type Date Requested Status
Matt Layman Approve
Review via email: mp+3427@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

This branch does a few things. The original reason for this branch was to
define an abstract interface that would stand as the contract for which all
other storage facilities can inherit and implement. This allows Entertainer's
client to know nothing about HOW it's getting its info, and just receive it
based on a storage object implementing this base Storage class. When the
client wants all the music tracks, it just calls storage.music_tracks, and the
storage implementation hides the gory details from the client.

One of my next branches will implement this Storage in a LocalStorage flavor,
allowing me to demonstrate how this will work, and to work out an kinks in the
implementation (and truly there will be).

Along with that, I started consolidating exceptions into the
entertainerlib.exceptions module. This will allow us to keep track of what
types of Exceptions we have already created, so we don't go creating more. I
haven't grabbed all the Entertainer specific exceptions, but I at least wanted
to demonstrate what I was trying to achieve.

There is a lint warning R0921 that is my fault. It's detected that Storage is
an abstract class and lets me know I haven't implemented it anywhere.
Apparently pylint doesn't like disabling of the refactoring warnings, and since
it's a temporary warning, I thought we could let it slide. If you as the
reviewer feel I should do something about it, then I'll probably create an
empty class that "implement" Storage for now.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Matt Layman (mblayman) wrote :

 approve merge_conditional

pylint --rcfile=pylintrc entertainer* tools/*.py setup.py
************* Module entertainerlib.frontend.frontend_client
W0612: 50:FrontendClient.__init__: Unused variable 'system_tray_icon'
************* Module entertainerlib.tests.test_storage
W0612: 20:TestStorage.test_not_implemented: Unused variable 'albums'
************* Module entertainerlib.storage.base
R0921: 4:Storage: Abstract class not referenced

I know that one warning isn't from your branch, but since this would probably be the next branch merged to trunk, it would be a good time to fix them.

I'm okay with the R0921 because it will have an associated implementation soon.

review: Approve
347. By Paul Hummer

Merge from trunk

348. By Paul Hummer

Fixed lint issues

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'entertainerlib/exceptions.py'
2--- entertainerlib/exceptions.py 1970-01-01 00:00:00 +0000
3+++ entertainerlib/exceptions.py 2009-02-06 06:17:51 +0000
4@@ -0,0 +1,15 @@
5+'''Various Exceptions for Entertainer.'''
6+
7+
8+class ThumbnailerException(Exception):
9+ '''Abstract thumbnailer exception'''
10+
11+
12+class ImageThumbnailerException(ThumbnailerException):
13+ '''An exception specific to the ImageThumbnailer'''
14+
15+
16+class VideoThumbnailerException(ThumbnailerException):
17+ '''An exception specific to the video thumbnailer'''
18+
19+
20
21=== added directory 'entertainerlib/storage'
22=== added file 'entertainerlib/storage/__init__.py'
23--- entertainerlib/storage/__init__.py 1970-01-01 00:00:00 +0000
24+++ entertainerlib/storage/__init__.py 2009-02-06 06:52:14 +0000
25@@ -0,0 +1,4 @@
26+'''Storage facilities for Entertainer (used by the client/frontend).'''
27+# pylint: disable-msg=W0611
28+from entertainerlib.storage.base import Storage
29+
30
31=== added file 'entertainerlib/storage/base.py'
32--- entertainerlib/storage/base.py 1970-01-01 00:00:00 +0000
33+++ entertainerlib/storage/base.py 2009-02-06 06:34:20 +0000
34@@ -0,0 +1,37 @@
35+'''Base classes for Entertainer Storages.'''
36+
37+
38+class Storage(object):
39+ '''Base Storage class.'''
40+
41+ @property
42+ def music_tracks(self):
43+ '''Return a list of all music tracks.'''
44+ raise NotImplementedError
45+
46+ @property
47+ def music_albums(self):
48+ '''Return a list of all music tracks.'''
49+ raise NotImplementedError
50+
51+ @property
52+ def photo_albums(self):
53+ '''Return a list of all music tracks.'''
54+ raise NotImplementedError
55+
56+ @property
57+ def photo_images(self):
58+ '''Return a list of all music tracks.'''
59+ raise NotImplementedError
60+
61+ @property
62+ def video_files(self):
63+ '''Return a list of all music tracks.'''
64+ raise NotImplementedError
65+
66+ @property
67+ def video_series(self):
68+ '''Return a list of all music tracks.'''
69+ raise NotImplementedError
70+
71+
72
73=== added file 'entertainerlib/tests/test_storage.py'
74--- entertainerlib/tests/test_storage.py 1970-01-01 00:00:00 +0000
75+++ entertainerlib/tests/test_storage.py 2009-02-06 06:37:55 +0000
76@@ -0,0 +1,54 @@
77+'''Test the Storage classes.'''
78+from entertainerlib.storage import Storage
79+from entertainerlib.tests import EntertainerTest
80+
81+class TestStorage(EntertainerTest):
82+ '''Test for entertainerlib.storage.base.Storage.'''
83+
84+ def test_create(self):
85+ '''Test the instantiation of a Storage object.'''
86+ storage = Storage()
87+ self.assertTrue(isinstance(storage, Storage))
88+
89+ def test_not_implemented(self):
90+ '''Test the calls to the various methods raise NotImplementedError.'''
91+ storage = Storage()
92+
93+ # The try/except blocks are used instead of assertRaises because these
94+ # attributes are not callable.
95+ try:
96+ albums = storage.music_albums
97+ self.fail()
98+ except NotImplementedError:
99+ pass
100+
101+ try:
102+ albums = storage.music_tracks
103+ self.fail()
104+ except NotImplementedError:
105+ pass
106+
107+ try:
108+ albums = storage.photo_albums
109+ self.fail()
110+ except NotImplementedError:
111+ pass
112+
113+ try:
114+ albums = storage.photo_images
115+ self.fail()
116+ except NotImplementedError:
117+ pass
118+
119+ try:
120+ albums = storage.video_files
121+ self.fail()
122+ except NotImplementedError:
123+ pass
124+
125+ try:
126+ albums = storage.video_series
127+ self.fail()
128+ except NotImplementedError:
129+ pass
130+
131
132=== modified file 'entertainerlib/utils/image_thumbnailer.py'
133--- entertainerlib/utils/image_thumbnailer.py 2009-01-11 00:17:47 +0000
134+++ entertainerlib/utils/image_thumbnailer.py 2009-02-06 06:18:09 +0000
135@@ -6,11 +6,10 @@
136 __maintainer__ = "Paul Hummer <paul@ironlionsoftware.no.spam.com>"
137
138 import Image
139+
140+from entertainerlib.exceptions import ImageThumbnailerException
141 from entertainerlib.utils import thumbnailer
142
143-class ImageThumbnailerException(Exception):
144- '''An exception specific to the ImageThumbnailer'''
145-
146 class ImageThumbnailer(thumbnailer.Thumbnailer):
147 """Thumbnailer for image files."""
148
149
150=== modified file 'entertainerlib/utils/thumbnailer.py'
151--- entertainerlib/utils/thumbnailer.py 2009-01-11 02:13:04 +0000
152+++ entertainerlib/utils/thumbnailer.py 2009-02-06 06:34:20 +0000
153@@ -11,11 +11,9 @@
154 except ImportError:
155 import md5
156
157+from entertainerlib.exceptions import ThumbnailerException
158 from entertainerlib.utils.configuration import Configuration
159
160-class ThumbnailerException(Exception):
161- '''Abstract thumbnailer exception'''
162-
163 class Thumbnailer(object):
164 """ Thumbnailer interface for video and image thumbnailers. """
165
166@@ -60,4 +58,5 @@
167 thumbnail directory in JPEG format. Thumbnail filename should be a MD5
168 hash of the absolute path of the original file.
169 """
170- raise Exception('Method not implemented')
171+ raise NotImplementedError
172+
173
174=== modified file 'entertainerlib/utils/video_thumbnailer.py'
175--- entertainerlib/utils/video_thumbnailer.py 2009-01-11 02:25:00 +0000
176+++ entertainerlib/utils/video_thumbnailer.py 2009-02-06 06:18:09 +0000
177@@ -17,13 +17,10 @@
178 import Image
179 import ImageStat
180
181+from entertainerlib.exceptions import VideoThumbnailerException
182 from entertainerlib.utils import thumbnailer
183
184
185-class VideoThumbnailerException(Exception):
186- '''An exception specific to the video thumbnailer'''
187-
188-
189 class VideoThumbnailer(thumbnailer.Thumbnailer):
190 ''' VideoThumbnailer does exactly what it's name demonstrates it does:
191 create thumbnailed images of the videos.'''

Subscribers

People subscribed via source and target branches