Skip to content

Commit c80e833

Browse files
authored
Merge pull request #21 from wolfy1339/lint-patch
Fix some linter errors (Pylint, Pyflakes)
2 parents 2d35f89 + 7b030f6 commit c80e833

8 files changed

Lines changed: 24 additions & 21 deletions

File tree

zirc/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
from .event import Event
33
from .flood import floodProtect
44
from .loop import EventLoop
5-
from .errors import *
5+
from .errors import NoSocket, NoConfig
66
from . import util
77
from .wrappers import connection_wrapper
88

9-
from base64 import b64encode
10-
import sys,time
11-
129
class Client(object):
1310
listeners = []
1411
def connect(self, config_class = None):

zirc/connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def __init__(self, wrapper=same, family=socket.AF_INET, socket_class=None, bind_
1919
self.wrapper = wrapper
2020
def connect(self, socket_address):
2121
self.sock = self.wrapper(self.sock)
22-
self.bind_address and sock.bind(self.bind_address)
22+
if self.bind_address:
23+
self.sock.bind(self.bind_address)
2324
self.sock.connect(socket_address)
2425

2526
return self.sock
26-
__call__ = connect
27+
__call__ = connect

zirc/ext/fifo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
def fifo_while(send_function, name):
44
if not os.path.exists(name):
55
os.mkfifo(name)
6-
with open(name, "r") as file:
6+
with open(name, "r") as f:
77
while True:
8-
line = file.readline()[:-1]
8+
line = f.readline()[:-1]
99
if len(line) > 0:
1010
send_function(line)
1111

1212
def Fifo(send_function, name="fifo"):
1313
thread = threading.Thread(target=fifo_while, args=(send_function, name))
1414
thread.daemon = True
15-
thread.start()
15+
thread.start()

zirc/ext/proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import socks,socket
1+
import socks, socket
22
SOCKS5 = socks.SOCKS5
33
SOCKS4 = socks.SOCKS4
44
HTTP = socks.HTTP
@@ -13,4 +13,4 @@ def __repr__(self):
1313
def __call__(self, family=socket.AF_INET, type=socket.SOCK_STREAM):
1414
socks.socksocket.__init__(self, family, type)
1515
self.set_proxy(self.protocol, self.host, self.port)
16-
return self
16+
return self

zirc/flood.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def queue_thread(self):
1313
connection = self.irc_queue[0][0]
1414
raw = self.irc_queue[0][1]
1515
self.irc_queue.pop(0)
16-
except:
16+
except Exception:
1717
self.irc_queue_running = False
1818
break
1919
connection.send(raw)
@@ -33,4 +33,4 @@ def queue_add_first(self, connection, raw):
3333
self.irc_queue_running = True
3434
self.queuet = Thread(target=self.queue_thread)
3535
self.queuet.daemon = True
36-
self.queuet.start()
36+
self.queuet.start()

zirc/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def start(self, log):
2020
print("Attempting to run on_all...")
2121
util.function_argument_call(self.on_all, args)()
2222

23-
text_type_func_name = "on_"+event.text_type.lower()
23+
text_type_func_name = "on_" + event.text_type.lower()
2424
if hasattr(self, text_type_func_name):
2525
print("Attempting to run {0}".format(text_type_func_name))
2626
util.function_argument_call(getattr(self, text_type_func_name), args)()
2727

28-
raw_type_func_name = "on_"+event.type.lower()
28+
raw_type_func_name = "on_" + event.type.lower()
2929
if raw_type_func_name != text_type_func_name:
3030
if hasattr(self, raw_type_func_name):
3131
print("Attempting to run {0}".format(raw_type_func_name))

zirc/util/bucket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from time import time
2+
13
class TokenBucket(object):
24
"""An implementation of the token bucket algorithm.
35
@@ -36,4 +38,4 @@ def get_tokens(self):
3638
self._tokens = min(self.capacity, self._tokens + delta)
3739
self.timestamp = now
3840
return self._tokens
39-
tokens = property(get_tokens)
41+
tokens = property(get_tokens)

zirc/wrappers.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from time import time
2+
13
class connection_wrapper(object):
24
def __init__(self, irc):
35
self.send = irc.send
46
self.reply = irc.reply
57
self.msg = irc.privmsg
68
self.privmsg = irc.privmsg
9+
710
def ping(self):
811
self.send("PING :{}".format(str(int(time()))).encode('utf-8'))
912

@@ -20,10 +23,10 @@ def invite(self, chan, user):
2023
self.send("INVITE {0} {1}".format(user, chan))
2124

2225
def action(self, channel, message):
23-
self.sendmsg(channel,"\x01ACTION {0}\x01".format(message))
26+
self.sendmsg(channel, "\x01ACTION {0}\x01".format(message))
2427

25-
def kick(self,channel, user, message):
26-
user = user.replace(" ","").replace(":","")
28+
def kick(self, channel, user, message):
29+
user = user.replace(" ", "").replace(":", "")
2730
self.send("KICK {0} {1} :{2}".format(channel, user, message))
2831

2932
def op(self, channel, nick):
@@ -52,12 +55,12 @@ def voice(self, channel, nick):
5255

5356
def mode(self, channel, nick, mode):
5457
self.send("MODE {0} {1} {2}".format(channel, mode, nick))
55-
58+
5659
def notice(self, user, message):
5760
self.send("NOTICE {0} :{1}".format(user, message))
5861

5962
def quit(self, message=""):
6063
self.send("QUIT : {0}".format(message))
61-
64+
6265
def ctcp(self, user, message):
6366
self.send("PRIVMSG {0} :\x01{1}\x01\x01".format(user, message))

0 commit comments

Comments
 (0)