Skip to content

Composite

sangfroid.value.Composite(*args, **kwargs) #

Bases: sangfroid.value.value.Value

Source code in sangfroid/value/transformation.py
12
13
14
15
16
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    if self.REQUIRED_KEYS is None:
        raise NotImplementedError()

is_animated property writable #

Whether the value is animated.

our_type property #

The name of the Synfig layer type.

For example, 'circle' or 'group'.

timeline property writable #

Our timeline, showing how our value changes over time.

If we're not animated, the timeline will be empty.

Timeline objects hold no state of their own except a reference back to their parent Value. So this call constructs a new Timeline instance every time.

from_tag(tag) classmethod #

Given a Beautiful Soup tag, returns an instance of an appropriate subclass of Value, representing it.

Parameters:

Name Type Description Default
tag bs4.Tag

the Beautiful Soup tag.

required

Raises:

Type Description
KeyError

if there's no known subclass of Value to represent that tag.

ValueError

if the tag is animated, but not marked with a type.

Source code in sangfroid/value/value.py
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
@classmethod
def from_tag(cls,
             tag: bs4.Tag,
             ) -> Self:
    """
    Given a Beautiful Soup tag, returns an instance of an appropriate
    subclass of `Value`, representing it.

    Args:
        tag: the Beautiful Soup tag.

    Raises:
        KeyError: if there's no known subclass of `Value` to represent
            that tag.
        ValueError: if the tag is animated, but not marked with a type.
    """

    if tag.name==cls.ANIMATED:

        type_name = tag['type']
        if type_name is None:
            raise ValueError(f"Animated values need a type: {tag}")

    else:
        type_name = tag.name

    result_type = cls.handles_type.from_name(name=type_name)
    result = result_type._construct_from(tag)

    return result