changeset 8653:ec73bce93d6a

extensions: rename internal names away from 'rcextensions' Additionally, get rid of the unnecessary 'EXT' variable in load_extensions.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Fri, 09 Oct 2020 13:39:08 +0200
parents d379e2c39bba
children 2228102b99ab
files kallithea/bin/kallithea_cli_index.py kallithea/config/app_cfg.py kallithea/lib/utils.py
diffstat 3 files changed, 12 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_index.py	Thu Oct 08 14:52:00 2020 +0200
+++ b/kallithea/bin/kallithea_cli_index.py	Fri Oct 09 13:39:08 2020 +0200
@@ -28,7 +28,7 @@
 import kallithea.bin.kallithea_cli_base as cli_base
 from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
 from kallithea.lib.pidlock import DaemonLock, LockHeld
-from kallithea.lib.utils import load_rcextensions
+from kallithea.lib.utils import load_extensions
 from kallithea.model.repo import RepoModel
 
 
@@ -41,7 +41,7 @@
     """Create or update full text search index"""
 
     index_location = kallithea.CONFIG['index_dir']
-    load_rcextensions(kallithea.CONFIG['here'])
+    load_extensions(kallithea.CONFIG['here'])
 
     if not repo_location:
         repo_location = RepoModel().repos_path
--- a/kallithea/config/app_cfg.py	Thu Oct 08 14:52:00 2020 +0200
+++ b/kallithea/config/app_cfg.py	Fri Oct 09 13:39:08 2020 +0200
@@ -34,7 +34,7 @@
 import kallithea.model.base
 import kallithea.model.meta
 from kallithea.lib import celerypylons
-from kallithea.lib.utils import check_git_version, load_rcextensions, set_app_settings, set_indexer_config, set_vcs_config
+from kallithea.lib.utils import check_git_version, load_extensions, set_app_settings, set_indexer_config, set_vcs_config
 from kallithea.lib.utils2 import asbool
 from kallithea.model import db
 
@@ -139,7 +139,7 @@
         kallithea.CELERY_APP = celerypylons.make_app()
     kallithea.CONFIG = config
 
-    load_rcextensions(root_path=config['here'])
+    load_extensions(root_path=config['here'])
 
     set_app_settings(config)
 
--- a/kallithea/lib/utils.py	Thu Oct 08 14:52:00 2020 +0200
+++ b/kallithea/lib/utils.py	Fri Oct 09 13:39:08 2020 +0200
@@ -520,32 +520,25 @@
     return added, removed
 
 
-def load_rcextensions(root_path):
+def load_extensions(root_path):
     path = os.path.join(root_path, 'rcextensions', '__init__.py')
     if os.path.isfile(path):
-        rcext = create_module('rc', path)
-        EXT = kallithea.EXTENSIONS = rcext
-        log.debug('Found rcextensions now loading %s...', rcext)
+        ext = create_module('rc', path)
+        kallithea.EXTENSIONS = ext
+        log.debug('Found rcextensions now loading %s...', ext)
 
         # Additional mappings that are not present in the pygments lexers
-        kallithea.config.conf.LANGUAGES_EXTENSIONS_MAP.update(getattr(EXT, 'EXTRA_MAPPINGS', {}))
+        kallithea.config.conf.LANGUAGES_EXTENSIONS_MAP.update(getattr(ext, 'EXTRA_MAPPINGS', {}))
 
         # OVERRIDE OUR EXTENSIONS FROM RC-EXTENSIONS (if present)
 
-        if getattr(EXT, 'INDEX_EXTENSIONS', []):
+        if getattr(ext, 'INDEX_EXTENSIONS', []):
             log.debug('settings custom INDEX_EXTENSIONS')
-            kallithea.config.conf.INDEX_EXTENSIONS = getattr(EXT, 'INDEX_EXTENSIONS', [])
+            kallithea.config.conf.INDEX_EXTENSIONS = getattr(ext, 'INDEX_EXTENSIONS', [])
 
         # ADDITIONAL MAPPINGS
         log.debug('adding extra into INDEX_EXTENSIONS')
-        kallithea.config.conf.INDEX_EXTENSIONS.extend(getattr(EXT, 'EXTRA_INDEX_EXTENSIONS', []))
-
-        # auto check if the module is not missing any data, set to default if is
-        # this will help autoupdate new feature of rcext module
-        #from kallithea.config import rcextensions
-        #for k in dir(rcextensions):
-        #    if not k.startswith('_') and not hasattr(EXT, k):
-        #        setattr(EXT, k, getattr(rcextensions, k))
+        kallithea.config.conf.INDEX_EXTENSIONS.extend(getattr(ext, 'EXTRA_INDEX_EXTENSIONS', []))
 
 
 #==============================================================================