diff options
author | Izhar Firdaus <kagesenshi.87@gmail.com> | 2008-06-23 23:40:53 +0800 |
---|---|---|
committer | Izhar Firdaus <kagesenshi.87@gmail.com> | 2008-06-23 23:40:53 +0800 |
commit | 40602488897fcf16f2eedad18eb33149c3b2341d (patch) | |
tree | 6651caff680e936e7c99c01dc4edd78419260b09 /chitin | |
parent | e5b94a96d02699032a1467e85bf82505181eb6f7 (diff) | |
download | chitin-40602488897fcf16f2eedad18eb33149c3b2341d.tar.gz chitin-40602488897fcf16f2eedad18eb33149c3b2341d.tar.xz chitin-40602488897fcf16f2eedad18eb33149c3b2341d.zip |
- code cleanup in parser
- added type filter in getRepoURL
Diffstat (limited to 'chitin')
-rw-r--r-- | chitin/__init__.pyo | bin | 178 -> 0 bytes | |||
-rw-r--r-- | chitin/parser.py | 11 |
2 files changed, 8 insertions, 3 deletions
diff --git a/chitin/__init__.pyo b/chitin/__init__.pyo Binary files differdeleted file mode 100644 index 2f4bca1..0000000 --- a/chitin/__init__.pyo +++ /dev/null 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 <izhar@fedoraproject.com> 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 |