pep8'd sugar3

This commit is contained in:
William Orr 2013-05-17 22:33:36 -04:00 committed by Daniel Narvaez
parent 1252d95671
commit c736ffefcd
8 changed files with 30 additions and 27 deletions

View File

@ -18,6 +18,7 @@ SUBDIRS = bin src po
check: test
pyflakes $(top_srcdir)
pep8 $(top_srcdir)
test:
mkdir -p $(TESTS_TMPDIR)

View File

@ -39,7 +39,7 @@ def get_profile_path(path=None):
except OSError:
print 'Could not create user directory.'
if path != None:
if path is not None:
return os.path.join(base, path)
else:
return base
@ -47,7 +47,7 @@ def get_profile_path(path=None):
def get_logs_path(path=None):
base = os.environ.get('SUGAR_LOGS_DIR', get_profile_path('logs'))
if path != None:
if path is not None:
return os.path.join(base, path)
else:
return base
@ -57,5 +57,6 @@ def get_user_activities_path():
return os.environ.get("SUGAR_ACTIVITIES_PATH",
os.path.expanduser('~/Activities'))
def get_user_library_path():
return os.path.expanduser('~/Library')

View File

@ -72,7 +72,7 @@ def _except_hook(exctype, value, traceback):
try:
from IPython.ultraTB import AutoFormattedTB
sys.excepthook = AutoFormattedTB(mode='Verbose',
color_scheme='NoColor')
color_scheme='NoColor')
except ImportError:
sys.excepthook = sys.__excepthook__
@ -147,9 +147,10 @@ def start(log_filename=None):
if e.errno != errno.ENOSPC:
raise e
logging.basicConfig(level=logging.WARNING,
format="%(created)f %(levelname)s %(name)s: %(message)s",
stream=SafeLogWrapper(sys.stderr))
logging.basicConfig(
level=logging.WARNING,
format="%(created)f %(levelname)s %(name)s: %(message)s",
stream=SafeLogWrapper(sys.stderr))
if 'SUGAR_LOGGER_LEVEL' in os.environ:
set_level(os.environ['SUGAR_LOGGER_LEVEL'])
@ -177,7 +178,7 @@ class TraceRepr(repr_.Repr):
# better handling of subclasses of basic types, e.g. for DBus
_TYPES = [int, long, bool, tuple, list, array.array, set, frozenset,
collections.deque, dict, str]
collections.deque, dict, str]
def repr1(self, x, level):
for t in self._TYPES:
@ -194,7 +195,7 @@ class TraceRepr(repr_.Repr):
def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
maxsize_list=30, maxsize_dict=30, maxsize_string=300):
maxsize_list=30, maxsize_dict=30, maxsize_string=300):
if skip_args is None:
skip_args = []
@ -218,12 +219,12 @@ def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
params_formatted = ", ".join(
[trace_repr.repr(a)
for (idx, a) in enumerate(args) if idx not in skip_args] + \
for (idx, a) in enumerate(args) if idx not in skip_args] +
['%s=%s' % (k, trace_repr.repr(v))
for (k, v) in kwargs.items() if k not in skip_kwargs])
trace_logger.log(TRACE, "%s(%s) invoked", f.__name__,
params_formatted)
params_formatted)
try:
res = f(*args, **kwargs)
@ -232,7 +233,7 @@ def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
raise
trace_logger.log(TRACE, "%s(%s) returned %s", f.__name__,
params_formatted, trace_repr.repr(res))
params_formatted, trace_repr.repr(res))
return res

View File

@ -50,15 +50,15 @@ def _get_supported_image_mime_types():
_extensions = {}
_globs_timestamps = []
_generic_types = [
{
'id': GENERIC_TYPE_TEXT,
'name': _('Text'),
'icon': 'text-x-generic',
'types': [
{
'id': GENERIC_TYPE_TEXT,
'name': _('Text'),
'icon': 'text-x-generic',
'types': [
'text/plain', 'text/rtf', 'application/pdf', 'application/x-pdf',
'text/html', 'application/vnd.oasis.opendocument.text',
'application/rtf', 'text/rtf', 'application/epub+zip'],
},
},
{
'id': GENERIC_TYPE_IMAGE,
'name': _('Image'),

View File

@ -94,7 +94,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self._file = None
self._srcid = 0
SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(
self, request, client_address, server)
self, request, client_address, server)
def log_request(self, code='-', size='-'):
pass
@ -188,11 +188,11 @@ class GlibURLDownloader(GObject.GObject):
__gsignals__ = {
'finished': (GObject.SignalFlags.RUN_FIRST, None,
([GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT])),
([GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT])),
'error': (GObject.SignalFlags.RUN_FIRST, None,
([GObject.TYPE_PYOBJECT])),
([GObject.TYPE_PYOBJECT])),
'progress': (GObject.SignalFlags.RUN_FIRST, None,
([GObject.TYPE_PYOBJECT])),
([GObject.TYPE_PYOBJECT])),
}
CHUNK_SIZE = 4096

View File

@ -73,9 +73,9 @@ class Profile(object):
color = client.get_string('/desktop/sugar/user/color')
return nick is not '' and \
color is not '' and \
self.pubkey is not None and \
self.privkey_hash is not None
color is not '' and \
self.pubkey is not None and \
self.privkey_hash is not None
def _load_pubkey(self):
key_path = os.path.join(env.get_profile_path(), 'owner.key.pub')

View File

@ -184,14 +184,14 @@ class LRU:
def __iter__(self):
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.me[1]
cur = cur2
def iteritems(self):
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.me
cur = cur2