Repository: yt-project/yt

Issue:
Auxiliary .kdtree file confuses frontend detection
# Bug report

Due to a brittle logic in `_is_valid` and `GadgetDataset.__init__` additional files in snapshot directory lead to wrong `GadgetDataset.parameter_filename`

**Code for reproduction**

```python
from yt.frontends.owls.data_structures import OWLSDataset
ds = OWLSDataset("/home/xarth/codes/yt_data/snapshot_033/")
ds.index.kdtree
ds = OWLSDataset("/home/xarth/codes/yt_data/snapshot_033/")
```

**Actual outcome**


```
Traceback (most recent call last):
  File "ala.py", line 2, in <module>
    ds = OWLSDataset("/home/xarth/codes/yt_data/snapshot_033/")
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/gadget/data_structures.py", line 571, in __init__
    super(GadgetHDF5Dataset, self).__init__(
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/gadget/data_structures.py", line 303, in __init__
    super(GadgetDataset, self).__init__(
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/sph/data_structures.py", line 34, in __init__
    super(SPHDataset, self).__init__(
  File "/home/xarth/codes/xarthisius/yt/yt/data_objects/static_output.py", line 1743, in __init__
    super(ParticleDataset, self).__init__(
  File "/home/xarth/codes/xarthisius/yt/yt/data_objects/static_output.py", line 256, in __init__
    self._parse_parameter_file()
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/owls/data_structures.py", line 19, in _parse_parameter_file
    hvals = self._get_hvals()
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/gadget/data_structures.py", line 583, in _get_hvals
    handle = h5py.File(self.parameter_filename, mode="r")
  File "/home/xarth/.local/lib/python3.8/site-packages/h5py/_hl/files.py", line 406, in __init__
    fid = make_fid(name, mode, userblock_size,
  File "/home/xarth/.local/lib/python3.8/site-packages/h5py/_hl/files.py", line 173, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
```

(`self.parameter_filename` is equal to `<test_data_dir>/snapshot_033/snap_033.0.hdf5.kdtree`)

**Expected outcome**

General happiness.

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Ubuntu 18.04
  * Python Version: 3.8
  * yt version: 53b2d0aa2842bedede76d7ced2a1450f3402206d
  * Other Libraries (if applicable): 


Discussion:

Resolving patch:
diff --git a/yt/frontends/gadget/data_structures.py b/yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -248,7 +248,12 @@ def __init__(
             # came through _is_valid in load()
             for f in os.listdir(filename):
                 fname = os.path.join(filename, f)
-                if (".0" in f) and (".ewah" not in f) and os.path.isfile(fname):
+                fext = os.path.splitext(fname)[-1]
+                if (
+                    (".0" in f)
+                    and (fext not in {".ewah", ".kdtree"})
+                    and os.path.isfile(fname)
+                ):
                     filename = os.path.join(filename, f)
                     break
         self._header = GadgetBinaryHeader(filename, header_spec)
diff --git a/yt/frontends/gizmo/data_structures.py b/yt/frontends/gizmo/data_structures.py
--- a/yt/frontends/gizmo/data_structures.py
+++ b/yt/frontends/gizmo/data_structures.py
@@ -20,7 +20,12 @@ def _is_valid(self, *args, **kwargs):
             valid_files = []
             for f in os.listdir(args[0]):
                 fname = os.path.join(args[0], f)
-                if (".0" in f) and (".ewah" not in f) and os.path.isfile(fname):
+                fext = os.path.splitext(fname)[-1]
+                if (
+                    (".0" in f)
+                    and (fext not in {".ewah", ".kdtree"})
+                    and os.path.isfile(fname)
+                ):
                     valid_files.append(fname)
             if len(valid_files) == 0:
                 valid = False
diff --git a/yt/frontends/owls/data_structures.py b/yt/frontends/owls/data_structures.py
--- a/yt/frontends/owls/data_structures.py
+++ b/yt/frontends/owls/data_structures.py
@@ -48,7 +48,12 @@ def _is_valid(self, *args, **kwargs):
             valid_files = []
             for f in os.listdir(args[0]):
                 fname = os.path.join(args[0], f)
-                if (".0" in f) and (".ewah" not in f) and os.path.isfile(fname):
+                fext = os.path.splitext(fname)[-1]
+                if (
+                    (".0" in f)
+                    and (fext not in {".ewah", ".kdtree"})
+                    and os.path.isfile(fname)
+                ):
                     valid_files.append(fname)
             if len(valid_files) == 0:
                 valid = False


Test patch: