# HG changeset patch # User Sylvain Thénault # Date 1466167499 -7200 # Node ID ab0a1863248e2ccf2b3bbd59083b229447ba6d44 # Parent b537c07e3bdc96de27361ce8491f68e21e4155bf [server] some pep8 changes diff -r b537c07e3bdc -r ab0a1863248e hooks/syncschema.py --- a/hooks/syncschema.py Thu Jun 16 17:35:39 2016 +0200 +++ b/hooks/syncschema.py Fri Jun 17 14:44:59 2016 +0200 @@ -30,8 +30,7 @@ from copy import copy from hashlib import md5 -from yams.schema import (BASE_TYPES, BadSchemaDefinition, - RelationSchema, RelationDefinitionSchema) +from yams.schema import BASE_TYPES, BadSchemaDefinition, RelationDefinitionSchema from yams import buildobjs as ybo, convert_default_value from logilab.common.decorators import clear_cache @@ -58,6 +57,7 @@ constraints.append(cstr) return constraints + def group_mapping(cw): try: return cw.transaction_data['groupmap'] @@ -65,6 +65,7 @@ cw.transaction_data['groupmap'] = gmap = ss.group_mapping(cw) return gmap + def add_inline_relation_column(cnx, etype, rtype): """add necessary column and index for an inlined relation""" attrkey = '%s.%s' % (etype, rtype) @@ -123,7 +124,7 @@ raise validation_error(entity, errors) -class _MockEntity(object): # XXX use a named tuple with python 2.6 +class _MockEntity(object): # XXX use a named tuple with python 2.6 def __init__(self, eid): self.eid = eid @@ -140,12 +141,12 @@ class DropTable(hook.Operation): """actually remove a database from the instance's schema""" - table = None # make pylint happy + table = None # make pylint happy + def precommit_event(self): - dropped = self.cnx.transaction_data.setdefault('droppedtables', - set()) + dropped = self.cnx.transaction_data.setdefault('droppedtables', set()) if self.table in dropped: - return # already processed + return # already processed dropped.add(self.table) self.cnx.system_sql('DROP TABLE %s' % self.table) self.info('dropped table %s', self.table) @@ -286,7 +287,8 @@ class CWETypeRenameOp(MemSchemaOperation): """this operation updates physical storage accordingly""" - oldname = newname = None # make pylint happy + + oldname = newname = None # make pylint happy def rename(self, oldname, newname): self.cnx.vreg.schema.rename_entity_type(oldname, newname) @@ -313,13 +315,14 @@ class CWRTypeUpdateOp(MemSchemaOperation): """actually update some properties of a relation definition""" - rschema = entity = values = None # make pylint happy + + rschema = entity = values = None # make pylint happy oldvalues = None def precommit_event(self): rschema = self.rschema if rschema.final: - return # watched changes to final relation type are unexpected + return # watched changes to final relation type are unexpected cnx = self.cnx if 'fulltext_container' in self.values: op = UpdateFTIndexOp.get_instance(cnx) @@ -497,7 +500,7 @@ if extra_unique_index or entity.indexed: try: syssource.create_index(cnx, table, column, - unique=extra_unique_index) + unique=extra_unique_index) except Exception as ex: self.error('error while creating index for %s.%s: %s', table, column, ex) diff -r b537c07e3bdc -r ab0a1863248e server/test/unittest_migractions.py --- a/server/test/unittest_migractions.py Thu Jun 16 17:35:39 2016 +0200 +++ b/server/test/unittest_migractions.py Fri Jun 17 14:44:59 2016 +0200 @@ -17,8 +17,8 @@ # with CubicWeb. If not, see . """unit tests for module cubicweb.server.migractions""" +import os.path as osp from datetime import date -import os, os.path as osp from contextlib import contextmanager from logilab.common.testlib import unittest_main, Tags, tag @@ -36,13 +36,13 @@ HERE = osp.dirname(osp.abspath(__file__)) +migrschema = None def setUpModule(): startpgcluster(__file__) -migrschema = None def tearDownModule(*args): global migrschema del migrschema