5 # A simple class for accumulating counts or lists
11 def incr(self
, key
, increment
= 1):
13 self
._data
[key
] += increment
15 self
._data
[key
] = increment
17 def get(self
, key
, default
= None):
19 return self
._data
[key
]
23 def append(self
, key
, item
, unique
= False):
24 if unique
and (key
in self
._data
) and (item
in self
._data
[key
]):
27 self
._data
[key
].append(item
)
29 self
._data
[key
] = [item
]
32 return self
._data
.keys()
34 def __getitem__(self
, key
):
35 return self
._data
[key
]