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

Anish Mangal anish at activitycentral.com
Thu May 17 13:30:51 EDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This patch does more than what it claims :-)

Besides making the file pep8-okay, it also cleans up some "apparently"
redundant code. Would be better to have them as two separate patches
going forward (or fix the comments for this patch atleast)

Also, could you tell which version (or git #) should this patch be
applied on top of. It doesnt apply cleanly on Infoslicer-14 downloaded
from ASLO.

On Wednesday 16 May 2012 12:27 AM, Manuel Kaufmann wrote:
> 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


- -- 
Anish
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPtTXLAAoJEBoxUdDHDZVpLXgH/0aOI2O8Q3hZRSSH1WwjRQhv
LgjsxNOW/Ey8THXnLGDFpI33iNXoJZRaPzoitOE717glODA6ExUxMsl0MThOsyV2
GmOynAyOA6ZVRUui28e+2kntPNHIi1+viHHwJDV/Rf+xhCQQQC2Sg8mybdDe7LJy
AarUthxuz/Ye/i4sYCtmzHSUabt90R7qXKLc22Hjo4gkYTWpaA47F0jFCE6UjIA+
l9Jj4+diYxN2sGTVqPTwazSUU6jELNLKW+DqbmvPjHsJO2jbRScLmd7JmMkRoe6F
Yr3SoN76ATr08llGZhqfr4ue2k+zPaUN4+b8l8MFQHjinQ43uwNPzxlItP8Auao=
=GTNR
-----END PGP SIGNATURE-----


More information about the Sugar-devel mailing list