From e80e99c32d91c326de47f46196d50c595d7f3bf2 Mon Sep 17 00:00:00 2001 From: randogoth Date: Tue, 6 Jun 2023 13:13:52 +0300 Subject: [PATCH] defaults --- context.yaml | 7 ------- index.yaml | 30 ------------------------------ orvani.py | 21 ++++++++++++++------- 3 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 context.yaml delete mode 100644 index.yaml diff --git a/context.yaml b/context.yaml deleted file mode 100644 index 979f741..0000000 --- a/context.yaml +++ /dev/null @@ -1,7 +0,0 @@ -TODO.md: - contexts: [] - projects: - - projectX - - markdown - tags: - - tagx diff --git a/index.yaml b/index.yaml deleted file mode 100644 index 91bb2d9..0000000 --- a/index.yaml +++ /dev/null @@ -1,30 +0,0 @@ -contexts: - weird: - - ./dir/test.txt -files: - ./TODO.md: - contexts: [] - projects: - - projectX - - markdown - tags: - - tagx - ./dir/test.txt: - contexts: - - weird - projects: [] - tags: - - testing - ./test/file.md: - contexts: [] - projects: - - markdown - tags: - - test2 -projects: - markdown: - - ./test/file.md - - ./TODO.md -tags: - testing: - - ./dir/test.txt diff --git a/orvani.py b/orvani.py index 7368efc..a7cb0c3 100644 --- a/orvani.py +++ b/orvani.py @@ -2,20 +2,27 @@ import os import yaml import shutil +# Defaults + +CONTEXT_FILE = '.context.yaml' +CACHE_FILE = '.index.yaml' + class OrvaniTag: - INDEX = {} - DB = dict() - FILENAME = '' - FILE = '' - CTX = { + INDEX = {} # our search index + CACHEFILE = '' # search index cache ('.index.yaml') + DB = dict() # holds the folder context data + FILENAME = '' # folder context data filename ('.context.yaml') + FILE = '' # holds the folder context file path + CTX = { # default contexts 'contexts' : '@', 'projects' : '+', 'tags' : '#' } - def __init__(self, path: str='context.yaml', contexts=CTX): + def __init__(self, path: str=CONTEXT_FILE, cache: str=CACHE_FILE, contexts=CTX): self.FILENAME = os.path.basename(path) + self.CACHEFILE = cache self.INDEX = self.CTX.copy() for ctx in self.INDEX: self.INDEX[ctx] = {} @@ -133,7 +140,7 @@ class OrvaniTag: path = './' if not os.path.dirname(path): path += '/' - cachefile = os.path.join(path, 'index.yaml') + cachefile = os.path.join(path, self.CACHEFILE) if cache and os.path.isfile(cachefile): try: with open(cachefile, 'r') as cache: