Skip to content

Commit

Permalink
[skip ci]: black/isort
Browse files Browse the repository at this point in the history
  • Loading branch information
black-isort-bot committed Sep 28, 2024
1 parent 3e8ebb1 commit 98f4ea0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
8 changes: 2 additions & 6 deletions PyPDFForm/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,9 @@ def update_annotation_name(annot: DictionaryObject, val: str) -> None:
"""Patterns to update the name of an annotation."""

if Parent in annot and T not in annot:
annot[NameObject(Parent)][NameObject(T)] = TextStringObject( # noqa
val
)
annot[NameObject(Parent)][NameObject(T)] = TextStringObject(val) # noqa
else:
annot[NameObject(T)] = TextStringObject( # noqa
val
)
annot[NameObject(T)] = TextStringObject(val) # noqa


def update_created_text_field_alignment(annot: DictionaryObject, val: int) -> None:
Expand Down
7 changes: 4 additions & 3 deletions PyPDFForm/template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
"""Contains helpers for generic template related processing."""

from io import BytesIO
from functools import lru_cache
from io import BytesIO
from sys import maxsize
from typing import Dict, List, Tuple, Union, cast

Expand All @@ -11,7 +11,7 @@
from reportlab.pdfbase.pdfmetrics import stringWidth

from .constants import (COMB, DEFAULT_FONT_SIZE, MULTILINE, NEW_LINE_SYMBOL,
WIDGET_TYPES, MaxLen, Rect, Annots)
WIDGET_TYPES, Annots, MaxLen, Rect)
from .font import (adjust_paragraph_font_size, adjust_text_field_font_size,
auto_detect_font, get_text_field_font_color,
get_text_field_font_size, text_field_font_size)
Expand All @@ -21,7 +21,8 @@
from .middleware.text import Text
from .patterns import (BUTTON_STYLE_PATTERNS, DROPDOWN_CHOICE_PATTERNS,
TEXT_FIELD_FLAG_PATTERNS, WIDGET_ALIGNMENT_PATTERNS,
WIDGET_KEY_PATTERNS, WIDGET_TYPE_PATTERNS, update_annotation_name)
WIDGET_KEY_PATTERNS, WIDGET_TYPE_PATTERNS,
update_annotation_name)
from .utils import find_pattern_match, stream_to_io, traverse_pattern
from .watermark import create_watermarks_and_draw

Expand Down
10 changes: 7 additions & 3 deletions PyPDFForm/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .middleware.text import Text
from .template import (build_widgets, dropdown_to_text,
set_character_x_paddings, update_text_field_attributes,
widget_rect_watermarks, update_widget_key)
update_widget_key, widget_rect_watermarks)
from .utils import (get_page_streams, merge_two_pdfs, preview_widget_to_draw,
remove_all_widgets)
from .watermark import create_watermarks_and_draw, merge_watermarks_with_pdf
Expand Down Expand Up @@ -235,11 +235,15 @@ def create_widget(

return self

def update_widget_key(self, old_key: str, new_key: str, index: int = 0) -> PdfWrapper:
def update_widget_key(
self, old_key: str, new_key: str, index: int = 0
) -> PdfWrapper:
"""Updates the key of an existed widget on a PDF form."""

self.__init__(
template=update_widget_key(self.read(), self.widgets, old_key, new_key, index),
template=update_widget_key(
self.read(), self.widgets, old_key, new_key, index
),
global_font=self.global_font,
global_font_size=self.global_font_size,
global_font_color=self.global_font_color,
Expand Down
8 changes: 2 additions & 6 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,7 @@ def test_fill_image(
assert obj.stream == expected


def test_update_radio_key(
template_with_radiobutton_stream, pdf_samples, request
):
def test_update_radio_key(template_with_radiobutton_stream, pdf_samples, request):
expected_path = os.path.join(pdf_samples, "test_update_radio_key.pdf")
with open(expected_path, "rb+") as f:
obj = PdfWrapper(template_with_radiobutton_stream)
Expand All @@ -645,9 +643,7 @@ def test_update_radio_key(
assert obj.preview == expected


def test_update_sejda_key(
sejda_template, pdf_samples, request
):
def test_update_sejda_key(sejda_template, pdf_samples, request):
expected_path = os.path.join(pdf_samples, "test_update_sejda_key.pdf")
with open(expected_path, "rb+") as f:
obj = PdfWrapper(sejda_template)
Expand Down

0 comments on commit 98f4ea0

Please sign in to comment.