🔍 Code Extractor

class GraphicType

Maturity: 43

An enumeration class that defines the types of graphics that can be generated in the system.

File:
/tf/active/vicechatdev/e-ink-llm/graphics_generator.py
Lines:
26 - 31
Complexity:
simple

Purpose

GraphicType is an Enum class that provides a standardized set of constants representing different categories of graphics that can be created. It serves as a type-safe way to specify and validate graphic types throughout the application, ensuring consistency when working with chart generation, diagram creation, illustrations, and sketches. This enum is typically used as a parameter in graphic generation functions or methods to determine the type of visual output to produce.

Source Code

class GraphicType(Enum):
    """Types of graphics that can be generated"""
    CHART = "chart"
    DIAGRAM = "diagram" 
    ILLUSTRATION = "illustration"
    SKETCH = "sketch"

Parameters

Name Type Default Kind
bases Enum -

Parameter Details

bases: Inherits from Enum base class, which provides enumeration functionality. No custom __init__ parameters are defined for this enum.

Return Value

Instantiating or accessing GraphicType members returns a GraphicType enum instance. Each member has a name (e.g., 'CHART') and a value (e.g., 'chart'). The value property returns the string representation of the graphic type.

Class Interface

Attributes

Name Type Description Scope
CHART GraphicType Represents chart-type graphics (value: 'chart') class
DIAGRAM GraphicType Represents diagram-type graphics (value: 'diagram') class
ILLUSTRATION GraphicType Represents illustration-type graphics (value: 'illustration') class
SKETCH GraphicType Represents sketch-type graphics (value: 'sketch') class

Dependencies

  • enum

Required Imports

from enum import Enum

Usage Example

from enum import Enum

class GraphicType(Enum):
    CHART = "chart"
    DIAGRAM = "diagram"
    ILLUSTRATION = "illustration"
    SKETCH = "sketch"

# Access enum members
graphic_type = GraphicType.CHART
print(graphic_type)  # GraphicType.CHART
print(graphic_type.value)  # "chart"
print(graphic_type.name)  # "CHART"

# Compare enum members
if graphic_type == GraphicType.CHART:
    print("This is a chart type")

# Get enum by value
type_from_string = GraphicType("diagram")
print(type_from_string)  # GraphicType.DIAGRAM

# Iterate over all types
for gtype in GraphicType:
    print(f"{gtype.name}: {gtype.value}")

# Use in function signatures
def generate_graphic(graphic_type: GraphicType) -> None:
    if graphic_type == GraphicType.CHART:
        print("Generating chart...")
    elif graphic_type == GraphicType.DIAGRAM:
        print("Generating diagram...")

Best Practices

  • Use GraphicType members directly (e.g., GraphicType.CHART) rather than string literals to ensure type safety
  • When accepting graphic types as parameters, use type hints with GraphicType to enable IDE autocomplete and type checking
  • Access the string value using the .value property when needed for serialization or API calls
  • Use GraphicType(string_value) to convert string values back to enum members, which will raise ValueError if the string is invalid
  • Enums are immutable and singleton - each member is instantiated only once
  • Compare enum members using == or 'is' operators, both work correctly
  • Use 'in' operator to check membership: if some_value in GraphicType._value2member_map_
  • Iterate over all graphic types using: for gtype in GraphicType

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class AnalysisType 66.5% similar

    An enumeration class that defines standardized types of statistical analyses available in the system.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class SectionType 62.3% similar

    An enumeration class that defines the types of sections that can be added to documents, providing standardized section type identifiers.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class GraphicSpec 59.8% similar

    A dataclass that defines the specification for a graphic to be generated, including its type, description, parameters, style preferences, and optional image data.

    From: /tf/active/vicechatdev/e-ink-llm/graphics_generator.py
  • class GraphicsGenerator 59.2% similar

    GraphicsGenerator is a coordinator class that orchestrates the generation of different types of graphics (charts, diagrams, illustrations, and sketches) by delegating to specialized generator classes.

    From: /tf/active/vicechatdev/e-ink-llm/graphics_generator.py
  • class CommentType 58.4% similar

    An enumeration class that defines standardized types for comments used in review and approval workflows.

    From: /tf/active/vicechatdev/CDocs single class/models/workflow_base.py
← Back to Browse