def _create_file(self, note): """ Creates file from note """ GeekNote().loadNoteContent(note) # Save images if 'saveImages' in self.imageOptions and self.imageOptions['saveImages']: imageList = Editor.getImages(note.content) if imageList: if 'imagesInSubdir' in self.imageOptions and self.imageOptions['imagesInSubdir']: os.mkdir(os.path.join(self.path, note.title + "_images")) imagePath = os.path.join(self.path, note.title + "_images", note.title) self.imageOptions['baseFilename'] = note.title + "_images/" + note.title else: imagePath = os.path.join(self.path, note.title) self.imageOptions['baseFilename'] = note.title for imageInfo in imageList: filename = "{}-{}.{}".format(imagePath, imageInfo['hash'], imageInfo['extension']) logger.info('Saving image to {}'.format(filename)) binaryHash = binascii.unhexlify(imageInfo['hash']) GeekNote().saveMedia(note.guid, binaryHash, filename) content = Editor.ENMLtoText(note.content, self.imageOptions) path = os.path.join(self.path, note.title + self.extension) open(path, "w").write(content) os.utime(path, (-1, note.updated / 1000)) return True
def _create_file(self, note): """ Creates file from note """ GeekNote(sleepOnRateLimit=self.sleep_on_ratelimit).loadNoteContent(note) escaped_title = re.sub(os.sep,'-', note.title) # Save images if 'saveImages' in self.imageOptions and self.imageOptions['saveImages']: imageList = Editor.getImages(note.content) if imageList: if 'imagesInSubdir' in self.imageOptions and self.imageOptions['imagesInSubdir']: os.mkdir(os.path.join(self.path, escaped_title + "_images")) imagePath = os.path.join(self.path, escaped_title + "_images", escaped_title) self.imageOptions['baseFilename'] = escaped_title + "_images/" + escaped_title else: imagePath = os.path.join(self.path, escaped_title) self.imageOptions['baseFilename'] = escaped_title for imageInfo in imageList: filename = "{}-{}.{}".format(imagePath, imageInfo['hash'], imageInfo['extension']) logger.info('Saving image to {}'.format(filename)) binaryHash = binascii.unhexlify(imageInfo['hash']) GeekNote(sleepOnRateLimit=self.sleep_on_ratelimit).saveMedia(note.guid, binaryHash, filename) content = Editor.ENMLtoText(note.content.encode('utf-8'), self.imageOptions) path = os.path.join(self.path, escaped_title + self.extension) open(path, "w").write(content) updated_seconds = note.updated / 1000.0 os.utime(path, (updated_seconds, updated_seconds)) return True
def _update_file(self, file_note, note): """ Updates file from note """ GeekNote().loadNoteContent(note) content = Editor.ENMLtoText(note.content) open(file_note['path'], "w").write(content)
def showNote(note, id, shardId): separator("#", "URL") printLine("NoteLink: " + (config.NOTE_LINK % (shardId, id, note.guid))) printLine("WebClientURL: " + (config.NOTE_WEBCLIENT_URL % note.guid)) separator("#", "TITLE") printLine(note.title) separator("=", "META") printLine("Notebook: %s" % note.notebookName) printLine("Created: %s" % printDate(note.created)) printLine("Updated: %s" % printDate(note.updated)) for key, value in note.attributes.__dict__.items(): if value and key not in ("reminderOrder", "reminderTime", "reminderDoneTime"): printLine("%s: %s" % (key, value)) separator("|", "REMINDERS") printLine("Order: %s" % str(note.attributes.reminderOrder)) printLine("Time: %s" % printDate(note.attributes.reminderTime)) printLine("Done: %s" % printDate(note.attributes.reminderDoneTime)) separator("-", "CONTENT") if note.tagNames: printLine("Tags: %s" % ", ".join(note.tagNames)) from editor import Editor printLine(Editor.ENMLtoText(note.content))
def _update_file(self, file_note, note): """ Updates file from note """ GeekNote(sleepOnRateLimit=self.sleep_on_ratelimit).loadNoteContent(note) content = Editor.ENMLtoText(note.content) open(file_note['path'], "w").write(content) updated_seconds = note.updated / 1000.0 os.utime(file_note['path'], (updated_seconds, updated_seconds))
def _create_file(self, note): """ Creates file from note """ GeekNote().loadNoteContent(note) content = Editor.ENMLtoText(note.content) path = os.path.join(self.path, note.title + self.extension) open(path, "w").write(content) return True
def showNote(note): separator("#", "TITLE") printLine(note.title) separator("=", "META") printLine("Created: %s Updated:%s" % (printDate(note.created).ljust( 15, " "), printDate(note.updated).ljust(15, " "))) separator("-", "CONTENT") if note.tagNames: printLine("Tags: %s" % ', '.join(note.tagNames)) printLine(Editor.ENMLtoText(note.content))
def _update_file(self, file_note, note): """ Updates file from note """ GeekNote().loadNoteContent(note) print("update {}".format(file_note['path'])) if self.format != "enex": open(file_note['path'], "w").write(content) content = Editor.ENMLtoText(note.content) else: enex.note_to_file(note, file_note['path']) updated_seconds = note.updated / 1000.0 os.utime(file_note['path'], (updated_seconds, updated_seconds))
def showNote(note): separator("#", "TITLE") printLine(note.title) separator("=", "META") printLine("Created: %s" % (printDate(note.created).ljust(15, " "))) printLine("Updated: %s" % (printDate(note.updated).ljust(15, " "))) for key, value in note.attributes.__dict__.items(): if value: printLine("%s: %s" % (key, value)) separator("-", "CONTENT") if note.tagNames: printLine("Tags: %s" % ', '.join(note.tagNames)) printLine(Editor.ENMLtoText(note.content))
def _create_file(self, note): """ Creates file from note """ GeekNote( sleepOnRateLimit=self.sleep_on_ratelimit).loadNoteContent(note) escaped_title = re.sub(os.sep, "-", note.title) # Save images if "saveImages" in self.imageOptions and self.imageOptions[ "saveImages"]: imageList = Editor.getImages(note.content) if imageList: if ("imagesInSubdir" in self.imageOptions and self.imageOptions["imagesInSubdir"]): try: os.mkdir( os.path.join(self.path, escaped_title + "_images")) except OSError: # Folder already exists pass imagePath = os.path.join(self.path, escaped_title + "_images", escaped_title) self.imageOptions["baseFilename"] = (escaped_title + "_images/" + escaped_title) else: imagePath = os.path.join(self.path, escaped_title) self.imageOptions["baseFilename"] = escaped_title for imageInfo in imageList: filename = "{}-{}.{}".format(imagePath, imageInfo["hash"], imageInfo["extension"]) logger.info("Saving image to {}".format(filename)) binaryHash = binascii.unhexlify(imageInfo["hash"]) if not GeekNote(sleepOnRateLimit=self. sleep_on_ratelimit).saveMedia( note.guid, binaryHash, filename): logger.warning( "Failed to save image {}".format(filename)) content = Editor.ENMLtoText(note.content, self.imageOptions) path = os.path.join(self.path, escaped_title + self.extension) open(path, "w").write(content) updated_seconds = note.updated / 1000.0 os.utime(path, (updated_seconds, updated_seconds)) return True
def _create_file(self, note): """ Creates file from note """ GeekNote().loadNoteContent(note) escaped_title = note.title.replace(os.sep, '-') path = os.path.join( self.path, escaped_title.decode('utf8').encode(os_encoding) + self.extension) if self.format != "enex": # Save images if 'saveImages' in self.imageOptions and self.imageOptions[ 'saveImages'] and self.format != "enex": imageList = Editor.getImages(note.content) if imageList: if 'imagesInSubdir' in self.imageOptions and self.imageOptions[ 'imagesInSubdir']: os.mkdir( os.path.join(self.path, escaped_title + "_images")) imagePath = os.path.join(self.path, escaped_title + "_images", escaped_title) self.imageOptions[ 'baseFilename'] = escaped_title + "_images/" + escaped_title else: imagePath = os.path.join(self.path, escaped_title) self.imageOptions['baseFilename'] = escaped_title for imageInfo in imageList: filename = "{}-{}.{}".format(imagePath, imageInfo['hash'], imageInfo['extension']) logger.info('Saving image to {}'.format(filename)) binaryHash = binascii.unhexlify(imageInfo['hash']) GeekNote().saveMedia(note.guid, binaryHash, filename) content = Editor.ENMLtoText(note.content, self.imageOptions) open(path, "w").write(content) else: enex.note_to_file(note, path) logger.info("create file {}".format(path)) updated_seconds = note.updated / 1000.0 os.utime(path, (updated_seconds, updated_seconds)) return True
def showNote(note, id, shardId): separator("#", "URL") printLine("NOTEURL: https://www.evernote.com/shard/%s/nl/%s/%s" % (shardId, id, note.guid)) #printLine(config.NOTE_URL % note.guid) separator("#", "TITLE") printLine(note.title) separator("=", "META") printLine("Created: %s" % (printDate(note.created).ljust(15, " "))) printLine("Updated: %s" % (printDate(note.updated).ljust(15, " "))) for key, value in note.attributes.__dict__.items(): if value: printLine("%s: %s" % (key, value)) separator("-", "CONTENT") if note.tagNames: printLine("Tags: %s" % ', '.join(note.tagNames)) printLine(Editor.ENMLtoText(note.content))
def showNoteRaw(note): printLine(Editor.ENMLtoText(note.content, 'pre'))
def showNoteRaw(note): from editor import Editor printLine(Editor.ENMLtoText(note.content, 'pre'))