Browse Source

[RFR] Flake8

pull/95/head
Stefan Rijnhart 11 years ago
parent
commit
addc2d5b4f
  1. 4
      database_cleanup/__openerp__.py
  2. 7
      database_cleanup/model/purge_columns.py
  3. 1
      database_cleanup/model/purge_data.py
  4. 2
      database_cleanup/model/purge_models.py
  5. 6
      database_cleanup/model/purge_tables.py
  6. 1
      database_cleanup/model/purge_wizard.py

4
database_cleanup/__openerp__.py

@ -36,8 +36,8 @@
],
'description': """\
Clean your OpenERP database from remnants of modules, models, columns and
tables left by uninstalled modules (prior to 7.0) or a homebrew database upgrade
to a new major version of OpenERP.
tables left by uninstalled modules (prior to 7.0) or a homebrew database
upgrade to a new major version of OpenERP.
After installation of this module, go to the Settings menu -> Technical ->
Database cleanup. Go through the modules, models, columns and tables

7
database_cleanup/model/purge_columns.py

@ -53,7 +53,7 @@ class CleanupPurgeLineColumn(orm.TransientModel):
'WHERE attrelid = '
'( SELECT oid FROM pg_class WHERE relname = %s ) '
'AND attname = %s',
(model_pool._table, line.name));
(model_pool._table, line.name))
if not cr.fetchone()[0]:
continue
@ -68,6 +68,7 @@ class CleanupPurgeLineColumn(orm.TransientModel):
cr.commit()
return True
class CleanupPurgeWizardColumn(orm.TransientModel):
_inherit = 'cleanup.purge.wizard'
_name = 'cleanup.purge.wizard.column'
@ -123,7 +124,6 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
res = []
model_pool = self.pool['ir.model']
model_ids = model_pool.search(cr, uid, [], context=context)
line_pool = self.pool['cleanup.purge.line.column']
# mapping of tables to tuples (model id, [pool1, pool2, ...])
table2model = {}
@ -132,7 +132,8 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
model_pool = self.pool.get(model.model)
if not model_pool or not model_pool._auto:
continue
table2model.setdefault(model_pool._table, (model.id, []))[1].append(model_pool)
table2model.setdefault(
model_pool._table, (model.id, []))[1].append(model_pool)
for table, model_spec in table2model.iteritems():
for column in self.get_orphaned_columns(

1
database_cleanup/model/purge_data.py

@ -48,6 +48,7 @@ class CleanupPurgeLineData(orm.TransientModel):
self.pool['ir.model.data'].unlink(cr, uid, data_ids, context=context)
return self.write(cr, uid, ids, {'purged': True}, context=context)
class CleanupPurgeWizardData(orm.TransientModel):
_inherit = 'cleanup.purge.wizard'
_name = 'cleanup.purge.wizard.data'

2
database_cleanup/model/purge_models.py

@ -53,7 +53,7 @@ class CleanupPurgeLineModel(orm.TransientModel):
constraint_pool = self.pool['ir.model.constraint']
fields_pool = self.pool['ir.model.fields']
local_context=(context or {}).copy()
local_context = (context or {}).copy()
local_context.update({
MODULE_UNINSTALL_FLAG: True,
'no_drop_table': True,

6
database_cleanup/model/purge_tables.py

@ -56,8 +56,8 @@ class CleanupPurgeLineTable(orm.TransientModel):
FROM pg_attribute af, pg_attribute a,
(SELECT conname, conrelid, confrelid,conkey[i] AS conkey,
confkey[i] AS confkey
FROM (select conname, conrelid, confrelid, conkey, confkey,
generate_series(1,array_upper(conkey,1)) AS i
FROM (select conname, conrelid, confrelid, conkey,
confkey, generate_series(1,array_upper(conkey,1)) AS i
FROM pg_constraint WHERE contype = 'f') ss) ss2
WHERE af.attnum = confkey AND af.attrelid = confrelid AND
a.attnum = conkey AND a.attrelid = conrelid
@ -80,6 +80,7 @@ class CleanupPurgeLineTable(orm.TransientModel):
cr.commit()
return True
class CleanupPurgeWizardTable(orm.TransientModel):
_inherit = 'cleanup.purge.wizard'
_name = 'cleanup.purge.wizard.table'
@ -97,7 +98,6 @@ class CleanupPurgeWizardTable(orm.TransientModel):
Ignore views for now.
"""
model_ids = self.pool['ir.model'].search(cr, uid, [], context=context)
line_pool = self.pool['cleanup.purge.line.table']
# Start out with known tables with no model
known_tables = ['wkf_witm_trans']
for model in self.pool['ir.model'].browse(

1
database_cleanup/model/purge_wizard.py

@ -36,6 +36,7 @@ class CleanupPurgeLine(orm.AbstractModel):
def purge(self, cr, uid, ids, context=None):
raise NotImplementedError
class PurgeWizard(orm.AbstractModel):
""" Abstract base class for the purge wizards """
_name = 'cleanup.purge.wizard'

Loading…
Cancel
Save