PEP8 white space and long line fixes
This commit is contained in:
@@ -31,6 +31,7 @@ from sugar import util
|
||||
from sugar.bundle.bundle import Bundle, \
|
||||
MalformedBundleException, NotInstalledException
|
||||
|
||||
|
||||
class ActivityBundle(Bundle):
|
||||
"""A Sugar activity bundle
|
||||
|
||||
@@ -89,8 +90,8 @@ class ActivityBundle(Bundle):
|
||||
return ret
|
||||
|
||||
def _read_manifest(self):
|
||||
"""return a list with the lines in MANIFEST, with invalid lines replaced
|
||||
by empty lines.
|
||||
"""return a list with the lines in MANIFEST, with invalid lines
|
||||
replaced by empty lines.
|
||||
|
||||
Since absolute order carries information on file history, it should
|
||||
be preserved. For instance, when renaming a file, you should leave
|
||||
@@ -170,7 +171,7 @@ class ActivityBundle(Bundle):
|
||||
|
||||
if cp.has_option(section, 'mime_types'):
|
||||
mime_list = cp.get(section, 'mime_types').strip(';')
|
||||
self._mime_types = [ mime.strip() for mime in mime_list.split(';') ]
|
||||
self._mime_types = [mime.strip() for mime in mime_list.split(';')]
|
||||
|
||||
if cp.has_option(section, 'show_launcher'):
|
||||
if cp.get(section, 'show_launcher') == 'no':
|
||||
@@ -251,10 +252,10 @@ class ActivityBundle(Bundle):
|
||||
"""Get the activity bundle id"""
|
||||
return self._bundle_id
|
||||
|
||||
# FIXME: this should return the icon data, not a filename, so that
|
||||
# we don't need to create a temp file in the zip case
|
||||
def get_icon(self):
|
||||
"""Get the activity icon name"""
|
||||
# FIXME: this should return the icon data, not a filename, so that
|
||||
# we don't need to create a temp file in the zip case
|
||||
icon_path = os.path.join('activity', self._icon + '.svg')
|
||||
if self._zip_file is None:
|
||||
return os.path.join(self._path, icon_path)
|
||||
@@ -301,7 +302,7 @@ class ActivityBundle(Bundle):
|
||||
|
||||
# List installed files
|
||||
manifestfiles = self.get_files(self._raw_manifest())
|
||||
paths = []
|
||||
paths = []
|
||||
for root, dirs_, files in os.walk(install_path):
|
||||
rel_path = root[len(install_path) + 1:]
|
||||
for f in files:
|
||||
@@ -320,7 +321,7 @@ class ActivityBundle(Bundle):
|
||||
# Is anything in MANIFEST left over after accounting for all files?
|
||||
if manifestfiles:
|
||||
err = ("Bundle %s: files in MANIFEST not included: %s"%
|
||||
(self._name,str(manifestfiles)))
|
||||
(self._name, str(manifestfiles)))
|
||||
if strict_manifest:
|
||||
raise MalformedBundleException(err)
|
||||
else:
|
||||
@@ -351,7 +352,7 @@ class ActivityBundle(Bundle):
|
||||
mime_types = self.get_mime_types()
|
||||
if mime_types is not None:
|
||||
installed_icons_dir = os.path.join(xdg_data_home,
|
||||
'icons/sugar/scalable/mimetypes')
|
||||
'icons/sugar/scalable/mimetypes')
|
||||
if not os.path.isdir(installed_icons_dir):
|
||||
os.makedirs(installed_icons_dir)
|
||||
|
||||
@@ -390,7 +391,7 @@ class ActivityBundle(Bundle):
|
||||
mime_types = self.get_mime_types()
|
||||
if mime_types is not None:
|
||||
installed_icons_dir = os.path.join(xdg_data_home,
|
||||
'icons/sugar/scalable/mimetypes')
|
||||
'icons/sugar/scalable/mimetypes')
|
||||
if os.path.isdir(installed_icons_dir):
|
||||
for f in os.listdir(installed_icons_dir):
|
||||
path = os.path.join(installed_icons_dir, f)
|
||||
|
||||
@@ -26,24 +26,31 @@ import shutil
|
||||
import StringIO
|
||||
import zipfile
|
||||
|
||||
|
||||
class AlreadyInstalledException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class NotInstalledException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidPathException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ZipExtractException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class RegistrationException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class MalformedBundleException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Bundle(object):
|
||||
"""A Sugar activity, content module, etc.
|
||||
|
||||
@@ -71,7 +78,7 @@ class Bundle(object):
|
||||
# manifest = self._get_file(self._infodir + '/contents')
|
||||
# if manifest is None:
|
||||
# raise MalformedBundleException('No manifest file')
|
||||
#
|
||||
|
||||
# signature = self._get_file(self._infodir + '/contents.sig')
|
||||
# if signature is None:
|
||||
# raise MalformedBundleException('No signature file')
|
||||
@@ -112,7 +119,7 @@ class Bundle(object):
|
||||
if self._zip_file is None:
|
||||
path = os.path.join(self._path, filename)
|
||||
try:
|
||||
f = open(path,"rb")
|
||||
f = open(path, "rb")
|
||||
except IOError:
|
||||
return None
|
||||
else:
|
||||
|
||||
@@ -29,6 +29,7 @@ from sugar import env
|
||||
from sugar.bundle.bundle import Bundle, NotInstalledException, \
|
||||
MalformedBundleException
|
||||
|
||||
|
||||
class ContentBundle(Bundle):
|
||||
"""A Sugar content bundle
|
||||
|
||||
@@ -78,8 +79,8 @@ class ContentBundle(Bundle):
|
||||
try:
|
||||
if int(version) != 1:
|
||||
raise MalformedBundleException(
|
||||
'Content bundle %s has unknown host_version number %s' %
|
||||
(self._path, version))
|
||||
'Content bundle %s has unknown host_version '
|
||||
'number %s' % (self._path, version))
|
||||
except ValueError:
|
||||
raise MalformedBundleException(
|
||||
'Content bundle %s has invalid host_version number %s' %
|
||||
@@ -209,17 +210,17 @@ class ContentBundle(Bundle):
|
||||
def get_start_uri(self):
|
||||
return "file://" + urllib.pathname2url(self.get_start_path())
|
||||
|
||||
# TODO treat ContentBundle in special way
|
||||
# needs rethinking while fixing ContentBundle support
|
||||
def get_bundle_id(self):
|
||||
# TODO treat ContentBundle in special way
|
||||
# needs rethinking while fixing ContentBundle support
|
||||
if self._bundle_class is not None:
|
||||
return self._bundle_class
|
||||
else:
|
||||
return self._global_name
|
||||
|
||||
# TODO treat ContentBundle in special way
|
||||
# needs rethinking while fixing ContentBundle support
|
||||
def get_activity_version(self):
|
||||
# TODO treat ContentBundle in special way
|
||||
# needs rethinking while fixing ContentBundle support
|
||||
return self._library_version
|
||||
|
||||
def is_installed(self):
|
||||
|
||||
Reference in New Issue
Block a user