Open carlosalvidrez opened 11 months ago
.. 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:
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.
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.
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 changeif not self.options.get('ignore_ncx'):
toif 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.")
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.')