Exemplo n.º 1
0
 def RebuildDb(self):
     if(evt.Get().listeners('tagsfound')):
         evt.Get().clear_listeners('tagsfound')
     evt.Get().on("tagsfound",self.OnTags)
     self.Files = []
     self.files = {}
     self.orgPaths = sets.Get("orgDirs",None)
     self.orgFiles = sets.Get("orgFiles",None)
     self.orgExcludePaths = sets.Get("orgExcludeDirs",None)
     self.orgExcludeFiles = sets.Get("orgExcludeFiles",None)
     matches = []
     if(self.orgPaths):
         for orgPath in self.orgPaths:
             orgPath = orgPath.replace('\\','/')
             globSuffix = sets.Get("validOrgExtensions",[".org"])
             for suffix in globSuffix:
                 if('archive' in suffix):
                     continue
                 suffix = "*" + suffix
                 dirGlobPos = orgPath.find("*")
                 if(dirGlobPos > 0):
                     suffix  = os.path.join(orgPath[dirGlobPos:],suffix)
                     orgPath = orgPath[0:dirGlobPos]
                 if("*" in orgPath):
                     log.error(" orgDirs only supports double star style directory wildcards! Anything else is not supported: " + str(orgPath))
                     if(sublime.active_window().active_view()):
                         sublime.active_window().active_view().set_status("Error: ","orgDirs only supports double star style directory wildcards! Anything else is not supported: " + str(orgPath))
                     log.error(" skipping orgDirs value: " + str(orgPath))
                     continue
                 if not Path(orgPath).exists():
                     log.warning('orgDir path {} does not exist!'.format(orgPath))
                     continue
                 try:
                     for path in Path(orgPath).glob(suffix):
                         if OrgDb.IsExcluded(str(path), self.orgExcludePaths, self.orgExcludeFiles):
                             continue
                         try:
                             filename = str(path)
                             file = FileInfo(filename,loader.load(filename), self.orgPaths)
                             self.AddFileInfo(file)
                         except Exception as e:
                             #x = sys.exc_info()
                             log.warning("FAILED PARSING: %s\n  %s",str(path),traceback.format_exc())
                 except Exception as e:
                     log,logging.warning("ERROR globbing {}\n{}".format(orgPath, traceback.format_exc()))
     if(self.orgFiles):
         for orgFile in self.orgFiles:
             path = orgFile.replace('\\','/')
             if OrgDb.IsExcluded(str(path), self.orgExcludePaths, self.orgExcludeFiles):
                 continue
             try:
                 filename = str(path)
                 file = FileInfo(filename,loader.load(filename), self.orgPaths)
                 self.AddFileInfo(file)
             except Exception as e:
                 #x = sys.exc_info()
                 log.warning("FAILED PARSING: %s\n  %s",str(path),traceback.format_exc())
     self.SortFiles()
     self.RebuildIds()
Exemplo n.º 2
0
def plugin_loaded():
    evt.Get().off("tagsfound",db.Get().OnTags)
    sets.setup_user_settings()
    # Load our settings file.
    # We probably need a command to reload it
    # When it is modified, and probably to reload
    # the DB automatically when your orgs change.
    sets.Load()
    clocking.Load()

    # To enable debug logging, set the env var to a non-blank value.
    # This is the same pattern that neovintageous uses and I think
    # it is a reasonably decent mechanism
    _DEBUG = bool(os.getenv('SUBLIME_ORGEXTENDED_DEBUG'))
    _DEBUG = _DEBUG or sets.Get("enableDebugLogging",False)
    #_DEBUG = True
    if _DEBUG:
        logger = logging.getLogger('OrgExtended')
        logger.propagate = 0
        if not logger.hasHandlers():
            logger.setLevel(logging.DEBUG)
            stream_handler = logging.StreamHandler()
            stream_handler.setFormatter(logging.Formatter(
                'Org: %(levelname)-7s [%(filename)15s:%(lineno)4d] %(message)s'
            ))
            logger.addHandler(stream_handler)
            logger.debug('debug logger initialized')
    global log
    log = logging.getLogger(__name__)
    db.Get().RebuildDb()
    #window = sublime.active_window()
    #if window is None:
    sublime.set_timeout_async(lambda: sync_up_on_loaded(), 1000)
    log.debug("DONE INITIALIZING ORG CAPTURE")
Exemplo n.º 3
0
 def on_cancel(self):
     global inputCommand
     inputCommand = None
     if(self.onDone):
         evt.Get().emit(self.onDone,None)
     self.inputpanel.close()
     self.inputpanel = None
Exemplo n.º 4
0
 def onLoaded(self):
     view = self.savedView
     self.n.move_cursor_to(view)
     eventName = util.RandomString()
     evt.Get().once(eventName, self.onEdited)
     log.debug("Trying to run: " + self.command)
     cmds = self.cmds
     cmds["onDone"] = eventName
     view.run_command(self.command, cmds)
Exemplo n.º 5
0
def SetupMouse():
    evt.Get().on("orgmouse", onMouse)
Exemplo n.º 6
0
 def on_canceled(self):
     self.dateView.output.close()
     if (self.onDone):
         evt.Get().emit(self.onDone, None)
Exemplo n.º 7
0
 def on_done(self, text):
     self.dateView.output.close()
     print("INPUT DONE")
     if (self.onDone):
         evt.Get().emit(self.onDone, self.dateView.cdate)
Exemplo n.º 8
0
 def run(self, edit, event=None):
     pt = 0 if not event else self.view.window_to_text(
         (event["x"], event["y"]))
     evt.Get().emit("orgmouse", pt, self.view, edit)
Exemplo n.º 9
0
 def on_done(self, text):
     global inputCommand
     inputCommand = None
     self.inputpanel = None
     if(None != self.onDone):
         evt.Get().emit(self.onDone,text)
Exemplo n.º 10
0
 def on_done(self, text):
     self.dateView.output.close()
     if (self.onDone):
         evt.Get().emit(self.onDone, self.dateView.cdate)