defaults
This commit is contained in:
parent
07c3e974eb
commit
e80e99c32d
3 changed files with 14 additions and 44 deletions
|
|
@ -1,7 +0,0 @@
|
|||
TODO.md:
|
||||
contexts: []
|
||||
projects:
|
||||
- projectX
|
||||
- markdown
|
||||
tags:
|
||||
- tagx
|
||||
30
index.yaml
30
index.yaml
|
|
@ -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
|
||||
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