Files
pyGUI/backend/csv_file_metadata.py
T
Jack.Le e43bf258e3 Add initial backend structure with models, utilities, and settings management
- Introduced .gitignore to exclude common Python artifacts and IDE files.
- Added contour models for contour generation.
- Implemented cryptographic utilities for data encryption and decryption.
- Created CSV metadata model for handling wafer data.
- Developed time-indexed data segment model.
- Established local settings model for application configuration.
- Added Z-wafer data models and parser for CSV file handling.
- Implemented Marching Squares algorithm for contour generation.
2026-04-23 11:40:47 -07:00

50 lines
1.6 KiB
Python

from datetime import datetime
# ===== CSV Metadata Model =====
class CSVFileMetadata:
# ===== Lifecycle =====
def __init__(self, wafer="", date="", chamber="", notes="", filename="", columns=0):
self.wafer = wafer
self.date = date
self.chamber = chamber
self.notes = notes
self.filename = filename
self.columns = columns
# ===== Accessors =====
def get_wafer_type(self) -> str:
"""Return the first character of the wafer string, or empty if none"""
return self.wafer[0] if self.wafer else ""
def get_date(self) -> datetime:
"""Parsifes the date string. Returns current time if parsing fails"""
date_format = "%Y-%m-%d %H:%M:%S"
try:
return datetime.strptime(self.date, date_format)
except (ValueError, TypeError):
# If format is wrong or date is None, return current time
return datetime.now()
# ===== Formatting =====
@staticmethod
def format_date(dt: datetime) -> str:
"""Formats a datetime object into the standard ISO-like string."""
if not isinstance(dt, datetime):
return ""
return dt.strftime("%Y-%m-%d %H:%M:%S")
# ===== Serialization =====
def to_dict(self) -> dict:
return {
"wafer": self.wafer,
"date": self.string_date_format(), # Ensure we save as string
"chamber": self.chamber,
"notes": self.notes,
}
def string_date_format(self) -> str:
"""Helper to ensure the date is always a string for JSON."""
return self.format_date(self.get_date())