def configure(self, binder: Binder): binder.install(PostRepositoryModule) binder.install(FeatureRepositoryModule) binder.install(AnalyzeServiceModule) binder.install(ReadMediaServiceModule) binder.install(PostIndexModule) binder.bind(FeatureService)
def configure_binding(binder: Binder) -> Binder: binder.bind(GetUserProfileUseCase, to=GetUserProfileUseCase, scope=singleton) # binder.bind(ProfileRepository, to=MockProfileRepository, scope=singleton) binder.bind(ProfileRepository, to=SqlProfileRepository, scope=singleton) return binder
def core(binder: Binder): binder.bind(CommandBus, to=lambda: LocalSynchronousCommandBus(), scope=SingletonScope) binder.bind(EventBus, to=lambda: LocalSynchronousEventBus(), scope=SingletonScope)
def bind_databases(binder: Binder) -> Binder: application = binder.injector.get(Flask) metadata = MetaData() try: department_mapping(metadata) province_mapping(metadata) district_mapping(metadata) user_mapping(metadata) except Exception as e: # nosec, pylint: disable=broad-except print(e) db = SQLAlchemy(application) metadata.reflect(db.engine) metadata.drop_all(db.engine) db.session.commit() metadata.create_all(db.engine) db.session.commit() seed_data(db) binder.bind(SQLAlchemy, to=db, scope=singleton) return binder
def configure(binder: Binder): IocManager.binder = binder for config in IocManager.config_manager.get_all(): binder.bind( config.get("type"), to=config.get("instance"), scope=singleton, ) for singletonScope in ISingleton.__subclasses__(): binder.bind( singletonScope, to=singletonScope, scope=singleton, ) for scoped in IScoped.__subclasses__(): binder.bind( scoped, to=scoped, scope=threadlocal, ) for controller in ResourceBase.__subclasses__(): binder.bind( controller, to=controller, scope=request, ) if IocManager.app_wrapper is not None: api_config = IocManager.config_manager.get(ApiConfig) binder.bind(IocManager.app_wrapper, to=IocManager.app_wrapper(api_config))
def _inject_redis(binder: Binder) -> None: binder.bind( Storage, # Here we can inject different Storage subclasses, we can also use a Storage factory Redis(flask_app.config['STORAGE_HOST'], flask_app.config['STORAGE_PORT']), )
def configure(self, binder: Binder) -> None: neo4j_storage = Neo4jStorage(hostname=self.config.NEO4J_HOSTNAME, port=self.config.NEO4J_PORT, username=self.config.NEO4J_LOGIN, password=self.config.NEO4J_PASSWORD) binder.bind(interface=Storage, to=neo4j_storage, scope=singleton) binder.bind(interface=CategoryDAO, to=Neo4jCategoryDAO, scope=singleton)
def _configure_crypto_quots(binder: Binder, settings: LazySettings): from crypto.services.repositories.quote_pair import QuotesPairRepository binder.bind( QuotesPairRepository.Configuration, QuotesPairRepository.Configuration( file_folder_path=settings.CRYPTO_QUOTES_FOLDER), )
def __configure(binder: Binder) -> None: binder.bind(AbstractFileRepository, to=file_repository, scope=singleton) binder.bind(AbstractEnvironment, to=Environment, scope=singleton) binder.bind(AbstractLogger, to=Logger, scope=singleton) binder.bind(AbstractSpotifyClient, to=SpotifyClient, scope=singleton) binder.bind(AbstractJqbxClient, to=JqbxClient, scope=singleton)
def configure(self, binder: Binder): binder.install(PostRepositoryModule) binder.install(PostServiceModule) binder.install(PostIndexModule) binder.install(PostSearchServiceModule) binder.install(AnalyzeServiceModule) binder.install(FeatureServiceModule) binder.bind(Test)
def _configure_quotes_storer(binder: Binder, settings: LazySettings): from core.utils.download_data.quotes.boursorama import QuotationDownloader binder.bind( QuotationDownloader.Configuration, QuotationDownloader.Configuration( quotes_json_folder=settings.QUOTES_FOLDER_PATH), )
def _configure_company_storer(binder: Binder, settings: LazySettings): from core.utils.store_data.companies import CompanyImporter binder.bind( CompanyImporter.Configuration, CompanyImporter.Configuration( companies_json_path=settings.COMPANIES_JSON_PATH), )
def configure(binder: Binder) -> Binder: binder.bind( elasticSearchIndex, elasticSearchIndex( elasticSearchFactory(os.environ['ELASTICSEARCH_HOST'], os.environ['ELASTICSEARCH_PORT']), 'rooms', 'room', room_mapping)) return binder
def configure(binder: Binder) -> Binder: binder.bind( ElasticSearchIndex, ElasticSearchIndex( ElasticSearchFactory( os.environ['ELASTICSEARCH_HOST'], os.environ['ELASTICSEARCH_PORT'], ), 'rooms_index', 'room', {})) return binder
def configure(binder: Binder) -> Binder: binder.bind( ElasticSearchIndex, ElasticSearchIndex( ElasticSearchFactory( config('ELASTICSEARCH_HOST'), config('ELASTICSEARCH_PORT'), ), 'rooms', 'room', room_mapping)) return binder
def _configure_data_downloader(binder: Binder, settings: LazySettings): from core.utils.driver_manager.driver import DriverManager binder.bind( DriverManager.Configuration, DriverManager.Configuration( download_path=settings.DOWNLOAD_STOCKS_PATH, driver_path=settings.CHROME_DRIVER_PATH, ), )
def configure(binder: Binder) -> Binder: binder.bind( IfElseEngine, IfElseEngine({ 'crash': 0.6, 'died': 0.7, 'married': 0.76, 'funeral': 0.8 })) return binder
def configure(binder: Binder) -> Binder: binder.bind( ItemsProvider, ItemsProvider([{ "Name": "Test1" }]), ElasticSearchIndex, ElasticSearchIndex( ElasticSearchFactory(os.environ['ELASTICSEARCH_HOST'], os.environ['ELASTICSEARCH_PORT']), 'rooms', 'room', room_mapping)) return binder
def configure(binder: Binder) -> Binder: """ Sets DI configurations """ config = get_config() provider_factory = CryptoProviderFactory(config) binder.bind( CryptoProService, to=CryptoProService(provider_factory, config), ) return binder
def configure(self, binder: Binder) -> None: binder.bind(Pool, connection_pool, scope=SingletonScope) binder.bind(SampleRepository, SampleDbRepositoryImpl, scope=SingletonScope) binder.bind(UserRepository, UserDbRepositoryImpl, scope=SingletonScope) binder.bind(SessionRepository, SessionDbRepositoryImpl, scope=SingletonScope) binder.bind(AppointmentRepository, AppointmentRepositoryImpl, scope=SingletonScope)
def configure(self, binder: Binder): for plugin in self.plugins: binder.bind(plugin, scope=singleton) binder.bind(Configuration, to=configuration_provider) binder.bind(WebClient, to=slack_client_provider) binder.bind(PluginsCollection, to=PluginsCollection(self.plugins)) binder.bind(Database, to=MongoClient(os.environ['MONGO_URI'])['antibot'], scope=NoScope) for module in self.submodules: binder.install(module())
def configure(self, binder: Binder): binder.install(EventInstanceContext(self.__event_instance)) binder.install(EventEmittersContext()) # binder.install(ThreadManagerContext()) # TODO fix this -> global_context seems to exists once PER THREAD socket_thread_manager = SocketThreadManager(self.__event_instance) global_infos = GlobalInfos(socket_thread_manager) binder.bind(ThreadManager, to=socket_thread_manager) binder.bind(GlobalInfos, to=global_infos) binder.install(RobotInstanceContext(RobotInfos())) binder.install(SequenceContext())
def configure_services(binder: Binder) -> Binder: binder.bind(ItemsProvider, to=ItemsProvider([{ "Name": "Test 1" }, { "Name": "Test 2" }, { "Name": "Test 3" }, { "Name": "Test 4" }, { "Name": "Test 5" }])) return binder
def configure(self, binder: Binder) -> None: super().configure(binder) binder.bind(BaseRunner, to=WatchdogRunner) binder.bind(CheckableObserver, to=SnapshotObserver) binder.bind(FileSystemEventHandler, to=SnapshotEventHandler) binder.bind(BaseLoggerFactory, to=SystemdLoggerFactory)
def configure(binder: Binder) -> Binder: binder.bind( ElasticSearchIndex, ElasticSearchIndex( ElasticSearchFactory( #os.environ['ELASTICSEARCH_HOST'], #os.environ['ELASTICSEARCH_PORT'], '127.0.0.1', 9200), 'rooms', 'room', room_mapping)) return binder
def configure(self, binder: Binder): binder.bind(ImageAcquisitionService, to=ImageAcquisitionService, scope=singleton) binder.bind(PendantPhysicalParamsFactory, scope=singleton) binder.bind(PendantFeaturesParamsFactory, scope=singleton) binder.bind(PendantFeaturesService, scope=singleton) binder.bind(YoungLaplaceFitService, scope=singleton) binder.bind(PendantAnalysisService, scope=singleton) binder.bind(IFTSession, to=IFTSession, scope=singleton)
def configure(self, binder: Binder) -> None: binder.bind(interface=SwaggerService, to=SwaggerServiceImpl, scope=singleton) binder.bind(interface=UrlService, to=UrlServiceImpl, scope=singleton) binder.bind(interface=HeaderService, to=HeaderServiceImpl, scope=singleton) binder.bind(interface=BodyService, to=BodyServiceImpl, scope=singleton)
def configure(self, binder: Binder) -> None: billpay_private_client = BillpayClient( self._app.config.get('BILLPAY_MERCHANT_ID'), self._app.config.get('BILLPAY_PRIVATE_PORTAL_ID'), self._app.config.get('BILLPAY_PRIVATE_PASSWORD_HASH'), self._app.config.get('BILLPAY_API_URL')) billpay_business_client = BillpayClient( self._app.config.get('BILLPAY_MERCHANT_ID'), self._app.config.get('BILLPAY_BUSINESS_PORTAL_ID'), self._app.config.get('BILLPAY_BUSINESS_PASSWORD_HASH'), self._app.config.get('BILLPAY_API_URL')) billpay_provider = BillpayProvider(billpay_private_client, billpay_business_client) binder.bind(BillpayProvider, to=billpay_provider, scope=singleton)
def configure(binder: Binder) -> None: binder.bind(str, to=provide_str)
def configure(self, binder: Binder) -> None: binder.bind(flask.Flask, to=self.app, scope=singleton) binder.bind(Config, to=self.app.config, scope=singleton) binder.bind(Request, to=lambda: flask.request)
def configure(binder: Binder) -> Binder: binder.bind(ItemsProvider, ItemsProvider([{ 'Name': 'Test 1' }, { 'Name': 'Test 2' }]))
def configure(binder: Binder): def get_count(): global count count = count + 1 return count binder.bind(Count, to=CallableProvider(get_count), scope=flask_injector.request) binder.bind(MessageGenerator, to=MessageGenerator(message='hi there {}!'.format(text)))