Package scapi :: Module util
[hide private]
[frames] | no frames]

Source Code for Module scapi.util

 1  ##    SouncCloudAPI implements a Python wrapper around the SoundCloud RESTful 
 2  ##    API 
 3  ## 
 4  ##    Copyright (C) 2008  Diez B. Roggisch 
 5  ##    Contact mailto:deets@soundcloud.com 
 6  ## 
 7  ##    This library is free software; you can redistribute it and/or 
 8  ##    modify it under the terms of the GNU Lesser General Public 
 9  ##    License as published by the Free Software Foundation; either 
10  ##    version 2.1 of the License, or (at your option) any later version. 
11  ## 
12  ##    This library is distributed in the hope that it will be useful, 
13  ##    but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
15  ##    Lesser General Public License for more details. 
16  ## 
17  ##    You should have received a copy of the GNU Lesser General Public 
18  ##    License along with this library; if not, write to the Free Software 
19  ##    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
20   
21  import urllib 
22   
23 -def escape(s):
24 # escape '/' too 25 return urllib.quote(s, safe='')
26 27 28 29 30 31
32 -class MultiDict(dict):
33 34
35 - def add(self, key, new_value):
36 if key in self: 37 value = self[key] 38 if not isinstance(value, list): 39 value = [value] 40 self[key] = value 41 value.append(new_value) 42 else: 43 self[key] = new_value
44 45
46 - def iteritemslist(self):
47 for key, value in self.iteritems(): 48 if not isinstance(value, list): 49 value = [value] 50 yield key, value
51