Browse Source

EmClass: pylint and pep8

ignoring:
 - line too long
 - doctring
ArnAud 9 years ago
parent
commit
fcbf952d6d
1 changed files with 19 additions and 20 deletions
  1. 19
    20
      EditorialModel/classes.py

+ 19
- 20
EditorialModel/classes.py View File

@@ -12,12 +12,14 @@ import sqlalchemy as sql
12 12
 import EditorialModel.fieldtypes as ftypes
13 13
 import EditorialModel
14 14
 
15
+
15 16
 ## @brief Manipulate Classes of the Editorial Model
16 17
 # Create classes of object.
17 18
 #@see EmClass, EmType, EmFieldGroup, EmField
18 19
 class EmClass(EmComponent):
20
+
19 21
     table = 'em_class'
20
-    
22
+
21 23
     ## @brief Specific EmClass fields
22 24
     # @see EditorialModel::components::EmComponent::_fields
23 25
     _fields = [
@@ -31,12 +33,12 @@ class EmClass(EmComponent):
31 33
     # @param class_type EmClasstype: type of the class
32 34
     # @return An EmClass instance
33 35
     @classmethod
34
-    def create(c, name, class_type):
36
+    def create(cls, name, class_type):
35 37
         try:
36 38
             res = EmClass(name)
37 39
             logger.info("Trying to create an EmClass that allready exists")
38 40
         except EmComponentNotExistError:
39
-            res = c._createDb(name, class_type)
41
+            res = cls._create_db(name, class_type)
40 42
             logger.debug("EmClass successfully created")
41 43
 
42 44
         return res
@@ -45,39 +47,37 @@ class EmClass(EmComponent):
45 47
     ## Isolate SQL for EmClass::create
46 48
     # @todo Remove hardcoded default value for icon
47 49
     # @return An instance of EmClass
48
-    def _createDb(c, name, class_type):
50
+    def _create_db(cls, name, class_type):
49 51
         """ Do the db querys for EmClass::create() """
50 52
 
51 53
         #Create a new entry in the em_class table
52
-        values = { 'name':name, 'classtype':class_type['name'], 'icon':0 }
53
-        resclass = super(EmClass,c).create(**values)
54
+        values = {'name': name, 'classtype': class_type['name'], 'icon': 0}
55
+        resclass = super(EmClass, cls).create(**values)
54 56
 
55
-
56
-        dbe = c.getDbE()
57
+        dbe = cls.getDbE()
57 58
         conn = dbe.connect()
58 59
 
59 60
         #Create a new table storing LodelObjects of this EmClass
60 61
         meta = sql.MetaData()
61 62
         emclasstable = sql.Table(name, meta,
62
-            sql.Column('uid', sql.VARCHAR(50), primary_key = True))
63
+            sql.Column('uid', sql.VARCHAR(50), primary_key=True))
63 64
         emclasstable.create(conn)
64 65
 
65 66
         conn.close()
66 67
 
67 68
         return resclass
68 69
 
69
-
70 70
     ## Retrieve list of the field_groups of this class
71 71
     # @return field_groups [EmFieldGroup]:
72 72
     def fieldgroups(self):
73
-        records = self._fieldgroupsDb()
74
-        fieldgroups = [ EditorialModel.fieldgroups.EmFieldGroup(int(record.uid)) for record in records ]
73
+        records = self._fieldgroups_db()
74
+        fieldgroups = [EditorialModel.fieldgroups.EmFieldGroup(int(record.uid)) for record in records]
75 75
 
76 76
         return fieldgroups
77 77
 
78 78
     ## Isolate SQL for EmClass::fieldgroups
79 79
     # @return An array of dict (sqlalchemy fetchall)
80
-    def _fieldgroupsDb(self):
80
+    def _fieldgroups_db(self):
81 81
         dbe = self.__class__.getDbE()
82 82
         emfg = sql.Table(EditorialModel.fieldgroups.EmFieldGroup.table, sqlutils.meta(dbe))
83 83
         req = emfg.select().where(emfg.c.class_id == self.uid)
@@ -86,18 +86,17 @@ class EmClass(EmComponent):
86 86
         res = conn.execute(req)
87 87
         return res.fetchall()
88 88
 
89
-
90 89
     ## Retrieve list of fields
91 90
     # @return fields [EmField]:
92 91
     def fields(self):
93 92
         fieldgroups = self.fieldgroups()
94 93
         fields = []
95 94
         for fieldgroup in fieldgroups:
96
-            fields += self._fieldsDb(fieldgroup.uid)
95
+            fields += self._fields_db(fieldgroup.uid)
97 96
 
98 97
         return fields
99 98
 
100
-    def _fieldsDb(fieldgroup_id):
99
+    def _fields_db(self, fieldgroup_id):
101 100
         dbe = self.__class__.getDbE()
102 101
         fields = sql.Table(EditorialModel.fields.EmField.table, sqlutils.meta(dbe))
103 102
         req = fields.select().where(fields.c.fieldgroup_id == fieldgroup_id)
@@ -109,14 +108,14 @@ class EmClass(EmComponent):
109 108
     ## Retrieve list of type of this class
110 109
     # @return types [EmType]:
111 110
     def types(self):
112
-        records = self._typesDb()
113
-        types = [ EditorialModel.types.EmType(int(record.uid)) for record in records ]
111
+        records = self._types_db()
112
+        types = [EditorialModel.types.EmType(int(record.uid)) for record in records]
114 113
 
115 114
         return types
116 115
 
117 116
     ## Isolate SQL for EmCLass::types
118 117
     # @return An array of dict (sqlalchemy fetchall)
119
-    def _typesDb(self):
118
+    def _types_db(self):
120 119
         dbe = self.__class__.getDbE()
121 120
         emtype = sql.Table(EditorialModel.types.EmType.table, sqlutils.meta(dbe))
122 121
         req = emtype.select().where(emtype.c.class_id == self.uid)
@@ -137,7 +136,7 @@ class EmClass(EmComponent):
137 136
         #Create a new table storing LodelObjects that are linked to this EmClass
138 137
         conn = self.__class__.getDbE().connect()
139 138
         meta = sql.MetaData()
140
-        emlinketable = sql.Table(table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key = True))
139
+        emlinketable = sql.Table(table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key=True))
141 140
         emlinketable.create(conn)
142 141
         conn.close()
143 142
 

Loading…
Cancel
Save