Esempio 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()
Esempio n. 2
0
 def LoadNew(self, fileOrView):
     if(fileOrView == None):
         return None
     if(not hasattr(self,'orgPaths') or self.orgPaths == None):
         self.orgPaths = sets.Get("orgDirs",None)
     filename = self.FilenameFromFileOrView(fileOrView)
     if(util.isPotentialOrgFile(filename)):
         file = FileInfo(filename, loader.load(filename), self.orgPaths)
         self.AddFileInfo(file)
         return file
     elif(util.isView(fileOrView) and util.isOrgSyntax(fileOrView)):
         bufferContents = fileOrView.substr(sublime.Region(0, fileOrView.size()))
         file = FileInfo(filename if filename else util.getKey(fileOrView), loader.loads(bufferContents), self.orgPaths)
         self.AddFileInfo(file)
         return file
     else:
         log.debug("File is not an org file, not loading into the database: " + str(filename))
         return None
Esempio n. 3
0
 def Reload(self):
     self.org = loader.load(self.filename)
     self.org.setFile(self)
Esempio n. 4
0
 def Reload(self):
     self.org = loader.load(self.filename)
     self.org.setFile(self)
     self.RebuildBacklinks()