formatted

main
Anish Lakhwara 2022-03-17 14:07:20 +10:00
parent d9a9e93fab
commit 8ce3e39764
1 changed files with 14 additions and 5 deletions

View File

@ -5,12 +5,14 @@ from os import listdir, path
from shared.censor import privateList
# TODO don't hardcode the path
def loadTagFile(path='/home/anish/vimwiki/.vimwiki_tags'):
# Available file information keys:
# opened - was the tag file successfully opened?
# error_number - errno value when 'opened' is false
# format - format of tag file (1 = original, 2 = extended)
# sort - how is the tag file sorted?
# sort - how is the tag file sorted?
# author - name of author of generating program (may be empy string)
# name - name of program (may be empy string)
# url - URL of distribution (may be empy string)
@ -22,6 +24,7 @@ def loadTagFile(path='/home/anish/vimwiki/.vimwiki_tags'):
print("No tagfile at {}".format(path))
sys.exit(1)
def makeSetFromTags(tagFile, key='file'):
# Available TagEntry keys:
# name - name of tag
@ -30,9 +33,9 @@ def makeSetFromTags(tagFile, key='file'):
# lineNumber - line number in source file of tag definition (may be zero if not known)
# kind - kind of tag (none if not known)
# fileScope - is tag of file-limited scope?
# Note: other keys will be assumed as an extension key and will
# return None if no such key is found
# Note: other keys will be assumed as an extension key and will
# return None if no such key is found
entry = TagEntry()
tag = tagFile.next(entry)
AllFileList = set()
@ -41,6 +44,7 @@ def makeSetFromTags(tagFile, key='file'):
tag = tagFile.next(entry)
return AllFileList
def makeDictFromTags(tagFile, key='name', value='file'):
entry = TagEntry()
tag = tagFile.next(entry)
@ -57,20 +61,25 @@ def makeDictFromTags(tagFile, key='name', value='file'):
tag = tagFile.next(entry)
return ret
def getAllFilesWithTags():
# Returns a set containing all the files we wish to make public
return makeSetFromTags(loadTagFile())
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)
return files
def getUntaggedFiles():
allFiles = getAllFiles()
allTags = getAllFilesWithTags()
return allFiles - allTags
def getAllTags():
# Returns a dictionary with:
# - key as tag titles