Skip to content

Commit 97cc3ac

Browse files
committed
🐛 Fixes verbose checks and PDF read/write
1 parent 29587c2 commit 97cc3ac

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

inject_javascript/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ def return_pdf_data(self, pdf_path = None):
5151
## Setup output data object and load source PDF data
5252
writable_pdf_data = PdfFileWriter()
5353
with open(pdf_path, 'rb') as fb:
54-
# source_pdf_data = PdfFileReader(open(pdf_path, 'rb'))
5554
source_pdf_data = PdfFileReader(fb)
55+
## Load source PDF into output object
56+
for i in range(source_pdf_data.getNumPages()):
57+
writable_pdf_data.addPage(source_pdf_data.getPage(i))
5658

57-
## Load source PDF into output object
58-
for i in range(source_pdf_data.getNumPages()):
59-
writable_pdf_data.addPage(source_pdf_data.getPage(i))
60-
61-
if self.verbose > 0:
59+
if self.verbose and self.verbose > 0:
6260
notice('finished loading data into output object from: {0}'.format(pdf_path))
6361

6462
## Return output object to calling process
@@ -79,7 +77,7 @@ def return_js_data(self, js_path = None):
7977
else:
8078
message = 'finished loading JavaScript data from: '
8179

82-
if self.verbose > 0:
80+
if self.verbose and self.verbose > 0:
8381
notice(message + js_path)
8482

8583
return js_data
@@ -113,7 +111,7 @@ def save_combined_data(self, pdf_data = None, js_data = None, pdf_path = None, s
113111
error('Unable to remove temp path: {0}'.format(tmp_path))
114112

115113
if path_exists(save_path) is True:
116-
if self.verbose > 0:
114+
if self.verbose and self.verbose > 0:
117115
notice(message + save_path)
118116
return save_path
119117
else:

inject_javascript/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def main():
8787
js_path = args.get('js_path'),
8888
save_path = args.get('save_path'))
8989

90-
if verbose > 0:
90+
if verbose and verbose > 0:
9191
print('Enhanced file maybe found at: {0}'.format(injected))
9292

9393
if args.get('watch') is True:

0 commit comments

Comments
 (0)