Exemple #1
0
def backupFileToBeIngested(filename, folderOut, contentLines):
    saveFolder = folderOut

    util.createFolderIfNotExist(saveFolder)
    content = "".join(contentLines)
    h = hashlib.new('sha256')
    h.update(content.encode())
    unixTime = time.time() 
    timeTag = unixTimeAsSafeStr(unixTime)
    saveFile = os.path.join('ingest.%s.%s.processed' %  (timeTag, h.hexdigest()[-16:]))
    saveFile = os.path.join(saveFolder, saveFile)

    with open(saveFile, 'w') as fh:
        print('Saving ingested data at `%s`.' % saveFile)
        fh.write(content)
Exemple #2
0
    if force or 'time::' not in fileContent:
        annotation = 'time::' + dateForAnnotation() + '\n'

        with open(file, 'w') as fh:
            fh.write(annotation + '\n' + fileContent)

def openInEditor(noteFilename):
    if platform.system() == 'Windows':
        c = 'notepad %s' % noteFilename
    else:
        c = 'vim %s' % noteFilename
    os.system(c)

def resolveDataLocation(dataLocation = None):
    if dataLocation == None:
        dataLocation = data.notesRoot()

    file = data.ingestFilename(dataLocation)
    return dataLocation, file

if __name__ == '__main__':
    args = getArgs()

    dataLocation, noteFilename = resolveDataLocation()
    util.createFolderIfNotExist(dataLocation)
    util.createFileIfNotExist(noteFilename)

    annotateDateIfNotAlreadyDoneg(noteFilename, args.force_time_tagging)
    openInEditor(noteFilename)