defaults
This commit is contained in:
parent
07c3e974eb
commit
e80e99c32d
3 changed files with 14 additions and 44 deletions
21
orvani.py
21
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue