|
8 | 8 | """ |
9 | 9 | __docformat__ = 'restructuredtext' |
10 | 10 |
|
11 | | -import os, marshal, shutil, time, logging |
| 11 | +import logging |
| 12 | +import os |
| 13 | +import shutil |
| 14 | +import time |
| 15 | + |
12 | 16 |
|
13 | 17 | from roundup import hyperdb, date, password |
14 | 18 | from roundup.backends import rdbms_common |
@@ -75,36 +79,36 @@ class Database(rdbms_common.Database): |
75 | 79 | implements_double_precision = False |
76 | 80 |
|
77 | 81 | 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 |
86 | 90 | } |
87 | 91 | 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 |
97 | 101 | } |
98 | 102 | 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 |
108 | 112 | } |
109 | 113 |
|
110 | 114 | # We're using DBM for managing session info and one-time keys: |
@@ -247,8 +251,7 @@ def fix_version_3_tables(self): |
247 | 251 |
|
248 | 252 | def _add_fts5_table(self): |
249 | 253 | self.sql('CREATE virtual TABLE __fts USING fts5(_class, ' |
250 | | - '_itemid, _prop, _textblob)' |
251 | | - ) |
| 254 | + '_itemid, _prop, _textblob)') |
252 | 255 |
|
253 | 256 | def fix_version_6_tables(self): |
254 | 257 | # 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): |
386 | 389 | v = None |
387 | 390 | if name == 'id': |
388 | 391 | 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]): |
391 | 394 | v = retired_id |
392 | 395 | d.append(v) |
393 | 396 | self.sql(sql, tuple(d)) |
@@ -425,12 +428,12 @@ def sql_commit(self): |
425 | 428 | def list_dir(dir): |
426 | 429 | import os |
427 | 430 | files = os.listdir(self.dir) |
428 | | - # ['db-journal', 'files', 'db'] |
| 431 | + # ['db-journal', 'files', 'db'] |
429 | 432 | for entry in [''] + files: |
430 | 433 | path = self.dir + '/' + entry |
431 | 434 | 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)) |
434 | 437 |
|
435 | 438 | # Getting sqlite3.OperationalError: disk I/O error |
436 | 439 | # in CI. It happens intermittently. Try to get more |
@@ -520,7 +523,7 @@ def clear(self): |
520 | 523 |
|
521 | 524 | def create_class(self, spec): |
522 | 525 | 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)' % ( |
524 | 527 | self.arg, self.arg) |
525 | 528 | vals = (spec.classname, 1) |
526 | 529 | self.sql(sql, vals) |
|
0 commit comments