Merge lp:~samuel-buffet/entertainer/bug_380745 into lp:entertainer

Proposed by Samuel Buffet
Status: Merged
Approved by: Matt Layman
Approved revision: 382
Merged at revision: not available
Proposed branch: lp:~samuel-buffet/entertainer/bug_380745
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~samuel-buffet/entertainer/bug_380745
Reviewer Review Type Date Requested Status
Matt Layman Approve
Review via email: mp+6818@code.launchpad.net

Commit message

Movie screen handles empty data for genres, actors, directors or writters. (Fixes Bug 380745)

To post a comment you must log in.
Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Devs,

Here is a proposed fixed for the linked bug.

In a few words, the bug was due to the fact that the movie screen was not handling the possibility to receive empty list for genres, actors, directors or writters.

Those cases are now handled and "Unknown" will be displayed instead of a nice traceback.

I've also taken the occasion to improve variable names. No more dlist or wri_title ...

Samuel-

381. By Samuel Buffet

Merged with trunk 381.

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

Samuel,

Here are my comments:
 * Actors could have as many as 5 actors (according to entertainerlib.medialibrary.videos.Movie) so you'll need to slice the actor_list to actor_list[:5] instead of actor_list[:3] or else we may lose actors. It looks like you were just indenting this line of code, but this is just something I happened to notice.
 * Just like above, but with directors and in the opposite direction. There will only ever be two directors according to the Movie class so the slice should probably just be to :2.
 * Same story with writers. There will only ever be two, according to the Movie class.
 * Did you think about making a common method since this seems to be a repeated pattern here? Maybe it's not worth it with because of the number of size and position variables, but I was just curious if you considered it.
 * I like the one lining of the quick constant labels like "Directed by." That was a nice touch to clean things up.

Thanks,
Matt

review: Approve
382. By Samuel Buffet

Fixes after Matt's comments.

Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Matt hi,

> * Actors could have as many as 5 actors (according to
> entertainerlib.medialibrary.videos.Movie) so you'll need to slice the
> actor_list to actor_list[:5] instead of actor_list[:3] or else we may lose
> actors. It looks like you were just indenting this line of code, but this is
> just something I happened to notice.
> * Just like above, but with directors and in the opposite direction. There
> will only ever be two directors according to the Movie class so the slice
> should probably just be to :2.
> * Same story with writers. There will only ever be two, according to the
> Movie class.

Yep that's right. I've committed those changes.

> * Did you think about making a common method since this seems to be a
> repeated pattern here? Maybe it's not worth it with because of the number of
> size and position variables, but I was just curious if you considered it.

This is something I constantly try to do when it reduces code drastically or makes it more readable.

Thanks for the review.
Samuel-

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'entertainerlib/frontend/gui/screens/movie.py'
2--- entertainerlib/frontend/gui/screens/movie.py 2009-05-06 03:40:22 +0000
3+++ entertainerlib/frontend/gui/screens/movie.py 2009-05-26 21:16:17 +0000
4@@ -72,15 +72,15 @@
5 self.add(year)
6
7 # Show only 2 genres (or one if there is only one)
8- genres = self.movie.get_genres()
9- if len(genres) > 1:
10- genre = genres[0] + "/" + genres[1]
11+ genres_list = self.movie.get_genres()
12+ if len(genres_list) == 0:
13+ genres_text = _("Unknown")
14 else:
15- genre = genres[0]
16+ genres_text = "/".join(genres_list[:2])
17
18 # Runtime and genres
19 info_text = _("%(runtime)s min, %(genre)s") % \
20- {'runtime': self.movie.get_runtime(), 'genre': genre}
21+ {'runtime': self.movie.get_runtime(), 'genre': genres_text}
22 info = Label(0.032, "subtitle", 0.47, 0.24, info_text)
23 info.set_ellipsize(pango.ELLIPSIZE_END)
24 info.set_size(0.5124, 0.05208)
25@@ -116,39 +116,40 @@
26 self.add(self.scroll_area)
27
28 # Actors
29- act_title = Label(0.032, "title", 0.33, 0.8, _("Starring"))
30- self.add(act_title)
31+ self.add(Label(0.032, "title", 0.33, 0.8, _("Starring")))
32
33- actors_text = ", ".join(self.movie.get_actors()[:3])
34+ actors_list = self.movie.get_actors()
35+ if len(actors_list) == 0:
36+ actors_text = _("Unknown")
37+ else:
38+ actors_text = ", ".join(actors_list[:3])
39 actors = Label(0.032, "subtitle", 0.46, 0.8, actors_text)
40 actors.set_ellipsize(pango.ELLIPSIZE_END)
41 actors.set_size(0.5124, 0.05208)
42 self.add(actors)
43
44 # Directors
45- dict_title = Label(0.032, "title", 0.33, 0.86, _("Directed by"))
46- self.add(dict_title)
47+ self.add(Label(0.032, "title", 0.33, 0.86, _("Directed by")))
48
49- dlist = self.movie.get_directors()
50- if len(dlist) > 1:
51- director = dlist[0] + ", " + dlist[1]
52+ directors_list = self.movie.get_directors()
53+ if len(directors_list) == 0:
54+ directors_text = _("Unknown")
55 else:
56- director = dlist[0]
57- directors = Label(0.032, "subtitle", 0.46, 0.86, director)
58+ directors_text = ", ".join(directors_list[:3])
59+ directors = Label(0.032, "subtitle", 0.46, 0.86, directors_text)
60 directors.set_ellipsize(pango.ELLIPSIZE_END)
61 directors.set_size(0.5124, 0.05208)
62 self.add(directors)
63
64 # Writers
65- wri_title = Label(0.032, "title", 0.33, 0.92, _("Written by"))
66- self.add(wri_title)
67+ self.add(Label(0.032, "title", 0.33, 0.92, _("Written by")))
68
69- wlist = self.movie.get_writers()
70- if len(wlist) > 1:
71- writer = wlist[0] + ", " + wlist[1]
72+ writers_list = self.movie.get_writers()
73+ if len(directors_list) == 0:
74+ writers_text = _("Unknown")
75 else:
76- writer = wlist[0]
77- writers = Label(0.032, "subtitle", 0.46, 0.92, writer)
78+ writers_text = ", ".join(writers_list[:3])
79+ writers = Label(0.032, "subtitle", 0.46, 0.92, writers_text)
80 writers.set_ellipsize(pango.ELLIPSIZE_END)
81 writers.set_size(0.5124, 0.05208)
82 self.add(writers)

Subscribers

People subscribed via source and target branches