Browse Source

PEP8/PyLint on fields.py

Roland Haroutiounian 8 years ago
parent
commit
a07f0a10af
1 changed files with 9 additions and 11 deletions
  1. 9
    11
      EditorialModel/fields.py

+ 9
- 11
EditorialModel/fields.py View File

@@ -55,15 +55,15 @@ class EmField(EmComponent):
55 55
 
56 56
         self.fieldtype = fieldtype
57 57
         self._fieldtype_args = kwargs
58
-        self._fieldtype_args.update({'nullable' : nullable, 'uniq' : uniq, 'internal': self.internal})
58
+        self._fieldtype_args.update({'nullable': nullable, 'uniq': uniq, 'internal': self.internal})
59 59
         try:
60 60
             fieldtype_instance = self._fieldtype_cls(**self._fieldtype_args)
61 61
         except AttributeError as e:
62
-            raise AttributeError("Error will instanciating fieldtype : %s"%e)
62
+            raise AttributeError("Error will instanciating fieldtype : %s" % e)
63 63
 
64 64
         if 'default' in kwargs:
65 65
             if not fieldtype_instance.check(default):
66
-                raise TypeError("Default value ('%s') is not valid given the fieldtype '%s'"%(default, fieldtype))
66
+                raise TypeError("Default value ('%s') is not valid given the fieldtype '%s'" % (default, fieldtype))
67 67
 
68 68
         self.nullable = nullable
69 69
         self.uniq = uniq
@@ -76,13 +76,13 @@ class EmField(EmComponent):
76 76
     @staticmethod
77 77
     ## @brief Return the list of allowed field type
78 78
     def fieldtypes_list():
79
-        return [f for f in EditorialModel.fieldtypes.__all__ if f != '__init__' and f != 'generic' ]
79
+        return [f for f in EditorialModel.fieldtypes.__all__ if f != '__init__' and f != 'generic']
80 80
 
81 81
     ##@brief Return the EmFieldgroup this EmField belongs to
82 82
     @property
83 83
     def _fieldgroup(self):
84 84
         return self.model.component(self.fieldgroup_id)
85
-    
85
+
86 86
     ## @brief Returns the EmClass this EmField belongs to
87 87
     @property
88 88
     def em_class(self):
@@ -92,7 +92,6 @@ class EmField(EmComponent):
92 92
     # @return a fieldtype instance
93 93
     def fieldtype_instance(self):
94 94
         return self._fieldtype_cls(**self._fieldtype_args)
95
-        
96 95
 
97 96
     ## @brief Return the list of relation fields for a rel_to_type
98 97
     # @return None if the field is not a rel_to_type else return a list of EmField
@@ -103,7 +102,7 @@ class EmField(EmComponent):
103 102
         return [f for f in self.model.components(EmField) if f.rel_field_id == self.uid]
104 103
 
105 104
     ## Check if the EmField is valid
106
-    # 
105
+    #
107 106
     # Check multiple things :
108 107
     # - the fieldgroup_id is valid
109 108
     # - the name is uniq in the EmClass
@@ -120,13 +119,12 @@ class EmField(EmComponent):
120 119
             raise EmComponentCheckError("fieldgroup_id contains an uid from a component that is not an EmFieldGroup but a %s" % str(type(em_fieldgroup)))
121 120
         """
122 121
         #Uniq Name check
123
-        if len([ f for f in self.em_class.fields() if f.name == self.name]) > 1:
124
-            raise EmComponentCheckError("The field %d has a name '%s' that is not uniq in the EmClass %d"%(self.uid, self.name, self.em_class.uid))
122
+        if len([f for f in self.em_class.fields() if f.name == self.name]) > 1:
123
+            raise EmComponentCheckError("The field %d has a name '%s' that is not uniq in the EmClass %d" % (self.uid, self.name, self.em_class.uid))
125 124
         #rel2type uniq check
126 125
         if self.fieldtype == 'rel2type':
127 126
             if len([f for f in self.em_class.fields() if f.fieldtype == 'rel2type' and f.rel_to_type_id == self.rel_to_type_id]) > 1:
128
-                raise EmComponentCheckError("The rel2type %d is not uniq, another field is linked to the same type '%s' in the same class '%s'"%(self.uid, self.model.component(self.rel_to_type_id).name, self.em_class.name))
129
-
127
+                raise EmComponentCheckError("The rel2type %d is not uniq, another field is linked to the same type '%s' in the same class '%s'" % (self.uid, self.model.component(self.rel_to_type_id).name, self.em_class.name))
130 128
 
131 129
     ## @brief Delete a field if it's not linked
132 130
     # @return bool : True if deleted False if deletion aborded

Loading…
Cancel
Save