GeezerVison is showing github.com — pyupgrade --py37-plus **/*.py (#1654) · SharathKumarGithub/Python@28419cf
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: backtracking/all_combinations.py -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -# -*- coding: utf-8 -*- | 2 | | - | 3 | 1 | """ | 4 | 2 | In this problem, we want to determine all possible combinations of k | 5 | 3 | numbers out of 1 ... n. We use backtracking to solve this problem. | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/brute_force_caesar_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,7 @@ def decrypt(message): | 40 | 40 | translated = translated + LETTERS[num] | 41 | 41 | else: | 42 | 42 | translated = translated + symbol | 43 | | - print("Decryption using Key #%s: %s" % (key, translated)) | | 43 | + print(f"Decryption using Key #{key}: {translated}") | 44 | 44 |
| 45 | 45 |
| 46 | 46 | def main(): | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/hill_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -78,7 +78,7 @@ def checkDeterminant(self): | 78 | 78 | req_l = len(self.key_string) | 79 | 79 | if gcd(det, len(self.key_string)) != 1: | 80 | 80 | raise ValueError( | 81 | | - "discriminant modular {0} of encryption key({1}) is not co prime w.r.t {2}.\nTry another key.".format( | | 81 | + "discriminant modular {} of encryption key({}) is not co prime w.r.t {}.\nTry another key.".format( | 82 | 82 | req_l, det, req_l | 83 | 83 | ) | 84 | 84 | ) | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/rsa_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -101,7 +101,7 @@ def encryptAndWriteToFile( | 101 | 101 | for i in range(len(encryptedBlocks)): | 102 | 102 | encryptedBlocks[i] = str(encryptedBlocks[i]) | 103 | 103 | encryptedContent = ",".join(encryptedBlocks) | 104 | | - encryptedContent = "%s_%s_%s" % (len(message), blockSize, encryptedContent) | | 104 | + encryptedContent = "{}_{}_{}".format(len(message), blockSize, encryptedContent) | 105 | 105 | with open(messageFilename, "w") as fo: | 106 | 106 | fo.write(encryptedContent) | 107 | 107 | return encryptedContent | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/rsa_key_generator.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,11 +43,11 @@ def makeKeyFiles(name, keySize): | 43 | 43 | publicKey, privateKey = generateKey(keySize) | 44 | 44 | print("\nWriting public key to file %s_pubkey.txt..." % name) | 45 | 45 | with open("%s_pubkey.txt" % name, "w") as fo: | 46 | | - fo.write("%s,%s,%s" % (keySize, publicKey[0], publicKey[1])) | | 46 | + fo.write("{},{},{}".format(keySize, publicKey[0], publicKey[1])) | 47 | 47 |
| 48 | 48 | print("Writing private key to file %s_privkey.txt..." % name) | 49 | 49 | with open("%s_privkey.txt" % name, "w") as fo: | 50 | | - fo.write("%s,%s,%s" % (keySize, privateKey[0], privateKey[1])) | | 50 | + fo.write("{},{},{}".format(keySize, privateKey[0], privateKey[1])) | 51 | 51 |
| 52 | 52 |
| 53 | 53 | if __name__ == "__main__": | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/shuffled_shift_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | import string | 3 | 3 |
| 4 | 4 |
| 5 | | -class ShuffledShiftCipher(object): | | 5 | +class ShuffledShiftCipher: | 6 | 6 | """ | 7 | 7 | This algorithm uses the Caesar Cipher algorithm but removes the option to | 8 | 8 | use brute force to decrypt the message. | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/simple_substitution_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ def main(): | 17 | 17 | mode = "decrypt" | 18 | 18 | translated = decryptMessage(key, message) | 19 | 19 |
| 20 | | - print("\n%sion: \n%s" % (mode.title(), translated)) | | 20 | + print("\n{}ion: \n{}".format(mode.title(), translated)) | 21 | 21 |
| 22 | 22 |
| 23 | 23 | def checkValidKey(key): | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/xor_cipher.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | """ | 19 | 19 |
| 20 | 20 |
| 21 | | -class XORCipher(object): | | 21 | +class XORCipher: | 22 | 22 | def __init__(self, key=0): | 23 | 23 | """ | 24 | 24 | simple constructor that receives a key or uses | |
Collapse file Copy file name to clipboardExpand all lines: compression/burrows_wheeler.py +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -135,16 +135,14 @@ def reverse_bwt(bwt_string: str, idx_original_string: int) -> str: | 135 | 135 | idx_original_string = int(idx_original_string) | 136 | 136 | except ValueError: | 137 | 137 | raise TypeError( | 138 | | - ( | 139 | | - "The parameter idx_original_string type must be int or passive" | 140 | | - " of cast to int." | 141 | | - ) | | 138 | + "The parameter idx_original_string type must be int or passive" | | 139 | + " of cast to int." | 142 | 140 | ) | 143 | 141 | if idx_original_string < 0: | 144 | 142 | raise ValueError("The parameter idx_original_string must not be lower than 0.") | 145 | 143 | if idx_original_string >= len(bwt_string): | 146 | 144 | raise ValueError( | 147 | | - ("The parameter idx_original_string must be lower than" " len(bwt_string).") | | 145 | + "The parameter idx_original_string must be lower than" " len(bwt_string)." | 148 | 146 | ) | 149 | 147 |
| 150 | 148 | ordered_rotations = [""] * len(bwt_string) | |
Collapse file Copy file name to clipboardExpand all lines: data_structures/binary_tree/avl_tree.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -# -*- coding: utf-8 -*- | 2 | 1 | """ | 3 | 2 | An auto-balanced binary tree! | 4 | 3 | """ | |
|