This commit is contained in:
randogoth 2023-06-06 13:13:52 +03:00
parent 07c3e974eb
commit e80e99c32d
3 changed files with 14 additions and 44 deletions

View file

@ -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: