Small refactoring (static method and comments)
This commit is contained in:
parent
5e310df926
commit
8d0a54618e
@ -21,7 +21,8 @@ class FiasFactory:
|
||||
self.normalize_templ = template('aore/templates/postgre/normalize_query.sql', aoid="//aoid")
|
||||
|
||||
# Проверка, что строка является действительым UUID v4
|
||||
def __check_uuid(self, guid):
|
||||
@staticmethod
|
||||
def __check_uuid(guid):
|
||||
try:
|
||||
UUID(guid)
|
||||
except ValueError:
|
||||
|
@ -30,15 +30,19 @@ class SphinxSearch:
|
||||
|
||||
sphinx_host = sphinx_conf.listen
|
||||
sphinx_port = None
|
||||
|
||||
# Получаем строку подключения для Sphinx
|
||||
if ":" in sphinx_conf.listen and "unix:/" not in sphinx_conf.listen:
|
||||
sphinx_host, sphinx_port = sphinx_conf.listen.split(":")
|
||||
sphinx_port = int(sphinx_port)
|
||||
|
||||
# Настраиваем подключение для подсказок
|
||||
self.client_sugg = sphinxapi.SphinxClient()
|
||||
self.client_sugg.SetServer(sphinx_host, sphinx_port)
|
||||
self.client_sugg.SetLimits(0, self.max_result)
|
||||
self.client_sugg.SetConnectTimeout(3.0)
|
||||
|
||||
# Настраиваем подключение для поиска адреса
|
||||
self.client_show = sphinxapi.SphinxClient()
|
||||
self.client_show.SetServer(sphinx_host, sphinx_port)
|
||||
self.client_show.SetLimits(0, self.max_result)
|
||||
@ -141,12 +145,12 @@ class SphinxSearch:
|
||||
rs = self.client_show.RunQueries()
|
||||
elapsed_t = time.time() - start_t
|
||||
|
||||
if basic.logging:
|
||||
logging.info("Sphinx time for {} = {}".format(text, elapsed_t))
|
||||
|
||||
if rs is None:
|
||||
raise FiasException("Cannot find sentence.")
|
||||
|
||||
if basic.logging:
|
||||
logging.info("Sphinx time for {} = {}".format(text, elapsed_t))
|
||||
|
||||
results = []
|
||||
parsed_ids = []
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user