pep8'd sugar3
This commit is contained in:
parent
1252d95671
commit
c736ffefcd
@ -18,6 +18,7 @@ SUBDIRS = bin src po
|
|||||||
|
|
||||||
check: test
|
check: test
|
||||||
pyflakes $(top_srcdir)
|
pyflakes $(top_srcdir)
|
||||||
|
pep8 $(top_srcdir)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
mkdir -p $(TESTS_TMPDIR)
|
mkdir -p $(TESTS_TMPDIR)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Multi-consumer multi-producer dispatching mechanism
|
"""Multi-consumer multi-producer dispatching mechanism
|
||||||
|
|
||||||
Originally based on pydispatch (BSD)
|
Originally based on pydispatch (BSD)
|
||||||
http://pypi.python.org/pypi/PyDispatcher/2.0.1
|
http://pypi.python.org/pypi/PyDispatcher/2.0.1
|
||||||
See license.txt for original license.
|
See license.txt for original license.
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ def get_profile_path(path=None):
|
|||||||
except OSError:
|
except OSError:
|
||||||
print 'Could not create user directory.'
|
print 'Could not create user directory.'
|
||||||
|
|
||||||
if path != None:
|
if path is not None:
|
||||||
return os.path.join(base, path)
|
return os.path.join(base, path)
|
||||||
else:
|
else:
|
||||||
return base
|
return base
|
||||||
@ -47,7 +47,7 @@ def get_profile_path(path=None):
|
|||||||
|
|
||||||
def get_logs_path(path=None):
|
def get_logs_path(path=None):
|
||||||
base = os.environ.get('SUGAR_LOGS_DIR', get_profile_path('logs'))
|
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)
|
return os.path.join(base, path)
|
||||||
else:
|
else:
|
||||||
return base
|
return base
|
||||||
@ -57,5 +57,6 @@ def get_user_activities_path():
|
|||||||
return os.environ.get("SUGAR_ACTIVITIES_PATH",
|
return os.environ.get("SUGAR_ACTIVITIES_PATH",
|
||||||
os.path.expanduser('~/Activities'))
|
os.path.expanduser('~/Activities'))
|
||||||
|
|
||||||
|
|
||||||
def get_user_library_path():
|
def get_user_library_path():
|
||||||
return os.path.expanduser('~/Library')
|
return os.path.expanduser('~/Library')
|
||||||
|
@ -72,7 +72,7 @@ def _except_hook(exctype, value, traceback):
|
|||||||
try:
|
try:
|
||||||
from IPython.ultraTB import AutoFormattedTB
|
from IPython.ultraTB import AutoFormattedTB
|
||||||
sys.excepthook = AutoFormattedTB(mode='Verbose',
|
sys.excepthook = AutoFormattedTB(mode='Verbose',
|
||||||
color_scheme='NoColor')
|
color_scheme='NoColor')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.excepthook = sys.__excepthook__
|
sys.excepthook = sys.__excepthook__
|
||||||
|
|
||||||
@ -147,9 +147,10 @@ def start(log_filename=None):
|
|||||||
if e.errno != errno.ENOSPC:
|
if e.errno != errno.ENOSPC:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING,
|
logging.basicConfig(
|
||||||
format="%(created)f %(levelname)s %(name)s: %(message)s",
|
level=logging.WARNING,
|
||||||
stream=SafeLogWrapper(sys.stderr))
|
format="%(created)f %(levelname)s %(name)s: %(message)s",
|
||||||
|
stream=SafeLogWrapper(sys.stderr))
|
||||||
|
|
||||||
if 'SUGAR_LOGGER_LEVEL' in os.environ:
|
if 'SUGAR_LOGGER_LEVEL' in os.environ:
|
||||||
set_level(os.environ['SUGAR_LOGGER_LEVEL'])
|
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
|
# better handling of subclasses of basic types, e.g. for DBus
|
||||||
_TYPES = [int, long, bool, tuple, list, array.array, set, frozenset,
|
_TYPES = [int, long, bool, tuple, list, array.array, set, frozenset,
|
||||||
collections.deque, dict, str]
|
collections.deque, dict, str]
|
||||||
|
|
||||||
def repr1(self, x, level):
|
def repr1(self, x, level):
|
||||||
for t in self._TYPES:
|
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,
|
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:
|
if skip_args is None:
|
||||||
skip_args = []
|
skip_args = []
|
||||||
@ -218,12 +219,12 @@ def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
|
|||||||
|
|
||||||
params_formatted = ", ".join(
|
params_formatted = ", ".join(
|
||||||
[trace_repr.repr(a)
|
[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))
|
['%s=%s' % (k, trace_repr.repr(v))
|
||||||
for (k, v) in kwargs.items() if k not in skip_kwargs])
|
for (k, v) in kwargs.items() if k not in skip_kwargs])
|
||||||
|
|
||||||
trace_logger.log(TRACE, "%s(%s) invoked", f.__name__,
|
trace_logger.log(TRACE, "%s(%s) invoked", f.__name__,
|
||||||
params_formatted)
|
params_formatted)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = f(*args, **kwargs)
|
res = f(*args, **kwargs)
|
||||||
@ -232,7 +233,7 @@ def trace(logger=None, logger_name=None, skip_args=None, skip_kwargs=None,
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
trace_logger.log(TRACE, "%s(%s) returned %s", f.__name__,
|
trace_logger.log(TRACE, "%s(%s) returned %s", f.__name__,
|
||||||
params_formatted, trace_repr.repr(res))
|
params_formatted, trace_repr.repr(res))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ def _get_supported_image_mime_types():
|
|||||||
_extensions = {}
|
_extensions = {}
|
||||||
_globs_timestamps = []
|
_globs_timestamps = []
|
||||||
_generic_types = [
|
_generic_types = [
|
||||||
{
|
{
|
||||||
'id': GENERIC_TYPE_TEXT,
|
'id': GENERIC_TYPE_TEXT,
|
||||||
'name': _('Text'),
|
'name': _('Text'),
|
||||||
'icon': 'text-x-generic',
|
'icon': 'text-x-generic',
|
||||||
'types': [
|
'types': [
|
||||||
'text/plain', 'text/rtf', 'application/pdf', 'application/x-pdf',
|
'text/plain', 'text/rtf', 'application/pdf', 'application/x-pdf',
|
||||||
'text/html', 'application/vnd.oasis.opendocument.text',
|
'text/html', 'application/vnd.oasis.opendocument.text',
|
||||||
'application/rtf', 'text/rtf', 'application/epub+zip'],
|
'application/rtf', 'text/rtf', 'application/epub+zip'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': GENERIC_TYPE_IMAGE,
|
'id': GENERIC_TYPE_IMAGE,
|
||||||
'name': _('Image'),
|
'name': _('Image'),
|
||||||
|
@ -94,7 +94,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||||||
self._file = None
|
self._file = None
|
||||||
self._srcid = 0
|
self._srcid = 0
|
||||||
SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(
|
SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(
|
||||||
self, request, client_address, server)
|
self, request, client_address, server)
|
||||||
|
|
||||||
def log_request(self, code='-', size='-'):
|
def log_request(self, code='-', size='-'):
|
||||||
pass
|
pass
|
||||||
@ -188,11 +188,11 @@ class GlibURLDownloader(GObject.GObject):
|
|||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'finished': (GObject.SignalFlags.RUN_FIRST, None,
|
'finished': (GObject.SignalFlags.RUN_FIRST, None,
|
||||||
([GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT])),
|
([GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT])),
|
||||||
'error': (GObject.SignalFlags.RUN_FIRST, None,
|
'error': (GObject.SignalFlags.RUN_FIRST, None,
|
||||||
([GObject.TYPE_PYOBJECT])),
|
([GObject.TYPE_PYOBJECT])),
|
||||||
'progress': (GObject.SignalFlags.RUN_FIRST, None,
|
'progress': (GObject.SignalFlags.RUN_FIRST, None,
|
||||||
([GObject.TYPE_PYOBJECT])),
|
([GObject.TYPE_PYOBJECT])),
|
||||||
}
|
}
|
||||||
|
|
||||||
CHUNK_SIZE = 4096
|
CHUNK_SIZE = 4096
|
||||||
|
@ -73,9 +73,9 @@ class Profile(object):
|
|||||||
color = client.get_string('/desktop/sugar/user/color')
|
color = client.get_string('/desktop/sugar/user/color')
|
||||||
|
|
||||||
return nick is not '' and \
|
return nick is not '' and \
|
||||||
color is not '' and \
|
color is not '' and \
|
||||||
self.pubkey is not None and \
|
self.pubkey is not None and \
|
||||||
self.privkey_hash is not None
|
self.privkey_hash is not None
|
||||||
|
|
||||||
def _load_pubkey(self):
|
def _load_pubkey(self):
|
||||||
key_path = os.path.join(env.get_profile_path(), 'owner.key.pub')
|
key_path = os.path.join(env.get_profile_path(), 'owner.key.pub')
|
||||||
|
@ -184,14 +184,14 @@ class LRU:
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
cur = self.first
|
cur = self.first
|
||||||
while cur != None:
|
while cur is not None:
|
||||||
cur2 = cur.next
|
cur2 = cur.next
|
||||||
yield cur.me[1]
|
yield cur.me[1]
|
||||||
cur = cur2
|
cur = cur2
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
cur = self.first
|
cur = self.first
|
||||||
while cur != None:
|
while cur is not None:
|
||||||
cur2 = cur.next
|
cur2 = cur.next
|
||||||
yield cur.me
|
yield cur.me
|
||||||
cur = cur2
|
cur = cur2
|
||||||
|
Loading…
Reference in New Issue
Block a user