diff options
| author | jmdejong <jmdejong@users.noreply.github.com> | 2018-01-11 22:44:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-11 22:44:20 +0100 |
| commit | e15a7ee87517e47613473f0a3fcb7fc68f112849 (patch) | |
| tree | 1bb12831bf6d65a895004fcc229e9b7954048892 | |
| parent | e0164e21209cec0ec24e9d25eee90711bca78947 (diff) | |
| parent | 7ba1804af2ec34094171127d6eada72a1d1e199f (diff) | |
Merge pull request #1 from rakiru/code-review
Code review
| -rw-r--r-- | asciifarm/client/connection.py | 5 | ||||
| -rw-r--r-- | asciifarm/client/display/fieldpad.py | 6 | ||||
| -rwxr-xr-x | asciifarm/client/main.py | 2 | ||||
| -rw-r--r-- | asciifarm/common/utils.py | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/asciifarm/client/connection.py b/asciifarm/client/connection.py index 4eb0ffe..20f4964 100644 --- a/asciifarm/client/connection.py +++ b/asciifarm/client/connection.py @@ -10,6 +10,8 @@ class Connection: sockType = socket.AF_UNIX elif socketType == "inet": sockType = socket.AF_INET + else: + raise ValueError("Invalid socket type: %r" % (socketType,)) self.sock = socket.socket(sockType, socket.SOCK_STREAM) def connect(self, address): @@ -21,7 +23,8 @@ class Connection: data = receive(self.sock) except Exception as err: onError(err) - callback(data) + else: + callback(data) def send(self, message): send(self.sock, bytes(message, 'utf-8')) diff --git a/asciifarm/client/display/fieldpad.py b/asciifarm/client/display/fieldpad.py index 6619c1f..f64634e 100644 --- a/asciifarm/client/display/fieldpad.py +++ b/asciifarm/client/display/fieldpad.py @@ -29,14 +29,14 @@ class FieldPad: def changeCell(self, x, y, sprites): """ sprites must always have at least one element """ char, colour, bgcolour = sprites[0] - if bgcolour == None: + if bgcolour is None: for (ch, co, bg) in sprites: - if bg != None: + if bg is not None: bgcolour = bg break else: bgcolour = 0 - if colour != None and self.colours: + if colour is not None and self.colours: self.pad.addstr(y, x*self.charSize, char, self.colours.get(colour, bgcolour)) else: self.pad.addstr(y, x*self.charSize, char) diff --git a/asciifarm/client/main.py b/asciifarm/client/main.py index de77d09..48e89ad 100755 --- a/asciifarm/client/main.py +++ b/asciifarm/client/main.py @@ -57,7 +57,7 @@ def main(argv=None): keybindings = kf.read() address = args.address - if address == None: + if address is None: address = defaultAdresses[args.socket] if args.socket == "abstract": address = '\0' + address diff --git a/asciifarm/common/utils.py b/asciifarm/common/utils.py index cdc8dd5..95ac32b 100644 --- a/asciifarm/common/utils.py +++ b/asciifarm/common/utils.py @@ -27,7 +27,7 @@ def concat(arr): def writeFileSafe(filename, data, tempname=None): - if tempname == None: + if tempname is None: tempname = filename + ".tempfile" with open(tempname, 'w') as f: f.write(data) |
