From 82808d03dd2badc126afd379373c9b95a65a00c8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 6 Feb 2020 21:46:51 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Travis=20CI:=20Don=E2=80=99t=20allow=20bare?= =?UTF-8?q?=20exceptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 80ea1302990d..bd2dfbbe4496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ before_install: pip install --upgrade pip setuptools install: pip install -r requirements.txt before_script: - black --check . || true - - flake8 . --count --select=E101,E9,F4,F63,F7,F82,W191 --show-source --statistics + - flake8 . --count --select=E101,E722,E9,F4,F63,F7,F82,W191 --show-source --statistics - flake8 . --count --exit-zero --max-line-length=127 --statistics script: - scripts/validate_filenames.py # no uppercase, no spaces, in a directory From 0dbbf3dafd7de9d54ce29627dc382daf748f3b3c Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 6 Feb 2020 19:47:26 +0000 Subject: [PATCH 2/7] fixup! Format Python code with psf/black push --- ciphers/transposition_cipher.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ciphers/transposition_cipher.py b/ciphers/transposition_cipher.py index 3b69d6b99f67..4bba88955433 100644 --- a/ciphers/transposition_cipher.py +++ b/ciphers/transposition_cipher.py @@ -1,11 +1,13 @@ import math -''' +""" In cryptography, the TRANSPOSITION cipher is a method of encryption where the positions of plaintext are shifted a certain number(determined by the key) that follows a regular system that results in the permuted text, known as the encrypted text. The type of transposition cipher demonstrated under is the ROUTE cipher. -''' +""" + + def main(): message = input("Enter message: ") key = int(input("Enter key [2-%s]: " % (len(message) - 1))) From ba48dd8f5544bf90621982ea4d2d98b730648c4a Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 6 Feb 2020 22:02:29 +0200 Subject: [PATCH 3/7] except IOError: --- ciphers/xor_cipher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciphers/xor_cipher.py b/ciphers/xor_cipher.py index 58b5352672ef..0fcfbb0b9ae2 100644 --- a/ciphers/xor_cipher.py +++ b/ciphers/xor_cipher.py @@ -148,7 +148,7 @@ def encrypt_file(self, file, key=0): for line in fin: fout.write(self.encrypt_string(line, key)) - except: + except IOError: return False return True @@ -173,7 +173,7 @@ def decrypt_file(self, file, key): for line in fin: fout.write(self.decrypt_string(line, key)) - except: + except IOError: return False return True From f135836196c2d6c1554d177d7a230b9f699dfec9 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 6 Feb 2020 22:06:42 +0200 Subject: [PATCH 4/7] except IOError: --- hashes/hamming_code.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hashes/hamming_code.py b/hashes/hamming_code.py index 3e0424490781..24ee6b37e7f1 100644 --- a/hashes/hamming_code.py +++ b/hashes/hamming_code.py @@ -125,7 +125,7 @@ def emitterConverter(sizePar, data): if x != None: try: aux = (binPos[contLoop])[-1 * (bp)] - except: + except IndexError: aux = "0" if aux == "1": if x == "1": @@ -229,7 +229,7 @@ def receptorConverter(sizePar, data): if x != None: try: aux = (binPos[contLoop])[-1 * (bp)] - except: + except IOError:: aux = "0" if aux == "1": if x == "1": From d1d7d758524d500210272bf4cc676177565af44e Mon Sep 17 00:00:00 2001 From: John Law Date: Fri, 7 Feb 2020 14:21:30 +0100 Subject: [PATCH 5/7] Update hamming_code.py --- hashes/hamming_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashes/hamming_code.py b/hashes/hamming_code.py index 24ee6b37e7f1..6ddd05726436 100644 --- a/hashes/hamming_code.py +++ b/hashes/hamming_code.py @@ -229,7 +229,7 @@ def receptorConverter(sizePar, data): if x != None: try: aux = (binPos[contLoop])[-1 * (bp)] - except IOError:: + except IOError: aux = "0" if aux == "1": if x == "1": From 9ecad7650468836013a6bf7fd2abb1a29ed3f311 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 7 Feb 2020 17:40:47 +0200 Subject: [PATCH 6/7] IndexError --- hashes/hamming_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashes/hamming_code.py b/hashes/hamming_code.py index 6ddd05726436..1246e1817c76 100644 --- a/hashes/hamming_code.py +++ b/hashes/hamming_code.py @@ -229,7 +229,7 @@ def receptorConverter(sizePar, data): if x != None: try: aux = (binPos[contLoop])[-1 * (bp)] - except IOError: + except IndexError: aux = "0" if aux == "1": if x == "1": From 72de0c703a04940c3b007051d21907650ff64345 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 7 Feb 2020 21:54:18 +0200 Subject: [PATCH 7/7] Get rid of the nonsense logic --- linear_algebra/src/test_linear_algebra.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/linear_algebra/src/test_linear_algebra.py b/linear_algebra/src/test_linear_algebra.py index 5e28910af86a..8d2170e46da4 100644 --- a/linear_algebra/src/test_linear_algebra.py +++ b/linear_algebra/src/test_linear_algebra.py @@ -19,11 +19,7 @@ def test_component(self): x = Vector([1, 2, 3]) self.assertEqual(x.component(0), 1) self.assertEqual(x.component(2), 3) - try: - y = Vector() - self.assertTrue(False) - except: - self.assertTrue(True) + y = Vector() def test_str(self): """