Skip to content

Commit

Permalink
fix: Correct change that broke black formmating
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenetar committed Feb 19, 2024
1 parent 53d5ac0 commit e3a612a
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions core/pe/cache_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ class SqliteCache:
schema_version = 2
schema_version_description = "Added blocks for all 8 orientations."

create_table_query = ("CREATE TABLE IF NOT EXISTS "
"pictures(path TEXT, mtime_ns INTEGER, blocks BLOB, blocks2 BLOB, blocks3 BLOB, "
"blocks4 BLOB, blocks5 BLOB, blocks6 BLOB, blocks7 BLOB, blocks8 BLOB)")
create_table_query = (
"CREATE TABLE IF NOT EXISTS "
"pictures(path TEXT, mtime_ns INTEGER, blocks BLOB, blocks2 BLOB, blocks3 BLOB, "
"blocks4 BLOB, blocks5 BLOB, blocks6 BLOB, blocks7 BLOB, blocks8 BLOB)"
)
create_index_query = "CREATE INDEX IF NOT EXISTS idx_path on pictures (path)"
drop_table_query = "DROP TABLE IF EXISTS pictures"
drop_index_query = "DROP INDEX IF EXISTS idx_path"
Expand All @@ -45,13 +47,17 @@ def __delitem__(self, key):
# Optimized
def __getitem__(self, key):
if isinstance(key, int):
sql = ("select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
"from pictures "
"where rowid = ?")
sql = (
"select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
"from pictures "
"where rowid = ?"
)
else:
sql = ("select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
"from pictures "
"where path = ?")
sql = (
"select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
"from pictures "
"where path = ?"
)
blocks = self.con.execute(sql, [key]).fetchone()
if blocks:
result = [bytes_to_colors(block) for block in blocks]
Expand All @@ -76,12 +82,16 @@ def __setitem__(self, path_str, blocks):
else:
mtime = 0
if path_str in self:
sql = ("update pictures set blocks = ?, blocks2 = ?, blocks3 = ?, blocks4 = ?, blocks5 = ?, blocks6 = ?, "
"blocks7 = ?, blocks8 = ?, mtime_ns = ?"
"where path = ?")
sql = (
"update pictures set blocks = ?, blocks2 = ?, blocks3 = ?, blocks4 = ?, blocks5 = ?, blocks6 = ?, "
"blocks7 = ?, blocks8 = ?, mtime_ns = ?"
"where path = ?"
)
else:
sql = ("insert into pictures(blocks,blocks2,blocks3,blocks4,blocks5,blocks6,blocks7,blocks8,mtime_ns,path) "
"values(?,?,?,?,?,?,?,?,?,?)")
sql = (
"insert into pictures(blocks,blocks2,blocks3,blocks4,blocks5,blocks6,blocks7,blocks8,mtime_ns,path) "
"values(?,?,?,?,?,?,?,?,?,?)"
)
try:
self.con.execute(sql, blocks + [mtime, path_str])
except sqlite.OperationalError:
Expand Down Expand Up @@ -145,9 +155,10 @@ def get_id(self, path):
raise ValueError(path)

def get_multiple(self, rowids):
ids = ",".join(map(str, rowids))
sql = (
"select rowid, blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
f"from pictures where rowid in {",".join(map(str, rowids))}"
f"from pictures where rowid in {ids}"
)
cur = self.con.execute(sql)
return (
Expand Down

0 comments on commit e3a612a

Please sign in to comment.