Code cosmetics

This commit is contained in:
OzzieIsaacs 2017-04-02 10:42:33 +02:00
parent 7dd70db837
commit ab534b21c1
3 changed files with 14 additions and 16 deletions

View File

@ -67,9 +67,9 @@ class Identifiers(Base):
val = Column(String)
book = Column(Integer, ForeignKey('books.id'))
def __init__(self, val, type, book):
def __init__(self, val, id_type, book):
self.val = val
self.type = type
self.type = id_type
self.book = book
def formatType(self):
@ -209,9 +209,9 @@ class Data(Base):
uncompressed_size = Column(Integer)
name = Column(String)
def __init__(self, book, format, uncompressed_size, name):
def __init__(self, book, book_format, uncompressed_size, name):
self.book = book
self.format = format
self.format = book_format
self.uncompressed_size = uncompressed_size
self.name = name
@ -274,7 +274,7 @@ class Custom_Columns(Base):
display = Column(String)
is_multiple = Column(Boolean)
normalized = Column(Boolean)
def get_display_dict(self):
display_dict = ast.literal_eval(self.display)
return display_dict
@ -333,15 +333,15 @@ def setup_db():
'value': Column(String)}
cc_classes[row.id] = type('Custom_Column_' + str(row.id), (Base,), ccdict)
for id in cc_ids:
if id[1] == 'bool':
setattr(Books, 'custom_column_' + str(id[0]), relationship(cc_classes[id[0]],
for cc_id in cc_ids:
if cc_id[1] == 'bool':
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
primaryjoin=(
Books.id == cc_classes[id[0]].book),
Books.id == cc_classes[cc_id[0]].book),
backref='books'))
else:
setattr(Books, 'custom_column_' + str(id[0]), relationship(cc_classes[id[0]],
secondary=books_custom_column_links[id[0]],
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
secondary=books_custom_column_links[cc_id[0]],
backref='books'))
# Base.metadata.create_all(engine)

View File

@ -94,7 +94,7 @@ def make_mobi(book_id, calibrepath):
if not check or check < 2:
book.data.append(db.Data(
name=book.data[0].name,
format="MOBI",
book_format="MOBI",
book=book.id,
uncompressed_size=os.path.getsize(file_path + ".mobi")
))

View File

@ -293,10 +293,8 @@ class Config:
else:
self.config_google_drive_watch_changes_response=None
self.config_columns_to_ignore = data.config_columns_to_ignore
if self.config_calibre_dir is not None and (not self.config_use_google_drive or os.path.exists(self.config_calibre_dir + '/metadata.db')):
self.db_configured = True
else:
self.db_configured = False
self.db_configured = bool(self.config_calibre_dir is not None and
(not self.config_use_google_drive or os.path.exists(self.config_calibre_dir + '/metadata.db')))
@property
def get_main_dir(self):