ebooklib icon indicating copy to clipboard operation
ebooklib copied to clipboard

Option ignore_ncx (warning)

Open carlosalvidrez opened this issue 1 year ago • 4 comments

Getting this warning:

ebooklib/epub.py:1395: UserWarning: In the future version we will turn default option ignore_ncx to True. warnings.warn('In the future version we will turn default option ignore_ncx to True.')

carlosalvidrez avatar Dec 15 '23 15:12 carlosalvidrez

.. and the only way to silence it is to set it True like this: epub.read_epub(filename, {"ignore_ncx": True})

I think that the intention was to explicitly select whether you want it or not, and not use the default, which is False. But, as I said it forces you to select True, otherwise you got a warning that looks really bad in a CLI.

This is because in the code, there is an if not self.options.get('ignore_ncx'): where it should be if self.options.get('ignore_ncx') is None:

noembryo avatar Dec 22 '23 13:12 noembryo

Huh. Thanks. This was pesky. Is this something that could be solved with a PR? At least to make the comment more clear in how to suppress the warning.

paotsaq avatar Feb 01 '24 05:02 paotsaq

Huh. Thanks. This was pesky. Is this something that could be solved with a PR?

Yes, this is what the proposed change in the code does. It's really a very simple change and that's why I just post it here instead of creating a PR. epub.py line 1393 change if not self.options.get('ignore_ncx'): to if self.options.get('ignore_ncx') is None:

At least to make the comment more clear in how to suppress the warning.

You can't suppress the warning from your app in any other way. Only by changing the original code.

noembryo avatar Feb 01 '24 13:02 noembryo

Huh. Thanks. This was pesky. Is this something that could be solved with a PR?

Yes, this is what the proposed change in the code does. It's really a very simple change and that's why I just post it here instead of creating a PR. epub.py line 1393 change if not self.options.get('ignore_ncx'): to if self.options.get('ignore_ncx') is None:

At least to make the comment more clear in how to suppress the warning.

You can't suppress the warning from your app in any other way. Only by changing the original code.

will you can suppress only in your code just add these lines at start of your code

import warnings

# supress ignore_ncx

warnings.filterwarnings("ignore", message="In the future version we will turn default option ignore_ncx to True.")

alzamer2 avatar Aug 22 '24 07:08 alzamer2