def __init__(self, ext_tuple): self.name = ext_tuple.name self.default_package = ext_tuple.default_package self.default_path = ext_tuple.default_path self.cls = load_class(ext_tuple.cls)
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Separate module to avoid circular dependencies from wlauto.core.bootstrap import settings from wlauto.core.extension import Extension from wlauto.utils.misc import load_class _extension_bases = {ext.name: load_class(ext.cls) for ext in settings.extensions} def get_extension_type(ext): """Given an instance of ``wlauto.core.Extension``, return a string representing the type of the extension (e.g. ``'workload'`` for a Workload subclass instance).""" if not isinstance(ext, Extension): raise ValueError('{} is not an instance of Extension'.format(ext)) for name, cls in _extension_bases.iteritems(): if isinstance(ext, cls): return name raise ValueError('Unknown extension type: {}'.format(ext.__class__.__name__))
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Separate module to avoid circular dependencies from wlauto.core.bootstrap import settings from wlauto.core.extension import Extension from wlauto.utils.misc import load_class _extension_bases = { ext.name: load_class(ext.cls) for ext in settings.extensions } def get_extension_type(ext): """Given an instance of ``wlauto.core.Extension``, return a string representing the type of the extension (e.g. ``'workload'`` for a Workload subclass instance).""" if not isinstance(ext, Extension): raise ValueError('{} is not an instance of Extension'.format(ext)) for name, cls in _extension_bases.iteritems(): if isinstance(ext, cls): return name raise ValueError('Unknown extension type: {}'.format( ext.__class__.__name__))