tkarabela / ensight-reader

A pure Python reader for the EnSight Gold format
https://ensight-reader.readthedocs.io
MIT License
7 stars 3 forks source link

filenames containing quotes "" getting double quotes '""' #6

Closed shimwell closed 3 months ago

shimwell commented 3 months ago

I've been provided with an ansys output file that makes use of quotes for the filenames.

The encas file looks like this

FORMAT
type:  ensight gold
GEOMETRY
model: "filename.geo"
VARIABLE
scalar per element: uds_1_scalar                                     "filename.scl1"
vector per element: velocity                                         "filename.vel"
SCRIPTS
metadata: "filename.xml"

this leads to the files not being found as it looks like ensight-reader assumes these filenames don't have quotes so it makes a string with a double quote and errors

>>> case.get_variable(v[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/j/miniforge-pypy3/envs/f4enix_dev/lib/python3.11/site-packages/ensightreader.py", line 1698, in get_variable
    self._variable_file_cache[cache_key] = self.variables[name].get_file(geofile=geofile, timestep=timestep)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/j/miniforge-pypy3/envs/f4enix_dev/lib/python3.11/site-packages/ensightreader.py", line 1511, in get_file
    return EnsightVariableFile.from_file_path(path, variable_name=self.variable_name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/j/miniforge-pypy3/envs/f4enix_dev/lib/python3.11/site-packages/ensightreader.py", line 1251, in from_file_path
    with open(file_path, "rb") as fp:
         ^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '"filename.scl1"'

I guess this is due to Ansys putting quotes where there should not be quotes

tkarabela commented 3 months ago

Thanks for the bug report! I will assume it's a bug, since ANSYS now owns EnSight, so they cannot be wrong :)

Please upgrade to version 0.11.2, it should be fixed now.