当前位置: 首页>>代码示例>>Python>>正文


Python search.SearchEngine类代码示例

本文整理汇总了Python中pixelated.adapter.search.SearchEngine的典型用法代码示例。如果您正苦于以下问题:Python SearchEngine类的具体用法?Python SearchEngine怎么用?Python SearchEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SearchEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_client

    def start_client(self):
        soledad_test_folder = self._generate_soledad_test_folder_name()
        SearchEngine.DEFAULT_INDEX_HOME = soledad_test_folder

        self.cleanup = lambda: shutil.rmtree(soledad_test_folder)

        PixelatedMail.from_email_address = self.MAIL_ADDRESS

        self.soledad = initialize_soledad(tempdir=soledad_test_folder)
        self.soledad_querier = self._create_soledad_querier(self.soledad, self.INDEX_KEY)
        self.keymanager = mock()

        self.search_engine = SearchEngine(self.soledad_querier, agent_home=soledad_test_folder)
        self.mail_sender = self._create_mail_sender()

        self.account = SoledadBackedAccount(self.ACCOUNT, self.soledad, MagicMock())
        self.mailboxes = Mailboxes(self.account, self.soledad_querier, self.search_engine)
        self.draft_service = DraftService(self.mailboxes)

        self.mail_service = self._create_mail_service(self.mailboxes, self.mail_sender, self.soledad_querier, self.search_engine)
        self.search_engine.index_mails(self.mail_service.all_mails())

        self.app = App()
        self.app.resource = RootResource()
        self.app.resource.initialize(self.soledad_querier, self.keymanager, self.search_engine, self.mail_service, self.draft_service)
开发者ID:amukiza,项目名称:pixelated-user-agent,代码行数:25,代码来源:app_test_client.py

示例2: __init__

    def __init__(self, soledad_test_folder='/tmp/soledad-test/test'):

        self.soledad = initialize_soledad(tempdir=soledad_test_folder)
        self.mail_address = "[email protected]"

        # setup app
        PixelatedMail.from_email_address = self.mail_address

        SearchEngine.DEFAULT_INDEX_HOME = soledad_test_folder

        self.app = App()

        self.soledad_querier = SoledadQuerier(self.soledad)
        self.soledad_querier.get_index_masterkey = lambda: self.INDEX_KEY

        self.account = SoledadBackedAccount('test', self.soledad, MagicMock())
        self.mailboxes = Mailboxes(self.account, self.soledad_querier)
        self.mail_sender = Mock()
        self.tag_service = TagService()
        self.draft_service = DraftService(self.mailboxes)
        self.mail_service = MailService(self.mailboxes, self.mail_sender, self.tag_service,
                                        self.soledad_querier)
        self.search_engine = SearchEngine(self.soledad_querier)
        self.search_engine.index_mails(self.mail_service.all_mails())

        self.app.resource = RootResource()

        self.app.resource.initialize(self.soledad_querier, self.search_engine, self.mail_service, self.draft_service)
开发者ID:pedrovereza,项目名称:pixelated-user-agent,代码行数:28,代码来源:app_test_client.py

示例3: start_client

    def start_client(self):
        soledad_test_folder = self._generate_soledad_test_folder_name()
        SearchEngine.DEFAULT_INDEX_HOME = soledad_test_folder

        self.cleanup = lambda: shutil.rmtree(soledad_test_folder)

        self.soledad = yield initialize_soledad(tempdir=soledad_test_folder)

        self.keymanager = mock()

        self.search_engine = SearchEngine(self.INDEX_KEY, agent_home=soledad_test_folder)
        self.mail_sender = self._create_mail_sender()

        self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.search_engine)

        account_ready_cb = defer.Deferred()
        self.account = IMAPAccount(self.ACCOUNT, self.soledad, account_ready_cb)
        yield account_ready_cb
        self.draft_service = DraftService(self.mail_store)
        self.leap_session = mock()
        self.feedback_service = FeedbackService(self.leap_session)

        self.mail_service = self._create_mail_service(self.mail_sender, self.mail_store, self.search_engine)
        mails = yield self.mail_service.all_mails()
        self.search_engine.index_mails(mails)

        self.resource = RootResource()
        self.resource.initialize(
            self.keymanager, self.search_engine, self.mail_service, self.draft_service, self.feedback_service
        )
开发者ID:kaeff,项目名称:pixelated-user-agent,代码行数:30,代码来源:app_test_client.py

示例4: setup_soledad

    def setup_soledad(self):
        self.soledad = initialize_soledad(tempdir=soledad_test_folder)
        self.mail_address = "[email protected]"

        # setup app
        PixelatedMail.from_email_address = self.mail_address

        SearchEngine.INDEX_FOLDER = soledad_test_folder + '/search_index'

        self.client = pixelated.runserver.app.test_client()

        self._reset_routes(self.client.application)
        self.soledad_querier = SoledadQuerier(self.soledad)
        self.account = FakeAccount()
        self.mailboxes = Mailboxes(self.account, self.soledad_querier)
        self.mail_sender = mock()
        self.tag_service = TagService()
        self.draft_service = DraftService(self.mailboxes)
        self.mail_service = MailService(self.mailboxes, self.mail_sender, self.tag_service,
                                        self.soledad_querier)
        self.search_engine = SearchEngine()
        self.search_engine.index_mails(self.mail_service.all_mails())

        features_controller = FeaturesController()
        features_controller.DISABLED_FEATURES.append('autoReload')
        home_controller = HomeController()
        mails_controller = MailsController(mail_service=self.mail_service,
                                           draft_service=self.draft_service,
                                           search_engine=self.search_engine)
        tags_controller = TagsController(search_engine=self.search_engine)
        sync_info_controller = SyncInfoController()

        app_factory._setup_routes(self.client.application, home_controller, mails_controller, tags_controller,
                                  features_controller, sync_info_controller)
开发者ID:Nangal,项目名称:pixelated-user-agent,代码行数:34,代码来源:integration_helper.py

示例5: setup_soledad

    def setup_soledad(self):
        unstub()  # making sure all mocks from other tests are reset

        # making sure soledad test folder is not there
        if (os.path.isdir(soledad_test_folder)):
            shutil.rmtree(soledad_test_folder)

        self.soledad = initialize_soledad(tempdir=soledad_test_folder)
        self.mail_address = "[email protected]"

        # resetting soledad querier
        SoledadQuerier.reset()
        SoledadQuerier.get_instance(soledad=self.soledad)

        # setup app
        PixelatedMail.from_email_address = self.mail_address
        self.app = pixelated.user_agent.app.test_client()
        self.account = FakeAccount()
        self.pixelated_mailboxes = PixelatedMailBoxes(self.account)
        self.mail_sender = mock()
        self.tag_index = TagIndex(os.path.join(soledad_test_folder, 'tag_index'))
        self.tag_service = TagService(self.tag_index)
        self.draft_service = DraftService(self.pixelated_mailboxes)
        self.mail_service = MailService(self.pixelated_mailboxes, self.mail_sender, self.tag_service)

        SearchEngine.INDEX_FOLDER = soledad_test_folder + '/search_index'
        self.search_engine = SearchEngine()

        self.search_engine.index_mails(self.mail_service.all_mails())

        pixelated.user_agent.mail_service = self.mail_service
        pixelated.user_agent.draft_service = self.draft_service
        pixelated.user_agent.tag_service = self.tag_service
        pixelated.user_agent.search_engine = self.search_engine
开发者ID:vintrepid,项目名称:pixelated-user-agent,代码行数:34,代码来源:integration_helper.py

示例6: test_encoding

    def test_encoding(self):
        # given
        se = SearchEngine(INDEX_KEY, self.agent_home)

        headers = {
            "From": "[email protected]",
            "To": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Cc": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Subject": "Some test mail",
        }

        # when
        se.index_mail(test_helper.pixelated_mail(extra_headers=headers, chash="mailid"))

        result = se.search("folker")

        self.assertEqual((["mailid"], 1), result)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:17,代码来源:test_search.py

示例7: test_headers_encoding

    def test_headers_encoding(self):
        # given
        se = SearchEngine(INDEX_KEY, self.user_home)

        headers = {
            'From': '[email protected]',
            'To': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Cc': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Subject': 'Some test mail',
        }

        # when
        se.index_mail(LeapMail('mailid', 'INBOX', headers=headers))   # test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search('folker')

        self.assertEqual((['mailid'], 1), result)
开发者ID:carriercomm,项目名称:pixelated-user-agent,代码行数:17,代码来源:test_search.py

示例8: test_encoding

    def test_encoding(self):
        # given
        soledad_querier = mock()
        when(soledad_querier).get_index_masterkey().thenReturn(INDEX_KEY)

        se = SearchEngine(soledad_querier, self.agent_home)

        headers = {
            'From': '[email protected]',
            'To': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Cc': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Subject': 'Some test mail',
        }

        # when
        se.index_mail(test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search('folker')

        self.assertEqual((['mailid'], 1), result)
开发者ID:amukiza,项目名称:pixelated-user-agent,代码行数:20,代码来源:test_search.py

示例9: test_index_mail_secured_by_lock

    def test_index_mail_secured_by_lock(self):
        # given
        soledad_querier = mock()
        lock_stub = LockStub()
        when(soledad_querier).get_index_masterkey().thenReturn(INDEX_KEY)

        self.assertEqual(INDEX_KEY, soledad_querier.get_index_masterkey())
        se = SearchEngine(soledad_querier, self.agent_home)
        se._write_lock = lock_stub

        headers = {
            'From': '[email protected]',
            'To': '[email protected]',
            'Subject': 'Some test mail',
        }

        # when
        se.index_mail(test_helper.pixelated_mail(extra_headers=headers))

        # then
        self.assertTrue(lock_stub.called)
开发者ID:amukiza,项目名称:pixelated-user-agent,代码行数:21,代码来源:test_search.py

示例10: test_contents_encoding_special_characters

    def test_contents_encoding_special_characters(self):
        # given
        se = SearchEngine(INDEX_KEY, self.agent_home)

        headers = {
            'From': '[email protected]',
            'To': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Cc': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Subject': 'Some test mail',
        }

        body = "When doing the search, 您好  أهلا"

        # when
        se.index_mail(LeapMail('mailid', 'INBOX', headers=headers, body=body))   # test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search(u"您好")
        self.assertEqual((['mailid'], 1), result)

        result = se.search(u"أهلا")
        self.assertEqual((['mailid'], 1), result)
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:21,代码来源:test_search.py

示例11: test_contents_encoding_accents

    def test_contents_encoding_accents(self):
        # given
        se = SearchEngine(INDEX_KEY, self.user_home)

        headers = {
            "From": "[email protected]",
            "To": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Cc": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Subject": "Some test mail",
            "Date": str(datetime.now()),
        }

        body = "When doing the search, it's not possible to find words with graphical accents, e.g.: 'coração', 'é',  'Fièvre', La Pluie d'été, 'não'."

        # when
        se.index_mail(
            LeapMail("mailid", "INBOX", headers=headers, body=body)
        )  # test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search(u"'coração', 'é',")
        self.assertEqual((["mailid"], 1), result)

        result = se.search(u"Fièvre")
        self.assertEqual((["mailid"], 1), result)

        result = se.search(u"été")
        self.assertEqual((["mailid"], 1), result)
开发者ID:akjones,项目名称:pixelated-user-agent,代码行数:27,代码来源:test_search.py

示例12: test_contents_encoding_special_characters

    def test_contents_encoding_special_characters(self):
        # given
        se = SearchEngine(INDEX_KEY, self.user_home)

        headers = {
            "From": "[email protected]",
            "To": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Cc": "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=",
            "Subject": "Some test mail",
            "Date": str(datetime.now()),
        }

        body = "When doing the search, 您好  أهلا"

        # when
        se.index_mail(
            LeapMail("mailid", "INBOX", headers=headers, body=body)
        )  # test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search(u"您好")
        self.assertEqual((["mailid"], 1), result)

        result = se.search(u"أهلا")
        self.assertEqual((["mailid"], 1), result)
开发者ID:akjones,项目名称:pixelated-user-agent,代码行数:24,代码来源:test_search.py

示例13: start

    def start(self):
        self.soledad = yield initialize_soledad(tempdir=self.soledad_test_folder, uuid=self._uuid)
        self.search_engine = SearchEngine(self.INDEX_KEY, user_home=self.soledad_test_folder)
        self.keymanager = mock()
        self.mail_sender = self._create_mail_sender()
        self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.search_engine)
        self.attachment_store = LeapAttachmentStore(self.soledad)

        yield self._initialize_account()

        self.draft_service = DraftService(self.mail_store)
        self.leap_session = mock()
        self.feedback_service = FeedbackService(self.leap_session)

        self.mail_service = self._create_mail_service(self.mail_sender, self.mail_store, self.search_engine, self.attachment_store)

        mails = yield self.mail_service.all_mails()
        if len(mails) > 0:
            raise Exception('What? Where did these come from?')
        self.search_engine.index_mails(mails)
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:20,代码来源:app_test_client.py

示例14: __init__

    def __init__(self, soledad_test_folder='soledad-test'):

        self.soledad = initialize_soledad(tempdir=soledad_test_folder)
        self.mail_address = "[email protected]"

        # setup app
        PixelatedMail.from_email_address = self.mail_address

        SearchEngine.INDEX_FOLDER = soledad_test_folder + '/search_index'

        self.app = pixelated.runserver.app

        self.soledad_querier = SoledadQuerier(self.soledad)
        self.soledad_querier.get_index_masterkey = lambda: '_yg2oG_5ELM8_-sQYcsxI37WesI0dOtZQXpwAqjvhR4='

        self.account = SoledadBackedAccount('test', self.soledad, MagicMock())
        self.mailboxes = Mailboxes(self.account, self.soledad_querier)
        self.mail_sender = Mock()
        self.tag_service = TagService()
        self.draft_service = DraftService(self.mailboxes)
        self.mail_service = MailService(self.mailboxes, self.mail_sender, self.tag_service,
                                        self.soledad_querier)
        self.search_engine = SearchEngine(self.soledad_querier)
        self.search_engine.index_mails(self.mail_service.all_mails())

        features_controller = FeaturesController()
        features_controller.DISABLED_FEATURES.append('autoReload')
        home_controller = HomeController()
        mails_controller = MailsController(mail_service=self.mail_service,
                                           draft_service=self.draft_service,
                                           search_engine=self.search_engine)
        tags_controller = TagsController(search_engine=self.search_engine)
        contacts_controller = ContactsController(search_engine=self.search_engine)
        sync_info_controller = SyncInfoController()
        attachments_controller = AttachmentsController(self.soledad_querier)

        setup_routes(self.app, home_controller, mails_controller, tags_controller,
                     features_controller, sync_info_controller, attachments_controller, contacts_controller)
开发者ID:RogerS49,项目名称:pixelated-user-agent,代码行数:38,代码来源:app_test_client.py

示例15: test_contents_encoding_accents

    def test_contents_encoding_accents(self):
        # given
        se = SearchEngine(INDEX_KEY, self.agent_home)

        headers = {
            'From': '[email protected]',
            'To': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Cc': '=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?=',
            'Subject': 'Some test mail',
        }

        body = "When doing the search, it's not possible to find words with graphical accents, e.g.: 'coração', 'é',  'Fièvre', La Pluie d'été, 'não'."

        # when
        se.index_mail(LeapMail('mailid', 'INBOX', headers=headers, body=body))   # test_helper.pixelated_mail(extra_headers=headers, chash='mailid'))

        result = se.search(u"'coração', 'é',")
        self.assertEqual((['mailid'], 1), result)

        result = se.search(u"Fièvre")
        self.assertEqual((['mailid'], 1), result)

        result = se.search(u"été")
        self.assertEqual((['mailid'], 1), result)
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:24,代码来源:test_search.py


注:本文中的pixelated.adapter.search.SearchEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。