Skip to content

Angle

sangfroid.value.Angle(*args) #

Bases: sangfroid.value.simple.Simple

Values representing angles, which are based on floats.

The angles are measured in degrees.

Puzzled

This doesn't seem like it should be a Simple.

Source code in sangfroid/value/value.py
16
17
18
19
20
21
22
23
24
25
26
27
def __init__(self, *args):

    if len(args)==1 and isinstance(args[0], bs4.element.Tag):
        self._tag = args[0]
    else:
        self._tag = self._get_empty_tag()
        if len(args)==1:
            self.value = args[0]
        else:
            self.value = args

    assert self._tag is not None

is_animated property writable #

Whether the value is animated.

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