X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Frtmapi.py;h=d513fc87ab08d9216a0c364730f13111d5fe706d;hb=269295214d94b8234509bb38340cebd012c3e7ca;hp=e8f01837c1fea9b673ffe9a22c428b8673877937;hpb=589c19dc0e4b46f546cfda6a6057313f5f77ed20;p=doneit diff --git a/src/rtmapi.py b/src/rtmapi.py index e8f0183..d513fc8 100644 --- a/src/rtmapi.py +++ b/src/rtmapi.py @@ -78,13 +78,20 @@ class RTMapi(object): pairs = ''.join(['%s%s' % (k, v) for (k, v) in sortedItems(params)]) return md5(self._secret+pairs).hexdigest() + @staticmethod + def open_url(url, queryArgs=None): + if queryArgs: + url += '?' + urllib.urlencode(queryArgs) + warnings.warn("Performing download of %s" % url, stacklevel=5) + return urllib.urlopen(url) + def get(self, **params): "Get the XML response for the passed `params`." params['api_key'] = self._apiKey params['format'] = 'json' params['api_sig'] = self._sign(params) - json = open_url(SERVICE_URL, params).read() + json = self.open_url(SERVICE_URL, params).read() if _use_simplejson: data = DottedDict('ROOT', simplejson.loads(json)) @@ -168,12 +175,6 @@ def sortedItems(dictionary): yield key, dictionary[key] -def open_url(url, queryArgs=None): - if queryArgs: - url = url + '?' + urllib.urlencode(queryArgs) - return urllib.urlopen(url) - - class DottedDict(object): "Make dictionary items accessible via the object-dot notation."