Lint рефактор (кое-что поправлено)
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
from aore.config import folders
|
||||
from aore.dbutils.dbschemas import db_shemas
|
||||
from aore.miscutils.exceptions import FiasException
|
||||
from xmlparser import XMLParser
|
||||
from aore.updater.xmlparser import XMLParser
|
||||
|
||||
|
||||
class AoDataParser:
|
||||
|
||||
@@ -17,7 +17,7 @@ class AoRar:
|
||||
rarfile.UNRAR_TOOL = unrar_config.path
|
||||
|
||||
def download(self, url):
|
||||
logging.info("Downloading {}".format(url))
|
||||
logging.info("Downloading %s", url)
|
||||
try:
|
||||
local_filename = os.path.abspath(folders.temp + "/" + url.split('/')[-1])
|
||||
if os.path.isfile(local_filename):
|
||||
@@ -32,7 +32,7 @@ class AoRar:
|
||||
except:
|
||||
raise FiasException("Error downloading. Reason : {}".format(format_exc()))
|
||||
|
||||
logging.info("Downloaded {} bytes".format(request.headers['Content-length']))
|
||||
logging.info("Downloaded %d bytes", request.headers['Content-length'])
|
||||
return local_filename
|
||||
|
||||
def get_table_entries(self, file_name, allowed_tables):
|
||||
|
||||
@@ -44,7 +44,7 @@ class DbHandler:
|
||||
assert sql_query, "Invalid operation type: {}".format(operation_type)
|
||||
|
||||
self.db.execute(sql_query)
|
||||
logging.info("Processed {} queries FROM {}".format(processed_count - 1, csv_file_name))
|
||||
logging.info("Processed %d queries FROM %s", processed_count - 1, csv_file_name)
|
||||
|
||||
def create_structure(self):
|
||||
logging.info("Prepare to create DB structure...")
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import logging
|
||||
from os import walk, path
|
||||
|
||||
import psycopg2
|
||||
|
||||
from aore.config import db_conf
|
||||
from aore.dbutils.dbimpl import DBImpl
|
||||
from aore.dbutils.dbschemas import allowed_tables, db_shemas
|
||||
@@ -10,7 +12,6 @@ from aore.updater.aodataparser import AoDataParser
|
||||
from aore.updater.aorar import AoRar
|
||||
from aore.updater.aoxmltableentry import AoXmlTableEntry
|
||||
from aore.updater.dbhandler import DbHandler
|
||||
import psycopg2
|
||||
|
||||
|
||||
class Updater:
|
||||
@@ -42,15 +43,14 @@ class Updater:
|
||||
db.close()
|
||||
|
||||
@classmethod
|
||||
def __set__update_version(cls, updver = 0):
|
||||
def __set__update_version(cls, updver=0):
|
||||
db = DBImpl(psycopg2, db_conf)
|
||||
try:
|
||||
assert type(updver) is int, "Update version must be of int type."
|
||||
assert isinstance(updver, int), "Update version must be of int type."
|
||||
db.execute('UPDATE "CONFIG" SET version={} WHERE id=0'.format(updver))
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def __get_updates_from_folder(self, foldername):
|
||||
# TODO: Вычислять версию, если берем данные из каталога
|
||||
yield dict(intver=0, textver="Unknown", delta_url=foldername, complete_url=foldername)
|
||||
@@ -80,7 +80,7 @@ class Updater:
|
||||
self.db_handler.create_structure()
|
||||
|
||||
for update_entry in self.updalist_generator:
|
||||
logging.info("Processing DB #{}".format(update_entry['intver']))
|
||||
logging.info("Processing DB #%d", update_entry['intver'])
|
||||
for table_entry in self.tablelist_generator(update_entry['complete_url']):
|
||||
if table_entry.operation_type == AoXmlTableEntry.OperationType.update:
|
||||
table_entry.operation_type = AoXmlTableEntry.OperationType.create
|
||||
@@ -103,7 +103,7 @@ class Updater:
|
||||
if not indexes_dropped:
|
||||
self.db_handler.drop_indexes(allowed_tables)
|
||||
indexes_dropped = True
|
||||
logging.info("Processing update #{}".format(update_entry['intver']))
|
||||
logging.info("Processing update #%d", update_entry['intver'])
|
||||
for table_entry in self.tablelist_generator(update_entry['delta_url']):
|
||||
self.process_single_entry(table_entry.operation_type, table_entry)
|
||||
Updater.__set__update_version(update_entry['intver'])
|
||||
|
||||
Reference in New Issue
Block a user