(This will take a minute, because it compiles Cython and Numpy...)
GLOB sdist-make: /home/churchyard/Dokumenty/RedHat/numpy-stl/setup.py
py37-nix inst-nodeps: /home/churchyard/Dokumenty/RedHat/numpy-stl/.tox/dist/numpy-stl-2.6.0.zip
py37-nix installed: alabaster==0.7.11,apipkg==1.4,atomicwrites==1.1.5,attrs==18.1.0,Babel==2.6.0,certifi==2018.4.16,chardet==3.0.4,cov-core==1.15.0,coverage==4.5.1,Cython==0.28.3,docutils==0.14,execnet==1.5.0,flake8==3.5.0,idna==2.7,imagesize==1.0.0,Jinja2==2.10,MarkupSafe==1.0,mccabe==0.6.1,more-itertools==4.2.0,numpy==1.14.5,numpy-stl==2.6.0,packaging==17.1,pep8==1.7.1,pluggy==0.6.0,py==1.5.3,pycodestyle==2.3.1,pyflakes==2.0.0,Pygments==2.2.0,pyparsing==2.2.0,pytest==3.6.2,pytest-cache==1.0,pytest-cov==2.5.1,pytest-flakes==3.0.2,pytest-pep8==1.0.6,python-utils==2.3.0,pytz==2018.4,requests==2.19.1,six==1.11.0,snowballstemmer==1.2.1,Sphinx==1.7.5,sphinxcontrib-websupport==1.1.0,urllib3==1.23
py37-nix runtests: PYTHONHASHSEED='2657808664'
py37-nix runtests: commands[0] | python setup.py build_ext --inplace
running build_ext
copying build/lib.linux-x86_64-3.7/stl/_speedups.cpython-37m-x86_64-linux-gnu.so -> stl
py37-nix runtests: commands[1] | python -m pytest -vvv
============================= test session starts ==============================
platform linux -- Python 3.7.0rc1, pytest-3.6.2, py-1.5.3, pluggy-0.6.0 -- /home/churchyard/Dokumenty/RedHat/numpy-stl/.tox/py37-nix/bin/python
cachedir: .pytest_cache
rootdir: /home/churchyard/Dokumenty/RedHat/numpy-stl, inifile: pytest.ini
plugins: pep8-1.0.6, flakes-3.0.2, cov-2.5.1
collecting ... collected 133 items
setup.py SKIPPED [ 0%]
setup.py PASSED [ 0%]
stl/__about__.py SKIPPED [ 1%]
stl/__about__.py PASSED [ 1%]
stl/__init__.py SKIPPED [ 2%]
stl/__init__.py PASSED [ 2%]
stl/base.py SKIPPED [ 3%]
stl/base.py PASSED [ 3%]
stl/base.py::stl.base.BaseMesh PASSED [ 3%]
stl/main.py SKIPPED [ 4%]
stl/main.py PASSED [ 4%]
stl/mesh.py SKIPPED [ 5%]
stl/mesh.py PASSED [ 5%]
stl/stl.py SKIPPED [ 6%]
stl/stl.py PASSED [ 6%]
stl/utils.py SKIPPED [ 6%]
stl/utils.py PASSED [ 6%]
tests/__init__.py SKIPPED [ 7%]
tests/__init__.py PASSED [ 7%]
tests/conftest.py SKIPPED [ 8%]
tests/conftest.py PASSED [ 8%]
tests/stl_corruption.py SKIPPED [ 9%]
tests/stl_corruption.py PASSED [ 9%]
tests/stl_corruption.py::test_valid_ascii[False] FAILED [ 9%]
tests/stl_corruption.py::test_valid_ascii[True] PASSED [ 10%]
tests/stl_corruption.py::test_ascii_with_missing_name[False] FAILED [ 11%]
tests/stl_corruption.py::test_ascii_with_missing_name[True] PASSED [ 12%]
tests/stl_corruption.py::test_ascii_with_blank_lines[False] FAILED [ 12%]
tests/stl_corruption.py::test_ascii_with_blank_lines[True] PASSED [ 13%]
tests/stl_corruption.py::test_incomplete_ascii_file[False] PASSED [ 14%]
tests/stl_corruption.py::test_incomplete_ascii_file[True] PASSED [ 15%]
tests/stl_corruption.py::test_corrupt_ascii_file[False] PASSED [ 15%]
tests/stl_corruption.py::test_corrupt_ascii_file[True] PASSED [ 16%]
tests/stl_corruption.py::test_corrupt_binary_file[False] PASSED [ 17%]
tests/stl_corruption.py::test_corrupt_binary_file[True] PASSED [ 18%]
tests/stl_corruption.py::test_duplicate_polygons[False] PASSED [ 18%]
tests/stl_corruption.py::test_duplicate_polygons[True] PASSED [ 19%]
tests/test_ascii.py SKIPPED [ 20%]
tests/test_ascii.py PASSED [ 20%]
tests/test_ascii.py::test_long_name[False] FAILED [ 21%]
tests/test_ascii.py::test_long_name[True] PASSED [ 21%]
tests/test_ascii.py::test_scientific_notation[False] FAILED [ 22%]
tests/test_ascii.py::test_scientific_notation[True] PASSED [ 23%]
tests/test_binary.py SKIPPED [ 24%]
tests/test_binary.py PASSED [ 24%]
tests/test_binary.py::test_ascii_like_binary[False-Mode.BINARY] PASSED [ 24%]
tests/test_binary.py::test_ascii_like_binary[False-Mode.AUTOMATIC] PASSED [ 25%]
tests/test_binary.py::test_ascii_like_binary[True-Mode.BINARY] PASSED [ 26%]
tests/test_binary.py::test_ascii_like_binary[True-Mode.AUTOMATIC] PASSED [ 27%]
tests/test_binary.py::test_binary_in_ascii_mode[False] PASSED [ 27%]
tests/test_binary.py::test_binary_in_ascii_mode[True] PASSED [ 28%]
tests/test_commandline.py SKIPPED [ 29%]
tests/test_commandline.py PASSED [ 29%]
tests/test_commandline.py::test_main[False] FAILED [ 30%]
tests/test_commandline.py::test_main[True] PASSED [ 30%]
tests/test_commandline.py::test_args[False] PASSED [ 31%]
tests/test_commandline.py::test_args[True] PASSED [ 32%]
tests/test_commandline.py::test_ascii[False] PASSED [ 33%]
tests/test_commandline.py::test_ascii[True] PASSED [ 33%]
tests/test_commandline.py::test_binary[False] FAILED [ 34%]
tests/test_commandline.py::test_binary[True] PASSED [ 35%]
tests/test_convert.py SKIPPED [ 36%]
tests/test_convert.py PASSED [ 36%]
tests/test_convert.py::test_ascii_to_binary[False] PASSED [ 36%]
tests/test_convert.py::test_ascii_to_binary[True] PASSED [ 37%]
tests/test_convert.py::test_binary_to_ascii[False] PASSED [ 38%]
tests/test_convert.py::test_binary_to_ascii[True] PASSED [ 39%]
tests/test_convert.py::test_stl_mesh[False] FAILED [ 39%]
tests/test_convert.py::test_stl_mesh[True] PASSED [ 40%]
tests/test_mesh.py SKIPPED [ 41%]
tests/test_mesh.py PASSED [ 41%]
tests/test_mesh.py::test_units_1d[False] PASSED [ 42%]
tests/test_mesh.py::test_units_1d[True] PASSED [ 42%]
tests/test_mesh.py::test_units_2d[False] PASSED [ 43%]
tests/test_mesh.py::test_units_2d[True] PASSED [ 44%]
tests/test_mesh.py::test_units_3d[False] PASSED [ 45%]
tests/test_mesh.py::test_units_3d[True] PASSED [ 45%]
tests/test_mesh.py::test_duplicate_polygons[False] PASSED [ 46%]
tests/test_mesh.py::test_duplicate_polygons[True] PASSED [ 47%]
tests/test_mesh.py::test_remove_all_duplicate_polygons[False] PASSED [ 48%]
tests/test_mesh.py::test_remove_all_duplicate_polygons[True] PASSED [ 48%]
tests/test_mesh.py::test_empty_areas[False] PASSED [ 49%]
tests/test_mesh.py::test_empty_areas[True] PASSED [ 50%]
tests/test_mesh.py::test_base_mesh[False] PASSED [ 51%]
tests/test_mesh.py::test_base_mesh[True] PASSED [ 51%]
tests/test_meshProperties.py SKIPPED [ 52%]
tests/test_meshProperties.py PASSED [ 52%]
tests/test_meshProperties.py::test_mass_properties_for_half_donut[ascii-False] FAILED [ 53%]
tests/test_meshProperties.py::test_mass_properties_for_half_donut[ascii-True] PASSED [ 54%]
tests/test_meshProperties.py::test_mass_properties_for_moon[ascii-False] FAILED [ 54%]
tests/test_meshProperties.py::test_mass_properties_for_moon[ascii-True] PASSED [ 55%]
tests/test_meshProperties.py::test_mass_properties_for_star[ascii-False-Star.stl] FAILED [ 56%]
tests/test_meshProperties.py::test_mass_properties_for_star[ascii-False-StarWithEmptyHeader.stl] SKIPPED [ 57%]
tests/test_meshProperties.py::test_mass_properties_for_star[ascii-True-Star.stl] PASSED [ 57%]
tests/test_meshProperties.py::test_mass_properties_for_star[ascii-True-StarWithEmptyHeader.stl] SKIPPED [ 58%]
tests/test_meshProperties.py::test_mass_properties_for_half_donut[binary-False] PASSED [ 59%]
tests/test_meshProperties.py::test_mass_properties_for_half_donut[binary-True] PASSED [ 60%]
tests/test_meshProperties.py::test_mass_properties_for_moon[binary-False] PASSED [ 60%]
tests/test_meshProperties.py::test_mass_properties_for_moon[binary-True] PASSED [ 61%]
tests/test_meshProperties.py::test_mass_properties_for_star[binary-False-Star.stl] PASSED [ 62%]
tests/test_meshProperties.py::test_mass_properties_for_star[binary-False-StarWithEmptyHeader.stl] PASSED [ 63%]
tests/test_meshProperties.py::test_mass_properties_for_star[binary-True-Star.stl] PASSED [ 63%]
tests/test_meshProperties.py::test_mass_properties_for_star[binary-True-StarWithEmptyHeader.stl] PASSED [ 64%]
tests/test_multiple.py SKIPPED [ 65%]
tests/test_multiple.py PASSED [ 65%]
tests/test_multiple.py::test_single_stl[False] FAILED [ 66%]
tests/test_multiple.py::test_single_stl[True] PASSED [ 66%]
tests/test_multiple.py::test_multiple_stl[False] FAILED [ 67%]
tests/test_multiple.py::test_multiple_stl[True] PASSED [ 68%]
tests/test_multiple.py::test_single_stl_file[False] FAILED [ 69%]
tests/test_multiple.py::test_single_stl_file[True] PASSED [ 69%]
tests/test_multiple.py::test_multiple_stl_file[False] FAILED [ 70%]
tests/test_multiple.py::test_multiple_stl_file[True] PASSED [ 71%]
tests/test_rotate.py SKIPPED [ 72%]
tests/test_rotate.py PASSED [ 72%]
tests/test_rotate.py::test_rotation[False] PASSED [ 72%]
tests/test_rotate.py::test_rotation[True] PASSED [ 73%]
tests/test_rotate.py::test_rotation_over_point[False] PASSED [ 74%]
tests/test_rotate.py::test_rotation_over_point[True] PASSED [ 75%]
tests/test_rotate.py::test_double_rotation[False] PASSED [ 75%]
tests/test_rotate.py::test_double_rotation[True] PASSED [ 76%]
tests/test_rotate.py::test_no_rotation[False] PASSED [ 77%]
tests/test_rotate.py::test_no_rotation[True] PASSED [ 78%]
tests/test_rotate.py::test_no_translation[False] PASSED [ 78%]
tests/test_rotate.py::test_no_translation[True] PASSED [ 79%]
tests/test_rotate.py::test_translation[False] PASSED [ 80%]
tests/test_rotate.py::test_translation[True] PASSED [ 81%]
tests/test_rotate.py::test_no_transformation[False] PASSED [ 81%]
tests/test_rotate.py::test_no_transformation[True] PASSED [ 82%]
tests/test_rotate.py::test_transformation[False] PASSED [ 83%]
tests/test_rotate.py::test_transformation[True] PASSED [ 84%]
tests/utils.py SKIPPED [ 84%]
tests/utils.py PASSED [ 84%]
=================================== FAILURES ===================================
___________________________ test_valid_ascii[False] ____________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_valid_ascii_False_0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_valid_ascii_False_0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_valid_ascii_False_0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_valid_ascii_False_0')
speedups = False
def test_valid_ascii(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('w+') as fh:
fh.write(_STL_FILE)
fh.seek(0)
> mesh.Mesh.from_file(str(tmp_file), fh=fh, speedups=speedups)
tests/stl_corruption.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_valid_ascii_False_0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_____________________ test_ascii_with_missing_name[False] ______________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_missing_name_F0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex 0.399344'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_missing_name_F0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_missing_name_F0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex 0.399344'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_missing_name_F0')
speedups = False
def test_ascii_with_missing_name(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('w+') as fh:
# Split the file into lines
lines = _STL_FILE.splitlines()
# Remove everything except solid
lines[0] = lines[0].split()[0]
# Join the lines to test files that start with solid without space
fh.write('\n'.join(lines))
fh.seek(0)
> mesh.Mesh.from_file(str(tmp_file), fh=fh, speedups=speedups)
tests/stl_corruption.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_missing_name_F0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
------------------------------ Captured log call -------------------------------
logger.py 46 WARNING ASCII STL files should start with solid <space>. The application that produced this STL file may be faulty, please report this error. The erroneous line: b'solid'
______________________ test_ascii_with_blank_lines[False] ______________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_blank_lines_Fa0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid test.stl\n\n\n facet normal -0.014565 0.073223 -0.002897\n\n outer '
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
> return get(prefix)
stl/stl.py:158:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_blank_lines_Fa0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_blank_lines_Fa0/tmp.stl' mode='w+' encoding='UTF-8'>
header = b'solid test.stl\n\n\n facet normal -0.014565 0.073223 -0.002897\n\n outer '
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_blank_lines_Fa0')
speedups = False
def test_ascii_with_blank_lines(tmpdir, speedups):
_stl_file = '''
solid test.stl
facet normal -0.014565 0.073223 -0.002897
outer loop
vertex 0.399344 0.461940 1.044090
vertex 0.500000 0.500000 1.500000
vertex 0.576120 0.500000 1.117320
endloop
endfacet
endsolid test.stl
'''.lstrip()
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('w+') as fh:
fh.write(_stl_file)
fh.seek(0)
> mesh.Mesh.from_file(str(tmp_file), fh=fh, speedups=speedups)
tests/stl_corruption.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.TextIOWrapper name='/tmp/pytest-of-churchyard/pytest-1/test_ascii_with_blank_lines_Fa0/tmp.stl' mode='w+' encoding='UTF-8'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
____________________________ test_long_name[False] _____________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_long_name_False_0/tmp.stl'>
header = b'solid just some very long name which will not fit within the standardjust some very long name which will not fit wit...00 0.500000 1.500000\n vertex 0.576120 0.500000 1.117320\n endloop\n endfacet\n endsolid\n '
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_long_name_False_0/tmp.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_long_name_False_0/tmp.stl'>
header = b'solid just some very long name which will not fit within the standardjust some v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_long_name_False_0')
speedups = False
def test_long_name(tmpdir, speedups):
name = 'just some very long name which will not fit within the standard'
name += name
_stl_file = ('''
solid %s
facet normal -0.014565 0.073223 -0.002897
outer loop
vertex 0.399344 0.461940 1.044090
vertex 0.500000 0.500000 1.500000
vertex 0.576120 0.500000 1.117320
endloop
endfacet
endsolid
''' % name).lstrip()
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
fh.write(b(_stl_file))
fh.seek(0)
test_mesh = mesh.Mesh.from_file(str(tmp_file), fh=fh,
> speedups=speedups)
tests/test_ascii.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_long_name_False_0/tmp.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_______________________ test_scientific_notation[False] ________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_scientific_notation_False0/tmp.stl'>
header = b'solid just some very long name which will not fit within the standardjust some very long name which will not fit wit...000e-5 5.00000e-5 1.500000e-3\n vertex 0 2.22045e-15 -10\n endloop\n endfacet\n endsolid\n '
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_scientific_notation_False0/tmp.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_scientific_notation_False0/tmp.stl'>
header = b'solid just some very long name which will not fit within the standardjust some v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_scientific_notation_False0')
speedups = False
def test_scientific_notation(tmpdir, speedups):
name = 'just some very long name which will not fit within the standard'
name += name
_stl_file = ('''
solid %s
facet normal 1.014565e-10 7.3223e-5 -10
outer loop
vertex 0.399344 0.461940 1.044090e-5
vertex 5.00000e-5 5.00000e-5 1.500000e-3
vertex 0 2.22045e-15 -10
endloop
endfacet
endsolid
''' % name).lstrip()
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
fh.write(b(_stl_file))
fh.seek(0)
test_mesh = mesh.Mesh.from_file(str(tmp_file), fh=fh,
> speedups=speedups)
tests/test_ascii.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_scientific_notation_False0/tmp.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_______________________________ test_main[False] _______________________________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
ascii_file = '/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'
binary_file = '/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_binary/HalfDonut.stl'
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_main_False_0')
speedups = False
def test_main(ascii_file, binary_file, tmpdir, speedups):
original_argv = sys.argv[:]
args_pre = ['stl']
args_post = [str(tmpdir.join('output.stl'))]
if not speedups:
args_pre.append('-s')
try:
sys.argv[:] = args_pre + [ascii_file] + args_post
> main.main()
tests/test_commandline.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/main.py:53: in main
speedups=not args.disable_speedups)
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
______________________________ test_binary[False] ______________________________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
ascii_file = '/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_binary_False_0')
speedups = False
def test_binary(ascii_file, tmpdir, speedups):
original_argv = sys.argv[:]
try:
sys.argv[:] = [
'stl',
'-s' if not speedups else '',
ascii_file,
str(tmpdir.join('binary.stl')),
]
try:
> main.to_binary()
tests/test_commandline.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/main.py:85: in to_binary
speedups=not args.disable_speedups)
stl/stl.py:329: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_____________________________ test_stl_mesh[False] _____________________________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
ascii_file = '/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_stl_mesh_False_0')
speedups = False
def test_stl_mesh(ascii_file, tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
> mesh = stl.StlMesh(ascii_file, speedups=speedups)
tests/test_convert.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:334: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_______________ test_mass_properties_for_half_donut[ascii-False] _______________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
header = b'solid halfdonut.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n v'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
binary_ascii_path = local('/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii')
speedups = False
def test_mass_properties_for_half_donut(binary_ascii_path, speedups):
"""
Checks the results of method get_mass_properties() on
STL ASCII and binary files HalfDonut.stl
One checks the results obtained with stl
with the ones obtained with meshlab
"""
filename = binary_ascii_path.join('HalfDonut.stl')
> mesh = stl.StlMesh(str(filename), speedups=speedups)
tests/test_meshProperties.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:334: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/HalfDonut.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
__________________ test_mass_properties_for_moon[ascii-False] __________________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Moon.stl'>
header = b'solid moon.stl\nfacet normal -0.091618 0.000000 -0.072093\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Moon.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Moon.stl'>
header = b'solid moon.stl\nfacet normal -0.091618 0.000000 -0.072093\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
binary_ascii_path = local('/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii')
speedups = False
def test_mass_properties_for_moon(binary_ascii_path, speedups):
"""
Checks the results of method get_mass_properties() on
STL ASCII and binary files Moon.stl
One checks the results obtained with stl
with the ones obtained with meshlab
"""
filename = binary_ascii_path.join('Moon.stl')
> mesh = stl.StlMesh(str(filename), speedups=speedups)
tests/test_meshProperties.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:334: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Moon.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
_____________ test_mass_properties_for_star[ascii-False-Star.stl] ______________
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Star.stl'>
header = b'solid star.stl\nfacet normal 0.000000 -0.645975 0.000000\n outer loop\n vertex '
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Star.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
> fh, header, speedups=speedups)
stl/stl.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Star.stl'>
header = b'solid star.stl\nfacet normal 0.000000 -0.645975 0.000000\n outer loop\n vertex '
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
During handling of the above exception, another exception occurred:
binary_ascii_path = local('/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii')
filename = local('/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Star.stl')
speedups = False
@pytest.mark.parametrize('filename', ('Star.stl', 'StarWithEmptyHeader.stl'))
def test_mass_properties_for_star(binary_ascii_path, filename, speedups):
"""
Checks the results of method get_mass_properties() on
STL ASCII and binary files Star.stl and
STL binary file StarWithEmptyHeader.stl (with no header)
One checks the results obtained with stl
with the ones obtained with meshlab
"""
filename = binary_ascii_path.join(filename)
if not filename.exists():
pytest.skip('STL file does not exist')
> mesh = stl.StlMesh(str(filename), speedups=speedups)
tests/test_meshProperties.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:334: in from_file
fh, mode=mode, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.stl.BaseStl'>
fh = <_io.BufferedReader name='/home/churchyard/Dokumenty/RedHat/numpy-stl/tests/stl_ascii/Star.stl'>
mode = <Mode.AUTOMATIC: 0>, speedups = False
@classmethod
def load(cls, fh, mode=AUTOMATIC, speedups=True):
'''Load Mesh from STL file
Automatically detects binary versus ascii STL files.
:param file fh: The file handle to open
:param int mode: Automatically detect the filetype or force binary
'''
header = fh.read(HEADER_SIZE).lower()
if not header:
return
if isinstance(header, str): # pragma: no branch
header = b(header)
name = ''
if mode in (AUTOMATIC, ASCII) and header.startswith(b('solid')):
try:
name, data = cls._load_ascii(
fh, header, speedups=speedups)
except RuntimeError as exception:
# Disable fallbacks in ASCII mode
if mode is ASCII:
raise
> (recoverable, e) = exception.args
E ValueError: not enough values to unpack (expected 2, got 1)
stl/stl.py:81: ValueError
____________________________ test_single_stl[False] ____________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_single_stl_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_single_stl_False_0')
speedups = False
def test_single_stl(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
fh.write(_STL_FILE)
fh.seek(0)
for m in mesh.Mesh.from_multi_file(
> str(tmp_file), fh=fh, speedups=speedups):
tests/test_multiple.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:364: in from_multi_file
raw_data = cls.load(fh, mode=mode, speedups=speedups)
stl/stl.py:75: in load
fh, header, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_single_stl_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
___________________________ test_multiple_stl[False] ___________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_False_0')
speedups = False
def test_multiple_stl(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
for _ in range(10):
fh.write(_STL_FILE)
fh.seek(0)
for i, m in enumerate(mesh.Mesh.from_multi_file(
> str(tmp_file), fh=fh, speedups=speedups)):
tests/test_multiple.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:364: in from_multi_file
raw_data = cls.load(fh, mode=mode, speedups=speedups)
stl/stl.py:75: in load
fh, header, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedRandom name='/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
_________________________ test_single_stl_file[False] __________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedReader name='/tmp/pytest-of-churchyard/pytest-1/test_single_stl_file_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_single_stl_file_False_0')
speedups = False
def test_single_stl_file(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
fh.write(_STL_FILE)
fh.seek(0)
for m in mesh.Mesh.from_multi_file(
> str(tmp_file), speedups=speedups):
tests/test_multiple.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:364: in from_multi_file
raw_data = cls.load(fh, mode=mode, speedups=speedups)
stl/stl.py:75: in load
fh, header, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedReader name='/tmp/pytest-of-churchyard/pytest-1/test_single_stl_file_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
________________________ test_multiple_stl_file[False] _________________________
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedReader name='/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_file_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
@classmethod
def _ascii_reader(cls, fh, header):
if b'\n' in header:
recoverable = [True]
else:
recoverable = [False]
header += b(fh.read(BUFFER_SIZE))
lines = b(header).split(b('\n'))
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
raise StopIteration()
else:
raise RuntimeError(recoverable[0],
'%r should start with %r' % (line,
prefix))
if len(values) == 3:
return [float(v) for v in values]
else: # pragma: no cover
raise RuntimeError(recoverable[0],
'Incorrect value %r' % line)
else:
return b(line)
line = get()
if not line.startswith(b('solid ')) and line.startswith(b('solid')):
cls.warning('ASCII STL files should start with solid <space>. '
'The application that produced this STL file may be '
'faulty, please report this error. The erroneous '
'line: %r', line)
if not lines:
raise RuntimeError(recoverable[0],
'No lines found, impossible to read')
# Yield the name
yield line[5:].strip()
while True:
# Read from the header lines first, until that point we can recover
# and go to the binary option. After that we cannot due to
# unseekable files such as sys.stdin
#
# Numpy doesn't support any non-file types so wrapping with a
# buffer and/or StringIO does not work.
try:
> normals = get('facet normal')
stl/stl.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prefix = b'facet normal'
def get(prefix=''):
prefix = b(prefix)
if lines:
line = lines.pop(0)
else:
raise RuntimeError(recoverable[0], 'Unable to find more lines')
if not lines:
recoverable[0] = False
# Read more lines and make sure we prepend any old data
lines[:] = b(fh.read(BUFFER_SIZE)).split(b('\n'))
line += lines.pop(0)
line = line.lower().strip()
if line == b(''):
return get(prefix)
if prefix:
if line.startswith(prefix):
values = line.replace(prefix, b(''), 1).strip().split()
elif line.startswith(b('endsolid')):
# go back to the beginning of new solid part
size_unprocessedlines = sum(len(l) + 1 for l in lines) - 1
if size_unprocessedlines > 0:
position = fh.tell()
fh.seek(position - size_unprocessedlines)
> raise StopIteration()
E StopIteration
stl/stl.py:169: StopIteration
The above exception was the direct cause of the following exception:
tmpdir = local('/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_file_False_0')
speedups = False
def test_multiple_stl_file(tmpdir, speedups):
tmp_file = tmpdir.join('tmp.stl')
with tmp_file.open('wb+') as fh:
for _ in range(10):
fh.write(_STL_FILE)
fh.seek(0)
for i, m in enumerate(mesh.Mesh.from_multi_file(
> str(tmp_file), speedups=speedups)):
tests/test_multiple.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stl/stl.py:364: in from_multi_file
raw_data = cls.load(fh, mode=mode, speedups=speedups)
stl/stl.py:75: in load
fh, header, speedups=speedups)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'stl.mesh.Mesh'>
fh = <_io.BufferedReader name='/tmp/pytest-of-churchyard/pytest-1/test_multiple_stl_file_False_0/tmp.stl'>
header = b'solid test.stl\nfacet normal -0.014565 0.073223 -0.002897\n outer loop\n vertex'
speedups = False
@classmethod
def _load_ascii(cls, fh, header, speedups=True):
# The speedups module is covered by travis but it can't be tested in
# all environments, this makes coverage checks easier
if _speedups and speedups: # pragma: no cover
return _speedups.ascii_read(fh, header)
else:
iterator = cls._ascii_reader(fh, header)
name = next(iterator)
> return name, numpy.fromiter(iterator, dtype=cls.dtype)
E RuntimeError: generator raised StopIteration
stl/stl.py:228: RuntimeError
=============== 15 failed, 96 passed, 22 skipped in 1.94 seconds ===============
/home/churchyard/Dokumenty/RedHat/numpy-stl/.tox/py37-nix/lib/python3.7/site-packages/pep8.py:110: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
ERROR: InvocationError: '/home/churchyard/Dokumenty/RedHat/numpy-stl/.tox/py37-nix/bin/python -m pytest -vvv'
___________________________________ summary ____________________________________
ERROR: py37-nix: commands failed
See https://docs.python.org/3.7/whatsnew/3.7.html#changes-in-python-behavior and https://www.python.org/dev/peps/pep-0479/
A generator now cannot raise StopIteration, it should return instead.
(This will take a minute, because it compiles Cython and Numpy...)