fix loading ink.csv from XDG storage

This commit is contained in:
Don Harper 2026-05-05 10:41:23 -05:00
parent 4d919c9746
commit 3a1ab2be66
4 changed files with 16 additions and 6 deletions

View file

@ -33,8 +33,13 @@ class Pen:
class InkTracker:
def __init__(self, storage_file: str = None):
if storage_file is None:
storage_file = os.path.abspath('inks.csv')
self.storage_file = os.path.abspath(storage_file)
storage_file = os.getenv('INK_TRACKER_CSV')
if storage_file is None:
data_home = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share'))
app_data_dir = os.path.join(data_home, 'pen-tracker')
os.makedirs(app_data_dir, exist_ok=True)
storage_file = os.path.join(app_data_dir, 'inks.csv')
self.storage_file = storage_file
self.headers = ['Vendor', 'Name', 'Color', 'Purchased', 'Size', 'Notes']
self.inks: List[Ink] = self.load_data()