Mercurial > libervia-web
annotate src/browser/collections.py @ 611:6016c74ee323 frontends_multi_profiles
browser side: web widget is recreated when there is already one
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 10 Feb 2015 19:13:25 +0100 |
parents | a5019e62c3e9 |
children | 2664fe93ceb3 |
rev | line source |
---|---|
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2014 Jérôme Poisson <goffi@goffi.org> |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 class OrderedDict(object): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 """Naive implementation of OrderedDict which is compatible with pyjamas""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 def __init__(self, *args, **kwargs): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 self.__internal_dict = {} |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 self.__keys = [] # this list keep the keys in order |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 if args: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 if len(args)>1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 raise TypeError("OrderedDict expected at most 1 arguments, got {}".format(len(args))) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 if isinstance(args[0], (dict, OrderedDict)): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 for key, value in args[0].iteritems(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 self[key] = value |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 for key, value in args[0]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 self[key] = value |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 def __setitem__(self, key, value): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 self.__keys.append(key) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 self.__internal_dict[key] = value |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 def __getitem__(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 return self.__internal_dict[key] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 def __delitem__(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 del self.__internal_dict[key] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 self.__keys.remove(key) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 def clear(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 self.__internal_dict.clear() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 del self.__keys[:] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 def copy(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 return OrderedDict(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 @classmethod |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 def fromkeys(cls, seq, value=None): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 ret = OrderedDict() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 for key in seq: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 ret[key] = value |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 return ret |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 def get(self, key, default=None): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 return self.__internal_dict[key] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 except KeyError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 return default |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 def has_key(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 return key in self.__keys |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 def keys(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 return self.__keys[:] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 def iterkeys(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 for key in self.__keys: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 yield key |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 def items(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 ret = [] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 for key in self.__keys: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 ret.append((key, self.__internal_dict[key])) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 return ret |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 def iteritems(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 for key in self.__keys: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 yield (key, self.__internal_dict[key]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 def values(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 ret = [] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 for key in self.__keys: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 ret.append(self.__internal_dict[key]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 return ret |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 def itervalues(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 for key in self.__keys: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 yield (self.__internal_dict[key]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 def popitem(self, last=True): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 key = self.__keys.pop(-1 if last else 0) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 except IndexError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 raise KeyError('dictionnary is empty') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 value = self.__internal_dict.pop(key) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 return((key, value)) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 def setdefault(self, key, default=None): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 return self.__internal_dict[key] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 except KeyError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 self.__internal_dict[key] = default |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 return default |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 def update(self, *args, **kwargs): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 if len(args) > 1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 raise TypeError('udpate expected at most 1 argument, got {}'.format(len(args))) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 if args: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 if hasattr(args[0], 'keys'): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 for k in args[0]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 self[k] = args[0][k] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 for (k, v) in args[0]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 self[k] = v |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 for k, v in kwargs.items(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 self[k] = v |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 def pop(self, *args): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 if not args: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 raise TypeError('pop expected at least 1 argument, got 0') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 self.__internal_dict.pop(args[0]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 except KeyError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 if len(args) == 2: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 return args[1] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 raise KeyError(args[0]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 self.__keys.remove(args[0]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 def viewitems(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 raise NotImplementedError |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 def viewkeys(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 raise NotImplementedError |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 def viewvalues(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 raise NotImplementedError |