Quellcode durchsuchen

Added comments on filesystem session plugin's modules

Roland Haroutiounian vor 8 Jahren
Ursprung
Commit
48f295998b

+ 9
- 0
plugins/filesystem_session/filesystem_session.py Datei anzeigen

@@ -1,20 +1,29 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 
4
+## @brief An extended dictionary representing a session in the file system
4 5
 class FileSystemSession(dict):
5 6
 
7
+    ## @brief Constructor
8
+    # @param token str
6 9
     def __init__(self, token):
7 10
         self.__token = token
8 11
         self.__path = None
9 12
 
13
+    ## @brief token getter
14
+    # @return str
10 15
     @property
11 16
     def token(self):
12 17
         return self.__token
13 18
 
19
+    ## @brief path getter
20
+    # @return str
14 21
     @property
15 22
     def path(self):
16 23
         return self.__path
17 24
 
25
+    ## @brief path setter
26
+    # @param path str
18 27
     @path.setter
19 28
     def path(self, path):
20 29
         self.__path = path

+ 9
- 1
plugins/filesystem_session/main.py Datei anzeigen

@@ -16,6 +16,7 @@ __sessions = dict()
16 16
 
17 17
 SESSION_TOKENSIZE = 150
18 18
 
19
+
19 20
 ## @brief generates a new session token
20 21
 # @return str
21 22
 def generate_token():
@@ -34,7 +35,7 @@ def check_token(token):
34 35
     if token not in __sessions.keys():
35 36
         raise ClientAuthenticationFailure("No session found for this token")
36 37
 
37
-
38
+## @brief returns a session file path for a specific token
38 39
 def generate_file_path(token):
39 40
     return os.path.abspath(os.path.join(Settings.sessions.directory, Settings.sessions.file_template) % token)
40 41
 
@@ -81,6 +82,9 @@ def destroy_session(token):
81 82
     logger.debug("Session %s unregistered" % token)
82 83
 
83 84
 
85
+## @brief restores a session's content
86
+# @param token str
87
+# @return FileSystemSession|None
84 88
 def restore_session(token):
85 89
     gc()
86 90
     check_token(token)
@@ -93,6 +97,9 @@ def restore_session(token):
93 97
         return None  # raise FileNotFoundError("Session file not found for the token %s" % token)
94 98
 
95 99
 
100
+## @brief saves the session's content to a file
101
+# @param token str
102
+# @param datas dict
96 103
 def save_session(token, datas):
97 104
     session = datas
98 105
     if not isinstance(datas, FileSystemSession):
@@ -109,6 +116,7 @@ def save_session(token, datas):
109 116
     logger.debug("Session %s saved" % token)
110 117
 
111 118
 
119
+## @brief session store's garbage collector
112 120
 def gc():
113 121
     # Unregistered files in the session directory
114 122
     session_files_directory = os.path.abspath(Settings.sessions.directory)

Laden…
Abbrechen
Speichern