Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option ignore_ncx (warning) #296

Open
carlosalvidrez opened this issue Dec 15, 2023 · 4 comments
Open

Option ignore_ncx (warning) #296

carlosalvidrez opened this issue Dec 15, 2023 · 4 comments

Comments

@carlosalvidrez
Copy link

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.')

@noembryo
Copy link

noembryo commented Dec 22, 2023

.. 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:

@paotsaq
Copy link

paotsaq commented Feb 1, 2024

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.

@noembryo
Copy link

noembryo commented Feb 1, 2024

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.

@alzamer2
Copy link

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.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants