def get_ohloh_api_request(url, api_key, params=None):
 parameters = {u'api_key': api_key}
 if (params is not None):
  for (key, value) in params.items():
   parameters[key] = value
 xml = urlopen((u'%s?%s' % (url, urlencode(parameters))))
 tree = ElementTree.parse(xml)
 error = tree.getroot().find(u'error')
 if (error is not None):
  raise Exception(ElementTree.tostring(error))
 return tree

def get_ohloh_api_request ( url , api_key , params = None ) : parameters = { u'api_key' : api_key } if ( params is not None ) : for ( key , value ) in params . items ( ) : parameters [ key ] = value xml = urlopen ( ( u'%s?%s' % ( url , urlencode ( parameters ) ) ) ) tree = ElementTree . parse ( xml ) error = tree . getroot ( ) . find ( u'error' ) if ( error is not None ) : raise Exception ( ElementTree . tostring ( error ) ) return tree
sends an api request to ohloh and returns the resulting xml tree or raises an exception if an error occurred .