fix loading ink.csv from XDG storage
This commit is contained in:
parent
4d919c9746
commit
3a1ab2be66
4 changed files with 16 additions and 6 deletions
|
|
@ -33,8 +33,13 @@ class Pen:
|
||||||
class InkTracker:
|
class InkTracker:
|
||||||
def __init__(self, storage_file: str = None):
|
def __init__(self, storage_file: str = None):
|
||||||
if storage_file is None:
|
if storage_file is None:
|
||||||
storage_file = os.path.abspath('inks.csv')
|
storage_file = os.getenv('INK_TRACKER_CSV')
|
||||||
self.storage_file = os.path.abspath(storage_file)
|
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.headers = ['Vendor', 'Name', 'Color', 'Purchased', 'Size', 'Notes']
|
||||||
self.inks: List[Ink] = self.load_data()
|
self.inks: List[Ink] = self.load_data()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "pen-tracker"
|
name = "pen-tracker"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Don Harper", email="don@donharper.org" },
|
{ name="Don Harper", email="don@donharper.org" },
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Metadata-Version: 2.4
|
Metadata-Version: 2.4
|
||||||
Name: pen-tracker
|
Name: pen-tracker
|
||||||
Version: 0.4.0
|
Version: 0.4.1
|
||||||
Summary: A fountain pen collection tracker.
|
Summary: A fountain pen collection tracker.
|
||||||
Author-email: Don Harper <don@donharper.org>
|
Author-email: Don Harper <don@donharper.org>
|
||||||
Requires-Python: >=3.8
|
Requires-Python: >=3.8
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,13 @@ class Pen:
|
||||||
class InkTracker:
|
class InkTracker:
|
||||||
def __init__(self, storage_file: str = None):
|
def __init__(self, storage_file: str = None):
|
||||||
if storage_file is None:
|
if storage_file is None:
|
||||||
storage_file = os.path.abspath('inks.csv')
|
storage_file = os.getenv('INK_TRACKER_CSV')
|
||||||
self.storage_file = os.path.abspath(storage_file)
|
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.headers = ['Vendor', 'Name', 'Color', 'Purchased', 'Size', 'Notes']
|
||||||
self.inks: List[Ink] = self.load_data()
|
self.inks: List[Ink] = self.load_data()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue