def __init__(self, climate=None, *args, **kwargs): # -- Define the factory which will give us access to # -- the available animals self.factory = factories.Factory(abstract=Animal, plugin_identifier='species', paths=[ os.path.join( os.path.dirname(__file__), 'animals', ), ], *args, **kwargs) # -- Randomly choose a climate self.climate = climate or random.choice([ 'tropical', 'artic', 'temperate', ]) # -- Define our list of animals self._animals = list() self._pens = dict()
def __init__(self): self.factory = factories.Factory( abstract=ReaderPlugin, versioning_identifier='version', paths=[os.path.join( os.path.dirname(__file__), 'readers', )])
def __init__(self, identifier): self.identifier = identifier # -- This signal is triggered on each scan identifier self.scanned = Signal() # -- This signal is emitted whenever a scan is completed self.scan_complete = Signal() # -- Read in all our command data. We do this once so we dont take # -- an IO hit each time we want to run an sql query self._commands = self._command_dict() # -- Only request plugin locations from the db if the # -- db actually exists plugin_locations = list() if os.path.exists(identifier): plugin_locations = self.plugin_locations() # -- Always add our built in plugins plugin_locations.append(constants.BUILT_IN_PLUGIN_DIR) # -- We do not hard code the concept of scan mechanisms or # -- data elements. Instead we utilise dynamic factories which # -- load plugins on the fly. self._scan_factory = factories.Factory( abstract=ScanProcess, paths=plugin_locations, plugin_identifier='scan_type', ) self._data_factory = factories.Factory( abstract=DataElement, paths=plugin_locations, plugin_identifier='data_type', ) # -- We will access data plugins a lot - and they need to be # -- in priority order, therefore we cache the plugin classes # -- in a prioritised list. We then re-cache this data whenever # -- plugin paths are changed. self._data_plugins = sorted( self._data_factory.plugins(), key=lambda x: x.priority, reverse=True, )
def test_generic_factory(self): factory = factories.Factory(platform='ios-simulator-13', configuration='release', architectures='arm64') self.assertBuildSteps(factory.steps, [ _BuildStepFactory(steps.ConfigureBuild, platform='ios-simulator-13', configuration='release', architectures='arm64', buildOnly=True, triggers=None, remotes=None, additionalArguments=None), _BuildStepFactory(steps.ValidatePatch), _BuildStepFactory(steps.PrintConfiguration), _BuildStepFactory(steps.CheckOutSource), _BuildStepFactory(steps.CheckOutSpecificRevision), _BuildStepFactory(steps.ApplyPatch), ])
def __init__(self, pluginsRoot: str = './plugins'): """ Initialize the plugin factory. Assumptions for this implementations: 1. plugins are stateless & re-entrant i.e. plugIns can be called by multiple threads concurently. 2. initialization is lazy """ # holds one instance of each plugin class. self.plugins = dict() self.factory = factories.Factory( abstract=DCMPlugin, plugin_identifier='name', ) self.add_plugins_root(pluginsRoot)