Skip to content

Commit

Permalink
remove "legacy_mode" usage from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed Aug 24, 2020
1 parent cc1885e commit 4f0cd94
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
News
====

Version 0.14a4 - dev
Version 0.14a5 - dev
--------------------

- Release notes: https://ezdxf.mozman.at/release-v0-14.html
Expand Down
18 changes: 14 additions & 4 deletions docs/source/drawing/recover.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ functions to load the document.
The :func:`auto_read` and :func:`auto_readfile` functions will repair as much
flaws as possible and run the required audit process automatically
afterwards and return the result of this audit process. These functions are the
recommended usage of this module.
recommended usage of this module:

.. code-block:: Python
from ezdxf import recover
doc, auditor = recover.auto_readfile("messy.dxf")
if auditor.has_errors:
auditor.print_error_report()
The :func:`read` and :func:`readfile` functions will repair as much flaws
as possible to take the document to a state, where the
Expand All @@ -23,7 +31,9 @@ but the audit process has to be started manually:

.. code-block:: Python
doc = ezdxf.recover.readfile("messy.dxf")
from ezdxf import recover
doc = recover.readfile("messy.dxf")
auditor = doc.audit()
if auditor.has_errors:
auditor.print_error_report()
Expand Down Expand Up @@ -60,7 +70,7 @@ recover mode:
doc = ezdxf.readfile(name)
except ezdxf.DXFStructureError:
try: # slow path with low level structure repair:
doc, auditor = ezdxf.recover.auto_readfile(name)
doc, auditor = recover.auto_readfile(name)
if auditor.has_errors:
print(f'Found unrecoverable errors in DXF file: {name}.')
auditor.print_error_report()
Expand All @@ -76,7 +86,7 @@ extra fee for the recover mode:
.. code-block:: Python
try: # low level structure repair:
doc, auditor = ezdxf.recover.auto_readfile(name)
doc, auditor = recover.auto_readfile(name)
if auditor.has_errors:
print(f'Found unrecoverable errors in DXF file: {name}.')
auditor.print_error_report()
Expand Down
4 changes: 1 addition & 3 deletions integration_tests/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

DIR1 = r"D:\Source\dxftest\CADKitSamples\*.dxf"
DIR2 = r"D:\Source\dxftest\*.dxf"
LEGACY_MODE = False


def run(start):
if start > 0:
Expand All @@ -18,7 +16,7 @@ def run(start):
for filename in names:
count += 1
print("processing: {}/{} file: {}".format(count+start, len(names)+start, filename))
doc = ezdxf.readfile(filename, legacy_mode=LEGACY_MODE)
doc = ezdxf.readfile(filename)

auditor = Auditor(doc)
if len(auditor):
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"CADKitSamples/*.dxf",
"dxftest/*.dxf",
]
LEGACY_MODE = False
options.check_entity_tag_structures = True


Expand All @@ -24,7 +23,7 @@ def filename(request):

def test_readfile(filename):
try:
ezdxf.readfile(filename, legacy_mode=LEGACY_MODE)
ezdxf.readfile(filename)
except Exception:
assert False
else:
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_audit_critical_dxf_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def filename(request):


def test_leica_disto_r12(filename):
doc = ezdxf.readfile(filename, legacy_mode=True)
doc = ezdxf.readfile(filename)
auditor = doc.audit()
assert len(auditor) == 0
3 changes: 1 addition & 2 deletions integration_tests/test_leica_disto_r12.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def filename(request):


def test_leica_disto_r12(filename):
# new entity system: legacy mode not necessary
dwg = ezdxf.readfile(filename, legacy_mode=False)
dwg = ezdxf.readfile(filename)
msp = dwg.modelspace()
points = list(msp.query('POINT'))
assert len(points) == 11
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/test_open_coord_order_issue.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) 2018-2019, Manfred Moitzi
# Copyright (c) 2018-2020, Manfred Moitzi
# License: MIT License
import os
import pytest
import ezdxf

from ezdxf import recover

BASEDIR = 'integration_tests' if os.path.exists('integration_tests') else '.'
DATADIR = 'data'
Expand All @@ -19,10 +19,10 @@ def filename(request):

def test_coordinate_order_problem(filename):
try:
dwg = ezdxf.readfile(filename, legacy_mode=True)
doc, auditor = recover.auto_readfile(filename)
except ezdxf.DXFError as e:
pytest.fail(str(e))
else:
msp = dwg.modelspace()
msp = doc.modelspace()
lines = msp.query('LINE')
assert lines[0].dxf.start == (1.5, 0, 0)
2 changes: 1 addition & 1 deletion src/ezdxf/recover.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def safe_tag_loader(stream: BinaryIO,
encoding = detect_encoding(detector_stream)

# Apply repair filter:
tags = repair.filter_invalid_yz_point_codes(tags)
tags = repair.tag_reorder_layer(tags)
tags = repair.filter_invalid_yz_point_codes(tags)
return byte_tag_compiler(tags, encoding)


Expand Down

0 comments on commit 4f0cd94

Please sign in to comment.