Remove workarounds and backports for Python 2 support

In particular:
- In common/, remove the backport of weakref.WeakMethod
- In docs/ and ui/, use the standard FileNotFoundError class
- Use built-in open() instead of io.open(), and stop importing io
- In core/stats.py, use the standard implementation of xml.etree instead
of the C one
This commit is contained in:
Candice Bentéjac 2022-12-05 16:34:01 +01:00
parent 635f85e7fd
commit 8bef398bed
9 changed files with 10 additions and 88 deletions

View file

@ -17,12 +17,6 @@ from meshroom.core.node import Node, CompatibilityNode, Status, Position
from meshroom.ui.graph import UIGraph
from meshroom.ui.utils import makeProperty
# Python2 compatibility
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError
class Message(QObject):
""" Simple structure wrapping a high-level message. """
@ -623,9 +617,8 @@ class Reconstruction(UIGraph):
sfmFile = panoramaInit.attribute('outSfMData').value
if not os.path.exists(sfmFile):
return QVector3D(0.0, 0.0, 0.0)
import io # use io.open for Python2/3 compatibility (allow to specify encoding + errors handling)
# skip decoding errors to avoid potential exceptions due to non utf-8 characters in images metadata
with io.open(sfmFile, 'r', encoding='utf-8', errors='ignore') as f:
with open(sfmFile, 'r', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
intrinsics = data.get('intrinsics', [])