add xdg_base_dirs
This commit is contained in:
parent
48d29b4d0c
commit
076f43b082
@ -11,6 +11,7 @@ dependencies = [
|
||||
"textual>=1.0.0",
|
||||
"tomlkit>=0.13.2",
|
||||
"typer>=0.15.1",
|
||||
"xdg-base-dirs>=6.0.2",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
@ -1,11 +1,29 @@
|
||||
import tomlkit
|
||||
from xdg_base_dirs import xdg_config_home
|
||||
|
||||
# This code implements a singleton-like pattern.
|
||||
#
|
||||
# The global variable _raw_config contains the cached config loaded
|
||||
# from a TOML config file.
|
||||
#
|
||||
# _load_config populates the variable if it has not already been loaded.
|
||||
#
|
||||
# Functions that need the config, can use _load_config() which will
|
||||
# always return a copy of the config regardless of it needed to be loaded
|
||||
# or not.
|
||||
#
|
||||
# Eventually, this approach could also enable a live-reload function.
|
||||
#
|
||||
# A command could be introduced that would reset _raw_config to None,
|
||||
# and the next read would reload the fresh data.
|
||||
|
||||
_raw_config = None
|
||||
|
||||
def _load_config():
|
||||
global _raw_config
|
||||
if not _raw_config:
|
||||
with open("tt.toml", "r") as f:
|
||||
# ~/.config/tt/tt.toml
|
||||
with open(xdg_config_home() / "tt/tt.toml", "r") as f:
|
||||
_raw_config = tomlkit.load(f)
|
||||
return _raw_config
|
||||
|
||||
@ -24,6 +42,6 @@ def get_view(name):
|
||||
|
||||
raise ValueError(f"no such view! {name}")
|
||||
|
||||
|
||||
# Valid statuses & projects are read dynamically from the user's config.
|
||||
STATUSES = get_enum("status")
|
||||
PROJECTS = get_enum("projects")
|
||||
|
@ -1,5 +1,6 @@
|
||||
import json
|
||||
from datetime import date, timedelta, datetime
|
||||
from xdg_base_dirs import xdg_data_home
|
||||
from peewee import (
|
||||
BooleanField,
|
||||
CharField,
|
||||
@ -9,8 +10,11 @@ from peewee import (
|
||||
TextField,
|
||||
)
|
||||
|
||||
# This module defines the core data types.
|
||||
#
|
||||
|
||||
db = SqliteDatabase(
|
||||
"tasks.db",
|
||||
xdg_data_home() / "tt/tasks.db",
|
||||
pragmas={
|
||||
"journal_mode": "wal",
|
||||
"synchronous": "normal",
|
||||
|
99
tt.toml
99
tt.toml
@ -1,99 +0,0 @@
|
||||
[[enums]]
|
||||
name = "status"
|
||||
values = [
|
||||
{ value = "zero", color = "#666666" },
|
||||
{ value = "blocked", color = "#cc9900" },
|
||||
{ value = "wip", color = "#33aa99" },
|
||||
{ value = "done", color = "#009900" },
|
||||
]
|
||||
|
||||
[[enums]]
|
||||
name = "projects"
|
||||
values = [
|
||||
{ value = "SECT", color = "purple" },
|
||||
{ value = "life", color = "#00cc00" },
|
||||
{ value = "CAPP", color = "#cc0000" },
|
||||
{ value = "ilikethis", color = "#cccc00" },
|
||||
{ value = "krang", color = "#ff00ff"},
|
||||
{ value = "artworld", color = "#0000cc"},
|
||||
{ value = "TT", color = "#00ff00"},
|
||||
]
|
||||
|
||||
[[enums]]
|
||||
name = "recurrences"
|
||||
values = [
|
||||
{ value = "days-btwn" },
|
||||
{ value = "monthly" },
|
||||
]
|
||||
|
||||
[[views]]
|
||||
name = "tasks"
|
||||
sort = "due,status"
|
||||
|
||||
[views.filters]
|
||||
status = "wip,blocked,zero"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "id"
|
||||
read_only = true
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "text"
|
||||
display_name = "Task"
|
||||
default = "new task"
|
||||
editor = true
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "status"
|
||||
field_type = "enum"
|
||||
enum = "status"
|
||||
default = "zero"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "type"
|
||||
default = ""
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "due"
|
||||
field_type = "date"
|
||||
default = "1999-01-01"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "due_week"
|
||||
read_only = true
|
||||
#field_type = "date"
|
||||
#default = "1999-01-01"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "project"
|
||||
display_name = "Project"
|
||||
default = ""
|
||||
field_type = "enum"
|
||||
enum = "projects"
|
||||
|
||||
[[views]]
|
||||
name = "recurring"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "id"
|
||||
read_only = true
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "template"
|
||||
default = "recur {val}"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "type"
|
||||
default = "days-btwn"
|
||||
field_type = "enum"
|
||||
enum = "generators"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "val"
|
||||
display_name = "Value"
|
||||
default = "1"
|
||||
|
||||
[[views.columns]]
|
||||
field_name = "next_at"
|
||||
display_name = "Next @"
|
||||
read_only = true
|
11
uv.lock
generated
11
uv.lock
generated
@ -922,6 +922,7 @@ dependencies = [
|
||||
{ name = "textual" },
|
||||
{ name = "tomlkit" },
|
||||
{ name = "typer" },
|
||||
{ name = "xdg-base-dirs" },
|
||||
]
|
||||
|
||||
[package.dev-dependencies]
|
||||
@ -939,6 +940,7 @@ requires-dist = [
|
||||
{ name = "textual", specifier = ">=1.0.0" },
|
||||
{ name = "tomlkit", specifier = ">=0.13.2" },
|
||||
{ name = "typer", specifier = ">=0.15.1" },
|
||||
{ name = "xdg-base-dirs", specifier = ">=6.0.2" },
|
||||
]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
@ -981,6 +983,15 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/37/87/1f677586e8ac487e29672e4b17455758fce261de06a0d086167bb760361a/uc_micro_py-1.0.3-py3-none-any.whl", hash = "sha256:db1dffff340817673d7b466ec86114a9dc0e9d4d9b5ba229d9d60e5c12600cd5", size = 6229 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xdg-base-dirs"
|
||||
version = "6.0.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bf/d0/bbe05a15347538aaf9fa5b51ac3b97075dfb834931fcb77d81fbdb69e8f6/xdg_base_dirs-6.0.2.tar.gz", hash = "sha256:950504e14d27cf3c9cb37744680a43bf0ac42efefc4ef4acf98dc736cab2bced", size = 4085 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fc/03/030b47fd46b60fc87af548e57ff59c2ca84b2a1dadbe721bb0ce33896b2e/xdg_base_dirs-6.0.2-py3-none-any.whl", hash = "sha256:3c01d1b758ed4ace150ac960ac0bd13ce4542b9e2cdf01312dcda5012cfebabe", size = 4747 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yarl"
|
||||
version = "1.18.3"
|
||||
|
Loading…
Reference in New Issue
Block a user