Revision 8975f6f6 astakosclient/astakosclient/keypath.py
b/astakosclient/astakosclient/keypath.py | ||
---|---|---|
30 | 30 |
# documentation are those of the authors and should not be |
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 |
import copy |
|
33 | 34 |
|
34 | 35 |
|
35 | 36 |
def dict_merge(a, b): |
... | ... | |
119 | 120 |
""" |
120 | 121 |
|
121 | 122 |
name_path, node_path, basename = \ |
122 |
lookup_path(container, path, sep=sep, createpath=False)
|
|
123 |
lookup_path(container, path, sep=sep, createpath=False) |
|
123 | 124 |
|
124 | 125 |
lastnode = node_path.pop() |
125 |
lastname = basename |
|
126 | 126 |
try: |
127 | 127 |
if basename in lastnode: |
128 | 128 |
del lastnode[basename] |
... | ... | |
157 | 157 |
|
158 | 158 |
""" |
159 | 159 |
name_path, node_path, basename = \ |
160 |
lookup_path(container, path, sep=sep, createpath=False)
|
|
160 |
lookup_path(container, path, sep=sep, createpath=False) |
|
161 | 161 |
name_path.append(basename) |
162 | 162 |
node = node_path[-1] |
163 | 163 |
|
... | ... | |
186 | 186 |
Traceback (most recent call last): |
187 | 187 |
KeyError: "'a.b.x': path not found" |
188 | 188 |
>>> set_path({'a': {'b': {'c': 'd'}}}, 'a.b.x.d', 1, createpath=True) |
189 |
|
|
189 |
|
|
190 | 190 |
>>> set_path({'a': {'b': {'c': 'd'}}}, 'a.b.c', 1) |
191 |
|
|
191 |
|
|
192 | 192 |
>>> set_path({'a': {'b': {'c': 'd'}}}, 'a.b.c', 1, overwrite=False) |
193 | 193 |
Traceback (most recent call last): |
194 | 194 |
ValueError: will not overwrite path 'a.b.c' |
195 | 195 |
|
196 | 196 |
""" |
197 | 197 |
name_path, node_path, basename = \ |
198 |
lookup_path(container, path, sep=sep, createpath=createpath)
|
|
198 |
lookup_path(container, path, sep=sep, createpath=createpath) |
|
199 | 199 |
name_path.append(basename) |
200 | 200 |
node = node_path[-1] |
201 | 201 |
|
Also available in: Unified diff