Skip to content

Commit

Permalink
Merge pull request #1682 from dmach/xml-etree-extend-ParseError
Browse files Browse the repository at this point in the history
Extend xml.etree.ElementTree.ParseError output with a snippet of broken XML
  • Loading branch information
dmach authored Jan 7, 2025
2 parents 31600b4 + 6fc5654 commit 93a851b
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 167 deletions.
7 changes: 4 additions & 3 deletions osc/_private/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..util.xml import xml_escape
from ..util.xml import xml_indent
from ..util.xml import xml_unescape
from ..util.xml import xml_parse


def get(apiurl, path, query=None):
Expand All @@ -36,7 +37,7 @@ def get(apiurl, path, query=None):

url = osc_core.makeurl(apiurl, path, query)
with osc_connection.http_GET(url) as f:
root = ET.parse(f).getroot()
root = xml_parse(f).getroot()
return root


Expand Down Expand Up @@ -64,7 +65,7 @@ def post(apiurl, path, query=None):

url = osc_core.makeurl(apiurl, path, query)
with osc_connection.http_POST(url) as f:
root = ET.parse(f).getroot()
root = xml_parse(f).getroot()
return root


Expand Down Expand Up @@ -92,7 +93,7 @@ def put(apiurl, path, query=None, data=None):

url = osc_core.makeurl(apiurl, path, query)
with osc_connection.http_PUT(url, data=data) as f:
root = osc_core.ET.parse(f).getroot()
root = xml_parse(f).getroot()
return root


Expand Down
5 changes: 3 additions & 2 deletions osc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .util import archquery, debquery, packagequery, rpmquery
from .util import repodata
from .util.helper import decode_it
from .util.xml import xml_parse


change_personality = {
Expand Down Expand Up @@ -79,7 +80,7 @@ class Buildinfo:
def __init__(self, filename, apiurl, buildtype='spec', localpkgs=None, binarytype='rpm'):
localpkgs = localpkgs or []
try:
tree = ET.parse(filename)
tree = xml_parse(filename)
except ET.ParseError:
print('could not parse the buildinfo:', file=sys.stderr)
print(open(filename).read(), file=sys.stderr)
Expand Down Expand Up @@ -1351,7 +1352,7 @@ def __str__(self):
if build_type == 'kiwi':
# Is a obsrepositories tag used?
try:
tree = ET.parse(build_descr)
tree = xml_parse(build_descr)
except:
print('could not parse the kiwi file:', file=sys.stderr)
print(open(build_descr).read(), file=sys.stderr)
Expand Down
104 changes: 53 additions & 51 deletions osc/commandline.py

Large diffs are not rendered by default.

Loading

0 comments on commit 93a851b

Please sign in to comment.