Skip to content

Commit ba144a9

Browse files
Merge pull request sameera-madushan#10 from DarkCeptor44/fix-pep8-violations
Fix PEP8 Violations/Minor Warnings
2 parents 9687740 + 9c5a2ff commit ba144a9

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ certifi==2020.4.5.1
22
chardet==3.0.4
33
idna==2.9
44
requests==2.23.0
5-
tk==0.1.0
65
urllib3==1.25.8

sbox.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,32 @@ def tk_get_file_path():
1717
file_path = filedialog.askopenfilename()
1818

1919
try:
20-
with open(file_path, 'r') as f:
20+
with open(file_path, 'r'):
2121
pass
22-
except:
22+
except IOError:
2323
print("Cancelled")
2424
sys.exit()
2525

2626
return file_path
2727

2828

2929
languages = {
30-
"en" : "English",
31-
"es" : "Spanish",
32-
"fr" : "French",
33-
"it" : "Italian",
34-
"nl" : "Dutch",
35-
"pl" : "Polish",
36-
"pt" : "Portuguese",
37-
"ro" : "Romanian",
38-
"sv" : "Swedish",
39-
"tr" : "Turkish"
30+
"en": "English",
31+
"es": "Spanish",
32+
"fr": "French",
33+
"it": "Italian",
34+
"nl": "Dutch",
35+
"pl": "Polish",
36+
"pt": "Portuguese",
37+
"ro": "Romanian",
38+
"sv": "Swedish",
39+
"tr": "Turkish"
4040
}
4141

4242

4343
def get_hash(name):
4444
readsize = 64 * 1024
4545
with open(name, 'rb') as f:
46-
size = os.path.getsize(name)
4746
data = f.read(readsize)
4847
f.seek(-readsize, os.SEEK_END)
4948
data += f.read(readsize)
@@ -58,14 +57,14 @@ def create_url(file_path):
5857

5958
def request_subtitle_languages(file_path):
6059
url = create_url(file_path)
61-
header = { "user-agent": "SubDB/1.0 (SubtitleBOX/1.0; https://github.com/sameera-madushan/SubtitleBOX.git)" }
60+
header = {"user-agent": "SubDB/1.0 (SubtitleBOX/1.0; https://github.com/sameera-madushan/SubtitleBOX.git)"}
6261
req = requests.get(url, headers=header)
6362
if req.status_code == 200:
6463
k = req.content.decode('utf-8')
6564
available_languages = k.split(",")
6665
print("\nSubtitle files are available in following languages...\n")
6766
for i in available_languages:
68-
for k,v in languages.items():
67+
for k, v in languages.items():
6968
if i == k:
7069
print(" " + k + " (" + v + ")")
7170
return available_languages
@@ -117,7 +116,7 @@ def main(cli_file_path, language_code_cli):
117116
url = create_url(file_path)
118117
search = re.sub(r'search', "download", url)
119118
final_url = search + "&language={}".format(selected_language)
120-
header = { "user-agent": "SubDB/1.0 (SubtitleBOX/1.0; https://github.com/sameera-madushan/SubtitleBOX.git)" }
119+
header = {"user-agent": "SubDB/1.0 (SubtitleBOX/1.0; https://github.com/sameera-madushan/SubtitleBOX.git)"}
121120
req = requests.get(final_url, headers=header)
122121
if req.status_code == 200:
123122
data = req.content
@@ -139,6 +138,3 @@ def main(cli_file_path, language_code_cli):
139138
args = parser.parse_args()
140139

141140
main(args.file_path, args.language_code)
142-
143-
144-

0 commit comments

Comments
 (0)