File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -42,13 +42,18 @@ def _plist_from_popen(popen):
42
42
if not out :
43
43
return []
44
44
try :
45
- # Beautiful soup ensures the XML is properly formed after it is parsed
46
- # so that it can be used by other less lenient commands without problems
47
- xml_representation = BeautifulSoup (out .decode ('utf8' ), 'xml' )
48
- if not xml_representation .get_text ():
49
- # The output is not in the XML format
45
+ try :
46
+ # Try simple and fast first if this fails fall back to the slower but better process
50
47
return loads (out )
51
- return loads (xml_representation .decode ().encode ('utf8' ))
48
+ except ExpatError :
49
+ # Beautiful soup ensures the XML is properly formed after it is parsed
50
+ # so that it can be used by other less lenient commands without problems
51
+ xml_representation = BeautifulSoup (out .decode ('utf8' ), 'xml' )
52
+
53
+ if not xml_representation .get_text ():
54
+ # The output is not in the XML format
55
+ return loads (out )
56
+ return loads (xml_representation .decode ().encode ('utf8' ))
52
57
except ExpatError :
53
58
return []
54
59
You can’t perform that action at this time.
0 commit comments