Skip to content

Background Image

CLASS DESCRIPTION
BackgroundImage

Python interface for Planka Background Images

BackgroundImage

BackgroundImage(schema: Schema, session: Planka)

Bases: PlankaModel[BackgroundImage]

Python interface for Planka Background Images

METHOD DESCRIPTION
copy

Create a deepcopy of the model and its associated schema.

delete

Delete the BackgroundImage

diff

Get a schema diff between two model schemas.

download

Get bytes for the full image

download_thumbnails

Get byte iterators for all thumbnails

ATTRIBUTE DESCRIPTION
__formatter__

Formatter func that allows overriding str behavior for models

TYPE: ModelFormatter[Self]

created_at

When the BackgroundImage was created

TYPE: datetime

project

The Project the BackgroundImage belongs to

TYPE: Project

size

The size of the BackgroundImage in bytes

TYPE: int

thumbnails

URLs for different thumbnail sizes of the background image

TYPE: dict[str, str]

updated_at

When the BackgroundImage was last updated

TYPE: datetime

url

The URL to access the BackgroundImage

TYPE: str

Source code in src/plankapy/v2/models/_base.py
30
31
32
33
34
35
36
def __init__(self, schema: Schema, session: Planka) -> None:
    self._schema = schema
    self.session = session
    self.endpoints = session.endpoints
    self.client = session.client
    self.current_role = session.current_role
    self.current_id = session.current_id

__formatter__ class-attribute instance-attribute

__formatter__: ModelFormatter[Self] = DEFAULT_FORMATTER

Formatter func that allows overriding str behavior for models

created_at property

created_at: datetime

When the BackgroundImage was created

project property

project: Project

The Project the BackgroundImage belongs to

size property

size: int

The size of the BackgroundImage in bytes

thumbnails property

thumbnails: dict[str, str]

URLs for different thumbnail sizes of the background image

updated_at property

updated_at: datetime

When the BackgroundImage was last updated

url property

url: str

The URL to access the BackgroundImage

copy

copy() -> Self

Create a deepcopy of the model and its associated schema.

Note

Since the endpoints for both instances of the Model are the same, any calls to update will restore the state and bring both copies into sync. copies like this are meant more for comparing changes when running a sync or update/assignemnt operation.

Example:

    >>> card_copy = card.copy()
    >>> card.name = 'Updated Name'
    >>> card_copy.name
    'Original Name'
    >>> card.name
    'Updated Name'
    >>> # This update may have had side effects
    >>> print(card_copy.diff(card))
    {'name': ('Original Name', 'Updated Name'), 'updatedAt': ('...2:00pm', '...2:45pm'), ...}

Source code in src/plankapy/v2/models/_base.py
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def copy(self) -> Self:
    """Create a deepcopy of the model and its associated schema.

    Note:
        Since the endpoints for both instances of the Model are the same, any 
        calls to update will restore the state and bring both copies into sync. 
        copies like this are meant more for comparing changes when running a sync 
        or update/assignemnt operation.

    Example:
    ```python
        >>> card_copy = card.copy()
        >>> card.name = 'Updated Name'
        >>> card_copy.name
        'Original Name'
        >>> card.name
        'Updated Name'
        >>> # This update may have had side effects
        >>> print(card_copy.diff(card))
        {'name': ('Original Name', 'Updated Name'), 'updatedAt': ('...2:00pm', '...2:45pm'), ...}
    ```
    """
    return copy.deepcopy(self)

delete

delete()

Delete the BackgroundImage

Source code in src/plankapy/v2/models/background_image.py
72
73
74
def delete(self):
    """Delete the BackgroundImage"""
    return self.endpoints.deleteBackgroundImage(self.id)

diff

diff(other: PlankaModel[Schema]) -> Diff

Get a schema diff between two model schemas.

Note

Only matching keys are diffed. Any schema keys that are not in the source schema will not be checked in the target schema

Source code in src/plankapy/v2/models/_base.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def diff(self, other: PlankaModel[Schema]) -> Diff:
    """Get a schema diff between two model schemas.

    Note:
        Only matching keys are diffed. Any schema keys that are not in the source schema 
        will not be checked in the target schema
    """
    return {
        k: (source, delta) 
        for k, source in self.schema
        if k in other.schema
        and (delta := other.schema[k]) 
        and delta != source
    }

download

download() -> Iterator[bytes]

Get bytes for the full image

RETURNS DESCRIPTION
Iterator[bytes]

A byte iterator for the full image

Source code in src/plankapy/v2/models/background_image.py
55
56
57
58
59
60
61
def download(self) -> Iterator[bytes]:
    """Get bytes for the full image

    Returns:
        (Iterator[bytes]): A byte iterator for the full image
    """
    return self.client.get(self.url).iter_bytes()

download_thumbnails

download_thumbnails() -> Generator[tuple[str, Iterator[bytes]]]

Get byte iterators for all thumbnails

YIELDS DESCRIPTION
tuple[str, Iterator[bytes]]

A tuple containing the size key and the thumbnail byte iterator

Source code in src/plankapy/v2/models/background_image.py
63
64
65
66
67
68
69
70
def download_thumbnails(self) -> Generator[tuple[str, Iterator[bytes]]]:
    """Get byte iterators for all thumbnails

    Yields:
        (tuple[str, Iterator[bytes]]): A tuple containing the size key and the thumbnail byte iterator
    """
    for size, url in self.thumbnails.items():
        yield size, self.client.get(url).iter_bytes()