diff --git a/.gitignore b/.gitignore index 799bff1..37fcd87 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ MANIFEST build/ dist/ -mopidy_touchscreen/.idea/ +.idea/ diff --git a/README.rst b/README.rst index b772a9b..d84ce45 100644 --- a/README.rst +++ b/README.rst @@ -3,22 +3,22 @@ Mopidy-Touchscreen **************************** .. image:: https://img.shields.io/pypi/v/Mopidy-Touchscreen.svg?style=flat - :target: https://pypi.python.org/pypi/Mopidy-Touchscreen/ +:target: https://pypi.python.org/pypi/Mopidy-Touchscreen/ :alt: Latest PyPI version .. image:: https://img.shields.io/pypi/dm/Mopidy-Touchscreen.svg?style=flat - :target: https://pypi.python.org/pypi/Mopidy-Touchscreen/ +:target: https://pypi.python.org/pypi/Mopidy-Touchscreen/ :alt: Number of PyPI downloads .. image:: https://img.shields.io/travis/9and3r/modipy-touchscreen/master.png?style=flat - :target: https://travis-ci.org/9and3r/modipy-touchscreen +:target: https://travis-ci.org/9and3r/modipy-touchscreen :alt: Travis CI build status .. image:: https://img.shields.io/coveralls/9and3r/modipy-touchscreen/master.svg?style=flat - :target: https://coveralls.io/r/9and3r/modipy-touchscreen?branch=master +:target: https://coveralls.io/r/9and3r/modipy-touchscreen?branch=master :alt: Test coverage -Extension for displaying track info and controlling Mopidy from a touch screen using `PyGame `_/SDL. + Extension for displaying track info and controlling Mopidy from a touch screen using `PyGame `_/SDL. Cover images are downloaded from `last.fm `_ diff --git a/docs/conf.py b/docs/conf.py index e3fcb6c..dc9a3c6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ @@ -182,22 +182,22 @@ htmlhelp_basename = 'Mopidy-Touchscreendoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'Mopidy-Touchscreen.tex', u'Mopidy-Touchscreen Documentation', - u'9and3r', 'manual'), + ('index', 'Mopidy-Touchscreen.tex', u'Mopidy-Touchscreen Documentation', + u'9and3r', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -240,9 +240,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Mopidy-Touchscreen', u'Mopidy-Touchscreen Documentation', - u'9and3r', 'Mopidy-Touchscreen', 'One line description of project.', - 'Miscellaneous'), + ('index', 'Mopidy-Touchscreen', u'Mopidy-Touchscreen Documentation', + u'9and3r', 'Mopidy-Touchscreen', 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. diff --git a/docs/index.rst b/docs/index.rst index bbef51e..9802838 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. Mopidy-Touchscreen documentation master file, created by - sphinx-quickstart on Mon Aug 4 00:48:14 2014. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +sphinx-quickstart on Mon Aug 4 00:48:14 2014. +You can adapt this file completely to your liking, but it should at least +contain the root `toctree` directive. Welcome to Mopidy-Touchscreen's documentation! ============================================== @@ -9,7 +9,7 @@ Welcome to Mopidy-Touchscreen's documentation! Contents: .. toctree:: - :maxdepth: 2 +:maxdepth: 2 diff --git a/mopidy_touchscreen/__init__.py b/mopidy_touchscreen/__init__.py index efdfe43..86e811a 100644 --- a/mopidy_touchscreen/__init__.py +++ b/mopidy_touchscreen/__init__.py @@ -36,5 +36,5 @@ class Extension(ext.Extension): def setup(self, registry): registry.add('frontend', TouchScreen) - #Backend used for controling volume + # Backend used for controling volume registry.add('backend', TouchScreenBackend) diff --git a/mopidy_touchscreen/dynamic_background.py b/mopidy_touchscreen/dynamic_background.py index e4590ff..47f3bc5 100644 --- a/mopidy_touchscreen/dynamic_background.py +++ b/mopidy_touchscreen/dynamic_background.py @@ -24,7 +24,7 @@ class DynamicBackground(): # Returns an array with 3 integers in range of 0-255 -#The sum of the three integers will be lower than 255*2 (510) to avoid very bright colors +# The sum of the three integers will be lower than 255*2 (510) to avoid very bright colors #White text should be seen ok with this background color diff --git a/mopidy_touchscreen/library_screen.py b/mopidy_touchscreen/library_screen.py index f4d19d7..9c3e796 100644 --- a/mopidy_touchscreen/library_screen.py +++ b/mopidy_touchscreen/library_screen.py @@ -77,6 +77,6 @@ class LibraryScreen(): self.manager.core.tracklist.add(uri=uri) self.manager.core.playback.play() else: - #TODO: add folder to tracks to play + # TODO: add folder to tracks to play pass diff --git a/mopidy_touchscreen/list_view.py b/mopidy_touchscreen/list_view.py index 8dce9e8..44797bb 100644 --- a/mopidy_touchscreen/list_view.py +++ b/mopidy_touchscreen/list_view.py @@ -19,7 +19,7 @@ class ListView(): self.set_list([]) self.selected = [] - #Sets the list for the lisview. It should be an iterable of strings + # Sets the list for the lisview. It should be an iterable of strings def set_list(self, item_list): self.list = item_list self.list_size = len(item_list) diff --git a/mopidy_touchscreen/main_screen.py b/mopidy_touchscreen/main_screen.py index 7975b52..6aae273 100644 --- a/mopidy_touchscreen/main_screen.py +++ b/mopidy_touchscreen/main_screen.py @@ -58,7 +58,7 @@ class MainScreen(): (width, self.size[1])) self.touch_text_manager.set_object("track_name", label) - #Album name + # Album name label = TextItem(self.fonts['base'], MainScreen.get_track_album_name(track), (x, self.base_size * 3), (width, self.size[1])) self.touch_text_manager.set_object("album_name", label) diff --git a/mopidy_touchscreen/menu_screen.py b/mopidy_touchscreen/menu_screen.py index 94bcf23..ea8908d 100644 --- a/mopidy_touchscreen/menu_screen.py +++ b/mopidy_touchscreen/menu_screen.py @@ -21,7 +21,7 @@ class MenuScreen(): None) self.screen_objects.set_touch_object("exit", button) - #Shutdown button + # Shutdown button button = TouchAndTextItem(self.manager.fonts['icon'], u"\ue60b", (0, self.base_size * 2), None) self.screen_objects.set_touch_object("shutdown_icon", button) button = TouchAndTextItem(self.manager.fonts['base'], "Shutdown", (button.get_right_pos(), self.base_size * 2), @@ -62,7 +62,7 @@ class MenuScreen(): elif key == "ip": self.check_connection() - #Will check internet connection + # Will check internet connection def check_connection(self): try: self.manager.set_connection(False, True) diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py index 18d4067..7e0b0c2 100644 --- a/mopidy_touchscreen/screen_manager.py +++ b/mopidy_touchscreen/screen_manager.py @@ -28,7 +28,7 @@ class ScreenManager(): self.background = DynamicBackground() self.current_screen = 0 self.base_size = self.size[1] / 8 - font = resource_filename(Requirement.parse("mopidy-touchscreen"),"mopidy_touchscreen/icomoon.ttf") + font = resource_filename(Requirement.parse("mopidy-touchscreen"), "mopidy_touchscreen/icomoon.ttf") self.fonts['base'] = pygame.font.SysFont("verdana", self.base_size) self.fonts['icon'] = pygame.font.Font(font, self.base_size) try: @@ -52,7 +52,7 @@ class ScreenManager(): self.screen_objects_manager.set_touch_object("pause_play", button) x = button.get_right_pos() - #Random + # Random button = TouchAndTextItem(self.fonts['icon'], u"\ue629 ", (x, 0), None) self.screen_objects_manager.set_touch_object("random", button) x = button.get_right_pos() diff --git a/mopidy_touchscreen/touch_screen.py b/mopidy_touchscreen/touch_screen.py index 9274d6f..fc46caf 100644 --- a/mopidy_touchscreen/touch_screen.py +++ b/mopidy_touchscreen/touch_screen.py @@ -31,7 +31,7 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener): screen = pygame.display.set_mode(self.screen_size, pygame.FULLSCREEN) else: screen = pygame.display.set_mode(self.screen_size) - pygame.mouse.set_visible(self.cursor) + pygame.mouse.set_visible(self.cursor) while self.running: clock.tick(15) screen.blit(self.screen_manager.update(), (0, 0)) diff --git a/mopidy_touchscreen/touch_text_manager.py b/mopidy_touchscreen/touch_text_manager.py index 3ab183e..8f06212 100644 --- a/mopidy_touchscreen/touch_text_manager.py +++ b/mopidy_touchscreen/touch_text_manager.py @@ -3,18 +3,16 @@ import logging logger = logging.getLogger(__name__) + class TouchTextManager(): - - - - def __init__(self,size,base_size): + def __init__(self, size, base_size): self.size = size self.base_size = base_size self.touch_objects = {} self.text_objects = {} def add_object(self, key, text, pos, pos2, color): - self.text_objects[key] = TextItem(text, pos,pos2,color,self.base_size) + self.text_objects[key] = TextItem(text, pos, pos2, color, self.base_size) def get_object(self, key): return self.text_objects[key] @@ -22,11 +20,11 @@ class TouchTextManager(): def add_touch_object(self, key, text, pos, color): self.touch_objects['key'] = TouchAndTextItem(text, pos, color, self.base_size) - def get_touch_object(self,key): + def get_touch_object(self, key): return self.touch_objects['key'] def add_progressbar(self, key, pos, pos2, max): - self.touch_objects['key'] = Progressbar(pos,pos2,max) + self.touch_objects['key'] = Progressbar(pos, pos2, max) def render(self, surface): for key in self.text_objects: @@ -37,21 +35,19 @@ class TouchTextManager(): class BaseItem(): - - def __init__(self,pos,pos2): + def __init__(self, pos, pos2): self.pos = pos self.pos2 = pos2 - self.size=[0,0] + self.size = [0, 0] self.size[0] = self.pos2[0] - self.pos[0] self.size[1] = self.pos2[1] - self.pos[1] - self.rect = pygame.Rect(0,0,self.size[0],self.size[1]) + self.rect = pygame.Rect(0, 0, self.size[0], self.size[1]) class TextItem(BaseItem): - - def __init__(self, text, pos,pos2, color,text_size): + def __init__(self, text, pos, pos2, color, text_size): if pos2 is not None: - BaseItem.__init__(self,pos,pos2) + BaseItem.__init__(self, pos, pos2) self.text_size = text_size self.font = pygame.font.SysFont("arial", text_size) self.text = text @@ -70,7 +66,7 @@ class TextItem(BaseItem): else: self.fit_vertical = True else: - BaseItem.__init__(self,pos,(pos[0]+self.box.get_rect().width,pos[1]+self.box.get_rect().height)) + BaseItem.__init__(self, pos, (pos[0] + self.box.get_rect().width, pos[1] + self.box.get_rect().height)) self.fit_horizontal = True self.fit_vertical = True @@ -93,50 +89,49 @@ class TextItem(BaseItem): else: self.step = self.step + 1 - def render(self,surface): + def render(self, surface): if self.fit_horizontal: self.box else: self.box = self.font.render(self.text, True, self.color) - surface.blit(self.box,self.pos,area=self.rect) + surface.blit(self.box, self.pos, area=self.rect) def set_text(self, text): - self.__init__(text,self.pos,self.pos2,self.color,self.text_size) + self.__init__(text, self.pos, self.pos2, self.color, self.text_size) + class TouchObject(BaseItem): - - def __init__(self,pos,pos2): - BaseItem.__init__(self,pos,pos2) + def __init__(self, pos, pos2): + BaseItem.__init__(self, pos, pos2) self.active = False self.background_box = pygame.Surface(self.size) - self.background_box.fill((0,128,255)) + self.background_box.fill((0, 128, 255)) - def render(self,surface): + def render(self, surface): surface.blit(self.background_box, self.pos) class TouchAndTextItem(TouchObject, TextItem): - - def __init__(self, text, pos, color,text_size): - TextItem.__init__(self,text, pos,None, color,text_size) - TouchObject.__init__(self,pos,self.pos2) + def __init__(self, text, pos, color, text_size): + TextItem.__init__(self, text, pos, None, color, text_size) + TouchObject.__init__(self, pos, self.pos2) def update(self): TextItem.update() - def render(self,surface): - TouchObject.render(self,surface) - TextItem.render(self,surface) + def render(self, surface): + TouchObject.render(self, surface) + TextItem.render(self, surface) + class Progressbar(BaseItem): - def __init__(self, pos, pos2, max): BaseItem.__init__(self, pos, pos2) logger.error(pos2) self.value = 0 self.max = max - self.back_color = (0,0,0) - self.main_color = (255,255,255) + self.back_color = (0, 0, 0) + self.main_color = (255, 255, 255) self.surface = pygame.Surface(self.size) self.surface.fill(self.back_color) @@ -150,6 +145,6 @@ class Progressbar(BaseItem): self.value = value self.surface.fill(self.back_color) pos_pixel = value * self.size[0] / self.max - rect = pygame.Rect(0,0,pos_pixel,self.size[1]) + rect = pygame.Rect(0, 0, pos_pixel, self.size[1]) self.surface.fill(self.main_color, rect) diff --git a/setup.py b/setup.py index 877d51b..1477351 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( 'setuptools', 'Mopidy >= 0.18', 'Pykka >= 1.1', - 'pygame' + 'pygame' ], test_suite='nose.collector', tests_require=[ diff --git a/tests/test_extension.py b/tests/test_extension.py index 35fc285..4c16cf5 100644 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -6,7 +6,6 @@ from mopidy_touchscreen import Extension, touch_screen as frontend_lib class ExtensionTest(unittest.TestCase): - def test_get_default_config(self): ext = Extension() @@ -21,7 +20,7 @@ class ExtensionTest(unittest.TestCase): schema = ext.get_config_schema() # TODO Test the content of your config schema - #self.assertIn('username', schema) + # self.assertIn('username', schema) #self.assertIn('password', schema) - # TODO Write more tests + # TODO Write more tests