From fafd3ef12512c7a7832a93de14b668bed1922f1c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 23 May 2010 18:35:55 +0200 Subject: add FedoraPkgdb->getPackageInfo() --- FedoraClient.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'FedoraClient.php') diff --git a/FedoraClient.php b/FedoraClient.php index 1a33ac9..1d0ce71 100644 --- a/FedoraClient.php +++ b/FedoraClient.php @@ -57,7 +57,7 @@ abstract class FedoraClient { function sendRequest($method, array $options=array()) { $curl = curl_init(); # And join to make our url. - $url = $this->url.urlencode($method); + $url = $this->url.$method; curl_setopt($curl, CURLOPT_URL, $url); # Boilerplate so pycurl processes cookies curl_setopt($curl, CURLOPT_COOKIEFILE, '/dev/null'); @@ -118,11 +118,11 @@ class FedoraPkgdb extends FedoraClient { function getBranches($refresh=false) { $rep = ($refresh ? false : $this->cache->get(__FUNCTION__,__CLASS__)); if ($rep) { - $this->logDebug(2,__CLASS__."::".__FUNCTION__." get from cache"); + $this->logDebug(2,__CLASS__."::".__FUNCTION__."() get from cache"); } else { $rep =$this->sendRequest('collections'); $this->cache->save($rep,__FUNCTION__,__CLASS__); - $this->logDebug(2,__CLASS__."::".__FUNCTION__." save to cache"); + $this->logDebug(2,__CLASS__."::".__FUNCTION__."() save to cache"); } $branches = array(); @@ -134,6 +134,24 @@ class FedoraPkgdb extends FedoraClient { return $branches; } + function getPackageInfo($name, $refresh=false) { + $url="acls/name/$name"; + $rep = ($refresh ? false : $this->cache->get($url,__CLASS__)); + if ($rep) { + $this->logDebug(2,__CLASS__."::".__FUNCTION__."($name) get from cache"); + } else { + $rep =$this->sendRequest($url); + $this->cache->save($rep,$url,__CLASS__); + $this->logDebug(2,__CLASS__."::".__FUNCTION__."($name) save to cache"); + } + + if (isset($rep['status']) && !$rep['status']) { + $this->logDebug(1,__CLASS__."::".__FUNCTION__."($name) ".$rep['message']); + return false; + } + return $rep; + } + function getBranch($name, $refresh=false) { $branches = $this->getBranches($refresh); -- cgit