formatted

This commit is contained in:
Anish Lakhwara 2022-03-17 14:07:20 +10:00
parent d9a9e93fab
commit 8ce3e39764

View file

@ -5,6 +5,8 @@ from os import listdir, path
from shared.censor import privateList from shared.censor import privateList
# TODO don't hardcode the path # TODO don't hardcode the path
def loadTagFile(path='/home/anish/vimwiki/.vimwiki_tags'): def loadTagFile(path='/home/anish/vimwiki/.vimwiki_tags'):
# Available file information keys: # Available file information keys:
# opened - was the tag file successfully opened? # opened - was the tag file successfully opened?
@ -22,6 +24,7 @@ def loadTagFile(path='/home/anish/vimwiki/.vimwiki_tags'):
print("No tagfile at {}".format(path)) print("No tagfile at {}".format(path))
sys.exit(1) sys.exit(1)
def makeSetFromTags(tagFile, key='file'): def makeSetFromTags(tagFile, key='file'):
# Available TagEntry keys: # Available TagEntry keys:
# name - name of tag # name - name of tag
@ -41,6 +44,7 @@ def makeSetFromTags(tagFile, key='file'):
tag = tagFile.next(entry) tag = tagFile.next(entry)
return AllFileList return AllFileList
def makeDictFromTags(tagFile, key='name', value='file'): def makeDictFromTags(tagFile, key='name', value='file'):
entry = TagEntry() entry = TagEntry()
tag = tagFile.next(entry) tag = tagFile.next(entry)
@ -57,20 +61,25 @@ def makeDictFromTags(tagFile, key='name', value='file'):
tag = tagFile.next(entry) tag = tagFile.next(entry)
return ret return ret
def getAllFilesWithTags(): def getAllFilesWithTags():
# Returns a set containing all the files we wish to make public # Returns a set containing all the files we wish to make public
return makeSetFromTags(loadTagFile()) return makeSetFromTags(loadTagFile())
def getAllFiles(): def getAllFiles():
files = [f for f in listdir('/home/anish/vimwiki') if '.wiki' in f and path.isfile('/home/anish/vimwiki/' + f)] files = [f for f in listdir(
'/home/anish/vimwiki') if '.wiki' in f and path.isfile('/home/anish/vimwiki/' + f)]
files = set(files) files = set(files)
return files return files
def getUntaggedFiles(): def getUntaggedFiles():
allFiles = getAllFiles() allFiles = getAllFiles()
allTags = getAllFilesWithTags() allTags = getAllFilesWithTags()
return allFiles - allTags return allFiles - allTags
def getAllTags(): def getAllTags():
# Returns a dictionary with: # Returns a dictionary with:
# - key as tag titles # - key as tag titles