[Sugar-devel] [PATCH InfoSlicer] File pep8-ized

Manuel Kaufmann humitos at gmail.com
Tue May 15 15:14:14 EDT 2012


Passed pep8.py script to correct some mistakes.

Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
 xol.py |   50 ++++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/xol.py b/xol.py
index d4774ef..b3bd297 100644
--- a/xol.py
+++ b/xol.py
@@ -15,16 +15,13 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 import os
-import gtk
 import zipfile
-import uuid
 import logging
 from glob import glob
 from gettext import gettext as _
 
-from sugar.activity.activity import get_bundle_path, get_activity_root, get_bundle_name
+from sugar.activity.activity import get_bundle_path
 from sugar.datastore import datastore
-from sugar import activity
 
 from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \
         as BeautifulStoneSoup
@@ -32,6 +29,7 @@ import book
 
 logger = logging.getLogger('infoslicer')
 
+
 def publish(activity, force=False):
     if not [i for i in book.custom.index if i['ready']]:
         activity.notify_alert(
@@ -42,7 +40,7 @@ def publish(activity, force=False):
     title = activity.metadata['title']
     jobject = datastore.find({
             'activity_id': activity.get_id(),
-            'activity'   : book.custom.uid})[0] or None
+            'activity': book.custom.uid})[0] or None
 
     logger.debug('publish: title=%s jobject=%s force=%s' \
             % (title, jobject and jobject[0].metadata['activity'], force))
@@ -90,13 +88,16 @@ def publish(activity, force=False):
 
     book.custom.sync_index()
 
-"""
- at author: Matthew Bailey
 
-This class deals with the creation of content packages, comprised of articles from 
-themes, with are zipped up and installed in the relevant OS specific location. From 
-here they can be distributed to the consumers 
+"""@author: Matthew Bailey
+
+This class deals with the creation of content packages, comprised of
+articles from themes, with are zipped up and installed in the relevant
+OS specific location.
+From here they can be distributed to the consumers
 """
+
+
 def _publish(title, jobject):
     zipfilename = '/tmp/infoslicer.xol'
     zip = zipfile.ZipFile(zipfilename, 'w')
@@ -109,22 +110,23 @@ def _publish(title, jobject):
     _info_file(zip, uid, title)
     _index_redirect(zip, uid)
     _dita_management(zip, uid, title)
-    
+
     zip.close()
 
     jobject.set_file_path(zipfilename)
     datastore.write(jobject, transfer_ownership=True)
 
+
 def _dita_management(zip, uid, title):
+    """Creates a DITA map, and copies the requested articles and their
+    associated images into the zipped directories
     """
-        Creates a DITA map, and copies the requested articles and their associated images into the zipped directories
-    """
-    map = [ '<?xml version=\'1.0\' encoding=\'utf-8\'?>',\
-            '<!DOCTYPE map PUBLIC "-//IBM//DTD DITA IBM Map//EN" ' \
-                    '"ibm-map.dtd">',\
-            '<?xml-stylesheet type="text/xsl" href="mapstylesheet.xsl"?>',\
-            '<map title="%s">' % title ]
-    
+    map = ['<?xml version=\'1.0\' encoding=\'utf-8\'?>',
+           '<!DOCTYPE map PUBLIC "-//IBM//DTD DITA IBM Map//EN" ' \
+           '"ibm-map.dtd">',
+           '<?xml-stylesheet type="text/xsl" href="mapstylesheet.xsl"?>',
+           '<map title="%s">' % title]
+
     images = {}
 
     for entry in book.custom.index:
@@ -145,7 +147,8 @@ def _dita_management(zip, uid, title):
             images[image_name] = image_num
             image_name = ('%08d%s' % (image_num, image_ext)).encode('CP437')
 
-            zip.write(image_path, os.path.join(uid, 'slicecontent', image_name))
+            zip.write(image_path, os.path.join(uid, 'slicecontent',
+                                               image_name))
             image['href'] = image_name
 
         content.insert(1, '<?xml-stylesheet type="text/xsl" ' \
@@ -160,6 +163,7 @@ def _dita_management(zip, uid, title):
     zipstr(zip, os.path.join(uid, 'slicecontent', 'librarymap.ditamap'),
             "\n".join(map))
 
+
 def _index_redirect(zip, uid):
     """
         Creates the redirecting index.html
@@ -175,9 +179,10 @@ def _index_redirect(zip, uid):
             '<body>',\
             '</body>',\
             '</html>']
-    
+
     zipstr(zip, os.path.join(uid, 'index.html'), "\n".join(html))
 
+
 def _info_file(zip, uid, title):
     """
         Creates the library.info file
@@ -196,10 +201,11 @@ def _info_file(zip, uid, title):
                    'icon = book.png',\
                    'activity = Web',\
                    'activity_start = index.html']
-    
+
     zipstr(zip, os.path.join(uid, 'library', 'library.info'),
             "\n".join(libraryfile))
 
+
 # XXX setup mode_t for files written by writestr()
 def zipstr(zip, arcname, str):
     import copy
-- 
1.7.10



More information about the Sugar-devel mailing list