diff --git a/src/mio.py b/src/mio.py index c87332eb4f042115c40640050a2d9f4e0e48b8b1..aab2f3ddfc93fbbaf1c9ab6ebc7f94f7457f7306 100755 --- a/src/mio.py +++ b/src/mio.py @@ -20,7 +20,7 @@ if not hasattr(__builtins__, "True"): __builtins__["True"] = 1 __builtins__["False"] = 0 -def parse(path, filename, repository): +def parse_with_path(path, filename, repository): f = mio.filecache.loadfile(path, filename) tree = mio.parser.parse(f.filename, url=f.key) @@ -36,11 +36,23 @@ def parse(path, filename, repository): repository.add(tree._group_) +def parse(filename, repository): + path = list(options.path) + for p in path: + try: + parse_with_path(p, filename, repository) + return + except IOError, e: + print e + raise + pass + raise Exception("Could not parse %s" % filename) + def find_and_parse(target, builder, url=None): path = list(options.path) if url: - print "CHECK THIS", path, target, url - path.insert(0, os.path.dirname(url)) + for p in url.path: + path.insert(0, os.path.dirname(p)) for p in path: if target.startswith("/"): @@ -66,7 +78,7 @@ def find_and_parse(target, builder, url=None): filename = "hostinfo.xml" pass try: - parse(p, filename, builder) + parse_with_path(p, filename, builder) return except IOError, e: pass