refactor: remove unused python2 code, optimize imports

This commit is contained in:
jar3b 2020-02-19 01:29:08 +03:00
parent d03aa0a78c
commit 966bec093f
21 changed files with 15 additions and 71 deletions

View File

@ -1,4 +1 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .common import *

View File

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
class BasicConfig:
logging = False
debug_print = False

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
from traceback import format_exc
import psycopg2.extras
from traceback import format_exc
from aore.miscutils.exceptions import FiasException

View File

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
class DbSchema:
def __init__(self, name, fieldlist, unique_key, xmltag):
self.tablename = name
@ -29,4 +26,3 @@ db_shemas['AOTRIG'] = \
None)
allowed_tables = ["ADDROBJ", "SOCRBASE"]

View File

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
class FiasException(Exception):
def __str__(self):
return repr(self.args[0])

View File

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import re
import Levenshtein
import re
def violet_ratio(pattern, candidate):
@ -21,7 +19,7 @@ def violet_ratio(pattern, candidate):
max_ratio = ratio
max_j = j
result.append(max_j*abs(max_ratio))
result.append(max_j * abs(max_ratio))
if max_j > -1:
del allowed_nums[max_j]

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import logging
import os
from bottle import template
from aore.config import Folders, DatabaseConfig, SphinxConfig

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
def trigram(inp):
inp = u"__"+inp+u"__"
inp = u"__" + inp + u"__"
output = []
for i in range(0, len(inp) - 2):

View File

@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-
from borest import app, Route, Error
import json
import logging
from borest import app, Route, Error
from bottle import response, request
from aore.search.fiasfactory import FiasFactory
class App(object):
class App:
_factory = None
def __init__(self, log_filename):

View File

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
import logging
import psycopg2
import re
import traceback
import urllib.parse
from uuid import UUID
import psycopg2
from bottle import template
from uuid import UUID
from aore.config import DatabaseConfig, BasicConfig
from aore.dbutils.dbimpl import DBImpl

View File

@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
import Levenshtein
import logging
import re
import time
import Levenshtein
import sphinxapi
import time
from aore.config import BasicConfig
from aore.config import SphinxConfig
@ -108,7 +106,6 @@ class SphinxSearch:
# text - текст найденного адресного объекта
# ratio - рейтинг найденного пункта
# cort - рейтинг количества совпавших слов
def find(self, text, strong):
def split_phrase(phrase):
phrase = phrase.lower()

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import re
from aore.config import SphinxConfig
@ -148,8 +147,5 @@ class WordEntry:
def get_type(self):
return ", ".join([x for x in self.match_types if self.__dict__[x]])
def __unicode__(self):
return self.word
def __str__(self):
return str(self.word)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from enum import Enum # Типы вариаций слова

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import os
import codecs
import os
from aore.config import Folders
from aore.dbutils.dbschemas import db_shemas
from aore.miscutils.exceptions import FiasException

View File

@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
import logging
import os.path
from traceback import format_exc
import rarfile
import requests
from traceback import format_exc
from aore.config import Folders, UnrarConfig
from aore.miscutils.exceptions import FiasException

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
import re
from enum import Enum
@ -42,8 +40,5 @@ class AoXmlTableEntry:
def close(self):
self.file_descriptor.close()
def __unicode__(self):
return "Entry for {} table {}".format(self.operation_type, self.table_name)
def __str__(self):
return "Entry for {} table {}".format(self.operation_type, self.table_name)

View File

@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
import logging
import psycopg2
from bottle import template
@ -66,4 +63,3 @@ class DbHandler:
self.db.execute(sql_query)
logging.info("All indexes was deleted.")

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from pysimplesoap.client import SoapClient

View File

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
import logging
from os import walk, path
import psycopg2
from os import walk, path
from aore.config import DatabaseConfig
from aore.dbutils.dbimpl import DBImpl

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from lxml import etree

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import logging
import optparse
import sys
@ -23,7 +22,7 @@ def print_fias_versions():
all_versions = imp.get_update_list()
print("Installed version: {}".format(current_version))
print("Avaliable updates:")
print("Available updates:")
print("Number\t\tDate")
for upd in all_versions:
mark_current = (' ', '*')[int(upd['intver']) == current_version]