@@ -57,25 +57,6 @@ def func(self):
5757 def __repr__ (self ):
5858 return "OPSCommandPlugin(" + self .name + ")"
5959
60-
61- class OPSParserPlugin (Plugin ):
62- """Plugin to add a new Parser (top-level stage in YAML parsing"""
63- def __init__ (self , parser , requires_ops = (1 , 0 ), requires_cli = (0 , 4 )):
64- self .parser = parser
65- super ().__init__ (requires_ops , requires_cli )
66-
67-
68- class OPSInstanceBuilderPlugin (Plugin ):
69- """
70- Plugin to add a new object type (InstanceBuilder) to YAML parsing.
71- """
72- def __init__ (self , yaml_name , instance_builder , requires_ops = (1 , 0 ),
73- requires_cli = (0 , 3 )):
74- self .yaml_name = yaml_name
75- self .instance_builder = instance_builder
76- super ().__init__ (requires_ops , requires_cli )
77-
78-
7960class CLIPluginLoader (object ):
8061 """Abstract object for CLI plugins
8162
@@ -103,25 +84,6 @@ def _find_candidates(self):
10384 def _make_nsdict (candidate ):
10485 raise NotImplementedError ()
10586
106- # TODO: this should validate with an isinstance of the plugin class
107- @staticmethod
108- def _validate (nsdict ):
109- for attr in ['CLI' , 'SECTION' ]:
110- if attr not in nsdict :
111- return False
112- return True
113-
114- def _get_command_name (self , candidate ):
115- raise NotImplementedError ()
116-
117- # TODO: this should return the actual plugin objects
118- def _find_valid (self ):
119- candidates = self ._find_candidates ()
120- namespaces = {cand : self ._make_nsdict (cand ) for cand in candidates }
121- valid = {cand : ns for cand , ns in namespaces .items ()
122- if self ._validate (ns )}
123- return valid
124-
12587 def _find_candidate_namespaces (self ):
12688 candidates = self ._find_candidates ()
12789 namespaces = {cand : self ._make_nsdict (cand ) for cand in candidates }
@@ -141,16 +103,6 @@ def __call__(self):
141103 namespaces = self ._find_candidate_namespaces ()
142104 plugins = list (self ._find_plugins (namespaces ))
143105 return plugins
144- # valid = self._find_valid()
145- # plugins = [
146- # OPSPlugin(name=self._get_command_name(cand),
147- # location=cand,
148- # func=ns['CLI'],
149- # section=ns['SECTION'],
150- # plugin_type=self.plugin_type)
151- # for cand, ns in valid.items()
152- # ]
153- # return plugins
154106
155107
156108class FilePluginLoader (CLIPluginLoader ):
@@ -188,12 +140,6 @@ def _make_nsdict(candidate):
188140 eval (code , ns , ns )
189141 return ns
190142
191- def _get_command_name (self , candidate ):
192- _ , command_name = os .path .split (candidate )
193- command_name = command_name [:- 3 ] # get rid of .py
194- command_name = command_name .replace ('_' , '-' ) # commands use -
195- return command_name
196-
197143
198144class NamespacePluginLoader (CLIPluginLoader ):
199145 """Load namespace plugins (plugins for wide distribution)
@@ -227,11 +173,3 @@ def iter_namespace(ns_pkg):
227173 @staticmethod
228174 def _make_nsdict (candidate ):
229175 return vars (candidate )
230-
231- def _get_command_name (self , candidate ):
232- command_name = candidate .__name__
233- # +1 for the dot
234- command_name = command_name [len (self .search_path ) + 1 :]
235- command_name = command_name .replace ('_' , '-' ) # commands use -
236- return command_name
237-
0 commit comments