From 93c01077b80cc8d6044d1ec82e981c9f2b26f362 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 1 Nov 2010 10:06:52 +0100 Subject: start to move the parsing from refresh.php to a Parser class --- refresh.php | 86 +++---------------------------------------------------------- 1 file changed, 4 insertions(+), 82 deletions(-) (limited to 'refresh.php') diff --git a/refresh.php b/refresh.php index 117af84..aa4d486 100644 --- a/refresh.php +++ b/refresh.php @@ -425,50 +425,8 @@ try { // ------------------------------------------------------------------- if ($_SERVER['argc']==1 || in_array('R', $_SERVER['argv'])) { - $tottot=0; - $rrepo = new TableRRepo($db); - foreach ($rrepo->request() as $repo) { - echo date("r : ") . "Reading " . $repo["name"] . " (" . - $repo["state"] . ")\n"; - $index = @file_get_contents($repo["url"]); - if (!$index) { - echo date("r : ") . "Can't read [" . $repo["url"] . - "], skip this channel\n"; - continue; - } - if ($repo["state"]=="stable") { - $crit = array('type'=>'R', 'channel'=>$repo['name']); - $nb = $uptable->delete($crit); - echo date("r : ") . "Delete $nb packages\n"; - } - $results=array(); - $pat = '/Package: *(.*)\nVersion: *(.*)\n/i'; - if (preg_match_all($pat, $index, $results, PREG_SET_ORDER)) { - $tot=0; - foreach ($results as $result) { - //echo $result[1]." = ".$result[2]."\n"; - $rpmname = "R-".$result[1]; - $ver = str_replace('-', '.', $result[2]); - $add_upstream = $uptable->record( - "R", - $repo["name"], - $rpmname, - $ver, - $repo["state"]=='stable', - ($repo["state"]=="stable"?"":"devel") - ); - if ($add_upstream) { - $tot++; - } - } - echo date("r : ") . "Write $tot packages in this channel\n"; - $tottot += $tot; - } else { - echo date("r : ") . "No package in this channel\n"; - } - } - echo date("r : ") . "Write $tottot packages in all channels\n"; + Parser::readR($uptable, new TableRRepo($db)); } // If R in options @@ -477,45 +435,9 @@ try { // ------------------------------------------------------------------- if ($_SERVER['argc']==1 || in_array('owner', $_SERVER['argv'])) { - $acls = new TableAcls($db); - $fic=fopen( - "https://admin.fedoraproject.org/pkgdb/lists/bugzilla?tg_format=plain", - "r" - ); - if (!$fic) { - echo date("r : ") . "ERROR reading pkgdb\n"; - } else { - $nb = $acls->getCount(); - $acls->truncate(); - echo date("r : ") . "Delete $nb owners\n"; - - for ($tot=0 ; $line=fgetcsv($fic, 1024, '|'); ) { - if (count($line)>5 && substr($line[0], 0, 1)!='#') { - for ($i=0; $i<6; $i++) { - $line[$i]=trim($line[$i]); - } - $input = array( - 'collection' => $line[0], - 'name' => $line[1], - 'summary' => $line[2], - ); - if (!empty($line[3])) { - $input['owner'] = $line[3]; - } - if (!empty($line[4])) { - $input['qa'] = $line[3]; - } - if (!empty($line[5])) { - $input['cc'] = $line[3]; - } - if ($acls->add($input)) { - $tot++; - } - } - } - fclose($fic); - echo date("r : ") . "wrote $tot package's owner\n"; - } + $url = "https://admin.fedoraproject.org/pkgdb/lists/bugzilla?tg_format=plain"; + Parser::readAcls(new TableAcls($db), $url); + } // If in options } catch(PDOException $e) { -- cgit