Пример #1
0
        def _generate_lexer_mapping():
            """Return dict {name > filename} of all lexer resource files (i.e.
            those ones that can include compiled UDL .lexres files).

            It yields directories that should "win" first.
            """
            from glob import glob

            lexresfile_from_lang = {}
            koDirs = components.classes["@activestate.com/koDirs;1"].getService(components.interfaces.koIDirs)

            # Find all possible lexer dirs.
            lexer_dirs = []
            lexer_dirs.append(join(koDirs.userDataDir, "lexers"))  # user
            for extensionDir in directoryServiceUtils.getExtensionDirectories():
                lexer_dirs.append(join(extensionDir, "lexers"))  # user-install extensions
            lexer_dirs.append(join(koDirs.commonDataDir, "lexers"))  # site/common
            lexer_dirs.append(join(koDirs.supportDir, "lexers"))  # factory
            for extra_dir in UDLLexer._extra_lexer_dirs:
                lexer_dirs.append(extra_dir)

            # Find all .lexeres files in these lexer dirs.
            for d in reversed(lexer_dirs):  # first come, first served
                lexer_files = glob(join(d, "*.lexres"))
                for f in lexer_files:
                    # Get lowered name without the ".lexres" extension.
                    name = basename(f).lower().rsplit(".", 1)[0]
                    lexresfile_from_lang[name] = f
            return lexresfile_from_lang
Пример #2
0
    def loadMainToolboxes(self):
        self.toolboxLoader = koToolbox2.ToolboxLoader(self.db_path, self.db)
        self.toolboxLoader.markAllTopLevelItemsUnloaded()
        koDirSvc = components.classes["@activestate.com/koDirs;1"].getService()
        stdToolboxDir = join(koDirSvc.userDataDir,
                             koToolbox2.DEFAULT_TARGET_DIRECTORY)
        if not os.path.exists(stdToolboxDir):
            try:
                os.mkdir(stdToolboxDir)
            except:
                log.error("Can't create tools dir %s", stdToolboxDir)

        import time
        t1 = time.time()
        toolbox_id = self.toolboxLoader.loadToolboxDirectory("", stdToolboxDir, koToolbox2.DEFAULT_TARGET_DIRECTORY)
        self.notifyAddedToolbox(stdToolboxDir, notifyAllWindows=True)
        t2 = time.time()
        #log.debug("Time to load std-toolbox: %g msec", (t2 - t1) * 1000.0)
        self.registerStandardToolbox(toolbox_id)
        
        import directoryServiceUtils
        extensionDirs = directoryServiceUtils.getExtensionDirectories()
        for extensionDir in extensionDirs:
            # Does this happen for disabled extensions?
            toolDir = join(extensionDir, koToolbox2.DEFAULT_TARGET_DIRECTORY)
            if os.path.exists(toolDir):
                self.activateExtensionToolbox(extensionDir)
            #else:
            #    log.debug("No tools in %s", extensionDir)
        self.toolboxLoader.deleteUnloadedTopLevelItems()
Пример #3
0
        def reset(self):
            catalogs = self._prefsProxy.prefs.getStringPref(
                "xmlCatalogPaths") or []
            if catalogs:
                catalogs = catalogs.split(os.pathsep)

            # get xml catalogs from extensions
            from directoryServiceUtils import getExtensionDirectories
            for dir in getExtensionDirectories():
                candidates = [
                    # The new, cleaner, location.
                    os.path.join(dir, "xmlcatalogs", "catalog.xml"),
                    # The old location (for compat). This is DEPRECATED
                    # and should be removed in a future Komodo version.
                    os.path.join(dir, "catalog.xml"),
                ]
                for candidate in candidates:
                    if os.path.exists(candidate):
                        catalogs.append(candidate)
                        break

            # add our default catalog file
            koDirs = components.classes["@activestate.com/koDirs;1"].\
              getService(components.interfaces.koIDirs)
            catalogs.append(
                os.path.join(str(koDirs.supportDir), "catalogs",
                             "catalog.xml"))
            self.setCatalogs(catalogs)
Пример #4
0
        def _generate_lexer_mapping():
            """Return dict {name > filename} of all lexer resource files (i.e.
            those ones that can include compiled UDL .lexres files).

            It yields directories that should "win" first.
            """
            from glob import glob
            lexresfile_from_lang = {}
            koDirs = components.classes["@activestate.com/koDirs;1"] \
                .getService(components.interfaces.koIDirs)

            # Find all possible lexer dirs.
            lexer_dirs = []
            lexer_dirs.append(join(koDirs.userDataDir, "lexers"))    # user
            for extensionDir in directoryServiceUtils.getExtensionDirectories():
                lexer_dirs.append(join(
                    extensionDir, "lexers"))      # user-install extensions
            lexer_dirs.append(join(
                koDirs.commonDataDir, "lexers"))  # site/common
            lexer_dirs.append(join(koDirs.supportDir, "lexers"))     # factory
            for extra_dir in UDLLexer._extra_lexer_dirs:
                lexer_dirs.append(extra_dir)

            # Find all .lexeres files in these lexer dirs.
            for d in reversed(lexer_dirs):  # first come, first served
                lexer_files = glob(join(d, "*.lexres"))
                for f in lexer_files:
                    # Get lowered name without the ".lexres" extension.
                    name = basename(f).lower().rsplit(".", 1)[0]
                    lexresfile_from_lang[name] = f
            return lexresfile_from_lang
Пример #5
0
        def reset(self):
            catalogs = self._prefSvc.prefs.getStringPref(
                "xmlCatalogPaths") or []
            if catalogs:
                catalogs = catalogs.split(os.pathsep)

            # get xml catalogs from extensions
            from directoryServiceUtils import getExtensionDirectories
            for dir in getExtensionDirectories():
                candidates = [
                    # The new, cleaner, location.
                    os.path.join(dir, "xmlcatalogs", "catalog.xml"),
                    # The old location (for compat). This is DEPRECATED
                    # and should be removed in a future Komodo version.
                    os.path.join(dir, "catalog.xml"),
                ]
                for candidate in candidates:
                    if os.path.exists(candidate):
                        catalogs.append(candidate)
                        break

            # add our default catalog file
            koDirs = components.classes["@activestate.com/koDirs;1"].\
                getService(components.interfaces.koIDirs)
            catalogs.append(os.path.join(str(
                koDirs.supportDir), "catalogs", "catalog.xml"))
            self.setCatalogs(catalogs)
Пример #6
0
    def loadMainToolboxes(self):
        self.toolboxLoader = koToolbox2.ToolboxLoader(self.db_path, self.db)
        self.toolboxLoader.markAllTopLevelItemsUnloaded()
        koDirSvc = components.classes["@activestate.com/koDirs;1"].getService()
        stdToolboxDir = join(koDirSvc.userDataDir,
                             koToolbox2.DEFAULT_TARGET_DIRECTORY)
        if not os.path.exists(stdToolboxDir):
            try:
                os.mkdir(stdToolboxDir)
            except:
                log.error("Can't create tools dir %s", stdToolboxDir)

        import time
        t1 = time.time()
        toolbox_id = self.toolboxLoader.loadToolboxDirectory("", stdToolboxDir, koToolbox2.DEFAULT_TARGET_DIRECTORY)
        self.notifyAddedToolbox(stdToolboxDir, notifyAllWindows=True)
        t2 = time.time()
        #log.debug("Time to load std-toolbox: %g msec", (t2 - t1) * 1000.0)
        self.registerStandardToolbox(toolbox_id)
        
        import directoryServiceUtils
        extensionDirs = directoryServiceUtils.getExtensionDirectories()
        for extensionDir in extensionDirs:
            # Does this happen for disabled extensions?
            toolDir = join(extensionDir, koToolbox2.DEFAULT_TARGET_DIRECTORY)
            if os.path.exists(toolDir):
                self.activateExtensionToolbox(extensionDir)
            #else:
            #    log.debug("No tools in %s", extensionDir)
        self.toolboxLoader.deleteUnloadedTopLevelItems()
Пример #7
0
 def _genTemplateDirs(self):
     """Yield all possible templates dirs.
     
     This doesn't bother checking if they exist.
     """
     from directoryServiceUtils import getExtensionDirectories
     yield self.getUserTemplatesDir()
     yield self.getSharedTemplatesDir()
     for extensionDir in getExtensionDirectories():
         yield os.path.join(extensionDir, self.basename)
     yield self.getDefaultTemplatesDir()
Пример #8
0
 def _genTemplateDirs(self):
     """Yield all possible templates dirs.
     
     This doesn't bother checking if they exist.
     """
     from directoryServiceUtils import getExtensionDirectories
     yield self.getUserTemplatesDir()
     yield self.getSharedTemplatesDir()
     for extensionDir in getExtensionDirectories():
         yield os.path.join(extensionDir, self.basename)
     yield self.getDefaultTemplatesDir()
Пример #9
0
     def _gen_lexer_dirs(self):
         """Return all possible lexer resource directories (i.e. those ones
         that can include compiled UDL .lexres files).
 
         It yields directories that should "win" first.
 
         This doesn't filter out non-existant directories.
         """
         koDirs = components.classes["@activestate.com/koDirs;1"] \
             .getService(components.interfaces.koIDirs)
 
         yield join(koDirs.userDataDir, "lexers")    # user
         for extensionDir in directoryServiceUtils.getExtensionDirectories():
             yield join(extensionDir, "lexers")      # user-install extensions
         yield join(koDirs.commonDataDir, "lexers")  # site/common
         yield join(koDirs.supportDir, "lexers")     # factory
Пример #10
0
        def _gen_lexer_dirs(self):
            """Return all possible lexer resource directories (i.e. those ones
            that can include compiled UDL .lexres files).
    
            It yields directories that should "win" first.
    
            This doesn't filter out non-existant directories.
            """
            koDirs = components.classes["@activestate.com/koDirs;1"] \
                .getService(components.interfaces.koIDirs)

            yield join(koDirs.userDataDir, "lexers")  # user
            for extensionDir in directoryServiceUtils.getExtensionDirectories(
            ):
                yield join(extensionDir, "lexers")  # user-install extensions
            yield join(koDirs.commonDataDir, "lexers")  # site/common
            yield join(koDirs.supportDir, "lexers")  # factory
Пример #11
0
    def _getJSONTreeData(self):
        items = self.walkFuncForKPZ(self.getDefaultTemplatesDir())
        headers, leaves = self._getLeaves(items)
        systemItems = leaves
        userItems = []
        #candidates = ['Komodo', 'Common'];
        #if len(leaves) <= 8:
        #    for x in candidates:
        #        if x in headers:
        #            header = x
        #            break
        #    else:
        #        header = candidates[0]
        #    finalItems = [[header, leaves]]
        #else:
        #    finalItems = [items]

        items = self.walkFuncForKPZ(self.getUserTemplatesDir())
        if items:
            headers, leaves = self._getLeaves(items)
            userItems += leaves

        from directoryServiceUtils import getExtensionDirectories
        for extensionDir in [
                d for d in getExtensionDirectories() if os.path.isdir(d)
        ]:
            items = self.walkFuncForKPZ(extensionDir)
            if items:
                headers, leaves = self._getLeaves(items)
                systemItems += leaves

        sharedDir = self.getSharedTemplatesDir()
        if sharedDir:
            items = self.walkFuncForKPZ(sharedDir)
            if items:
                headers, leaves = self._getLeaves(items)
                systemItems += leaves
        return [self._sortPaths(systemItems), self._sortPaths(userItems)]
Пример #12
0
    def _getJSONTreeData(self):
        items = self.walkFuncForKPZ(self.getDefaultTemplatesDir())
        headers, leaves = self._getLeaves(items)
        systemItems = leaves
        userItems = []
        #candidates = ['Komodo', 'Common'];
        #if len(leaves) <= 8:
        #    for x in candidates:
        #        if x in headers:
        #            header = x
        #            break
        #    else:
        #        header = candidates[0]
        #    finalItems = [[header, leaves]]
        #else:
        #    finalItems = [items]

        items = self.walkFuncForKPZ(self.getUserTemplatesDir())
        if items:
            headers, leaves = self._getLeaves(items)
            userItems += leaves
            
        from directoryServiceUtils import getExtensionDirectories
        for extensionDir in [d for d in getExtensionDirectories()
                             if os.path.isdir(d)]:
            items = self.walkFuncForKPZ(extensionDir)
            if items:
                headers, leaves = self._getLeaves(items)
                systemItems += leaves

        sharedDir = self.getSharedTemplatesDir()
        if sharedDir:
            items = self.walkFuncForKPZ(sharedDir)
            if items:
                headers, leaves = self._getLeaves(items)
                systemItems += leaves
        return [self._sortPaths(systemItems), self._sortPaths(userItems)]