1- from paths_cli .compiling .core import Compiler , InstanceBuilder
2- from paths_cli .compiling .plugins import CompilerPlugin
1+ from paths_cli .compiling .core import (
2+ CategoryCompiler , InstanceCompilerPlugin
3+ )
4+ from paths_cli .compiling .plugins import CategoryPlugin
35
46import logging
57logger = logging .getLogger (__name__ )
68
7- class CompilerRegistrationError (Exception ):
9+ class CategoryCompilerRegistrationError (Exception ):
810 pass
911
1012
@@ -34,7 +36,7 @@ def clean_input_key(key):
3436
3537### Managing known compilers and aliases to the known compilers ############
3638
37- _COMPILERS = {} # mapping: {canonical_name: Compiler }
39+ _COMPILERS = {} # mapping: {canonical_name: CategoryCompiler }
3840_ALIASES = {} # mapping: {alias: canonical_name}
3941# NOTE: _ALIASES does *not* include self-mapping of the canonical names
4042
@@ -57,40 +59,40 @@ def _get_compiler(compiler_name):
5759 """
5860 if compiler_name is None :
5961 if None not in _COMPILERS :
60- _COMPILERS [None ] = Compiler (None , None )
62+ _COMPILERS [None ] = CategoryCompiler (None , None )
6163 return _COMPILERS [None ]
6264
6365 canonical_name = _canonical_name (compiler_name )
6466 # create a new compiler if none exists
6567 if canonical_name is None :
6668 canonical_name = compiler_name
67- _COMPILERS [compiler_name ] = Compiler (None , compiler_name )
69+ _COMPILERS [compiler_name ] = CategoryCompiler (None , compiler_name )
6870 return _COMPILERS [canonical_name ]
6971
7072def _register_compiler_plugin (plugin ):
71- DUPLICATE_ERROR = CompilerRegistrationError (
73+ DUPLICATE_ERROR = CategoryCompilerRegistrationError (
7274 f"The name { plugin .name } has been reserved by another compiler"
7375 )
7476 if plugin .name in _COMPILERS or plugin .name in _ALIASES :
7577 raise DUPLICATE_ERROR
7678
77- compiler = _get_compiler (plugin .name )
78-
7979 # register aliases
8080 new_aliases = set (plugin .aliases ) - set ([plugin .name ])
8181 for alias in new_aliases :
8282 if alias in _COMPILERS or alias in _ALIASES :
8383 raise DUPLICATE_ERROR
8484 _ALIASES [alias ] = plugin .name
8585
86+ _ = _get_compiler (plugin .name )
87+
8688
8789### Handling delayed loading of compilers ##################################
8890#
8991# Many objects need to use compilers to create their input parameters. In
9092# order for them to be able to access dynamically-loaded plugins, we delay
9193# the loading of the compiler by using a proxy object.
9294
93- class _CompilerProxy :
95+ class _CategoryCompilerProxy :
9496 def __init__ (self , compiler_name ):
9597 self .compiler_name = compiler_name
9698
@@ -119,7 +121,7 @@ def compiler_for(compiler_name):
119121 compiler_name : str
120122 the name of the compiler to use
121123 """
122- return _CompilerProxy (compiler_name )
124+ return _CategoryCompilerProxy (compiler_name )
123125
124126
125127### Registering builder plugins and user-facing register_plugins ###########
@@ -149,9 +151,9 @@ def register_plugins(plugins):
149151 builders = []
150152 compilers = []
151153 for plugin in plugins :
152- if isinstance (plugin , InstanceBuilder ):
154+ if isinstance (plugin , InstanceCompilerPlugin ):
153155 builders .append (plugin )
154- elif isinstance (plugin , CompilerPlugin ):
156+ elif isinstance (plugin , CategoryPlugin ):
155157 compilers .append (plugin )
156158
157159 for plugin in compilers :
@@ -166,7 +168,7 @@ def _sort_user_categories(user_categories):
166168 """Organize user input categories into compile order.
167169
168170 "Cateogories" are the first-level keys in the user input file (e.g.,
169- 'engines', 'cvs', etc.) There must be one Compiler per category.
171+ 'engines', 'cvs', etc.) There must be one CategoryCompiler per category.
170172 """
171173 user_to_canonical = {user_key : _canonical_name (user_key )
172174 for user_key in user_categories }
0 commit comments