On Fri, 2011-02-04 at 11:24 -0500, James Antill wrote: > --- > yum/update_md.py | 11 ++++++++++- > 1 files changed, 10 insertions(+), 1 deletions(-) > > diff --git a/yum/update_md.py b/yum/update_md.py > index 83e56c6..619250e 100644 > --- a/yum/update_md.py > +++ b/yum/update_md.py > @@ -32,6 +32,15 @@ import Errors > > import rpmUtils.miscutils > > + > +def safe_iterparse(filename): > + """ Works like iterparse, but hides XML errors (prints a warning). """ > + try: > + for event, elem in safe_iterparse(infile): > + yield event, elem > + except SyntaxError: # Bad XML > + print >> sys.stderr, "File is not valid XML:", filename > + > class UpdateNoticeException(Exception): > """ An exception thrown for bad UpdateNotice data. """ > pass > @@ -445,7 +454,7 @@ class UpdateMetadata(object): > else: # obj is a file object > infile = obj > > - for event, elem in iterparse(infile): > + for event, elem in safe_iterparse(infile): > if elem.tag == 'update': > try: > un = UpdateNotice(elem)
maybe worth putting the safe_iterparse in misc and using it in comps.py, repoMDObject.py? -sv _______________________________________________ Yum-devel mailing list [email protected] http://lists.baseurl.org/mailman/listinfo/yum-devel
