Skip to content

Commit 9705b54

Browse files
Fixed assignment errors introduced in last commits caused by a function having the same name as it's return variables as well as correcting no-PEP8 compliant variable names (camelCase instead of snake_case)
1 parent 5440e09 commit 9705b54

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

calibre-web-automator/new-book-processor.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import glob
21
import json
32
import os
43
import sys
54
import time
6-
from pathlib import Path
75
import subprocess
86

97
supported_book_formats = ['azw', 'azw3', 'azw4', 'cbz', 'cbr', 'cb7', 'cbc', 'chm', 'djvu', 'docx', 'epub', 'fb2', 'fbz', 'html', 'htmlz', 'lit', 'lrf', 'mobi', 'odt', 'pdf', 'prc', 'pdb', 'pml', 'rb', 'rtf', 'snb', 'tcr', 'txt', 'txtz']
@@ -21,11 +19,11 @@
2119
def main():
2220
t_start = time.time()
2321

24-
isEpub = True if filepath.endswith('.epub') else False
22+
is_epub = True if filepath.endswith('.epub') else False
2523

26-
if not isEpub: # Books require conversion
24+
if not is_epub: # Books require conversion
2725
print("\n[new-book-processor]: No epub files found in the current directory. Starting conversion process...")
28-
can_convert, import_format = can_convert()
26+
can_convert, import_format = can_convert_check()
2927
print(f"[new-book-processor]: Converting file from to epub format...\n")
3028

3129
if (can_convert):
@@ -38,7 +36,7 @@ def main():
3836
else: # Books only need copying to the import folder
3937
print(f"\n[new-book-processor]: Found epub file from the most recent download.")
4038
print("[new-book-processor]: Moving resulting files to calibre-web import folder...\n")
41-
move_epub(isEpub)
39+
move_epub(is_epub)
4240
print(f"[new-book-processor]: Copied epub file to calibre-web import folder.")
4341

4442
t_end = time.time()
@@ -65,23 +63,23 @@ def convert_book(import_format: str) -> float:
6563
return time_total_conversion
6664

6765

68-
def can_convert():
66+
def can_convert_check():
6967
"""When no epubs are detected in the download, this function will go through the list of new files
7068
and check for the format the are in that has the highest chance of sucsessful conversion according to the input format hierarchy list
7169
provided by calibre"""
7270
can_convert = False
7371
import_format = ''
7472
for format in hierarchy_of_succsess:
75-
canBeConverted = True if filepath.endswith(f'.{format}') else False
76-
if canBeConverted:
73+
can_be_converted = True if filepath.endswith(f'.{format}') else False
74+
if can_be_converted:
7775
can_convert = True
7876
import_format = format
7977
break
8078

8179
return can_convert, import_format
8280

8381

84-
def move_epub(isEpub) -> None:
82+
def move_epub(is_epub) -> None:
8583
"""Moves the epubs from the download folder to the calibre-web import folder"""
8684
print(f"[new-book-processor]: Moving {filepath}...")
8785
filename = filepath.split('/')[-1]

0 commit comments

Comments
 (0)