Bladeren bron

Addons for xml translator

prieto 8 jaren geleden
bovenliggende
commit
7070838e92
1 gewijzigde bestanden met toevoegingen van 57 en 1 verwijderingen
  1. 57
    1
      lodel/editorial_model/model.py

+ 57
- 1
lodel/editorial_model/model.py Bestand weergeven

@@ -2,6 +2,7 @@
2 2
 
3 3
 import hashlib
4 4
 import importlib
5
+import copy
5 6
 
6 7
 from lodel.utils.mlstring import MlString
7 8
 from lodel.logger import logger
@@ -30,6 +31,59 @@ class EditorialModel(object):
30 31
         self.__active_classes = dict()
31 32
         self.__set_actives()
32 33
     
34
+    ##@brief EmClass uids accessor
35
+    #@return a dict of emclasses
36
+    def all_classes(self, uid = None):
37
+        if uid is None:
38
+            return copy.copy(self.__classes)
39
+        else:
40
+            try:
41
+                return copy.copy(self.__classes[uid])
42
+            except KeyError:
43
+                raise EditorialModelException("EmClass not found : '%s'" % uid)
44
+                
45
+    def all_classes_ref(self, uid = None):
46
+        if uid is None:
47
+            return self.__classes
48
+        else:
49
+            try:
50
+                return self.__classes[uid]
51
+            except KeyError:
52
+                raise EditorialModelException("EmGroup not found : '%s'" % uid)
53
+                                
54
+    ##@brief active EmClass uids accessor
55
+    #@return a list of class uids
56
+    def active_classes_uids(self):
57
+            return list(self.__active_classes.keys())
58
+        
59
+    
60
+    ##@brief EmGroups accessor
61
+    #@return a dict of groups
62
+    def all_groups(self, uid = None):
63
+        if uid is None:
64
+            return copy.copy(self.__groups)
65
+        else:
66
+            try:
67
+                return copy.copy(self.__groups[uid])
68
+            except KeyError:
69
+                raise EditorialModelException("EmGroup not found : '%s'" % uid)
70
+    
71
+    ##@brief EmGroups accessor
72
+    #@return a dict of groups
73
+    def all_groups_ref(self, uid = None):
74
+        if uid is None:
75
+            return self.__groups
76
+        else:
77
+            try:
78
+                return self.__groups[uid]
79
+            except KeyError:
80
+                raise EditorialModelException("EmGroup not found : '%s'" % uid)
81
+                
82
+    ##@brief active EmClass uids accessor
83
+    #@return a list of class uids
84
+    def active_groups_uids(self):
85
+            return list(self.__active_groups.keys())
86
+
33 87
     ##@brief EmClass accessor
34 88
     #@param uid None | str : give this argument to get a specific EmClass
35 89
     #@return if uid is given returns an EmClass else returns an EmClass
@@ -42,7 +96,7 @@ class EditorialModel(object):
42 96
                                         uid)
43 97
         except KeyError:
44 98
             raise EditorialModelException("EmClass not found : '%s'" % uid)
45
-
99
+             
46 100
     ##@brief EmGroup getter
47 101
     # @param uid None | str : give this argument to get a specific EmGroup
48 102
     # @return if uid is given returns an EmGroup else returns an EmGroup iterator
@@ -184,8 +238,10 @@ class EditorialModel(object):
184 238
         )
185 239
         for guid in sorted(self.__groups):
186 240
             payload += str(self.__groups[guid].d_hash())
241
+
187 242
         for cuid in sorted(self.__classes):
188 243
             payload += str(self.__classes[cuid].d_hash())
244
+
189 245
         return int.from_bytes(
190 246
                                 hashlib.md5(bytes(payload, 'utf-8')).digest(),
191 247
                                 byteorder='big'

Loading…
Annuleren
Opslaan