def on_done(self, text): if (text): # No spaces allowed in a custom id text = text.replace(" ", "-") node = db.Get().AtInView(self.view) if (node and not node.is_root()): props.UpdateProperty(self.view, node, "CUSTOM_ID", text, self.onDone)
def finish_archive_on_loaded(self): while (self.tempView.is_loading()): sublime.set_timeout_async(lambda: self.finish_archive_on_loaded(), 100) node = self.file.At(self.result.start_row) #:ARCHIVE_TIME: 2017-11-30 Thu 18:15 #:ARCHIVE_FILE: ~/notes/inxile/worklog.org #:ARCHIVE_OLPATH: Daily #:ARCHIVE_CATEGORY: InXile #:ARCHIVE_ITAGS: InXile props.UpdateProperty( self.tempView, node, "ARCHIVE_TIME", datetime.datetime.now().strftime("%Y-%m-%d %a %H:%M")) props.UpdateProperty(self.tempView, node, "ARCHIVE_FILE", self.view.file_name()) self.tempView.run_command("save") sublime.set_timeout_async(lambda: self.close_tempView(), 1000) # Now remove the old node self.sourceNode.remove_node() fromFile = db.Get().FindInfo(self.view) fromFile.Save() fromFile.Reload()
def run(self, edit, onDone=None): self.onDone = onDone idValue = "TODAY" node = db.Get().AtInView(self.view) if (not node or node.is_root()): log.debug("Cannot update root node or non existent node as today") return file, at = db.Get().FindByCustomId(idValue) if (file != None and at != None): node = file.At(at) if (node): props.RemoveProperty(self.view, node, "CUSTOM_ID") node = db.Get().AtInView(self.view) if (node and not node.is_root()): props.UpdateProperty(self.view, node, "CUSTOM_ID", idValue, self.onDone)
def ClockOut(view): if (not ClockManager.ClockRunning()): return # Eventually we want to navigate to this node # rather than doing this. node = db.Get().FindNode(ClockManager.Clock["file"], ClockManager.Clock["heading"]) if (node): end = datetime.datetime.now() start = ClockManager.Clock["start"] duration = end - start # Should we keep clocking entries less than a minute? shouldKeep = sets.Get("clockingSubMinuteClocks", True) if (not shouldKeep and duration.seconds < 60): props.RemoveProperty(view, node, "CLOCK") else: props.UpdateProperty( view, node, "CLOCK", ClockManager.FormatClock(start) + "--" + ClockManager.FormatClock(end) + " => " + ClockManager.FormatDuration(duration)) ClockManager.ClearClock() else: log.error("Failed to clock out, couldn't find node")
def OnLogAdded(): props.UpdateProperty(view, node, "LAST_REPEAT", stamp, onDone)