diff --git a/.context.yaml b/.context.yaml index 343c7e0..9cf8360 100644 --- a/.context.yaml +++ b/.context.yaml @@ -1,10 +1,10 @@ config: - plugins: - - id3 id3: types: - .wav -files: + plugins: + - id3 +items: TODO.md: contexts: - python @@ -13,3 +13,13 @@ files: - bokertov tags: - rusty + requirements.txt: + contexts: [] + note: pip reqs + projects: [] + tags: [] + test: + contexts: + - folder + projects: [] + tags: [] diff --git a/.index.yaml b/.index.yaml deleted file mode 100644 index d011ded..0000000 --- a/.index.yaml +++ /dev/null @@ -1,150 +0,0 @@ -contexts: - Chripo McFlu: - - ./test/chirpy.wav - 'calc #tessssting': - - ./test/sheet.xlsx - - ./test/table.ods - 'concon #tagz': - - ./test/word.docx - erfwegf: - - ./COMMANDS.md - frrreee: - - ./README.md - python: - - ./orvani/plugins/hashdoubleslash.py - - ./TODO.md - test: - - ./test/test.txt - this: - - ./test/office.odt - watch: - - ./test/chirpy.wav -files: - ./COMMANDS.md: - contexts: - - erfwegf - note: This is awesome - projects: - - coding - tags: - - super - - great - ./README.md: - contexts: - - frrreee - projects: - - test2 - - test - ./TODO.md: - contexts: - - python - note: Chawera - projects: - - bokertov - tags: - - frrr - - rusty - ./orvani/plugins/hashdoubleslash.py: - contexts: - - python - note: It even works in Python code - projects: - - orvani - tags: - - example - ./test/chirpy.wav: - contexts: - - watch - - Chripo McFlu - note: - - This is a title - projects: - - parakeetio - - sensorwatch - tags: - - funk - ./test/office.odt: - contexts: - - this - note: and a note - projects: - - oopsie - tags: - - whoa - - that - ./test/sheet.xlsx: - contexts: - - 'calc #tessssting' - projects: [] - tags: [] - ./test/table.ods: - contexts: - - 'calc #tessssting' - projects: [] - tags: [] - ./test/test.txt: - contexts: - - test - note: frrr - projects: - - test - tags: - - faa - - test - ./test/word.docx: - contexts: - - 'concon #tagz' - projects: [] - tags: [] -note: - Chawera: - - ./TODO.md - It even works in Python code: - - ./orvani/plugins/hashdoubleslash.py - This is a title: - - ./test/chirpy.wav - This is awesome: - - ./COMMANDS.md - and a note: - - ./test/office.odt - frrr: - - ./test/test.txt -projects: - bokertov: - - ./TODO.md - coding: - - ./COMMANDS.md - oopsie: - - ./test/office.odt - orvani: - - ./orvani/plugins/hashdoubleslash.py - parakeetio: - - ./test/chirpy.wav - sensorwatch: - - ./test/chirpy.wav - test: - - ./test/test.txt - - ./README.md - test2: - - ./README.md -tags: - example: - - ./orvani/plugins/hashdoubleslash.py - faa: - - ./test/test.txt - frrr: - - ./TODO.md - funk: - - ./test/chirpy.wav - great: - - ./COMMANDS.md - rusty: - - ./TODO.md - super: - - ./COMMANDS.md - test: - - ./test/test.txt - that: - - ./test/office.odt - whoa: - - ./test/office.odt diff --git a/orvani/cmd.py b/orvani/cmd.py index 23acd71..bafb603 100644 --- a/orvani/cmd.py +++ b/orvani/cmd.py @@ -17,7 +17,7 @@ def mktable(query: str, index: dict): for i, c in enumerate(ctx): table.add_column(ctx[i].title(), style=styles[i]) for file in index['found']: - fc = index['index']['files'][file] + fc = index['index']['items'][file] elements = [] elements.append(file) for c in ctx: diff --git a/orvani/orvani.py b/orvani/orvani.py index bd9defa..c08c8ac 100644 --- a/orvani/orvani.py +++ b/orvani/orvani.py @@ -46,7 +46,7 @@ class OrvaniTag: self.INDEX = self.CTX.copy() for context_key in self.INDEX: self.INDEX[context_key] = {} - self.INDEX['files'] = {} + self.INDEX['items'] = {} self.__cd('') def __cd(self, path: str): @@ -73,7 +73,7 @@ class OrvaniTag: self.FILE = Path(str(path)) / self.FILENAME if self.FILE.exists(): y = yaml.safe_load(self.FILE.read_text()) - self.DB = y['files'] + self.DB = y['items'] if 'config' in y: self.CONFIG = y['config'] self.CONF_FILES.append(str(path)) @@ -91,7 +91,7 @@ class OrvaniTag: """ file = Path(self.FILE) - yf = { 'files' : self.DB } + yf = { 'items' : self.DB } if file.is_file(): tmp = yaml.safe_load(file.read_text()) if 'config' in tmp: @@ -322,14 +322,14 @@ class OrvaniTag: def __updateindex(self, path: str, context: dict, context_key: str): # Update files index for key, value in context.items(): - if path in self.INDEX['files']: - if key in self.INDEX['files'][path] and isinstance(self.INDEX['files'][path][key], list) and isinstance(value, list): - self.INDEX['files'][path][key] += value - self.INDEX['files'][path][key] = list(set(self.INDEX['files'][path][key])) + if path in self.INDEX['items']: + if key in self.INDEX['items'][path] and isinstance(self.INDEX['items'][path][key], list) and isinstance(value, list): + self.INDEX['items'][path][key] += value + self.INDEX['items'][path][key] = list(set(self.INDEX['items'][path][key])) else: - self.INDEX['files'][path][key] = value + self.INDEX['items'][path][key] = value else: - self.INDEX['files'][path] = { key : value } + self.INDEX['items'][path] = { key : value } # Update context index if type(context[context_key]) == list: @@ -391,7 +391,7 @@ class OrvaniTag: min += sublist result['found'] = list(set(min)) else: - result['found'] = self.INDEX['files'].keys() + result['found'] = self.INDEX['items'].keys() result['found'] = sorted(result['found'], key=lambda x: x.count('/')) return result diff --git a/test/.context.yaml b/test/.context.yaml index 74aa813..170423e 100644 --- a/test/.context.yaml +++ b/test/.context.yaml @@ -1,13 +1,18 @@ config: id3: + map: + contexts: artist + note: title + projects: album + tags: genre types: - .wav - map: - projects: album - contexts: artist - tags: genre - note: title -files: +items: + sub: + contexts: + - folder + projects: [] + tags: [] test.txt: contexts: - test