Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BasioMeusPuga committed Mar 9, 2019
1 parent c8fe0ba commit c71985f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def add_books(self):
ebooks_string = self._translate('Main_UI', 'eBooks')
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
self, dialog_prompt, self.settings['last_open_path'],
f'{ebooks_string} ({self.available_parsers})')
f'{ebooks_string}({self.available_parsers})')

if not opened_files[0]:
return
Expand Down Expand Up @@ -742,7 +742,7 @@ def show_settings(self, stacked_widget_index):
else:
self.settingsDialog.hide()

#____________________________________________
#==================================================================
# The contentView modification functions are in the guifunctions
# module. self.profile_functions is the reference here.

Expand All @@ -763,7 +763,7 @@ def modify_comic_view(self, key_pressed=None):
self.profile_functions.modify_comic_view(
signal_sender, key_pressed)

#____________________________________________
#=================================================================

def change_page_view(self, key_pressed=False):
# Set zoom mode to best fit to
Expand Down
33 changes: 21 additions & 12 deletions lector/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,7 @@ def generate_model(self, mode, parsed_books=None, is_database_ready=True):
position = i[5]
if position:
position = pickle.loads(position)
if position['is_read']:
position_perc = 1
else:
try:
position_perc = (
position['current_block'] / position['total_blocks'])
except (KeyError, ZeroDivisionError):
try:
position_perc = (
position['current_chapter'] / position['total_chapters'])
except KeyError:
position_perc = None
position_perc = generate_position_percentage(position)

try:
file_exists = os.path.exists(path)
Expand Down Expand Up @@ -339,3 +328,23 @@ def prune_models(self, valid_paths):
# Remove invalid paths from the database as well
database.DatabaseFunctions(
self.main_window.database_path).delete_from_database('Path', invalid_paths)


def generate_position_percentage(position):
if not position:
return None

if position['is_read']:
position_perc = 1
else:
try:
position_perc = (
position['current_block'] / position['total_blocks'])
except (KeyError, ZeroDivisionError):
try:
position_perc = (
position['current_chapter'] / position['total_chapters'])
except KeyError:
position_perc = None

return position_perc
2 changes: 1 addition & 1 deletion lector/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

VERSION = '0.5.0'
VERSION = '0.5.1'

import os
import logging
Expand Down
4 changes: 3 additions & 1 deletion lector/sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def read_book(self, filename):
break

if not valid_extension:
logger.error('Unsupported extension: ' + filename)
this_error = 'Unsupported extension: ' + filename
self.errors.append(this_error)
logger.error(this_error)
return

book_ref = sorter[file_extension](filename, self.temp_dir, file_md5)
Expand Down

0 comments on commit c71985f

Please sign in to comment.