Module pysect.config.config

Expand source code
from ..printer.printer import Printer
from ..filament.filament import Filament
from ..slice.slice import Slice

import pyboiler.generic as generic


class Config(generic.slot_storage):

    __slots__ = ("printers", "filaments", "slices", "selected")

    def __init__(self):
        self.printers: dict[str, Printer] = {}
        self.filaments: dict[str, Filament] = {}
        self.slices: dict[str, Slice] = {}
        self.selected: dict[str, str] = {"printer": "", "filament": "", "slice": ""}

    def printer(self) -> Printer:
        return self.printers[self.selected["printer"]]

    def filament(self) -> Filament:
        return self.filaments[self.selected["filament"]]

    def slice(self) -> Slice:
        return self.slices[self.selected["slice"]]

    def add_printer(self, printer: Printer):
        self.printers[printer.name] = printer
        self.selected["printer"] = printer.name

    def add_filament(self, filament: Filament):
        self.filaments[filament.name] = filament
        self.selected["filament"] = filament.name

    def add_slice(self, slice: Slice):
        self.slices[slice.name] = slice
        self.selected["slice"] = slice.name

Classes

class Config

Children of this class must have slots defined

Expand source code
class Config(generic.slot_storage):

    __slots__ = ("printers", "filaments", "slices", "selected")

    def __init__(self):
        self.printers: dict[str, Printer] = {}
        self.filaments: dict[str, Filament] = {}
        self.slices: dict[str, Slice] = {}
        self.selected: dict[str, str] = {"printer": "", "filament": "", "slice": ""}

    def printer(self) -> Printer:
        return self.printers[self.selected["printer"]]

    def filament(self) -> Filament:
        return self.filaments[self.selected["filament"]]

    def slice(self) -> Slice:
        return self.slices[self.selected["slice"]]

    def add_printer(self, printer: Printer):
        self.printers[printer.name] = printer
        self.selected["printer"] = printer.name

    def add_filament(self, filament: Filament):
        self.filaments[filament.name] = filament
        self.selected["filament"] = filament.name

    def add_slice(self, slice: Slice):
        self.slices[slice.name] = slice
        self.selected["slice"] = slice.name

Ancestors

  • pyboiler.generic.slot_storage
  • pyboiler.generic.pyboiler_generic

Instance variables

var filaments

Return an attribute of instance, which is of type owner.

var printers

Return an attribute of instance, which is of type owner.

var selected

Return an attribute of instance, which is of type owner.

var slices

Return an attribute of instance, which is of type owner.

Methods

def add_filament(self, filament: Filament)
Expand source code
def add_filament(self, filament: Filament):
    self.filaments[filament.name] = filament
    self.selected["filament"] = filament.name
def add_printer(self, printer: Printer)
Expand source code
def add_printer(self, printer: Printer):
    self.printers[printer.name] = printer
    self.selected["printer"] = printer.name
def add_slice(self, slice: Slice)
Expand source code
def add_slice(self, slice: Slice):
    self.slices[slice.name] = slice
    self.selected["slice"] = slice.name
def filament(self) ‑> Filament
Expand source code
def filament(self) -> Filament:
    return self.filaments[self.selected["filament"]]
def printer(self) ‑> Printer
Expand source code
def printer(self) -> Printer:
    return self.printers[self.selected["printer"]]
def slice(self) ‑> Slice
Expand source code
def slice(self) -> Slice:
    return self.slices[self.selected["slice"]]