1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 16:37:47 +03:00

Minor changes on coding style

This commit is contained in:
Guillaume Ayoub 2024-05-12 11:37:52 +02:00
parent 8efa9a4a6c
commit bac7c501a1
3 changed files with 8 additions and 13 deletions

View File

@ -27,8 +27,7 @@ def rectangle_aabb(matrix, pos_x, pos_y, width, height):
return box_x1, box_y1, box_x2, box_y2
def gather_anchors(box, anchors, links, bookmarks, forms,
parent_matrix=None,
def gather_anchors(box, anchors, links, bookmarks, forms, parent_matrix=None,
parent_form=None):
"""Gather anchors and other data related to specific positions in PDF.
@ -123,8 +122,7 @@ def gather_anchors(box, anchors, links, bookmarks, forms,
anchors[anchor_name] = pos_x, pos_y
for child in box.all_children():
gather_anchors(child, anchors, links, bookmarks, forms, matrix,
parent_form=parent_form)
gather_anchors(child, anchors, links, bookmarks, forms, matrix, parent_form)
def make_page_bookmark_tree(page, skipped_levels, last_by_depth,

View File

@ -76,8 +76,7 @@ class Page:
#: The key ``None`` will contain inputs that are not part of a form.
self.forms = {None: []}
gather_anchors(
page_box, self.anchors, self.links, self.bookmarks, self.forms)
gather_anchors(page_box, self.anchors, self.links, self.bookmarks, self.forms)
self._page_box = page_box
def paint(self, stream, scale=1):

View File

@ -154,9 +154,8 @@ def add_forms(forms, matrix, pdf, page, resources, stream, font_map,
# Checkboxes
width = rectangle[2] - rectangle[0]
height = rectangle[1] - rectangle[3]
checked_stream = _make_checked_stream(resources,
width, height,
compress, style, font_size)
checked_stream = _make_checked_stream(
resources, width, height, compress, style, font_size)
pdf.add_object(checked_stream)
checked = 'checked' in element.attrib
@ -196,9 +195,8 @@ def add_forms(forms, matrix, pdf, page, resources, stream, font_map,
group = radio_groups[form][input_name]
width = rectangle[2] - rectangle[0]
height = rectangle[1] - rectangle[3]
on_stream = _make_checked_stream(resources,
width, height,
compress, style, font_size)
on_stream = _make_checked_stream(
resources, width, height, compress, style, font_size)
checked = 'checked' in element.attrib
field = pydyf.Dictionary({
'Type': '/Annot',
@ -226,7 +224,7 @@ def add_forms(forms, matrix, pdf, page, resources, stream, font_map,
selected_values = []
for option in element:
value = pydyf.String(option.attrib.get('value', ''))
text = pydyf.String(option.text or "")
text = pydyf.String(option.text or '')
options.append(pydyf.Array([value, text]))
if 'selected' in option.attrib:
selected_values.append(value)