Commit graph

69 commits

Author SHA1 Message Date
Ethan Dalool
5bc269fd21 Bump to version 0.0.6. 2020-03-07 16:40:12 -08:00
Ethan Dalool
d928b950ac Add a few metadata methods, just proof-of-concept for now.
I know I don't want to create a full-blown metadata editor, but
a couple methods for basic metadata types and simple adds/removes
could be useful.
2020-03-07 16:37:39 -08:00
Ethan Dalool
a68a69ab99 Improve some docstrings and comments. 2020-03-07 16:36:32 -08:00
Ethan Dalool
88fb94e84e Remove Epub.open, use Epub('path'); support read-only mode.
Instead of Epub.open('path'), now use Epub('path'). This makes the
class more intuitive to use. This also removes the need for the
_original_epub_filepath argument which was simply awkward.
We now support read-only books with the read_only argument. The main
benefit is that we don't need to unzip the epub file, so if you are
going to be reading from epubs but don't need to write, setting
read_only can significately improve speed.
2020-03-07 16:22:38 -08:00
Ethan Dalool
6c63444d27 Use voussoirkit.getpermission. 2020-03-07 13:52:29 -08:00
Ethan Dalool
a73dbba387 Use enumerate(start=1) instead of index += 1. 2020-03-07 13:50:39 -08:00
Ethan Dalool
b99eecf8c5 main should return args.func(args) value. 2020-02-08 16:19:58 -08:00
Ethan Dalool
f17b46d88e Add missing exec summary to main docstring. 2020-02-07 15:11:18 -08:00
Ethan Dalool
c56e0ec13e Fix toc from climbing too high when going from h2 to h4 to h2 etc.
Can you believe there was a bug amidst all these wonderful comments?
The code previously assumed that climbing .parent corresponded to
climbing from hX to hX-1, but this wasn't true when the headers
themselves skipped a level. After creating some toc for h2 then h4,
then encountering a new h2, it would try to climb back two levels to
go from 4 to 2, but actually there was only ever one level between them.
2020-02-04 16:40:14 -08:00
Ethan Dalool
92d595c00d Clarify this comment why the two .parent climbs are separate. 2020-02-04 00:18:25 -08:00
Ethan Dalool
38f432fe6e Improve comments in generate_toc. 2020-02-03 23:12:36 -08:00
Ethan Dalool
81fe7cd47b Use enumerate instead of manual counting, now that headers is exact. 2020-02-03 23:11:22 -08:00
Ethan Dalool
3cfb8030a7 Create a regex pattern for exactly needed headers, no postfiltering. 2020-02-03 23:07:02 -08:00
Ethan Dalool
3e254bddf1 Search for header elements directly instead of scanning descendants. 2020-02-03 22:45:20 -08:00
Ethan Dalool
edbd1e9996 Apply new pathclass.Extension with_dot. 2020-02-02 19:38:24 -08:00
Ethan Dalool
dfb3e9e6ed Split this line up for length reasons. 2020-02-02 19:36:57 -08:00
Ethan Dalool
dcfb2edf85 Add helptext for merge --demote_headers. 2020-02-02 19:36:16 -08:00
Ethan Dalool
30ae76367f Simplify move_nav_to_end by calling spine.index. 2020-02-02 19:35:46 -08:00
Ethan Dalool
7afb9fcb7a Use betterhelp to manage docstrings. 2020-01-30 23:41:42 -08:00
Ethan Dalool
711493a9a8 Bump to version 0.0.5. 2020-01-20 17:57:58 -08:00
Ethan Dalool
f6ab58eb78 Add these ### headers above the helper functions.
I'm trying to decide if I should create function classes to hold
these things, but for now these headers will do.
2020-01-20 17:56:21 -08:00
Ethan Dalool
9411e8cf80 Add function promote_xhtml_headers.
Isn't used anywhere yet but may as well have it to balance out.
2020-01-20 17:55:49 -08:00
Ethan Dalool
59776e5b4e Delete unused MIMETYPE_CONTENT, dupe of MIMETYPE_FILE_TEMPLATE. 2020-01-20 17:43:30 -08:00
Ethan Dalool
1f1b36b173 Assign opf, opf_filepath normally instead of mutating in method. 2020-01-20 17:34:51 -08:00
Ethan Dalool
6386f25cd4 Rearrange the lines in delete_file.
If anything is going to raise an exception here I expect it to be
the item missing from the manifest. In which case let's get that out
of the way early and only delete from disk at the very end.
2020-01-20 17:33:58 -08:00
Ethan Dalool
fd73ecfe2e Add, improve some comments, docstrings, exception texts. 2020-01-20 17:32:47 -08:00
Ethan Dalool
973731f797 Add argument demote_headers to merge. 2020-01-20 17:10:22 -08:00
Ethan Dalool
324689ea3c Replace glob with winglob. 2020-01-20 17:06:27 -08:00
Ethan Dalool
ebde327cce Change email in setup.py. 2020-01-18 22:41:32 -08:00
Ethan Dalool
73d88e12ce Move covercomesfirst's save line back to the argparse func.
Because args doesn't exist in the other function. oops.
2020-01-02 20:13:09 -08:00
Ethan Dalool
96650c2886 During opf normalize, ensure ncx mimetype is correct. 2020-01-02 20:12:08 -08:00
Ethan Dalool
046e8d9394 Bump to version 0.0.4. 2019-12-30 13:53:49 -08:00
Ethan Dalool
636b936539 Add argument number_headerfile to get index in the h1. 2019-12-30 13:53:12 -08:00
Ethan Dalool
fa65157779 When merging, start indices at 1 instead of 0.
When going through the resulting merged book in sigil, it's
confusing to remember that the index prefix on every file is not
actually the number of the book that you're working on, especially
if it's a numbered series of books.
2019-12-30 13:52:08 -08:00
Ethan Dalool
261faf66ae Treat addfile arguments as glob patterns. 2019-12-30 13:50:05 -08:00
Ethan Dalool
f29677d4e0 Add missing generate_toc to help text. 2019-12-30 13:48:37 -08:00
Ethan Dalool
2e070b5fa9 Add step for normalizing the opf file specifically. 2019-12-30 13:48:06 -08:00
Ethan Dalool
0075121607 Bump to version 0.0.3. 2019-09-10 15:25:27 -07:00
Ethan Dalool
1da9d93ec6 Add command exec. 2019-09-08 21:25:35 -07:00
Ethan Dalool
7cbdff827e Fix calculation of merge index, after globbing. 2019-09-08 21:25:10 -07:00
Ethan Dalool
5416276b00 Fix relink behavior when subfolder exists with wrong casing. 2019-09-06 16:54:40 -07:00
Ethan Dalool
70d3bdb2ae Add some docstrings to the interlinking functions. 2019-09-06 16:53:02 -07:00
Ethan Dalool
bddecab51f Recognize mimetype for xpgt. 2019-09-06 16:26:16 -07:00
Ethan Dalool
6d4200eb7c Alphabetize the extension mimetypes and mime directories. 2019-09-06 16:25:57 -07:00
Ethan Dalool
fc07652d16 Add some prototypical validation code. 2019-09-06 15:44:28 -07:00
Ethan Dalool
8763cf6c6c Let merge take glob patterns. 2019-09-06 15:39:26 -07:00
Ethan Dalool
60d9d646a2 Add argument _original_epub_filepath for better messaging later.
Printing the tempdir is not very helpful, so if we need to print
something about this epub file we can use _original_path to get
the epub if it was a .open() or the tempdir if it was .new().
2019-09-06 15:38:51 -07:00
Ethan Dalool
9821125f2c Recognize directory for application/x-font-ttf. 2019-09-06 15:36:51 -07:00
Ethan Dalool
9e020eaa11 Add method generate_toc and commandline command. 2019-08-29 16:44:57 -07:00
Ethan Dalool
365c28bfdb Add more formatters into NCX_TEMPLATE, NAV_TEMPLATE. 2019-08-29 16:34:54 -07:00