Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22faae5

Browse files
committed
whitespace
1 parent 30c64dd commit 22faae5

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

xhtml2pdf/document.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def pisaErrorDocument(dest, c):
3939

4040
return pisaDocument(out.getvalue(), dest, raise_exception=False)
4141

42-
def pisaStory(src, path = None, link_callback = None, debug = 0, default_css = None,
43-
xhtml = False, encoding = None, context = None, xml_output = None,
42+
def pisaStory(src, path=None, link_callback=None, debug=0, default_css=None,
43+
xhtml=False, encoding=None, context=None, xml_output=None,
4444
**kw):
4545

4646
# Prepare Context
@@ -67,7 +67,7 @@ def pisaStory(src, path = None, link_callback = None, debug = 0, default_css = N
6767

6868
def pisaDocument(src, dest=None, path=None, link_callback=None, debug=0,
6969
default_css=None, xhtml=False, encoding=None, xml_output=None,
70-
raise_exception=True, capacity=100 * 1024, **kw):
70+
raise_exception=True, capacity=100*1024, **kw):
7171

7272
log.debug("pisaDocument options:\n src = %r\n dest = %r\n path = %r\n link_callback = %r\n xhtml = %r",
7373
src,
@@ -81,21 +81,22 @@ def pisaDocument(src, dest=None, path=None, link_callback=None, debug=0,
8181
context.pathCallback = link_callback
8282

8383
# Build story
84-
context = pisaStory(src, path, link_callback, debug, default_css, xhtml, encoding,
85-
context=context, xml_output=xml_output)
84+
context = pisaStory(src, path, link_callback, debug, default_css, xhtml,
85+
encoding, context=context, xml_output=xml_output)
8686

8787
# Buffer PDF into memory
8888
out = pisaTempFile(capacity=context.capacity)
8989

9090
doc = PmlBaseDoc(
9191
out,
92-
pagesize = context.pageSize,
93-
author = context.meta["author"].strip(),
94-
subject = context.meta["subject"].strip(),
95-
keywords = [x.strip() for x in context.meta["keywords"].strip().split(",") if x],
96-
title = context.meta["title"].strip(),
97-
showBoundary = 0,
98-
allowSplitting = 1)
92+
pagesize=context.pageSize,
93+
author=context.meta["author"].strip(),
94+
subject=context.meta["subject"].strip(),
95+
keywords=[x.strip() for x in
96+
context.meta["keywords"].strip().split(",") if x],
97+
title=context.meta["title"].strip(),
98+
showBoundary=0,
99+
allowSplitting=1)
99100

100101
# Prepare templates and their frames
101102
if context.templateList.has_key("body"):
@@ -107,11 +108,11 @@ def pisaDocument(src, dest=None, path=None, link_callback=None, debug=0,
107108
id="body",
108109
frames=[
109110
Frame(x, y, w, h,
110-
id = "body",
111-
leftPadding = 0,
112-
rightPadding = 0,
113-
bottomPadding = 0,
114-
topPadding = 0)],
111+
id="body",
112+
leftPadding=0,
113+
rightPadding=0,
114+
bottomPadding=0,
115+
topPadding=0)],
115116
pagesize = context.pageSize)
116117

117118
doc.addPageTemplates([body] + context.templateList.values())
@@ -133,27 +134,27 @@ def _page_counter(page_no):
133134

134135
# Add watermarks
135136
if pyPdf:
136-
137137
for bgouter in context.pisaBackgroundList:
138-
139138
# If we have at least one background, then lets do it
140139
if bgouter:
141-
142140
istream = out
143141

144142
output = pyPdf.PdfFileWriter()
145143
input1 = pyPdf.PdfFileReader(istream)
146144
ctr = 0
147-
#TODO: Why do we loop over the same list again? see bgouter at line 137
145+
# TODO: Why do we loop over the same list again?
146+
# see bgouter at line 137
148147
for bg in context.pisaBackgroundList:
149148
page = input1.getPage(ctr)
150-
if bg and not bg.notFound() and (bg.mimetype=="application/pdf"):
149+
if (bg and not bg.notFound()
150+
and (bg.mimetype=="application/pdf")):
151151
bginput = pyPdf.PdfFileReader(bg.getFile())
152152
pagebg = bginput.getPage(0)
153153
pagebg.mergePage(page)
154154
page = pagebg
155155
else:
156-
log.warn(context.warning("Background PDF %s doesn't exist.", bg))
156+
log.warn(context.warning(
157+
"Background PDF %s doesn't exist.", bg))
157158
output.addPage(page)
158159
ctr += 1
159160
out = pisaTempFile(capacity=context.capacity)

0 commit comments

Comments
 (0)