Skip to content

Commit 81086db

Browse files
committed
flake8 fixes.
1 parent ca6a26d commit 81086db

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

roundup/backends/back_sqlite.py

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"""
99
__docformat__ = 'restructuredtext'
1010

11-
import os, marshal, shutil, time, logging
11+
import logging
12+
import os
13+
import shutil
14+
import time
15+
1216

1317
from roundup import hyperdb, date, password
1418
from roundup.backends import rdbms_common
@@ -75,36 +79,36 @@ class Database(rdbms_common.Database):
7579
implements_double_precision = False
7680

7781
hyperdb_to_sql_datatypes = {
78-
hyperdb.String : 'VARCHAR(255)',
79-
hyperdb.Date : 'VARCHAR(30)',
80-
hyperdb.Link : 'INTEGER',
81-
hyperdb.Interval : 'VARCHAR(255)',
82-
hyperdb.Password : 'VARCHAR(255)',
83-
hyperdb.Boolean : 'BOOLEAN',
84-
hyperdb.Number : 'REAL',
85-
hyperdb.Integer : 'INTEGER',
82+
hyperdb.String : 'VARCHAR(255)', # noqa: E203
83+
hyperdb.Date : 'VARCHAR(30)', # noqa: E203
84+
hyperdb.Link : 'INTEGER', # noqa: E203
85+
hyperdb.Interval : 'VARCHAR(255)', # noqa: E203
86+
hyperdb.Password : 'VARCHAR(255)', # noqa: E203
87+
hyperdb.Boolean : 'BOOLEAN', # noqa: E203
88+
hyperdb.Number : 'REAL', # noqa: E203
89+
hyperdb.Integer : 'INTEGER', # noqa: E203
8690
}
8791
hyperdb_to_sql_value = {
88-
hyperdb.String : str,
89-
hyperdb.Date : lambda x: x.serialise(),
90-
hyperdb.Link : int,
91-
hyperdb.Interval : str,
92-
hyperdb.Password : str,
93-
hyperdb.Boolean : int,
94-
hyperdb.Integer : int,
95-
hyperdb.Number : lambda x: x,
96-
hyperdb.Multilink : lambda x: x, # used in journal marshalling
92+
hyperdb.String : str, # noqa: E203
93+
hyperdb.Date : lambda x: x.serialise(), # noqa: E203
94+
hyperdb.Link : int, # noqa: E203
95+
hyperdb.Interval : str, # noqa: E203
96+
hyperdb.Password : str, # noqa: E203
97+
hyperdb.Boolean : int, # noqa: E203
98+
hyperdb.Integer : int, # noqa: E203
99+
hyperdb.Number : lambda x: x, # noqa: E203
100+
hyperdb.Multilink : lambda x: x, # used in journal marshalling, # noqa: E203
97101
}
98102
sql_to_hyperdb_value = {
99-
hyperdb.String : uany2s,
100-
hyperdb.Date : lambda x: date.Date(str(x)),
101-
hyperdb.Link : str, # XXX numeric ids
102-
hyperdb.Interval : date.Interval,
103-
hyperdb.Password : lambda x: password.Password(encrypted=x),
104-
hyperdb.Boolean : int,
105-
hyperdb.Integer : int,
106-
hyperdb.Number : rdbms_common._num_cvt,
107-
hyperdb.Multilink : lambda x: x, # used in journal marshalling
103+
hyperdb.String : uany2s, # noqa: E203
104+
hyperdb.Date : lambda x: date.Date(str(x)), # noqa: E203
105+
hyperdb.Link : str, # XXX numeric ids # noqa: E203
106+
hyperdb.Interval : date.Interval, # noqa: E203
107+
hyperdb.Password : lambda x: password.Password(encrypted=x), # noqa: E203
108+
hyperdb.Boolean : int, # noqa: E203
109+
hyperdb.Integer : int, # noqa: E203
110+
hyperdb.Number : rdbms_common._num_cvt, # noqa: E203
111+
hyperdb.Multilink : lambda x: x, # used in journal marshalling, # noqa: E203
108112
}
109113

110114
# We're using DBM for managing session info and one-time keys:
@@ -247,8 +251,7 @@ def fix_version_3_tables(self):
247251

248252
def _add_fts5_table(self):
249253
self.sql('CREATE virtual TABLE __fts USING fts5(_class, '
250-
'_itemid, _prop, _textblob)'
251-
)
254+
'_itemid, _prop, _textblob)')
252255

253256
def fix_version_6_tables(self):
254257
# note sqlite has no limit on column size so v6 fixes
@@ -386,8 +389,8 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
386389
v = None
387390
if name == 'id':
388391
retired_id = v
389-
elif name == '__retired__' and retired_id and \
390-
v not in ['0', 0]:
392+
elif (name == '__retired__' and retired_id and
393+
v not in ['0', 0]):
391394
v = retired_id
392395
d.append(v)
393396
self.sql(sql, tuple(d))
@@ -425,12 +428,12 @@ def sql_commit(self):
425428
def list_dir(dir):
426429
import os
427430
files = os.listdir(self.dir)
428-
# ['db-journal', 'files', 'db']
431+
# ['db-journal', 'files', 'db']
429432
for entry in [''] + files:
430433
path = self.dir + '/' + entry
431434
stat = os.stat(path)
432-
print("file: %s, uid: %s, gid: %s, mode: %o"%(path,
433-
stat.st_uid, stat.st_gid, stat.st_mode))
435+
print("file: %s, uid: %s, gid: %s, mode: %o" % (
436+
path, stat.st_uid, stat.st_gid, stat.st_mode))
434437

435438
# Getting sqlite3.OperationalError: disk I/O error
436439
# in CI. It happens intermittently. Try to get more
@@ -520,7 +523,7 @@ def clear(self):
520523

521524
def create_class(self, spec):
522525
rdbms_common.Database.create_class(self, spec)
523-
sql = 'insert into ids (name, num) values (%s, %s)' %(
526+
sql = 'insert into ids (name, num) values (%s, %s)' % (
524527
self.arg, self.arg)
525528
vals = (spec.classname, 1)
526529
self.sql(sql, vals)

0 commit comments

Comments
 (0)