-
Notifications
You must be signed in to change notification settings - Fork 2
/
ebookmaker-pyinstaller.patch
176 lines (150 loc) · 6.61 KB
/
ebookmaker-pyinstaller.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
--- ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/packagers/__init__.py 2020-12-27 15:09:18.381644200 -0800
+++ ./packagers/__init__.py 2020-06-17 17:06:40.168812700 -0700
@@ -18,11 +18,20 @@
import gzip
import zipfile
-from pkg_resources import resource_listdir # pylint: disable=E0611
+from importlib import import_module
from libgutenberg.Logger import debug, info, warning, error
import libgutenberg.GutenbergGlobals as gg
+packagerlist = [
+ "GzipPackager",
+ "HTMLPackager",
+ "PDFPackager",
+ "PushPackager",
+ "RSTPackager",
+ "TxtPackager",
+]
+
GZIP_EXTENSION = '.gzip'
class BasePackager (object):
@@ -157,16 +166,12 @@
def load_packagers (cls):
""" Load the packagers in the packagers directory. """
- for fn in resource_listdir ('ebookmaker.packagers', ''):
- modulename, ext = os.path.splitext (fn)
- if ext == '.py':
- if modulename.endswith ('Packager'):
- module = __import__ ('ebookmaker.packagers.' + modulename,
- fromlist = [modulename])
- debug ("Loading packager type: %s from module: %s for formats: %s" % (
- module.TYPE, modulename, ', '.join (module.FORMATS)))
- for format_ in module.FORMATS:
- cls.packagers[cls.mk_key (module.TYPE, format_)] = module
+ for modulename in packagerlist:
+ module = import_module("ebookmaker.packagers." + modulename)
+ debug ("Loading packager type: %s from module: %s for formats: %s" % (
+ module.TYPE, modulename, ', '.join (module.FORMATS)))
+ for format_ in module.FORMATS:
+ cls.packagers[cls.mk_key (module.TYPE, format_)] = module
return cls.packagers.keys ()
diff -r -u ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/ParserFactory.py ./ParserFactory.py
--- ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/ParserFactory.py 2020-12-27 15:09:18.357809500 -0800
+++ ./ParserFactory.py 2020-06-17 16:28:56.358764100 -0700
@@ -18,7 +18,7 @@
from six.moves import urllib
import six
-from pkg_resources import resource_listdir, resource_stream # pylint: disable=E0611
+from pkg_resources import resource_stream # pylint: disable=E0611
import requests
from libgutenberg.Logger import critical, debug, error, info
@@ -27,21 +27,22 @@
from ebookmaker.Version import VERSION
from ebookmaker import parsers
+from importlib import import_module
+from ebookmaker.parsers import parserlist
+
+
options = Options()
parser_modules = {}
def load_parsers():
""" See what types we can parse. """
- for fn in resource_listdir('ebookmaker.parsers', ''):
- modulename, ext = os.path.splitext(fn)
- if ext == '.py':
- if modulename.endswith('Parser'):
- module = __import__('ebookmaker.parsers.' + modulename, fromlist=[modulename])
- debug("Loading parser from module: %s for mediatypes: %s" % (
- modulename, ', '.join(module.mediatypes)))
- for mediatype in module.mediatypes:
- parser_modules[mediatype] = module
+ for modulename in parserlist:
+ module = import_module("ebookmaker.parsers." + modulename)
+ debug("Loading parser from module: %s for mediatypes: %s" % (
+ modulename, ', '.join(module.mediatypes)))
+ for mediatype in module.mediatypes:
+ parser_modules[mediatype] = module
return parser_modules.keys()
diff -r -u ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/parsers/__init__.py ./parsers/__init__.py
--- ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/parsers/__init__.py 2020-12-27 15:09:18.397267800 -0800
+++ ./parsers/__init__.py 2020-06-17 16:29:19.533619300 -0700
@@ -31,6 +31,17 @@
from ebookmaker.CommonCode import Options
+# explicitly define the set of available parsers in this directory
+parserlist = [
+ "AuxParser",
+ "CSSParser",
+ "GutenbergTextParser",
+ "HTMLParser",
+ "ImageParser",
+ "RSTParser",
+ "WrapperParser",
+]
+
options = Options()
BROKEN = 'resource://ebookmaker.parsers/broken.png'
diff -r -u ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/WriterFactory.py ./WriterFactory.py
--- ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/WriterFactory.py 2020-12-27 15:09:18.362809400 -0800
+++ ./WriterFactory.py 2020-06-17 16:57:30.094866100 -0700
@@ -16,7 +16,8 @@
import os.path
-from pkg_resources import resource_listdir # pylint: disable=E0611
+from importlib import import_module
+from ebookmaker.writers import writerlist
from libgutenberg.Logger import error, debug
from ebookmaker.CommonCode import Options
@@ -28,19 +29,17 @@
def __load_writers_from (package_name):
""" See what types we can write. """
- for fn in resource_listdir (package_name, ''):
- modulename, ext = os.path.splitext (fn)
- if ext == '.py' and modulename.endswith ('Writer'):
- type_ = modulename.lower ().replace ('writer', '')
- try:
- debug ("Loading writer type %s from module %s" % (type_, modulename))
- module = __import__ (package_name + '.' + modulename, fromlist = [modulename])
- writers[type_] = module
- except ImportError as what:
- error (
- "Could not load writer type %s from module %s. %s" %
- (type_, modulename, what)
- )
+ for modulename in writerlist:
+ type_ = modulename.lower ().replace ('writer', '')
+ try:
+ module = import_module("ebookmaker.writers." + modulename)
+ debug ("Loading writer type %s from module %s" % (type_, modulename))
+ writers[type_] = module
+ except ImportError as what:
+ error (
+ "Could not load writer type %s from module %s. %s" %
+ (type_, modulename, what)
+ )
def load_writers ():
diff -r -u ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/writers/__init__.py ./writers/__init__.py
--- ../../../../ebm_builder-GUvbroJI/Lib/site-packages/ebookmaker/writers/__init__.py 2020-12-27 15:09:18.412937600 -0800
+++ ./writers/__init__.py 2020-06-17 16:53:26.250041000 -0700
@@ -30,6 +30,16 @@
from ebookmaker.CommonCode import Options
from ebookmaker.Version import VERSION, GENERATOR
+writerlist = [
+ "EpubWriter",
+ "Epub3Writer",
+ "HTMLWriter",
+ "KindleWriter",
+ "PDFWriter",
+ "PicsDirWriter",
+ "RSTWriter",
+ "TxtWriter",
+]
options = Options()