Pārlūkot izejas kodu

[Doxygen] fixing some warnings at documentation generation

Yann Weber 8 gadus atpakaļ
vecāks
revīzija
e4fb0532f2
4 mainītis faili ar 52 papildinājumiem un 35 dzēšanām
  1. 2
    2
      EditorialModel/fieldtypes/naturerelation.py
  2. 11
    11
      Lodel/hooks.py
  3. 9
    2
      Lodel/logger.py
  4. 30
    20
      Lodel/user.py

+ 2
- 2
EditorialModel/fieldtypes/naturerelation.py Parādīt failu

@@ -1,11 +1,11 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-from .char import EmFieldType
3
+from . import char
4 4
 
5 5
 import EditorialModel.classtypes as classtypes
6 6
 import leapi.lerelation as lerelation
7 7
 
8
-class EmFieldType(EmFieldType):
8
+class EmFieldType(char.EmFieldType):
9 9
     
10 10
     help = 'Stores a relation\'s nature'
11 11
 

+ 11
- 11
Lodel/hooks.py Parādīt failu

@@ -16,23 +16,19 @@ class DecoratedWrapper(object):
16 16
         self._hook = hook
17 17
     
18 18
     ## @brief Call the callback
19
-    # @param *args
20
-    # @param **kwargs
19
+    # @param hook_name str : The name of the called hook
20
+    # @param caller * : The caller (depends on the hook)
21
+    # @param payload * : Datas that depends on the hook
21 22
     # @return modified payload
22 23
     def __call__(self, hook_name, caller, payload):
23 24
         return self._hook(hook_name, caller, payload)
24 25
 
25 26
 ## @brief Decorator designed to register hook's callbacks
26 27
 #
27
-# Example : 
28
-#
29
-# <pre>
30
-# @LodelHook('hook_name', 42)
31
-# def super_callback(hook_name, caller, payload):
32
-#    return payload
33
-#
34
-# LodelHook.call_hook('hook_name', caller, 'foobar') #calls super_callback('hook_name', caller, 'foobar')
35
-# </pre>
28
+# @note Decorated functions are expected to take 3 arguments :
29
+#  - hook_name : the called hook name
30
+#  - caller : the hook caller (depends on the hook)
31
+#  - payload : datas depending on the hook
36 32
 class LodelHook(object):
37 33
     
38 34
     ## @brief Stores all hooks (DecoratedWrapper instances)
@@ -58,7 +54,9 @@ class LodelHook(object):
58 54
 
59 55
     ## @brief Call hooks
60 56
     # @param hook_name str : the hook's name
57
+    # @param caller * : the hook caller (depends on the hook)
61 58
     # @param payload * : datas for the hook
59
+    # @param cls
62 60
     # @return modified payload
63 61
     @classmethod
64 62
     def call_hook(cls, hook_name, caller, payload):
@@ -69,6 +67,7 @@ class LodelHook(object):
69 67
     
70 68
     ## @brief Fetch registered hooks
71 69
     # @param names list | None : optionnal filter on name
70
+    # @param cls
72 71
     # @return a list of functions
73 72
     @classmethod
74 73
     def hook_list(cls, names = None):
@@ -80,6 +79,7 @@ class LodelHook(object):
80 79
         return { name: [(hook._hook, hook._priority) for hook in hooks] for name, hooks in res.items() }
81 80
     
82 81
     ## @brief Unregister all hooks
82
+    # @param cls
83 83
     # @warning REALLY NOT a good idea !
84 84
     # @note implemented for testing purpose
85 85
     @classmethod

+ 9
- 2
Lodel/logger.py Parādīt failu

@@ -24,9 +24,16 @@ def __init_from_settings():
24 24
         add_handler(name, logging_opt)
25 25
 
26 26
 ## @brief Add an handler, identified by a name, to a given logger 
27
-# @param logger logging.Logger : Basically the root logger
27
+#
28
+# logging_opt is a dict with logger option. Allowed keys are : 
29
+# - filename : take a filepath as value and cause the use of a logging.handlers.RotatingFileHandler
30
+# - level : the minimum logging level for a logger, takes values [ 'DEBUG', 'INFO', 'WARNING', 'SECURITY', 'ERROR', 'CRITICAL' ]
31
+# - format : DONT USE THIS OPTION (or if you use it be sure to includes %(_pathname)s %(_lineno)s %(_funcName)s format variables in format string
32
+# - context : boolean, if True include the context (module:lineno:function_name) in the log format
33
+# @todo Move the logging_opt documentation somewhere related with settings
34
+# 
28 35
 # @param name str : The handler name
29
-# @param logging_opt dict : dict containing options ( see @ref jesaispasou_pour_les_details )
36
+# @param logging_opt dict : dict containing options ( see above )
30 37
 def add_handler(name, logging_opt):
31 38
     logger = logging.getLogger()
32 39
     if name in handlers:

+ 30
- 20
Lodel/user.py Parādīt failu

@@ -1,7 +1,6 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-## @package Lodel.user
4
-# @brief Defines Classes designed to handle users and user's context.
3
+## @package Lodel.user Defines classes designed to handler users and user's context
5 4
 #
6 5
 # Classes defined in this package are "helpers" for Lodel2 UI
7 6
 
@@ -20,7 +19,10 @@ class UserIdentity(object):
20 19
     ## @brief Constructor
21 20
     # @note produce immutable instance
22 21
     # @param user_id * : user id
23
-    # @param username str : printable name for user identity
22
+    # @param username str : user name
23
+    # @param fullname str | None : user full name
24
+    # @param identified bool : set it to True if the user is identified
25
+    # @param authenticated bool : set it to True if the user is authenticated (force identified = True )
24 26
     def __init__(self, user_id, username, fullname = None, identified = False, authenticated = False):
25 27
         self.__user_id = user_id
26 28
         self.__username = username
@@ -43,14 +45,17 @@ class UserIdentity(object):
43 45
     def fullname(self):
44 46
         return self.__fullname
45 47
     
48
+    ## @return True if the user is considered as authenticated
46 49
     @property
47 50
     def is_authenticated(self):
48 51
         return self.__authenticated
49 52
 
53
+    ## @return True if the user is considered as identified
50 54
     @property
51 55
     def is_identified(self):
52 56
         return self.__identified
53 57
     
58
+    ## @brief String representation of the instance
54 59
     def __repr__(self):
55 60
         return "User '{user_id}'( username = '{username}', fullname = '{fullname}', identified : {identified}, authentified : {auth}".format(
56 61
                                     user_id = self.__user_id,
@@ -59,7 +64,8 @@ class UserIdentity(object):
59 64
                                     identified = str(self.__identified),
60 65
                                     auth = str(self.__authenticated),
61 66
         )
62
-
67
+    
68
+    ## @brief Human readable text representation of the instance
63 69
     def __str__(self):
64 70
         return self.__fullname
65 71
 
@@ -73,16 +79,11 @@ class UserIdentity(object):
73 79
 
74 80
 ## @brief Decorator class designed to register user authentication methods
75 81
 #
76
-# Example : 
77
-# <pre>
78
-# @authentication_method
79
-# def foo_auth(identity, proof):
80
-#   if ok:
81
-#       return True
82
-#   else:
83
-#       return False
84
-# </pre>
85
-#
82
+# @note Decorated functions are expected to take 2 arguments :
83
+#  - identifier : the user identifier
84
+#  - proof : a proof of identity
85
+# and are expected to return False if authentication fails. When authentication
86
+# is a success the function is expected to return a UserIdentity instance
86 87
 class authentication_method(object):
87 88
     
88 89
     ## @brief Stores registered authentication functions
@@ -101,8 +102,9 @@ class authentication_method(object):
101 102
         return self._method(identifier, proof)
102 103
     
103 104
     ## @brief Try to authenticate a user with registered functions
104
-    # @param identity * : user id
105
+    # @param identifier * : user id
105 106
     # @param proof * : user authentication proof
107
+    # @param cls
106 108
     # @return False or a User Identity instance
107 109
     @classmethod
108 110
     def authenticate(cls, identifier, proof):
@@ -123,11 +125,13 @@ class authentication_method(object):
123 125
         return res
124 126
 
125 127
     ## @return registered identification methods
128
+    # @param cls
126 129
     @classmethod
127 130
     def list_methods(cls):
128 131
         return list(copy.copy(cls.__methods))
129 132
 
130 133
     ## @brief Unregister all authentication methods
134
+    # @param cls
131 135
     # @warning REALLY NOT a good idead !
132 136
     # @note implemented for testing purpose
133 137
     @classmethod
@@ -137,7 +141,10 @@ class authentication_method(object):
137 141
 
138 142
 ## @brief Decorator class designed to register identification methods
139 143
 #
140
-# The decorated methods should take one client_infos argument and returns a UserIdentity instance
144
+# @note The decorated functions are expected to take one argument :
145
+# - client_infos : datas for identification
146
+# and are expected to return False if identification fails. When identification is a success
147
+# the function is expected to return a UserIdentity instance
141 148
 class identification_method(object):
142 149
     
143 150
     ## @brief Stores registered identification functions
@@ -155,7 +162,8 @@ class identification_method(object):
155 162
         return self._method(client_infos)
156 163
 
157 164
     ## @brief Identify someone given datas
158
-    # @param datas * :  datas that may identify a user
165
+    # @param client_infos * :  datas that may identify a user
166
+    # @param cls
159 167
     # @return False if identification fails, else returns an UserIdentity instance
160 168
     @classmethod
161 169
     def identify(cls, client_infos):
@@ -177,11 +185,13 @@ class identification_method(object):
177 185
         return res
178 186
     
179 187
     ## @return registered identification methods
188
+    # @param cls
180 189
     @classmethod
181 190
     def list_methods(cls):
182 191
         return list(copy.copy(cls.__methods))
183 192
 
184 193
     ## @brief Unregister all identification methods
194
+    # @param cls
185 195
     # @warning REALLY NOT a good idead !
186 196
     # @note implemented for testing purpose
187 197
     @classmethod
@@ -206,10 +216,9 @@ class UserContext(object):
206 216
         raise NotImplementedError("Static class")
207 217
 
208 218
     ## @brief User context constructor
209
-    # @param client str : client id (typically IP addr)
210
-    # @param login str|None : given when a client try to be authenticated
211
-    # @param proof str|None : given when a client try to be authenticated
219
+    # @param client_infos * : datas for client identification (typically IP address)
212 220
     # @param **kwargs dict : context
221
+    # @param cls
213 222
     # @todo find another exception to raise
214 223
     @classmethod
215 224
     def init(cls, client_infos, **kwargs):
@@ -235,6 +244,7 @@ class UserContext(object):
235 244
     ## @brief authenticate a user
236 245
     # @param identifier * : user identifier
237 246
     # @param proof * : proof of identity
247
+    # @param cls
238 248
     # @throw an exception if fails
239 249
     # @todo find a better exception to raise when auth fails
240 250
     @classmethod

Notiek ielāde…
Atcelt
Saglabāt