mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-17 18:18:06 +02:00
intel/genxml: Don't rewrite sorted xml if the contents didn't change
Rework: * Make better use of pathlib. (Dylan) Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Dylan Baker <dylan@pnwbakers> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24605>
This commit is contained in:
parent
e60a0b1616
commit
548a0bc7d2
1 changed files with 13 additions and 2 deletions
|
|
@ -5,6 +5,7 @@
|
|||
from __future__ import annotations
|
||||
from collections import OrderedDict
|
||||
import copy
|
||||
import io
|
||||
import pathlib
|
||||
import re
|
||||
import xml.etree.ElementTree as et
|
||||
|
|
@ -202,7 +203,17 @@ class GenXml(object):
|
|||
for old, new in zip(self.et.getroot(), other.et.getroot()))
|
||||
|
||||
def write_file(self):
|
||||
tmp = self.filename.with_suffix(f'{self.filename.suffix}.tmp')
|
||||
try:
|
||||
old_genxml = GenXml(self.filename)
|
||||
if self.is_equivalent_xml(old_genxml):
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
b_io = io.BytesIO()
|
||||
et.indent(self.et, space=' ')
|
||||
self.et.write(tmp, encoding="utf-8", xml_declaration=True)
|
||||
self.et.write(b_io, encoding="utf-8", xml_declaration=True)
|
||||
|
||||
tmp = self.filename.with_suffix(f'{self.filename.suffix}.tmp')
|
||||
tmp.write_bytes(b_io.getvalue())
|
||||
tmp.replace(self.filename)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue