[Sugar-devel] [PATCH 5/6] PEP8 test activity cleanup

Manuel Quiñones manuq at laptop.org
Mon May 14 15:51:58 EDT 2012


Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
 test/TestActivity.py |   21 ++++++++++++---------
 test/TestGame.py     |   35 ++++++++++++++++++-----------------
 2 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/test/TestActivity.py b/test/TestActivity.py
index d7c1695..1eb8744 100644
--- a/test/TestActivity.py
+++ b/test/TestActivity.py
@@ -11,15 +11,16 @@ from sugar3.graphics.toolbutton import ToolButton
 from sugar3.activity.widgets import StopButton
 
 
-sys.path.append('..') # Import sugargame package from top directory.
+sys.path.append('..')  # Import sugargame package from top directory.
 import sugargame.canvas
 
 import TestGame
 
+
 class TestActivity(sugar3.activity.activity.Activity):
     def __init__(self, handle):
         super(TestActivity, self).__init__(handle)
-        
+
         self.paused = False
 
         # Create the game instance.
@@ -31,13 +32,15 @@ class TestActivity(sugar3.activity.activity.Activity):
         # Build the Pygame canvas.
         self._pygamecanvas = sugargame.canvas.PygameCanvas(self)
 
-        # Note that set_canvas implicitly calls read_file when resuming from the Journal.
+        # Note that set_canvas implicitly calls read_file when
+        # resuming from the Journal.
         self.set_canvas(self._pygamecanvas)
-        
-        # Start the game running (self.game.run is called when the activity constructor returns).
+
+        # Start the game running (self.game.run is called when the
+        # activity constructor returns).
         self._pygamecanvas.run_pygame(self.game.run)
-        
-    def build_toolbar(self):        
+
+    def build_toolbar(self):
         toolbar_box = ToolbarBox()
         self.set_toolbar_box(toolbar_box)
         toolbar_box.show()
@@ -72,7 +75,7 @@ class TestActivity(sugar3.activity.activity.Activity):
         # Pause or unpause the game.
         self.paused = not self.paused
         self.game.set_paused(self.paused)
-        
+
         # Update the button to show the next action.
         if self.paused:
             button.set_icon('media-playback-start')
@@ -83,6 +86,6 @@ class TestActivity(sugar3.activity.activity.Activity):
 
     def read_file(self, file_path):
         self.game.read_file(file_path)
-        
+
     def write_file(self, file_path):
         self.game.write_file(file_path)
diff --git a/test/TestGame.py b/test/TestGame.py
index 7827cbf..3ab9026 100755
--- a/test/TestGame.py
+++ b/test/TestGame.py
@@ -2,6 +2,7 @@
 import pygame
 from gi.repository import Gtk
 
+
 class TestGame:
     def __init__(self):
         # Set up a clock for managing the frame rate.
@@ -14,7 +15,7 @@ class TestGame:
         self.vy = 0
 
         self.paused = False
-        
+
     def set_paused(self, paused):
         self.paused = paused
 
@@ -25,11 +26,11 @@ class TestGame:
     # Called to load the state of the game from the Journal.
     def read_file(self, file_path):
         pass
-        
+
     # The main game loop.
     def run(self):
-        self.running = True    
-            
+        self.running = True
+
         screen = pygame.display.get_surface()
 
         while self.running:
@@ -43,40 +44,40 @@ class TestGame:
                     return
                 elif event.type == pygame.VIDEORESIZE:
                     pygame.display.set_mode(event.size, pygame.RESIZABLE)
-            
+
             # Move the ball
             if not self.paused:
                 self.x += self.vx
                 if self.x > screen.get_width() + 100:
                     self.x = -100
-                
+
                 self.y += self.vy
                 if self.y > screen.get_height() - 100:
                     self.y = screen.get_height() - 100
                     self.vy = -self.vy
-                
-                self.vy += 5;
-            
+
+                self.vy += 5
+
             # Clear Display
-            screen.fill((255,255,255)) #255 for white
+            screen.fill((255, 255, 255))  # 255 for white
 
             # Draw the ball
-            pygame.draw.circle(screen, (255,0,0), (self.x, self.y), 100)
-                    
+            pygame.draw.circle(screen, (255, 0, 0), (self.x, self.y), 100)
+
             # Flip Display
-            pygame.display.flip()  
-            
+            pygame.display.flip()
+
             # Try to stay at 30 FPS
             self.clock.tick(30)
 
+
 # This function is called when the game is run directly from the command line:
-# ./TestGame.py 
+# ./TestGame.py
 def main():
     pygame.init()
     pygame.display.set_mode((0, 0), pygame.RESIZABLE)
-    game = TestGame() 
+    game = TestGame()
     game.run()
 
 if __name__ == '__main__':
     main()
-
-- 
1.7.7.6



More information about the Sugar-devel mailing list