Module osbot_utils.graphs.mermaid.models.Mermaid__Node__Shape

Expand source code
from __future__ import annotations
from enum import Enum


class Mermaid__Node__Shape(Enum):
    asymmetric          = ('>'  ,  ']'  )        # Asymmetric
    circle              = ('((' ,  '))' )        # Circle, used for endpoints or start/end points
    cylindrical         = ('[(' ,  ')]' )        # Cylindrical
    default             = ('['  ,  ']'  )        # Rectangle
    double_circle       = ('(((',  ')))')        # Double Circle
    round_edges         = ('('  ,  ')'  )        # Stadium shape, used for processes or operations
    rhombus             = ('{'  ,  '}'  )        # Rhombus, often synonymous with diamond in diagramming contexts
    hexagon             = ('{{' ,  '}}' )        # Hexagon, used for preparation or complex processing
    parallelogram       = ('[/' ,  '/]' )        # Parallelogram, used for input/output
    parallelogram_alt   = ('[\\',  '\\]')        # Alternative parallelogram, also used for input/output
    rectangle           = ('['  ,  ']'  )        # Rectangle, used for process
    stadium             = ('([' ,  '])' )        # Stadium
    subroutine          = ('[[',   ']]' )        # Subroutine
    trapezoid           = ('[/' , r'\]' )        # Trapezoid, used for manual operations             # todo: figure out why this line is throwing the compile error of: SyntaxWarning: invalid escape sequence '\]'
    trapezoid_alt       = ('[\\',  '/]' )        # Inverted trapezoid, also used for manual operations

    @staticmethod
    def get_shape(value = None) -> Mermaid__Node__Shape:
        if isinstance(value, Mermaid__Node__Shape):
            return value
        if type(value) is str:
            for shape in Mermaid__Node__Shape:
                if value == shape.name:
                    return shape
        return Mermaid__Node__Shape.default

Classes

class Mermaid__Node__Shape (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code
class Mermaid__Node__Shape(Enum):
    asymmetric          = ('>'  ,  ']'  )        # Asymmetric
    circle              = ('((' ,  '))' )        # Circle, used for endpoints or start/end points
    cylindrical         = ('[(' ,  ')]' )        # Cylindrical
    default             = ('['  ,  ']'  )        # Rectangle
    double_circle       = ('(((',  ')))')        # Double Circle
    round_edges         = ('('  ,  ')'  )        # Stadium shape, used for processes or operations
    rhombus             = ('{'  ,  '}'  )        # Rhombus, often synonymous with diamond in diagramming contexts
    hexagon             = ('{{' ,  '}}' )        # Hexagon, used for preparation or complex processing
    parallelogram       = ('[/' ,  '/]' )        # Parallelogram, used for input/output
    parallelogram_alt   = ('[\\',  '\\]')        # Alternative parallelogram, also used for input/output
    rectangle           = ('['  ,  ']'  )        # Rectangle, used for process
    stadium             = ('([' ,  '])' )        # Stadium
    subroutine          = ('[[',   ']]' )        # Subroutine
    trapezoid           = ('[/' , r'\]' )        # Trapezoid, used for manual operations             # todo: figure out why this line is throwing the compile error of: SyntaxWarning: invalid escape sequence '\]'
    trapezoid_alt       = ('[\\',  '/]' )        # Inverted trapezoid, also used for manual operations

    @staticmethod
    def get_shape(value = None) -> Mermaid__Node__Shape:
        if isinstance(value, Mermaid__Node__Shape):
            return value
        if type(value) is str:
            for shape in Mermaid__Node__Shape:
                if value == shape.name:
                    return shape
        return Mermaid__Node__Shape.default

Ancestors

  • enum.Enum

Class variables

var asymmetric
var circle
var cylindrical
var default
var double_circle
var hexagon
var parallelogram
var parallelogram_alt
var rectangle
var rhombus
var round_edges
var stadium
var subroutine
var trapezoid
var trapezoid_alt

Static methods

def get_shape(value=None) ‑> Mermaid__Node__Shape
Expand source code
@staticmethod
def get_shape(value = None) -> Mermaid__Node__Shape:
    if isinstance(value, Mermaid__Node__Shape):
        return value
    if type(value) is str:
        for shape in Mermaid__Node__Shape:
            if value == shape.name:
                return shape
    return Mermaid__Node__Shape.default