Skip to content

Base

BaseDefinition dataclass

BaseDefinition()

Base class for all profiles classes (Definition class in profiles files)

BaseStandard

Bases: Enum

Base class for all standards variants (Standard.<class> in profile files)

data_sources staticmethod

data_sources()

Optional list of references where the data about the standard or the variants can be found

Source code in src/bd_beams_and_bars/profiles/base.py
@staticmethod
def data_sources() -> list[str]:
    """Optional list of references where the data about the standard or the variants can be found"""
    return []

human_name staticmethod

human_name()

Human-readable name for this standard

Source code in src/bd_beams_and_bars/profiles/base.py
@staticmethod
def human_name() -> str:
    """Human-readable name for this standard"""
    raise NotImplementedError

matter staticmethod

matter()

Matter reference (e.g.: S235JR)

Source code in src/bd_beams_and_bars/profiles/base.py
@staticmethod
def matter() -> str:
    """Matter reference (e.g.: S235JR)"""
    raise NotImplementedError

standards staticmethod

standards()

Standards list

Source code in src/bd_beams_and_bars/profiles/base.py
@staticmethod
def standards() -> str:
    """Standards list"""
    raise NotImplementedError

Helpers

Helper methods used in the library

T class-attribute instance-attribute

T = TypeVar('T')

Represents a _BaseSize subclass: a size variant from a profile file

definition_from staticmethod

definition_from(value, definition_class, size_classes)

Parameters:

Name Type Description Default
value T | BaseStandard

Value to check

required
definition_class type[T]

Allowed definition class

required
size_classes list[type[BaseStandard]]

Allowed size classes

required

Returns:

Name Type Description
T T

Definition to use in section and beams

Raises:

Type Description
BaseException

when input value is unsupported (not a definition_class or not included in size_classes)

Source code in src/bd_beams_and_bars/profiles/base.py
@staticmethod
def definition_from(value: T | BaseStandard, definition_class: type[T], size_classes: list[type[BaseStandard]]) -> T:
    """
    Args:
        value (T | BaseStandard):                Value to check
        definition_class (type[T]):              Allowed definition class
        size_classes (list[type[BaseStandard]]): Allowed size classes

    Returns:
        T: Definition to use in section and beams

    Raises:
        BaseException: when input value is unsupported (not a definition_class or not included in size_classes)
    """
    if isinstance(value, definition_class):
        return value

    for klass in size_classes:
        if isinstance(value, klass):
            return value.value

    raise BaseException(f"Invalid type {type(value)} for section. Supported types are {definition_class} and {size_classes}")