Commit Graph

29649 Commits

Author SHA1 Message Date
Eli Schwartz 65c0ca944b py3: make pml input work
Opening a file in binary mode in python3 returns a BufferedReader which
does not have an encoding attribute. Assume in this case it is
functionally equivalent to None.

I'm not sure when pml_stream.encoding will ever equal anything, since
even on python2 the attribute exists but is None when opening files in
binary mode... which we explicitly do. So I'm not sure why this ever
checks the existing encoding. Possibly when the input plugin is given a
file opened in text mode, not raw mode? in that case, it may be wrong to
always decode it when reading.
2019-05-20 00:55:13 -04:00
Eli Schwartz 1ed017fabd py3: make pmlz output work
in python3, the re module is more picky about what arguments are used
with it, and invalid escapes do not fall back on being treated as string
literals, but raise an error. Use raw strings to ensure that the escaped
backslashes are preserved all the way to the regular expressions
themselves.
2019-05-20 00:55:13 -04:00
Eli Schwartz 8e368c0d46 py3: more fixes for snb output
string.split is deprecated, use native functions on the original string
itself.
2019-05-20 00:55:13 -04:00
Eli Schwartz 4bbc8df3ab py3: make pdb input work 2019-05-20 00:55:13 -04:00
Eli Schwartz 047d539e0a py3: os.walk explicitly returns bytes when given a bytes argument
And therefore when replacing paths in it, we need to use bytes as well.
2019-05-20 00:55:13 -04:00
Eli Schwartz 00ed9305cb py3: fix mobi ncx
get_id_tag/get_id_tag_by_pos_fid are internal functions that always
return bytes, but when using the former proxied through the latter, we
did not always decode the result in the process of generating an OPF.

As a result, books would end up with nav links pointing to urls
resembling "foo.html#b'anchor'".

Fix by moving down the decode attempt to cover both, right before
writing it back into the index_entries.
2019-05-20 00:55:13 -04:00
Eli Schwartz ab7e134a40 py3: make pdb output work 2019-05-20 00:55:13 -04:00
Kovid Goyal f32ea26bf1 py3: Port more files to not use str() andhave unicode literals 2019-05-20 06:56:45 +05:30
Kovid Goyal ee97edc94d Merge branch 'calibre-complete' of https://github.com/eli-schwartz/calibre 2019-05-20 06:31:45 +05:30
Eli Schwartz 09b4218b83 py3: recursive forcing to unicode missed converting set()
This resulted in e.g. ebook-convert-complete still storing most formats
in msgpack as bytestrings, and therefore not being completed.
2019-05-19 14:34:47 -04:00
j-howell 21b61b1040 Further improve handling of books with both old and new style KFX metadata 2019-05-19 08:35:38 -04:00
Kovid Goyal 3013170e56 Merge branch 'py3-bootstrapping' of https://github.com/aimylios/calibre 2019-05-19 14:31:39 +05:30
Kovid Goyal 14b7f0b51e py3: Use unicode_literals and migrate str() in a few more files 2019-05-19 14:29:14 +05:30
Aimylios 63e1d1e894 py3: Remove last occurrence of os.getcwdu() 2019-05-19 10:26:50 +02:00
Kovid Goyal 052cb43ae1 py3: Use unicode_literals and migrate str() in a few more files 2019-05-19 13:20:26 +05:30
Kovid Goyal 1de94d39e2 Report detected image type in exception 2019-05-18 15:41:38 +05:30
Kovid Goyal 4e604e52d7 PDF Output: Fix hang when converting some documents. Fixes #1829535 [ebook-convert hangs on some HTML to PDF conversions](https://bugs.launchpad.net/calibre/+bug/1829535) 2019-05-17 21:02:30 +05:30
Kovid Goyal 3d586aa15a PDF Output: Remove JS from HTML files before passing them to WebKit 2019-05-17 20:39:24 +05:30
Kovid Goyal c2e36408d3 py3: More unicode porting 2019-05-16 17:55:04 +05:30
Kovid Goyal fab8c8f2d4 py3: Use unicode_literals and no str() calls 2019-05-16 12:19:41 +05:30
Kovid Goyal 81e037e38c Port calibre.startup to use unicode_literals 2019-05-15 21:23:55 +05:30
Kovid Goyal fc2409cdd8 Port calibre.__init__ to use unicode_literals 2019-05-15 21:19:22 +05:30
Kovid Goyal f51e63718c Get rid of @dynamic_property 2019-05-15 20:39:48 +05:30
Kovid Goyal 846a1a5e9f Remove unused code 2019-05-15 17:02:01 +05:30
Kovid Goyal 17b84867dd Add a build test for getting unicode env vars on windows 2019-05-15 16:57:36 +05:30
Kovid Goyal 65a0eaeac2 oops 2019-05-15 16:54:45 +05:30
Kovid Goyal 2896bb3571 Finish getting rid of getcwdu() 2019-05-15 16:53:39 +05:30
Kovid Goyal a08bdbeb4e Dont depend on calibre in polyglot 2019-05-15 16:42:52 +05:30
Kovid Goyal bd118e6139 Framework to run 2to3 over the codebase 2019-05-15 16:13:12 +05:30
Kovid Goyal a78ede4c35 py3: Port constants.py to use unicode literals 2019-05-15 15:49:22 +05:30
Kovid Goyal 0cf114ada1 Handle newlines when serializing to csr files
See #1827198 (Book convertion loading regexPDF to epub)
2019-05-15 12:05:09 +05:30
Charles Haley 8fd98e6eb0 Bug 1828986: searching in manage tags throws away all changes 2019-05-14 12:48:35 +01:00
Kovid Goyal b1925a344a Edit metadata dialog: Remember relative sizes of the cover and comments editors. Fixes #1828291 [Editor dialog does not remember pane widths](https://bugs.launchpad.net/calibre/+bug/1828291) 2019-05-14 13:44:58 +05:30
Kovid Goyal 47aa91f7ba Remove margins around comments editor 2019-05-14 12:49:07 +05:30
Kovid Goyal 76d9f734e9 Fix #1828820 [calibre.utils.titlecase does not preserve whitespace](https://bugs.launchpad.net/calibre/+bug/1828820) 2019-05-14 11:59:09 +05:30
Kovid Goyal 7658dc65d9 Remove manual fixup of <br> in comments_to_html
Not needed with html5-parser 0.4.6
Modify the test to work with all versions of html5-parser
Fixes #990 (Update testsuite for html5-parser 0.4.6 changes)
2019-05-14 11:40:18 +05:30
Kovid Goyal 969ad38858 Merge branch 'staged-install' of https://github.com/eli-schwartz/calibre 2019-05-13 11:16:07 +05:30
Eli Schwartz 1aecd23852 calibre-uninstall: be even more thorough about deleting mime files
Since xdg-mime only cares about basename(filename) and that filename is
an existing file (and we don't know where the installed one is), create
an empty file with the right name and then delete that.
2019-05-12 18:14:42 -04:00
Eli Schwartz 121a5acad0 install: don't create calibre-uninstall for staged installs
The uninstaller is only meant to be used on systems where calibre is
being installed live. For staged installs, it can be assumed that the
same mechanism which takes care of installing files from the staging dir
to live systems, is also able to remove calibre when desired. Usually
this will be a linux package manager.
2019-05-12 18:14:42 -04:00
Eli Schwartz adcc2c5539 install: fix calibre-uninstall relying on the source tree
Injecting the location of the mime_resources file from P() in non-frozen
builds will depend on the mime resource from the source tree rather than
the same location during install time... a source tree which may be
deleted after successful installation. On a frozen build, or when using
'develop' instead of 'install', this path will be the same, and things
just work.

The solution is to add *both* paths, and try to uninstall whichever one
exists.
2019-05-12 18:14:42 -04:00
Eli Schwartz 2a63948440 install: when using a staging root, setup XDG_DATA_DIRS magic
In order for xdg-utils programs to successfully install resources to the
staging root instead of /usr, this variable needs to be set and
additionally some arcane directories must be created that xdg-utils,
astoundingly, does not know how to just gracefully handle.

xdg-mime is simply hopeless as it does not have a --noupdate flag. When
using a staged install, copy it with shutil instead.
2019-05-12 18:14:42 -04:00
Eli Schwartz 9dc1ccfe08 setup: add subcommand to update the version in constants.py from git
This creates an additional variable containing the version number
extracted from a git checkout via `git describe`, and diverts all
human-readable output to use that via get_version.
2019-05-12 02:32:59 -04:00
Kovid Goyal e3c889b10d Merge branch 'py3' of https://github.com/eli-schwartz/calibre 2019-05-12 11:08:35 +05:30
Eli Schwartz dc96af5763 py3: textwrap.dedent requires unicode strings, encode after the fact
Also all the format arguments are unicode strings, *and* in the wisdom
of python3, you can % format a bytestring but not .format() it.
2019-05-12 01:17:13 -04:00
Eli Schwartz aa8efc504d py3: make user auth work; don't mess with encodings for strftime
The Windows-specific hack initially added in commit
8743efbed1 should be able to be removed
now as it is no longer necessary. The python encoding on Windows is sane
in python3.
2019-05-12 01:17:13 -04:00
Eli Schwartz ba0a4992b6 py3: save server preferences using bytestrings 2019-05-12 01:17:13 -04:00
Eli Schwartz 457eea7407 py3: use correct __next__ method
I'm not sure why this is storing a seemingly unused method-wrapper
object, but it needs to use the correctly named one on python2/python3.
2019-05-12 01:17:13 -04:00
Eli Schwartz aa44bf1cd1 py3: hashlib .hexdigest() always returns a hexadecimal string
This is a subset of ascii and cannot be decoded.
2019-05-12 01:17:13 -04:00
Kovid Goyal 2cb8f6b076 py3: misc fixes 2019-05-11 08:12:25 +05:30
David f7b0190b45 Bump supported Kobo firmware version
No changes needed except the supported firmware and database versions.
2019-05-09 21:21:48 +10:00