From 40602488897fcf16f2eedad18eb33149c3b2341d Mon Sep 17 00:00:00 2001 From: Izhar Firdaus Date: Mon, 23 Jun 2008 23:40:53 +0800 Subject: - code cleanup in parser - added type filter in getRepoURL --- chitin/__init__.pyo | Bin 178 -> 0 bytes chitin/parser.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 chitin/__init__.pyo (limited to 'chitin') diff --git a/chitin/__init__.pyo b/chitin/__init__.pyo deleted file mode 100644 index 2f4bca1..0000000 Binary files a/chitin/__init__.pyo and /dev/null differ diff --git a/chitin/parser.py b/chitin/parser.py index 006d3a5..0a17979 100644 --- a/chitin/parser.py +++ b/chitin/parser.py @@ -21,7 +21,7 @@ # @author Izhar Firdaus from xml.etree.ElementTree import ElementTree,Element -import re, tempfile +import re from chitin.utils import attrsfilter,get_child_value ocins='http://opensuse.org/Standards/One_Click_Install' @@ -72,7 +72,7 @@ class Metapackage: products = self.getGroup().getiterator('{%s}%s' % (ocins,'product')) return attrsfilter(products,kwargs) - def getRepoURL(self,reponame): + def getRepoURL(self,reponame,type=None): """ Function to get 'url' values from current distversion group, and requested reponame @@ -83,11 +83,16 @@ class Metapackage: repos = self.getRepositories() urls = [] for r in repos: - if get_child_value(r,'name') == reponame: + if get_child_value(r,'name').lower() == reponame.lower(): for url in r.getiterator('{%s}%s' % (ocins,'url')): priority = 0 + if type: + if not url.attrib.has_key('type'): continue + if not url.attrib['type'].lower() == type.lower(): continue + if url.attrib.has_key('score'): priority = int(url.attrib['score']) urls.append((url.text.strip(),priority)) + def sorturl(x,y): if x[1] <= y[1]: return +1 -- cgit