Skip to content

Commit

Permalink
PPF-535: adding docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
chinapandaman committed Mar 25, 2024
1 parent 5c3daf1 commit 057681a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions PyPDFForm/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,42 @@


def simple_update_checkbox_value(annot: DictionaryObject) -> None:
"""Patterns to update values for checkbox annotations."""

annot[NameObject(AS)] = NameObject(Yes)


def simple_update_radio_value(annot: DictionaryObject, widget: Radio) -> None:
"""Patterns to update values for radio annotations."""

annot[NameObject(AS)] = NameObject(f"/{widget.value}")


def simple_update_dropdown_value(annot: DictionaryObject, widget: Dropdown) -> None:
"""Patterns to update values for dropdown annotations."""

annot[NameObject(V)] = TextStringObject(widget.choices[widget.value])
annot[NameObject(AP)] = TextStringObject(widget.choices[widget.value])


def simple_update_text_value(annot: DictionaryObject, widget: Text) -> None:
"""Patterns to update values for text annotations."""

annot[NameObject(V)] = TextStringObject(widget.value)
annot[NameObject(AP)] = TextStringObject(widget.value)


def simple_flatten_radio(annot: DictionaryObject) -> None:
"""Patterns to flatten checkbox annotations."""

annot[NameObject(Parent)][NameObject(Ff)] = NumberObject( # noqa
int(annot[NameObject(Parent)].get(NameObject(Ff), 0)) | READ_ONLY # noqa
)


def simple_flatten_generic(annot: DictionaryObject) -> None:
"""Patterns to flatten generic annotations."""

annot[NameObject(Ff)] = NumberObject(
int(annot.get(NameObject(Ff), 0)) | READ_ONLY # noqa
)

0 comments on commit 057681a

Please sign in to comment.