Advertisement
Guest User

Untitled

a guest
Dec 18th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # By Pedro Vapi @2015
  5. # This python file aim is to provide all configuration necessary for using this packageI
  6. #
  7.  
  8.  
  9. class DITICConfig:
  10. """
  11. This class contains all configuration for this server
  12. """
  13. def __init__(self):
  14. """
  15. This class contains those special variables.
  16. All configurations for this server should be done here!
  17. More important variables:
  18.  
  19. # Mapping email to user alias
  20. self.email_to_user = {
  21. 'email': 'user',
  22. ...
  23. }
  24.  
  25. # Map user alias to its Kanban limits
  26. self.user_limits = {
  27. 'user': {
  28. 'status': value,
  29. ...
  30. }
  31. ...
  32. }
  33.  
  34. # System configurations (server address, username, pwd, ...)
  35. self.system = {
  36. 'variable': 'value',
  37. ...
  38. }
  39.  
  40. :return: None
  41. """
  42. self.email_to_user = {
  43. #'vapi@uc.pt': 'Vapi',
  44. #'mviegas@uc.pt': 'Margarida',
  45. #'gina.costa@uc.pt': 'Gina',
  46. #'asantos@uc.pt': 'Alex',
  47. #'cpratas@uc.pt': 'Carlos',
  48. #'joaquim.silva@uc.pt': 'Joaquim',
  49. #'lcastro@uc.pt': 'Paulo',
  50. #'flaviopereira@uc.pt': 'Flavio',
  51. #'olivio@uc.pt': 'Olivio',
  52. #'cdantas@uc.pt': 'Carla',
  53. #'apleitao@uc.pt': 'Paula',
  54.  
  55. 'andresilva2abril@live.com.pt': 'Andre',
  56. 'antonio_jc_araujo@hotmail.com': 'Antonio',
  57. 'lee_3.18@hotmail.com': 'Catia',
  58. 'mailforfilipe@gmail.com': 'Filipe',
  59. 'inesmotapi7@gmail.com': 'Ines',
  60. 'jota.steves@gmail.com': 'Jorge',
  61. 'null@dei.uc.pt': 'null',
  62.  
  63. }
  64. self.email_limits = {
  65. #'vapi@uc.pt': {
  66. # 'new': 7,
  67. # 'open': 1,
  68. # 'rejected': 7,
  69. #},
  70. #'mviegas@uc.pt': {
  71. # 'new': 6,
  72. # 'open': 2,
  73. # 'rejected': 6,
  74. #},
  75. #'gina.costa@uc.pt': {
  76. # 'new': 5,
  77. # 'open': 2,
  78. # 'rejected': 5,
  79. #},
  80. #'asantos@uc.pt': {
  81. # 'new': 14,
  82. # 'open': 2,
  83. # 'rejected': 14,
  84. #},
  85. #'cpratas@uc.pt': {
  86. # 'new': 5,
  87. # 'open': 3,
  88. # 'rejected': 5,
  89. #},
  90. #'joaquim.silva@uc.pt': {
  91. # 'new': 5,
  92. # 'open': 1,
  93. # 'rejected': 5,
  94. #},
  95. #'lcastro@uc.pt': {
  96. # 'new': 7,
  97. # 'open': 3,
  98. # 'rejected': 7,
  99. #},
  100. #'flaviopereira@uc.pt': {
  101. # 'new': 8,
  102. # 'open': 3,
  103. # 'rejected': 8,
  104. #},
  105. #'olivio@uc.pt': {
  106. # 'new': 7,
  107. # 'open': 3,
  108. # 'rejected': 7,
  109. #},
  110. #'cdantas@uc.pt': {
  111. # 'new': 7,
  112. # 'open': 3,
  113. # 'rejected': 7,
  114. #},
  115. #'apleitao@uc.pt': {
  116. # 'new': 5,
  117. # 'open': 2,
  118. # 'rejected': 5,
  119. #},
  120. 'andresilva2abril@live.com.pt':{
  121. 'new': 7,
  122. 'open': 3,
  123. 'rejected':7,
  124.  
  125. },
  126. 'antonio_jc_araujo@hotmail.com':{
  127. 'new': 7,
  128. 'open': 3,
  129. 'rejected':7,
  130.  
  131. },
  132. 'lee_3.18@hotmail.com':{
  133. 'new': 7,
  134. 'open': 3,
  135. 'rejected':7,
  136. 'resolved': 50,
  137. },
  138. 'mailforfilipe@gmail.com':{
  139. 'new': 7,
  140. 'open': 3,
  141. 'rejected':7,
  142.  
  143. },
  144. 'inesmotapi7@gmail.com':{
  145. 'new': 7,
  146. 'open': 3,
  147. 'rejected': 7,
  148.  
  149. },
  150. 'jota.steves@gmail.com':{
  151. 'new':7,
  152. 'open':3,
  153. 'rejected':7,
  154.  
  155. },
  156. 'null@dei.uc.pt':{
  157. 'new':4,
  158. 'open':1,
  159. 'rejected':7,
  160.  
  161. },
  162.  
  163.  
  164. }
  165. self.list_status = [
  166. 'new',
  167. 'open',
  168. 'stalled',
  169. 'rejected',
  170. 'resolved',
  171. 'deleted',
  172. ]
  173. self.system = {
  174. 'working_dir': '/home/rita/env/dashboard/ditic_kanban',
  175. 'summary_file': 'summary',
  176. 'server': 'localhost/rt/',
  177. 'username': 'root',
  178. 'password': 'rtrita',
  179. 'statistics_file': 'statistics',
  180. }
  181.  
  182. def get_email_to_user(self):
  183. return self.email_to_user
  184.  
  185. def get_system(self):
  186. return self.system
  187.  
  188. def get_user_from_email(self, email):
  189. """
  190. Returns the user based on its email address. This information is based on the config file
  191.  
  192. :param email:
  193. :return:
  194. """
  195. return self.email_to_user[email]
  196.  
  197. def get_email_from_user(self, user):
  198. """
  199. Returns the email based on user alias
  200.  
  201. :param user: user alias
  202. :return: email address. If no alias found, return ''
  203. """
  204. for email in self.email_to_user:
  205. if user == self.email_to_user[email]:
  206. return email
  207. return ''
  208.  
  209. def get_users_list(self):
  210. """
  211. Returns the list of users (not it's emails!)
  212.  
  213. :return:
  214. """
  215. return self.email_to_user.values()
  216.  
  217. def get_email_limits(self, email, status=''):
  218. """
  219. Get the email Kanban limits
  220.  
  221. :return: If status is provided, then return that status limits (int).
  222. If no status is required, then return the dictionary with all limits
  223. """
  224. if status:
  225. if email not in self.email_limits.keys() or status not in self.email_limits[email]:
  226. return 0
  227. return self.email_limits[email][status]
  228. else:
  229. if email not in self.email_to_user.keys():
  230. return {}
  231. return self.email_limits[email]
  232.  
  233. def get_list_status(self):
  234. return self.list_status
  235.  
  236. def check_if_user_exist(self, user):
  237. """
  238. Check if the user (not it's email) exist.
  239. The user is defined in the config file. You may add there more users
  240.  
  241. :param user:
  242. :return:
  243. """
  244. return user in self.email_to_user.values()
  245.  
  246. def check_if_email_exist(self, email):
  247. """
  248. Check if the email exist.
  249. The email is defined in the config file. You may add there more emails
  250.  
  251. :param email:
  252. :return:
  253. """
  254. return email in self.email_to_user.keys()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement