Browse Source

Emtype: whitespace and syntax error (lint + pep8)

ArnAud 9 years ago
parent
commit
af878631a0
1 changed files with 14 additions and 14 deletions
  1. 14
    14
      EditorialModel/types.py

+ 14
- 14
EditorialModel/types.py View File

@@ -24,7 +24,7 @@ class EmType(EmComponent):
24 24
     ## Instanciate a new EmType
25 25
     # @todo define and check types for icon and sortcolumn
26 26
     # @todo better check self.subordinates
27
-    def __init__(self, model, uid, name, class_id, fields_list = None, superiors_list = None, icon = '0', sortcolumn = 'rank', string = None, help_text = None, date_update = None, date_create = None, rank = None):
27
+    def __init__(self, model, uid, name, class_id, fields_list=None, superiors_list=None, icon='0', sortcolumn='rank', string=None, help_text=None, date_update=None, date_create=None, rank=None):
28 28
         self.class_id = class_id
29 29
         self.check_type('class_id', int)
30 30
         self.fields_list = fields_list if fields_list is not None else []
@@ -146,7 +146,7 @@ class EmType(EmComponent):
146 146
     def _change_field_list(self, field, select=True):
147 147
         if not isinstance(field, EmField):
148 148
             raise TypeError("Excepted <class EmField> as field argument. But got " + str(type(field)))
149
-        if not field in self.em_class.fields():
149
+        if field not in self.em_class.fields():
150 150
             raise ValueError("This field " + str(field) + "is not part of the type " + str(self))
151 151
         if not field.optional:
152 152
             raise ValueError("This field is not optional")
@@ -211,7 +211,7 @@ class EmType(EmComponent):
211 211
     # @return Return a dict with relation nature as keys and an EmType as value
212 212
     # @throw RuntimeError if a nature has multiple superiors
213 213
     def superiors(self):
214
-        return { nature:[self.model.component(superior_uid) for superior_uid in superiors_uid] for nature, superiors_uid in self.superiors_list.items() }
214
+        return {nature: [self.model.component(superior_uid) for superior_uid in superiors_uid] for nature, superiors_uid in self.superiors_list.items()}
215 215
 
216 216
     ## Add a superior in the type hierarchy
217 217
     # @param em_type EmType: An EmType instance
@@ -292,17 +292,17 @@ class EmType(EmComponent):
292 292
         if not em_class:
293 293
             raise EmComponentCheckError("class_id contains an uid that does not exists '%d'" % self.class_id)
294 294
         if not isinstance(em_class, EditorialModel.classes.EmClass):
295
-            raise EmComponentCheckError("class_id contains an uid from a component that is not an EmClass but a %s" % str(type(emc_class)))
295
+            raise EmComponentCheckError("class_id contains an uid from a component that is not an EmClass but a %s" % str(type(em_class)))
296 296
 
297
-        for i,f_uid in enumerate(self.fields_list):
297
+        for i, f_uid in enumerate(self.fields_list):
298 298
             field = self.model.component(f_uid)
299 299
             if not field:
300
-                raise EmComponentCheckError("The element %d of selected_field is a non existing uid '%d'"%(i, f_uid))
300
+                raise EmComponentCheckError("The element %d of selected_field is a non existing uid '%d'" % (i, f_uid))
301 301
             if not isinstance(field, EmField):
302
-                raise EmComponentCheckError("The element %d of selected_field is not an EmField but a %s" % (i, str(type(field)) ))
302
+                raise EmComponentCheckError("The element %d of selected_field is not an EmField but a %s" % (i, str(type(field))))
303 303
             if not field.optional:
304
-                raise EmComponentCheckError("The element %d of selected_field is an EmField not optional"  % i )
305
-            if field.fieldgroup_id not in [ fg.uid for fg in self.fieldgroups() ]:
304
+                raise EmComponentCheckError("The element %d of selected_field is an EmField not optional" % i)
305
+            if field.fieldgroup_id not in [fg.uid for fg in self.fieldgroups()]:
306 306
                 raise EmComponentCheckError("The element %d of selected_field is an EmField that is part of an EmFieldGroup that is not associated with this EmType" % i)
307 307
 
308 308
         for nature, superiors_uid in self.superiors_list.items():
@@ -313,13 +313,13 @@ class EmType(EmComponent):
313 313
                 if not isinstance(em_type, EmType):
314 314
                     raise EmComponentCheckError("The superior is a component that is not an EmType but a %s" % (str(type(em_type))))
315 315
                 if nature not in EmClassType.natures(self.em_class.classtype):
316
-                    raise EmComponentCheckError("The relation nature '%s' of the superior is not valid for this EmType classtype '%s'", (nature, self.classtype) )
316
+                    raise EmComponentCheckError("The relation nature '%s' of the superior is not valid for this EmType classtype '%s'", (nature, self.classtype))
317 317
 
318 318
                 nat_spec = getattr(EmClassType, self.em_class.classtype)['hierarchy'][nature]
319 319
 
320 320
                 if nat_spec['attach'] == 'classtype':
321 321
                     if self.classtype != em_type.classtype:
322
-                        raise EmComponentCheckError("The superior is of '%s' classtype. But the current type is of '%s' classtype, and relation nature '%s' require two EmType of same classtype" % (em_type.classtype, self.classtype, nature) )
322
+                        raise EmComponentCheckError("The superior is of '%s' classtype. But the current type is of '%s' classtype, and relation nature '%s' require two EmType of same classtype" % (em_type.classtype, self.classtype, nature))
323 323
                 elif nat_spec['attach'] == 'type':
324 324
                     if self.uid != em_type.uid:
325 325
                         raise EmComponentCheckError("The superior is a different EmType. But the relation nature '%s' require the same EmType" % (nature))
@@ -330,14 +330,14 @@ class EmType(EmComponent):
330 330
                     depth = 1
331 331
                     cur_type = em_type
332 332
                     while depth >= nat_spec['max_depth']:
333
-                        depth +=1
333
+                        depth += 1
334 334
                         if len(cur_type.subordinates()[nature]) == 0:
335 335
                             break
336 336
                     else:
337
-                        raise EmComponentCheckError("The relation with the element %d of subordinates has a depth superior than the maximum depth ( %d ) allowed by the relation's nature ( '%s' )" %( i, nat_spec['max_depth'], nature) )
337
+                        raise EmComponentCheckError("The relation with superior %d  has a depth superior than the maximum depth (%d) allowed by the relation's nature '%s'" % (superior_uid, nat_spec['max_depth'], nature))
338 338
 
339 339
         for nature in self.subordinates():
340 340
             nat_spec = getattr(EmClassType, self.em_class.classtype)['hierarchy'][nature]
341 341
             if 'max_child' in nat_spec and nat_spec['max_child'] > 0:
342 342
                 if len(self.subordinates()[nature]) > nat_spec['max_child']:
343
-                    raise EmComponentCheckError("The EmType has more child than allowed in the relation's nature : %d > %d" (len(self.subordinates()[nature], nat_spec['max_child'])))
343
+                    raise EmComponentCheckError("The EmType has more child than allowed in the relation's nature : %d > %d" % (len(self.subordinates()[nature], nat_spec['max_child'])))

Loading…
Cancel
Save