Permalink
Browse files

e3: Fix some pylint warnings and make some other modifications that m…

…ake the code more PEP8 compatible
  • Loading branch information...
1 parent bca6a11 commit c25b0143db3e4074e8abff1aa521f8703a41ccb0 The98 committed with c10ud Aug 11, 2011
@@ -209,5 +209,3 @@ def get_online_total_count(self, contacts):
if contact.status != status.OFFLINE])
return (online, total)
-
-
View
@@ -290,9 +290,9 @@ class Logger(object):
WHERE f.id_event=? and
((f.id_src_acc=? and id_dest_acc=?) or
(f.id_dest_acc=? and id_src_acc=?) or
- (f.id_src_acc<>? and f.cid in
- ( SELECT f.cid FROM fact_event f
- WHERE f.id_event=? and ((f.id_src_acc=? and id_dest_acc=?)
+ (f.id_src_acc<>? and f.cid in
+ ( SELECT f.cid FROM fact_event f
+ WHERE f.id_event=? and ((f.id_src_acc=? and id_dest_acc=?)
or (f.id_dest_acc=? and id_src_acc=?)) )
)) and
f.id_src_info = i.id_info and
@@ -563,7 +563,7 @@ def _stat(self):
self._count = 0
self._count += 1
-
+
def _fetch_sorted(self):
'''puts list from the query in the right order'''
query_list = self.cursor.fetchall()
@@ -578,7 +578,7 @@ def execute(self, query, args=()):
# utility methods
def add_event(self, event, status, payload, src, dest=None, ext_time=None,
- id_time=None, cid = 0):
+ id_time=None, cid=0):
'''add an event on the fact and the dimensiones using the actual time'''
id_event = self.insert_event(event)
@@ -594,8 +594,10 @@ def add_event(self, event, status, payload, src, dest=None, ext_time=None,
if id_time is None:
if ext_time:
- (year, month, day, hour, minute, seconds, wday, yday, tm_isdst) = time.gmtime(ext_time)
- id_time = self.insert_time(year, month, day, wday, hour, minute, seconds)
+ (year, month, day, hour, minute, seconds, wday, yday,
+ tm_isdst) = time.gmtime(ext_time)
+ id_time = self.insert_time(year, month, day, wday,
+ hour, minute, seconds)
else:
id_time = self.insert_time_now()
@@ -694,8 +696,10 @@ def get_chats_between(self, src, dest, from_t, to_t, limit):
id_src = self.accounts[src].id_account
id_dest = self.accounts[dest].id_account
- self.execute(Logger.SELECT_CHATS_BETWEEN, (id_event, id_src, id_dest, id_src,
- id_dest, id_dest, id_event, id_src, id_dest, id_src, id_dest, from_t, to_t, limit))
+ self.execute(Logger.SELECT_CHATS_BETWEEN,
+ (id_event, id_src, id_dest, id_src, id_dest, id_dest,
+ id_event, id_src, id_dest, id_src, id_dest,
+ from_t, to_t, limit))
return self._fetch_sorted()
@@ -769,12 +773,14 @@ def add_contact_by_group(self, accounts, groups):
local_group = self.groups[gid]
if gid not in local_account.groups:
- self.insert_account_by_group(local_account.id_account, local_group.id)
+ self.insert_account_by_group(local_account.id_account,
+ local_group.id)
for gid in removed:
local_group = self.groups[gid]
local_account.groups.remove(gid)
- self.delete_account_by_group(local_account.id_account, local_group.id)
+ self.delete_account_by_group(local_account.id_account,
+ local_group.id)
class LoggerProcess(threading.Thread):
'''a process that exposes a thread safe api to log events of a session'''
@@ -832,7 +838,8 @@ def _process(self, data):
event, status, payload, src, dest, new_time, cid = args
except:
event, status, payload, src, dest, new_time = args
- self.logger.add_event(event, status, payload, src, dest, new_time, cid = cid)
+ self.logger.add_event(event, status, payload, src, dest, new_time,
+ cid=cid)
elif action == 'logs':
id_time = None
@@ -884,9 +891,11 @@ def check(self, sync=False):
return True
- def log(self, event, status, payload, src, dest = None, new_time = None, cid = None):
+ def log(self, event, status, payload, src, dest=None, new_time=None,
+ cid=None):
'''add an event to the log database'''
- self.input.put(('log', (event, status, payload, src, dest, new_time, cid)))
+ self.input.put(('log', (event, status, payload, src, dest, new_time,
+ cid)))
def logs(self, logs):
'''add a group of events to the log database with the same time_od'''
@@ -935,7 +944,8 @@ def get_chats_between(self, src, dest, from_t, to_t, limit, callback):
'''return the last # sent from src to dest or from dest to src ,
between two timestamps from_t and to_t, where # is the limit value
'''
- self.input.put(('get_chats_between', (src, dest, from_t, to_t, limit, callback)))
+ self.input.put(('get_chats_between', (src, dest, from_t, to_t, limit,
+ callback)))
def add_groups(self, groups):
'''add all groups to the database'''
@@ -960,15 +970,15 @@ def save_logs_as_txt(results, handle):
date_text = time.strftime('[%c]', time.gmtime(timestamp))
handle.write("%s %s: %s\n" % (date_text, nick, message))
-def log_message(session, members, message, sent, error=False, cid = None):
+def log_message(session, members, message, sent, error=False, cid=None):
'''log a message, session is an e3.Session object, members is a list of
members only used if sent is True, sent is True if we sent the message,
False if we received the message. error is True if the message send
failed'''
if not session.config.get_or_set('b_log_enabled', True):
return
-
+
if message.type == e3.Message.TYPE_TYPING:
return
@@ -1027,5 +1037,4 @@ def log_message(session, members, message, sent, error=False, cid = None):
if message.type == e3.Message.TYPE_NUDGE:
message.body = _("%s just sent you a nudge!" % display_name)
- session.log(event, status, message.body, src, dest, cid = cid)
-
+ session.log(event, status, message.body, src, dest, cid=cid)
@@ -18,9 +18,11 @@
class Message(object):
'''a class that represent a msn message'''
- (TYPE_MESSAGE, TYPE_TYPING, TYPE_NUDGE, TYPE_P2P, TYPE_UNK, TYPE_FLNMSG) = range(6)
+ (TYPE_MESSAGE, TYPE_TYPING, TYPE_NUDGE, TYPE_P2P, TYPE_UNK,
+ TYPE_FLNMSG) = range(6)
- def __init__(self, type_, body, account, style=None, timestamp=None, display_name=None):
+ def __init__(self, type_, body, account, style=None, timestamp=None,
+ display_name=None):
self.type = type_
self.body = body
self.account = account
@@ -165,4 +167,3 @@ def from_hex(cls, hex_str):
blue = int(hex_str[4:6], 16)
return Color(red, green, blue)
-
View
@@ -21,8 +21,8 @@ class Proxy(object):
This class represents the information of a proxy
"""
- def __init__(self, use_proxy=False, host='', port='', use_auth=False,
- user='', passwd=''):
+ def __init__(self, use_proxy=False, host='', port='', use_auth=False,
+ user='', passwd=''):
"""
Constructor.
use_proxy -- boolean that indicates if the proxy should be used
@@ -77,9 +77,10 @@ def _set_account(self, account):
self.logger.start()
self.config.get_or_set('b_log_enabled', True)
- def log(self, event, status, payload, src, dest = None, new_time = None, cid = None):
+ def log(self, event, status, payload, src, dest=None, new_time=None,
+ cid=None):
if self.config.get_or_set('b_log_enabled', True):
- self.logger.log(event,status,payload,src,dest,new_time,cid)
+ self.logger.log(event, status, payload, src, dest, new_time, cid)
def logs(self, logs):
if self.config.get_or_set('b_log_enabled', True):
@@ -262,4 +263,3 @@ def make_cb(event):
raise Exception("function collision %s fixme right now" % fname)
setattr(Session, fname, make_cb(event))
-
@@ -23,7 +23,8 @@ class FileTransfer(object):
'''a class that represent a file transfer'''
(WAITING, TRANSFERRING, RECEIVED, FAILED, CANCELED) = range(5)
- def __init__(self, obj, filename, contact, size, preview, sender='Me', completepath=''):
+ def __init__(self, obj, filename, contact, size, preview,
+ sender='Me', completepath=''):
self.filename = filename
self.completepath = completepath
self.size = size
@@ -62,7 +63,8 @@ def get_eta(self):
return 0
if self.received_data:
- return ((self.size - self.received_data) / (self.get_speed() or 0.1))
+ return ((self.size - self.received_data) /
+ (self.get_speed() or 0.1))
return 0
def get_speed(self):
View
@@ -102,7 +102,7 @@ class Worker(threading.Thread):
def __init__(self, app_name, session):
'''class constructor'''
threading.Thread.__init__(self)
- self._continue=True
+ self._continue = True
self.setDaemon(True)
self.app_name = app_name
@@ -367,7 +367,7 @@ def _handle_action_p2p_cancel(self, pid):
# ft handlers
def _handle_action_ft_invite(self, t):
pass
-
+
def _handle_action_ft_accept(self, t):
pass
@@ -378,9 +378,10 @@ def _handle_action_ft_cancel(self, t):
pass
# call handlers
- def _handle_action_call_invite(self, cid, account, a_v_both, surface_other, surface_self):
+ def _handle_action_call_invite(self, cid, account, a_v_both, surface_other,
+ surface_self):
pass
-
+
def _handle_action_call_accept(self, c):
pass
@@ -389,4 +390,3 @@ def _handle_action_call_reject(self, c):
def _handle_action_call_cancel(self, c):
pass
-
View
@@ -63,7 +63,7 @@
'setuptools-0.6c11-py2.7.egg': 'fe1f997bc722265116870bc7919059ea',
}
-import sys, os
+import os
try: from hashlib import md5
except ImportError: from md5 import md5
@@ -101,7 +101,7 @@ def do_download():
try:
import pkg_resources
except ImportError:
- return do_download()
+ return do_download()
try:
pkg_resources.require("setuptools>="+version); return
except pkg_resources.VersionConflict, e:
@@ -166,41 +166,6 @@ def download_setuptools(
if dst: dst.close()
return os.path.realpath(saveto)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
def main(argv, version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
try:
@@ -209,15 +174,15 @@ def main(argv, version=DEFAULT_VERSION):
egg = None
try:
egg = download_setuptools(version, delay=0)
- sys.path.insert(0,egg)
+ sys.path.insert(0, egg)
from setuptools.command.easy_install import main
return main(list(argv)+[egg]) # we're done here
finally:
if egg and os.path.exists(egg):
os.unlink(egg)
else:
if setuptools.__version__ == '0.0.1':
- print >>sys.stderr, (
+ print >> sys.stderr, (
"You have an obsolete version of setuptools installed. Please\n"
"remove it from your system entirely before rerunning this script."
)
@@ -239,7 +204,7 @@ def main(argv, version=DEFAULT_VERSION):
from setuptools.command.easy_install import main
main(argv)
else:
- print "Setuptools version",version,"or greater has been installed."
+ print "Setuptools version", version, "or greater has been installed."
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
def update_md5(filenames):
@@ -272,13 +237,8 @@ def update_md5(filenames):
f.close()
-if __name__=='__main__':
- if len(sys.argv)>2 and sys.argv[1]=='--md5update':
+if __name__ == '__main__':
+ if len(sys.argv) > 2 and sys.argv[1] == '--md5update':
update_md5(sys.argv[2:])
else:
main(sys.argv[1:])
-
-
-
-
-

0 comments on commit c25b014

Please sign in to comment.