chore: prune boilerplate and refresh stale docs
- Remove 257 redundant per-definition comment stubs across the package - Drop dead nonlocal declarations in autoslicer_detection.py - Document the swapped flag and swap_left_right in architecture docs - Remove unsupported 'legacy override' claims from autotune/runtime docs
This commit is contained in:
parent
929c828438
commit
426a18f342
24 changed files with 5 additions and 264 deletions
|
|
@ -2,9 +2,7 @@ import json
|
|||
import os
|
||||
|
||||
|
||||
# Parameter: class definition for ScanSlicer behavior.
|
||||
class Parameter:
|
||||
# __init__: function definition for ScanSlicer behavior.
|
||||
def __init__(self, default, min, max, step, label, label_secondary=""):
|
||||
self.default = default
|
||||
self.min = min
|
||||
|
|
@ -14,11 +12,9 @@ class Parameter:
|
|||
self.label_secondary = label_secondary
|
||||
self.value = default
|
||||
|
||||
# get: function definition for ScanSlicer behavior.
|
||||
def get(self):
|
||||
return self.value
|
||||
|
||||
# set: function definition for ScanSlicer behavior.
|
||||
def set(self, value):
|
||||
int_value = int(value)
|
||||
if int_value < self.min:
|
||||
|
|
@ -27,12 +23,10 @@ class Parameter:
|
|||
int_value = self.max
|
||||
self.value = int_value
|
||||
|
||||
# reset: function definition for ScanSlicer behavior.
|
||||
def reset(self):
|
||||
self.value = self.default
|
||||
|
||||
|
||||
# AutoslicerParams: class definition for ScanSlicer behavior.
|
||||
class AutoslicerParams:
|
||||
SPECS = [
|
||||
("detect_pipeline", 0, 0, 1, 1, "Edge Detector", "(0=Threshold, 1=Canny)"),
|
||||
|
|
@ -59,7 +53,6 @@ class AutoslicerParams:
|
|||
]
|
||||
PRESETS = {}
|
||||
|
||||
# __init__: function definition for ScanSlicer behavior.
|
||||
def __init__(self):
|
||||
for spec in self.SPECS:
|
||||
if len(spec) == 6:
|
||||
|
|
@ -78,13 +71,11 @@ class AutoslicerParams:
|
|||
self.user_presets = self.load_user_presets()
|
||||
self.load_user_defaults()
|
||||
|
||||
# items: function definition for ScanSlicer behavior.
|
||||
def items(self):
|
||||
for name, *_ in self.SPECS:
|
||||
yield name, getattr(self, name)
|
||||
|
||||
@classmethod
|
||||
# defaults_path: function definition for ScanSlicer behavior.
|
||||
def defaults_path(cls):
|
||||
override = os.environ.get("SCANSLICER_DEFAULTS_PATH")
|
||||
if override:
|
||||
|
|
@ -99,7 +90,6 @@ class AutoslicerParams:
|
|||
return os.path.join(config_home, "scanslicer", "defaults.json")
|
||||
|
||||
@classmethod
|
||||
# presets_path: function definition for ScanSlicer behavior.
|
||||
def presets_path(cls):
|
||||
override = os.environ.get("SCANSLICER_PRESETS_PATH")
|
||||
if override:
|
||||
|
|
@ -113,11 +103,9 @@ class AutoslicerParams:
|
|||
config_home = os.path.join(os.path.expanduser("~"), ".config")
|
||||
return os.path.join(config_home, "scanslicer", "presets.json")
|
||||
|
||||
# to_dict: function definition for ScanSlicer behavior.
|
||||
def to_dict(self):
|
||||
return {name: parameter.get() for name, parameter in self.items()}
|
||||
|
||||
# apply_values: function definition for ScanSlicer behavior.
|
||||
def apply_values(self, values):
|
||||
if not isinstance(values, dict):
|
||||
return
|
||||
|
|
@ -141,12 +129,10 @@ class AutoslicerParams:
|
|||
if self.canny_low.get() > self.canny_high.get():
|
||||
self.canny_high.set(self.canny_low.get())
|
||||
|
||||
# reset_to_factory_defaults: function definition for ScanSlicer behavior.
|
||||
def reset_to_factory_defaults(self):
|
||||
for _, parameter in self.items():
|
||||
parameter.reset()
|
||||
|
||||
# load_user_defaults: function definition for ScanSlicer behavior.
|
||||
def load_user_defaults(self):
|
||||
path = self.defaults_path()
|
||||
if not os.path.isfile(path):
|
||||
|
|
@ -164,7 +150,6 @@ class AutoslicerParams:
|
|||
self.apply_values(loaded)
|
||||
return True
|
||||
|
||||
# load_defaults: function definition for ScanSlicer behavior.
|
||||
def load_defaults(self):
|
||||
if self.load_user_defaults():
|
||||
return "saved"
|
||||
|
|
@ -172,7 +157,6 @@ class AutoslicerParams:
|
|||
self.reset_to_factory_defaults()
|
||||
return "factory"
|
||||
|
||||
# save_user_defaults: function definition for ScanSlicer behavior.
|
||||
def save_user_defaults(self):
|
||||
path = self.defaults_path()
|
||||
directory = os.path.dirname(path)
|
||||
|
|
@ -181,7 +165,6 @@ class AutoslicerParams:
|
|||
json.dump(self.to_dict(), fh, indent=2, sort_keys=True)
|
||||
return path
|
||||
|
||||
# load_user_presets: function definition for ScanSlicer behavior.
|
||||
def load_user_presets(self):
|
||||
path = self.presets_path()
|
||||
if not os.path.isfile(path):
|
||||
|
|
@ -208,7 +191,6 @@ class AutoslicerParams:
|
|||
cleaned[normalized_name] = values
|
||||
return cleaned
|
||||
|
||||
# save_user_presets: function definition for ScanSlicer behavior.
|
||||
def save_user_presets(self):
|
||||
path = self.presets_path()
|
||||
directory = os.path.dirname(path)
|
||||
|
|
@ -217,13 +199,11 @@ class AutoslicerParams:
|
|||
json.dump(self.user_presets, fh, indent=2, sort_keys=True)
|
||||
return path
|
||||
|
||||
# preset_names: function definition for ScanSlicer behavior.
|
||||
def preset_names(self):
|
||||
builtin_names = list(self.PRESETS.keys())
|
||||
user_names = sorted(self.user_presets.keys(), key=str.lower)
|
||||
return builtin_names + user_names
|
||||
|
||||
# save_named_preset: function definition for ScanSlicer behavior.
|
||||
def save_named_preset(self, preset_name):
|
||||
normalized_name = str(preset_name).strip()
|
||||
if len(normalized_name) == 0:
|
||||
|
|
@ -237,7 +217,6 @@ class AutoslicerParams:
|
|||
self.save_user_presets()
|
||||
return normalized_name
|
||||
|
||||
# delete_named_preset: function definition for ScanSlicer behavior.
|
||||
def delete_named_preset(self, preset_name):
|
||||
normalized_name = str(preset_name).strip()
|
||||
if len(normalized_name) == 0:
|
||||
|
|
@ -253,7 +232,6 @@ class AutoslicerParams:
|
|||
self.save_user_presets()
|
||||
return normalized_name
|
||||
|
||||
# apply_preset: function definition for ScanSlicer behavior.
|
||||
def apply_preset(self, preset_name):
|
||||
values = self.PRESETS.get(preset_name)
|
||||
if values is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue