Repository navigation
Closed
Description
Configurable Columns Enhancements Design Spec (Refactored & Unified)
Date: 2026-08-07
Topic: Configurable Columns Enhancements (Unified match + transform with Group Reference Support, Stretch Control, and Friendly Header Names)
1. Overview & Goals
This specification details the final refactored design for ProFiles dynamic column extraction and rendering. The goals are:
- Intuitive Matching (
match): Unify built-in macros and custom regexes under a single, clear property (match: versionormatch: "custom_regex"). - Unified Group & Transform (
transform): Replace separategroupproperties with standard regex backreferences (\1,\2, etc.) insidetransform. Iftransformis omitted, it defaults to returning group 1 (or group 0). - Stretch Control (
stretch): Support per-column resizing behavior in the Tkinter Treeview (stretch: trueorstretch: false). - Friendly Column Names (
name): Separate internal identifiers from user-facing UI column header labels.
2. Configuration Schema & Data Models
2.1. Refactored Pydantic Model (ColumnMapping / ColumnConfiguration)
class ColumnMapping(BaseModel):
name: str | None = None # User-friendly header display name
width: int = 150
stretch: bool = False # Tkinter treeview stretch behavior
match: str = ".*" # Built-in keyword (e.g. "version", "date") or raw regex
transform: str | None = None # Optional replacement pattern with group backreferences (e.g. "\\1 (Build \\2)")
priority: int = 0 # Processing priority
default: str = "" # Default value on non-match2.2. Example .profiles YAML Configuration
columns:
File:
width: 600
stretch: true
match: ".*"
priority: 100
Version:
name: "Version Number"
width: 120
stretch: false
match: version # Uses built-in version regex macro
transform: "Ver. \\1" # Prepends "Ver. " to captured group 1
priority: 20
ProjectBuild:
name: "Project & Build"
width: 160
stretch: false
match: "Project_([A-Z0-9]+)_Build_(\\d+)"
transform: "\\1 (Build \\2)" # Combines multiple groups into a single formatted string
priority: 153. Core Processing Architecture
3.1. Unified Match & Transform Engine (ColumnRule / ColumnExtractor)
When a match occurs:
- If
transformis specified, we use Python'smatch.expand(transform)which natively supports group backreferences (\1,\g<1>, etc.). - If
transformis NOT specified, we default to returningmatch.group(1)if group 1 exists, elsematch.group(0).
BUILTIN_PATTERNS = {
"version": r"[-_]V(\d+(?:\.\d+)*)(?=[^\\/]*\.[a-zA-Z0-9]+$)",
"date": r"(\d{4}[-_]\d{2}[-_]\d{2}|\d{8})",
"git_commit": r"_g([a-f0-9]{7})",
"type": r"(PRO|ENG|DEV|TMP|DEBUG)(?!.*(?:PRO|ENG|DEV|TMP|DEBUG))",
"filename": r"([^/\\\\]+)$",
"extension": r"\.([^./\\\\]+)$",
}
def extract(self, filename: str) -> str:
pattern = BUILTIN_PATTERNS.get(self.match.lower(), self.match)
compiled = re.compile(pattern, re.IGNORECASE)
match = compiled.search(filename)
if not match:
return self.default
try:
if self.transform:
return match.expand(self.transform)
else:
# Default fallback: group 1 if available, else group 0
return match.group(1) if match.lastindex and match.lastindex >= 1 else match.group(0)
except Exception:
return self.default4. GUI & Treeview Integration
column_names: Internal dictionary keys (e.g.("File", "Version", "ProjectBuild")).column_headers: Display names mapped fromname(falling back to key).column_stretches: Tuple of booleans mapped fromstretchpassed intottk.Treeview.column(..., stretch=...).
5. Testing & Verification
- Unit tests for built-in macro resolution via
match. - Unit tests for multi-group backreference formatting in
transform. - Configuration validation and GUI integration tests.
Metadata
Metadata
Assignees
Labels
No labels
Activity