Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 119072e

Browse files
Make code consistent
1 parent aecd86c commit 119072e

File tree

8 files changed

+53
-47
lines changed

8 files changed

+53
-47
lines changed

‎addLogo/addLogo.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
# If logo file does not ecists or is not a supported image file
1919
if not os.path.exists(logoName):
20-
print('The filename '+logoName+' does not exists.')
20+
print(f'The filename {logoName} does not exists.')
2121
sys.exit()
2222
elif not (logoName.lower().endswith('.png') or \
2323
logoName.lower().endswith('.jpg') or logoName.lower().endswith('.jpeg')):
24-
print('The filename '+logoName+' is not a supported image file.')
24+
print(f'The filename {logoName} is not a supported image file.')
2525
sys.exit()
2626

2727
logoIm = Image.open(logoName).convert("RGBA")
@@ -62,10 +62,10 @@
6262
logoIm = logoIm.resize((logoWidth, logoHeight), Image.ANTIALIAS)
6363

6464
# Add logo
65-
print(f'Adding logo to {fileName}...')
65+
print(f'\nAdding logo to {fileName}...')
6666
im.paste(logoIm, (width - logoWidth - pad, height - logoHeight - pad), \
6767
logoIm)
6868

6969
# Save the image with added logo
7070
im.save(os.path.join('withLogo', fileName), quality = 100)
71-
print(f'Saved {fileName} with added logo.')
71+
print(f'Saved {fileName} with added logo')

‎addWatermarkPDF/addWatermarkPDF.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
# Check if entered filenames are valid
1919
if not path.exists(baseFileName) or baseFileName[-4:].lower() != '.pdf':
20-
print('The filename '+baseFileName+' is not a PDF.')
20+
print(f'The filename {baseFileName} is not a PDF.')
2121
sys.exit()
2222

2323
elif not path.exists(watermarkName) or watermarkName[-4:].lower() != '.pdf':
24-
print('The filename '+watermarkName+' is not a PDF.')
24+
print(f'The filename {watermarkName} is not a PDF.')
2525
sys.exit()
2626

2727
else:
@@ -44,4 +44,4 @@
4444
baseFile.close()
4545
markedPdfFile.close()
4646

47-
print('Watermarked file saved as watermarked'+path.basename(baseFileName))
47+
print(f'Watermarked file saved as watermarked{path.basename(baseFileName)}')

‎codeDestroyer/codeDestroyer.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
"""
22
codeDestroyer.py - Replaces semicolon(;) in files with Greek
33
Question Mark(;) that looks alike but shows syntax errors,
44
(since it is a different character) leaving the programmer
@@ -10,18 +10,19 @@
1010
"""
1111

1212
import sys
13-
import os
13+
from osimportpath
1414
import re
1515

1616
# Unicode symbols for semicolon and the Greek Question mark
1717
semicolon = u'\u003b'
1818
greekQmark = u'\u037e'
1919

2020
# Name of file
21-
fileName = input("Enter the file name (like helloWorld.c):\n")
22-
filename = os.path.abspath(fileName)
23-
if (not os.path.exists(fileName)) or os.path.islink(fileName):
24-
print("\nThe filename you entered is not valid. Please enter a valid filename.")
21+
fileName = input('Enter the file name (like helloWorld.c):\n')
22+
fileName = path.abspath(fileName)
23+
if (not path.exists(fileName)) or path.islink(fileName):
24+
print(f'\n{fileName} is not a valid file.\
25+
Please enter a valid filename.')
2526
sys.exit()
2627
else:
2728
# Open the file to be destroyed
@@ -31,8 +32,9 @@
3132
contents = destroyFile.read()
3233
contents = re.sub(semicolon, greekQmark, contents)
3334

35+
print(f'Destroying {fileName}...')
3436
# Overwrite on the original file
3537
destroyFile.seek(0, 0)
3638
destroyFile.write(contents)
3739
destroyFile.close()
38-
print("\n"+fileName+" destroyed syccessfully XD.")
40+
print(f'\n{fileName}destroyed successfully XD.')

‎combinePDF/combinePDF.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
# Loop through the pages and add them
2929
start = 0
3030
if pdfReader.numPages > 1:
31-
ans = input('Do you want to include the cover page of '+filename\
32-
+' ? (y/n): ')
31+
ans = input(f'Do you want to include the cover page of {filename}? \
32+
(y/n): ')
3333
start = 0 if ans.lower() == 'y' else 1
3434
for pageNum in range(start, pdfReader.numPages):
3535
pageObj = pdfReader.getPage(pageNum)
@@ -41,4 +41,4 @@
4141
pdfWriter.write(pdfOutput)
4242
pdfOutput.close()
4343

44-
print('Combined PDF saved as '+'combined'+pdfFiles[0])
44+
print(f'Combined PDF saved as combined{pdfFiles[0]}')

‎encryptDecryptPDF/encryptDecryptPDF.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def encrypt():
2020

2121
# Check if entered filename is valid
2222
if not path.exists(pdfName) or pdfName[-4:].lower() != '.pdf':
23-
print('The filename '+pdfName+' is not a PDF.')
23+
print(f'The filename {pdfName} is not a PDF.')
2424
sys.exit()
2525

2626
pdfFile = open(pdfName, 'rb')
@@ -39,7 +39,7 @@ def encrypt():
3939
encryptedPdf = open('encrypted' + path.basename(pdfName), 'wb')
4040
pdfWriter.write(encryptedPdf)
4141
encryptedPdf.close()
42-
print('File encrypted and saved as encrypted'+path.basename(pdfName))
42+
print(f'File encrypted and saved as encrypted{path.basename(pdfName)}')
4343

4444
# Decrypt
4545
def decrypt():
@@ -48,7 +48,7 @@ def decrypt():
4848

4949
# Check if entered filename is valid
5050
if not path.exists(pdfName) or pdfName[-4:].lower() != '.pdf':
51-
print('The filename '+pdfName+' is not a PDF.')
51+
print(f'The filename {pdfName} is not a PDF.')
5252
sys.exit()
5353

5454
pdfFile = open(pdfName, 'rb')
@@ -67,7 +67,7 @@ def decrypt():
6767
decryptedPdf = open('decrypted' + path.basename(pdfName), 'wb')
6868
pdfWriter.write(decryptedPdf)
6969
decryptedPdf.close()
70-
print('File decrypted and saved as decrypted'+path.basename(pdfName))
70+
print(f'File decrypted and saved as decrypted{path.basename(pdfName)}')
7171

7272
print('Enter the task to perform (1 or 2)\n1. Encrypt a PDF\n2. Decrypt a PDF')
7373
response = int(input())

‎fillGap/fillGap.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import shutil
1818

1919
# Input file/folder name and extension
20-
filename = input("Enter the name prefix for the files/folders\n")
21-
print("\nEnter the extension after the dot in filenames (like txt in spam01.txt)")
22-
print("Type \"folder\" (without the quotes) if the files are folders")
20+
filename = input('Enter the name prefix for the files/folders\n')
21+
print('\nEnter the extension after the dot in filenames \
22+
(like txt in spam01.txt)')
23+
print('Type \'folder\' (without the quotes) if the files are folders')
2324
ext = input()
2425

2526
# Create filename regex
@@ -34,11 +35,11 @@
3435
)
3536

3637
# Put matching file/folder names in a list
37-
path = input("\nEnter the path of folder containing the file/folder\n")
38+
path = input('\nEnter the path of folder containing the file/folder\n')
3839
path = os.path.abspath(path)
3940
print(path)
4041
if not os.path.isdir(path):
41-
print("The path entered is not a valid folder.")
42+
print('The path entered is not a valid folder.')
4243
sys.exit()
4344
else:
4445
lst = []
@@ -51,6 +52,8 @@
5152
lst = sorted(lst)
5253
padding = int(log(len(lst))//log(10)) + 1
5354

55+
print('Renamaming files/folders...')
56+
5457
# Rename files/folders
5558
for i in range(len(lst)):
5659
if ext == 'folder':
@@ -63,4 +66,4 @@
6366
oldPath = os.path.join(path, lst[i])
6467
newPath = os.path.join(path, newName)
6568
shutil.move(oldPath, newPath)
66-
print("The files are renamed with gaps closed.")
69+
print('The files are renamed with gaps closed.')

‎phoneAndEmailExtractor/phoneAndEmail.py‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,35 @@
118118
# Save results in .txt files
119119
phoneNumbers = open('phoneNumbers.txt', 'w')
120120

121-
phoneNumbers.write("Mobile Phone Numbers:\n")
121+
phoneNumbers.write('Mobile Phone Numbers:\n')
122122
if mobileMatches == []:
123-
phoneNumbers.write("No Mobile Phone Numbers Found")
123+
phoneNumbers.write('No Mobile Phone Numbers Found')
124124
else:
125125
phoneNumbers.write('\n'.join(mobileMatches))
126-
phoneNumbers.write("\n\n")
126+
phoneNumbers.write('\n\n')
127127

128-
phoneNumbers.write("Toll-Free/LocalRate Phone Numbers:\n")
128+
phoneNumbers.write('Toll-Free/LocalRate Phone Numbers:\n')
129129
if tollFreeMatches == []:
130-
phoneNumbers.write("No Toll-Free/Local-Rate Phone Numbers Found")
130+
phoneNumbers.write('No Toll-Free/Local-Rate Phone Numbers Found')
131131
else:
132132
phoneNumbers.write('\n'.join(tollFreeMatches))
133-
phoneNumbers.write("\n\n")
133+
phoneNumbers.write('\n\n')
134134

135-
phoneNumbers.write("Telephone Numbers:\n")
135+
phoneNumbers.write('Telephone Numbers:\n')
136136
if telMatches == []:
137-
phoneNumbers.write("No Telephone Numbers Found")
137+
phoneNumbers.write('No Telephone Numbers Found')
138138
else:
139139
phoneNumbers.write('\n'.join(telMatches))
140-
phoneNumbers.write("\n")
140+
phoneNumbers.write('\n')
141141

142142
emails = open('emails.txt', 'w')
143-
emails.write("Emails:\n")
143+
emails.write('Emails:\n')
144144
if emailMatches == []:
145-
emails.write("No Emails Found")
145+
emails.write('No Emails Found')
146146
else:
147147
emails.write('\n'.join(emailMatches))
148-
emails.write("\n")
148+
emails.write('\n')
149149

150150
phoneNumbers.close()
151151
emails.close()
152-
print("Phone Numbers and Emails saved to phoneNumbers.txt and emails.txt")
152+
print('Phone Numbers and Emails saved to phoneNumbers.txt and emails.txt')

‎searchSize/searchSize.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,29 @@ def getSize(folPath):
3838
return totalSize
3939

4040
# Input minimum size
41-
size = int(input("Enter the minimum size (in bytes)\n"))
41+
size = int(input('Enter the minimum size (in bytes)\n'))
4242

4343
# Input folder name
44-
folder = input("Enter the path of the folder to search\n")
44+
folder = input('Enter the path of the folder to search\n')
4545
folder = os.path.abspath(folder) # Absolute path
4646

4747
# Verify if folder name and path exists
4848
if not os.path.exists(folder):
49-
print("The folder path entered does not exists.")
49+
print('The folder path entered does not exists.')
5050
sys.exit()
5151
else:
5252
folderSize = getSize(folder)
5353

5454
# If no files/folders found
5555
if large == {}:
56-
print(f"There are no files or folders with size greater than {size} bytes.")
56+
print(f'There are no files or folders with size greater than {size} \
57+
bytes.')
5758

5859
# Print paths with size
5960
else:
60-
print(f"The files and folders with size greater than {size} are:")
61+
print(f'The files and folders with size greater than {size} are:')
6162
for path in large.keys():
6263
if os.path.isfile(path):
63-
print(f"The size of the file {path} is: {large[path]} bytes.")
64+
print(f'The size of the file {path} is: {large[path]} bytes.')
6465
elif os.path.isdir(path):
65-
print(f"The size of the folder {path} is: {large[path]} bytes.")
66+
print(f'The size of the folder {path} is: {large[path]} bytes.')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /