def __init__(self, dirName = "../LogbookEntries", LogBookFolder = "../Logbook"): self.dirName = dirName self.LogBookFolder = LogBookFolder self.entries = {} #"date string" => [entry1, entry2, ...] self.tags = {} self.ignoreFiles = configFunctions.getIgnoredFiles() for datestr in os.listdir(dirName): if datestr in self.ignoreFiles: continue #Skip over any files that should be ignored if not datestr in self.entries: self.entries[datestr] = [] files = os.listdir('%s/%s'%(dirName, datestr)) #Could have used a regexp here lol normalEntryFiles = [f for f in files if (f.upper().rfind("ENTRY") > -1 and f.upper().rfind(".HTM") > -1) and f.rfind('~') == -1] for f in normalEntryFiles: entry = LogbookEntry() entry.initFromHTMLFile("%s/%s/%s"%(dirName, datestr, f)) self.entries[datestr].append(entry) files = os.listdir('%s/%s'%(dirName, datestr)) meetingEntryFiles = [f for f in files if (f.upper().rfind("MEETING") > -1 and f.upper().rfind(".TXT") > -1) and f.rfind('~') == -1] for f in meetingEntryFiles: entry = LogbookEntry() entry.initMeetingFromTXTFile("%s/%s/%s"%(dirName, datestr, f)) self.entries[datestr].append(entry)
def getFilenames(dirName = "../LogbookEntries", LogBookFolder = "../Logbook"): filenames = [] ignoreFiles = configFunctions.getIgnoredFiles() for datestr in os.listdir(dirName): if datestr in ignoreFiles: continue #Skip over any files that should be ignored files = os.listdir('%s/%s'%(dirName, datestr)) #Could have used a regexp here lol normalEntryFiles = [f for f in files if (f.upper().rfind("ENTRY") > -1 and f.upper().rfind(".HTM") > -1) and f.rfind('~') == -1] meetingEntryFiles = [f for f in files if (f.upper().rfind("MEETING") > -1 and f.upper().rfind(".TXT") > -1) and f.rfind('~') == -1] filenames = filenames + ["%s/%s/%s"%(dirName, datestr, f) for f in (normalEntryFiles + meetingEntryFiles)] return filenames
import StringIO import datetime import configFunctions # Note: This script requires the program "html2text" to be installed if __name__ == "__main__": # dirName is the directory that holds the folders with the logbook entries # LogbookFolder is the root of the directory that holds the generated HTML files # It is assumed that dirName and LogbookFolder are at the same level dirName = "../LogbookEntries" LogBookFolder = "../Logbook" dirName = dirName LogBookFolder = LogBookFolder entries = {} # "date string" => [entry1, entry2, ...] tags = {} ignoreFiles = configFunctions.getIgnoredFiles() os.popen3("touch logbookText.txt") os.popen3("rm logbookText.txt") for datestr in os.listdir(dirName): if datestr in ignoreFiles: continue # Skip over any files that should be ignored if not datestr in entries: entries[datestr] = [] files = os.listdir("%s/%s" % (dirName, datestr)) # Could have used a regexp here lol normalEntryFiles = [ f for f in files if (f.upper().rfind("ENTRY") > -1 and f.upper().rfind(".HTM") > -1) and f.rfind("~") == -1 ] for f in normalEntryFiles: HTMLFilename = "%s/%s/%s" % (dirName, datestr, f) print HTMLFilename