Pārlūkot izejas kodu

Some docstring fixes

Roland Haroutiounian 7 gadus atpakaļ
vecāks
revīzija
c376302786

+ 25
- 19
lodel/editorial_model/translator/xmlfile.py Parādīt failu

@@ -16,17 +16,19 @@ LodelContext.expose_modules(globals(), {
16 16
 #
17 17
 # Structure of a xml file which represents an editorial model:
18 18
 # <ul>
19
-# <li>\<name\>: name of the model, field <b><em>name</em></b>  in class <b><em>EditorialModel</em></b> 
20
-# <li>\<description\>: field <b><em>description</em></b>  of a composed element, one for each language translation named 
21
-#               <ul><li>\<fre\> for french, 
22
-#               <li>\<eng\> for english,
23
-#               <li>\<esp\> for spanish,
24
-#               <li>\<ger\> for german</ul>
25
-# <li>\<classes\>: set of all <b><em>EmClass</em></b> in the model \n
19
+#   <li>\<name\>: name of the model, field <b><em>name</em></b>  in class <b><em>EditorialModel</em></b>
20
+#   <li>\<description\>: field <b><em>description</em></b>  of a composed element, one for each language translation named
21
+#               <ul>
22
+#                   <li>\<fre\> for french,
23
+#                   <li>\<eng\> for english,
24
+#                   <li>\<esp\> for spanish,
25
+#                   <li>\<ger\> for german
26
+#               </ul>
27
+#   <li>\<classes\>: set of all <b><em>EmClass</em></b> in the model \n
26 28
 #    for each classe: \n
27 29
 #       \<class\><ul>
28
-#       <li>\<uid\>the class's id
29
-#       <li>\<display_name\> The name of the class, field <b><em>display_name</em></b>  of the <b><em>EmClass</em></b> , in different languages if they're available :
30
+#           <li>\<uid\>the class's id
31
+#           <li>\<display_name\> The name of the class, field <b><em>display_name</em></b>  of the <b><em>EmClass</em></b> , in different languages if they're available :
30 32
 #               <ul><li>\<fre\> for french, 
31 33
 #               <li>\<eng\> for english,
32 34
 #               <li>\<esp\> for spanish,
@@ -43,8 +45,9 @@ LodelContext.expose_modules(globals(), {
43 45
 #               <li>\<help_text\> Short explanation of the class's purpose, in different languages, as above
44 46
 #               <li>\<group\><b><em>uid</em></b> of the group of the field <b><em>group</em></b> of the <b><em>EmClass</em></b>
45 47
 #               <li>\<datahandler_name\> field <b><em>datahandler_name</em></b> of the Emfield, the name of a datahandler
46
-#               <li>\<datahandler_options\>, a list of xml items, each of them named with an option name and contains its value</ul></ul>
47
-# <li>\<groups\>: set of all the groups <b><em>EmGroup</em></b> in the model\n
48
+#               <li>\<datahandler_options\>, a list of xml items, each of them named with an option name and contains its value</ul>
49
+#               </ul>
50
+#   <li>\<groups\>: set of all the groups <b><em>EmGroup</em></b> in the model\n
48 51
 #    for each group:\n
49 52
 #       <ul><li>\<uid\> uid of the <b><em>EmField</em></b>
50 53
 #       <li>\<display_name\> field <b><em>display_name</em></b>  of the <b><em>EmField</em></b>, in different languages, as above
@@ -58,7 +61,7 @@ LodelContext.expose_modules(globals(), {
58 61
 #           <li>\<emclasses\> all the emclasses with, for each of them:\n
59 62
 #               \<emclass\> \n
60 63
 #                   <ul><li> \<uid\> <b><em>uid</em></b> of the <b><em>EmClass</em></b></ul></ul></ul>
61
-
64
+# </ul>
62 65
 
63 66
 
64 67
 
@@ -66,8 +69,8 @@ LodelContext.expose_modules(globals(), {
66 69
 
67 70
 ##@brief Saves a model in a xml file
68 71
 # @param model EditorialModel : the model to save
69
-# @param filename str|None : if None display on stdout else writes in the file filename
70
-
72
+# @param kwargs dict :
73
+#    - filename str|None : if None display on stdout else writes in the file filename
71 74
 def save(model, **kwargs):
72 75
     Em = etree.Element("editorial_model")
73 76
     em_name = etree.SubElement(Em, 'name')
@@ -144,9 +147,9 @@ def write_datahandler_xml(etree, elem, dhdl_name, **kwargs):
144 147
 # @param uid : the uid of the EmField
145 148
 # @param name : the name of the field
146 149
 # @param help_text : explanations of the EmField
147
-# @param group_uid : the uid of a group, can be None
148
-# @datahandler_name
149
-# @**kwargs : options of the datahandler
150
+# @param group : the uid of a group, can be None
151
+# @param datahandler_name str
152
+# @param **kwargs : options of the datahandler
150 153
 def write_emfield_xml(etree, elem, uid, name, help_text, group, datahandler_name, **kwargs):
151 154
     emfield = etree.SubElement(elem,'field')
152 155
     emfield_uid = etree.SubElement(emfield, 'uid')
@@ -170,9 +173,11 @@ def write_emfield_xml(etree, elem, uid, name, help_text, group, datahandler_name
170 173
 ##@brief Writes a representation of a EmGroup in xml
171 174
 # @param etree : the xml object
172 175
 # @param elem : the element for the EmGroup
176
+# @param uid str : lodel unique identifier
173 177
 # @param name  : the name of the group
174 178
 # @param help_text : explanations of the EmGroup
175 179
 # @param requires : a list of the group's uids whose this group depends
180
+# @param components
176 181
 def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
177 182
     emgroup = etree.SubElement(elem, 'group')
178 183
     emgroup_uid = etree.SubElement(emgroup, 'uid')
@@ -207,8 +212,10 @@ def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
207 212
 ##@brief Writes a representation of a EmClass in xml
208 213
 # @param etree : the xml object
209 214
 # @param elem : the element for the EmClass
215
+# @param uid
210 216
 # @param name  : the name of the group
211 217
 # @param help_text : explanations of the EmClass
218
+# @param group
212 219
 # @param fields : a dict
213 220
 # @param parents : a list of EmClass uids
214 221
 # @param abstract : a boolean
@@ -245,7 +252,7 @@ def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents,
245 252
     emclass_parents.text = ",".join(parents_list)
246 253
 
247 254
 ##@brief Loads a model from a xml file
248
-# @param model EditorialModel : the model to load
255
+# @param filename str : file path of the XML file from which the model will be loaded
249 256
 # @return a new EditorialModel object
250 257
 def load(filename):
251 258
 
@@ -452,7 +459,6 @@ def load_group_xml(model, elem):
452 459
 
453 460
 ##@brief Constructs a MlString from a xml description
454 461
 # @param elem : the element which represents the MlString
455
-# @param model  : the model which will contain the new group
456 462
 # @return a new MlString object
457 463
 def load_mlstring_xml(elem):
458 464
     mlstr = dict()

+ 19
- 15
lodel/leapi/datahandlers/base_classes.py Parādīt failu

@@ -36,10 +36,13 @@ class DataHandler(object):
36 36
 
37 37
     directly_editable = True
38 38
     ##@brief constructor
39
-    # @param internal False | str : define whether or not a field is internal
40
-    # @param immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is
41
-    #                         designed globally and immutable
42
-    # @param **args
39
+    # @param **kwargs dict
40
+    #   - internal False | str : define whether or not a field is internal
41
+    #   - immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is designed globally and immutable
42
+    #   - nullable bool
43
+    #   - uniq bool
44
+    #   - primary_key bool
45
+    #   - default mixed
43 46
     # @throw NotImplementedError if it is instanciated directly
44 47
     def __init__(self, **kwargs):
45 48
         if self.__class__ == DataHandler:
@@ -143,7 +146,7 @@ class DataHandler(object):
143 146
     #@param cur_value : the value from the current field (identified by fieldname)
144 147
     #@return the value
145 148
     #@see construct_data() lodel2_dh_check_impl
146
-    def _construct_data(self, empcomponent, fname, datas, cur_value):
149
+    def _construct_data(self, emcomponent, fname, datas, cur_value):
147 150
         return cur_value
148 151
 
149 152
     ##@brief Check datas consistency
@@ -206,21 +209,21 @@ class DataHandler(object):
206 209
     # @return DataField child class
207 210
     # @note To access custom data handlers it can be cool to prefix the handler name by plugin name for example ? (to ensure name unicity)
208 211
     @classmethod
209
-    def from_name(cls, name):
212
+    def from_name(cls, fieldtype_name):
210 213
         cls.load_base_handlers()
211 214
         all_handlers = dict(cls._base_handlers, **cls.__custom_handlers)
212
-        name = name.lower()
213
-        if name not in all_handlers:
214
-            raise NameError("No data handlers named '%s'" % (name,))
215
-        return all_handlers[name]
215
+        fieldtype_name = fieldtype_name.lower()
216
+        if fieldtype_name not in all_handlers:
217
+            raise NameError("No data handlers named '%s'" % (fieldtype_name,))
218
+        return all_handlers[fieldtype_name]
216 219
 
217 220
     ##@brief Return the module name to import in order to use the datahandler
218 221
     # @param data_handler_name str : Data handler name
219 222
     # @return a str
220 223
     @classmethod
221
-    def module_name(cls, name):
222
-        name = name.lower()
223
-        handler_class = cls.from_name(name)
224
+    def module_name(cls, data_handler_name):
225
+        data_handler_name = data_handler_name.lower()
226
+        handler_class = cls.from_name(data_handler_name)
224 227
         return '{module_name}.{class_name}'.format(
225 228
                                                     module_name=handler_class.__module__,
226 229
                                                     class_name=handler_class.__name__
@@ -386,6 +389,7 @@ class MultipleRef(Reference):
386 389
 
387 390
     ##
388 391
     # @param max_item int | None : indicate the maximum number of item referenced by this field, None mean no limit
392
+    # @param kwargs dict
389 393
     def __init__(self, max_item=None, **kwargs):
390 394
         self.max_item = max_item
391 395
         super().__init__(**kwargs)
@@ -421,7 +425,7 @@ class MultipleRef(Reference):
421 425
         return new_val
422 426
 
423 427
     ##@brief Utility method designed to fetch referenced objects
424
-    #@param value mixed : the field value
428
+    #@param values mixed : the field value
425 429
     #@return A list of LeObject child class instance
426 430
     #@throw LodelDataHandlerConsistencyException if some referenced objects
427 431
     #were not found
@@ -453,7 +457,7 @@ some referenced objects. Followinf uid were not found : %s" % ','.join(left))
453 457
 class DatasConstructor(object):
454 458
 
455 459
     ## @brief Init a DatasConstructor
456
-    # @param lec LeCrud : @ref LeObject child class
460
+    # @param leobject LeCrud : @ref LeObject child class
457 461
     # @param datas dict : dict with field name as key and field values as value
458 462
     # @param fields_handler dict : dict with field name as key and data handler instance as value
459 463
     def __init__(self, leobject, datas, fields_handler):

+ 0
- 2
lodel/leapi/datahandlers/datas.py Parādīt failu

@@ -21,7 +21,6 @@ build its content'
21 21
     
22 22
     ##@brief Build its content with a field list and a format string
23 23
     # @param format_string str
24
-    # @param max_length int : the maximum length of the handled value
25 24
     # @param field_list list : List of field to use
26 25
     # @param **kwargs
27 26
     def __init__(self, format_string, field_list, **kwargs):
@@ -115,7 +114,6 @@ class Concat(FormatString):
115 114
     
116 115
     ##@brief Build its content with a field list and a separator
117 116
     # @param field_list list : List of field to use
118
-    # @param max_length int : the maximum length of the handled value
119 117
     # @param separator str
120 118
     # @param **kwargs    
121 119
     def __init__(self, field_list, separator = ' ', **kwargs):

+ 2
- 1
lodel/leapi/datahandlers/datas_base.py Parādīt failu

@@ -45,7 +45,8 @@ class Integer(DataField):
45 45
 
46 46
     ##@brief Check and cast value in appropriate type
47 47
     #@param value *
48
-    #@throw FieldValidationError if value is unappropriate or can not be cast 
48
+    #@param strict bool : if True, checks if the given value is strictly of the Integer type, if False, it tries to cast it to an Integer
49
+    #@throw FieldValidationError if value is unappropriate or can not be cast
49 50
     #@return value
50 51
     def _check_data_value(self, value, strict = False):
51 52
         value = super()._check_data_value(value)

+ 2
- 6
lodel/leapi/datahandlers/references.py Parādīt failu

@@ -16,8 +16,7 @@ class Link(SingleRef):
16 16
 class List(MultipleRef):
17 17
 
18 18
     ##@brief instanciates a list reference
19
-    # @param allowed_classes list | None : list of allowed em classes if None no restriction
20
-    # @param internal bool
19
+    # @param max_length
21 20
     # @param kwargs
22 21
     def __init__(self, max_length = None, **kwargs):
23 22
         super().__init__(**kwargs)
@@ -43,8 +42,6 @@ a list : %s" % e)
43 42
 class Set(MultipleRef):
44 43
 
45 44
     ##@brief instanciates a set reference
46
-    # @param allowed_classes list | None : list of allowed em classes if None no restriction
47
-    # @param internal bool : if False, the field is not internal
48 45
     # @param kwargs : Other named arguments
49 46
     def __init__(self, **kwargs):
50 47
         super().__init__(**kwargs)
@@ -69,8 +66,6 @@ a set : %s" % e)
69 66
 class Map(MultipleRef):
70 67
 
71 68
     ##@brief instanciates a dict reference
72
-    # @param allowed_classes list | None : list of allowed em classes if None no restriction
73
-    # @param internal bool : if False, the field is not internal
74 69
     # @param kwargs : Other named arguments
75 70
     def __init__(self, **kwargs):
76 71
         super().__init__(**kwargs)
@@ -97,6 +92,7 @@ class Hierarch(MultipleRef):
97 92
     # @param back_reference tuple : Here it is mandatory to have a back ref (like a parent field)
98 93
     # @param max_depth int | None :  limit of depth
99 94
     # @param max_childs int | Nine : maximum number of childs by nodes
95
+    # @param kwargs
100 96
     def __init__(self, back_reference, max_depth = None, max_childs = None, **kwargs):
101 97
         super().__init__(   back_reference = back_reference,
102 98
                             max_depth = max_depth,

+ 0
- 1
lodel/leapi/lefactory.py Parādīt failu

@@ -115,7 +115,6 @@ def forge_optval(optval):
115 115
 
116 116
 ##@brief Generate dyncode from an EmClass
117 117
 # @param model EditorialModel : 
118
-# @param emclass EmClass : EmClass instance
119 118
 # @todo delete imports. It is never use, consequently changed return parameters.
120 119
 # @return a tuple with emclass python code, a set containing modules name to import, and a list of python instruction to bootstrap dynamic code, in this order
121 120
 def generate_classes(model):

+ 1
- 1
lodel/leapi/lefactory_common.py Parādīt failu

@@ -17,7 +17,7 @@ def name2class(name):
17 17
 ##@brief Return a dynamically generated class given it's name
18 18
 #@note Case insensitive version of name2class
19 19
 #@param name str
20
-#@retrun False or a child class of LeObject
20
+#@return False or a child class of LeObject
21 21
 def lowername2class(name):
22 22
     name = name.lower()
23 23
     new_dict = {k.lower():v for k,v in dynclasses_dict.items()}

+ 4
- 5
lodel/leapi/leobject.py Parādīt failu

@@ -294,7 +294,7 @@ class LeObject(object):
294 294
 
295 295
     ##@brief Read only access to all datas
296 296
     # @note for fancy data accessor use @ref LeObject.g attribute @ref LeObjectValues instance
297
-    # @param name str : field name
297
+    # @param field_name str : field name
298 298
     # @return the Value
299 299
     # @throw RuntimeError if the field is not initialized yet
300 300
     # @throw NameError if name is not an existing field name
@@ -516,6 +516,7 @@ construction and consitency when datas are not complete\n")
516 516
     # @warning assert that datas is complete
517 517
     # @param cls
518 518
     # @param datas dict : Datas that have been returned by LeCrud.prepare_datas() method
519
+    # @param type_query str : Type of query
519 520
     @classmethod
520 521
     def make_consistency(cls, datas, type_query = 'insert'):
521 522
         for fname, dh in cls._fields.items():
@@ -565,8 +566,8 @@ construction and consitency when datas are not complete\n")
565 566
         return result
566 567
     
567 568
     ## @brief Delete instances of LeObject
568
-    #@param uids a list: lists of (fieldname, fieldvalue), with fieldname in cls._uids
569
-    #@returns the 
569
+    #@param query_filters list: lists of (fieldname, fieldvalue), with fieldname in cls._uids
570
+    #@returns the number of deleted items
570 571
     @classmethod
571 572
     def delete_bundle(cls, query_filters):
572 573
         deleted = 0
@@ -585,7 +586,6 @@ construction and consitency when datas are not complete\n")
585 586
             
586 587
     ## @brief Get instances of LeObject
587 588
     #
588
-    #@param target_class LeObject : class of object the query is about
589 589
     #@param query_filters dict : (filters, relational filters), with filters is a list of tuples : (FIELD, OPERATOR, VALUE) )
590 590
     #@param field_list list|None : list of string representing fields see 
591 591
     #@ref leobject_filters
@@ -593,7 +593,6 @@ construction and consitency when datas are not complete\n")
593 593
     #@param group list : A list of field names or tuple (FIELDNAME,[ASC | DESC])
594 594
     #@param limit int : The maximum number of returned results
595 595
     #@param offset int : offset
596
-    #@param Inst
597 596
     #@return a list of items (lists of (fieldname, fieldvalue))
598 597
     @classmethod
599 598
     def get(cls, query_filters, field_list=None, order=None, group=None, limit=None, offset=0):

Notiek ielāde…
Atcelt
Saglabāt