1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
.TH "cmd2::StubbornDict" 3 "Fri Sep 9 2011" "Cmd2" \" -*- nroff -*-
.ad l
.nh
.SH NAME
cmd2::StubbornDict \-
.SH SYNOPSIS
.br
.PP
.SS "Public Member Functions"
.in +1c
.ti -1c
.RI "def \fB__add__\fP"
.br
.ti -1c
.RI "def \fB__iadd__\fP"
.br
.ti -1c
.RI "def \fB__radd__\fP"
.br
.ti -1c
.RI "def \fBto_dict\fP"
.br
.ti -1c
.RI "def \fBupdate\fP"
.br
.in -1c
.SS "Static Public Attributes"
.in +1c
.ti -1c
.RI "\fBappend\fP = update"
.br
.in -1c
.SH "Detailed Description"
.PP
.PP
.nf
Dictionary that tolerates many input formats.
Create it with stubbornDict(arg) factory function.
>>> d = StubbornDict(large='gross', small='klein')
>>> sorted(d.items())
[('large', 'gross'), ('small', 'klein')]
>>> d.append(['plain', ' plaid'])
>>> sorted(d.items())
[('large', 'gross'), ('plaid', ''), ('plain', ''), ('small', 'klein')]
>>> d += ' girl Frauelein, Maedchen\\n\\n shoe schuh'
>>> sorted(d.items())
[('girl', 'Frauelein, Maedchen'), ('large', 'gross'), ('plaid', ''), ('plain', ''), ('shoe', 'schuh'), ('small', 'klein')]
.fi
.PP
.PP
Definition at line 271 of file cmd2\&.py'\&.
.SH "Member Function Documentation"
.PP
.SS "def cmd2::StubbornDict::__add__ (self, arg)"
.PP
Definition at line 291 of file cmd2\&.py'\&.
.PP
References cmd2::stubbornDict()\&.
.PP
.nf
291
292 def __add__(self, arg):
293 selfcopy = copy\&.copy(self)
294 selfcopy\&.update(stubbornDict(arg))
return selfcopy
.fi
.SS "def cmd2::StubbornDict::__iadd__ (self, arg)"
.PP
Definition at line 288 of file cmd2\&.py'\&.
.PP
References update()\&.
.PP
.nf
288
289 def __iadd__(self, arg):
290 self\&.update(arg)
return self
.fi
.SS "def cmd2::StubbornDict::__radd__ (self, arg)"
.PP
Definition at line 295 of file cmd2\&.py'\&.
.PP
References cmd2::stubbornDict()\&.
.PP
.nf
295
296 def __radd__(self, arg):
297 selfcopy = copy\&.copy(self)
298 selfcopy\&.update(stubbornDict(arg))
299 return selfcopy
.fi
.SS "def cmd2::StubbornDict::to_dict (cls, arg)"
.PP
Definition at line 301 of file cmd2\&.py'\&.
.PP
.nf
301
302 def to_dict(cls, arg):
303 'Generates dictionary from string or list of strings'
304 if hasattr(arg, 'splitlines'):
305 arg = arg\&.splitlines()
306 if hasattr(arg, '__reversed__'):
307 result = {}
308 for a in arg:
309 a = a\&.strip()
310 if a:
311 key_val = a\&.split(None, 1)
312 key = key_val[0]
313 if len(key_val) > 1:
314 val = key_val[1]
315 else:
316 val = ''
317 result[key] = val
318 else:
319 result = arg
320 return result
.fi
.SS "def cmd2::StubbornDict::update (self, arg)"
.PP
Definition at line 285 of file cmd2\&.py'\&.
.PP
Referenced by __iadd__()\&.
.PP
.nf
285
286 def update(self, arg):
dict\&.update(self, StubbornDict\&.to_dict(arg))
.fi
.SH "Member Data Documentation"
.PP
.SS "\fBcmd2::StubbornDict::append\fP = update\fC [static]\fP"
.PP
Definition at line 287 of file cmd2\&.py'\&.
.PP
Referenced by cmd2::History::extend()\&.
.SH "Author"
.PP
Generated automatically by Doxygen for Cmd2 from the source code'\&.
|