PHASTA / vtkpytools

Internal tools for using VTK
https://fluid.colorado.edu/wiki/index.php/VTKpytools
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Enforce better globbing in bar2vtk #47

Closed jrwrigh closed 3 years ago

jrwrigh commented 3 years ago

Instead of just globbing velbar*.{timestep number}*, have it be more strict by only allowing the * to apply for file extensions.

Example: For time step number = 200: Match:

Fail:

jrwrigh commented 3 years ago

The following regex string works for the above cases: ^velbar\.200(?!\d).*$

Effectively, after 200, if the next character is a digit, the matching fails. Otherwise, it succeeds with any other characters.

In [5]: os.listdir('.')      
Out[5]: ['velbar.200', 'velbar.200.1', 'velbar.2000']

In [6]: for filename in filter(re.compile(r'^velbar\.200(?!\d).*$').match, os.listdir('.')):
   ...:     print(filename) 
   ...:                      
velbar.200
velbar.200.1