Ejemplo n.º 1
0
def generate_html_files(cfg):
    evernote_basepath = cfg['backup_target'] + "/evernote/notebooks"
    index = file(evernote_basepath + "/index.html", 'w')
    index.write("""
        <html>
         <head>
           <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
          </head>
         <body>
         <ul>
        """)
    for notebook, notes in et.get_local_notes(evernote_basepath).items(): 
        notebook_path = evernote_basepath + "/" + notebook
        index.write("<li><a href='%s'>%s</a> <ul>" % (notebook_path, notebook))
        for note in notes:
            note_path = notebook_path + "/" + et.clean_filename(note[1]['title'])
            note_content = file(note_path).read()
            output = file(note_path + ".html", 'w')
            output.write("""
                     <html>
                      <head>
                       <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
                      </head>
                      <body>
                        %s
                      </body>
                     </html>
                     """ % note_content)
            output.close()
            index.write("<li><a href='%s'>%s</a></li>" % (note_path + ".html", note[1]['title']))
        index.write("</ul>")
    index.write("</ul></body></html>")
    index.close()
Ejemplo n.º 2
0
def pull_notes(filelist, save):
    if cfg['verbose']:
        print "Now Syncing the Notes from Evernote to local"

    for ident, data in filelist:
        if cfg['verbose']:
            print " -- %s" % data['name'] 
        note = note_store.getNote(local_cfg['auth_token'], ident, True, True, True, True)
        nbname = et.clean_filename(data['path'])
        note_name = et.clean_filename(data['name'])
        save(note_name+"-content.xml", nbname, str(note.content))
        #Saving Attachments
        if note.resources:
            for res in note.resources:
                if res.attributes.fileName != None:
                    filename = et.clean_filename(res.attributes.fileName)
                    save(filename, "%s/%s-files" % (nbname, note_name), res.data.body)