summaryrefslogtreecommitdiffstats
path: root/chitin/parser.py
diff options
context:
space:
mode:
authorIzhar Firdaus <kagesenshi.87@gmail.com>2008-06-23 23:40:53 +0800
committerIzhar Firdaus <kagesenshi.87@gmail.com>2008-06-23 23:40:53 +0800
commit40602488897fcf16f2eedad18eb33149c3b2341d (patch)
tree6651caff680e936e7c99c01dc4edd78419260b09 /chitin/parser.py
parente5b94a96d02699032a1467e85bf82505181eb6f7 (diff)
downloadchitin-40602488897fcf16f2eedad18eb33149c3b2341d.tar.gz
chitin-40602488897fcf16f2eedad18eb33149c3b2341d.tar.xz
chitin-40602488897fcf16f2eedad18eb33149c3b2341d.zip
- code cleanup in parser
- added type filter in getRepoURL
Diffstat (limited to 'chitin/parser.py')
-rw-r--r--chitin/parser.py11
1 files changed, 8 insertions, 3 deletions
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