Skip to content

Commit d6d3bfc

Browse files
committed
conditionalize FileSpec support to PDAL 2.9+
1 parent c3519d8 commit d6d3bfc

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

src/pdal/pipeline.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
LogLevelFromPDAL = {v: k for k, v in LogLevelToPDAL.items()}
3434

3535

36+
HaveFileSpecSupport = False
37+
if libpdalpython.getInfo().major == 2 and \
38+
libpdalpython.getInfo().minor >= 9 or \
39+
libpdalpython.getInfo().major > 2:
40+
HaveFileSpecSupport = True
41+
42+
3643
class Pipeline(libpdalpython.Pipeline):
3744
def __init__(
3845
self,
@@ -220,11 +227,22 @@ def __init__(self, filename: Optional[str] = None, **options: Any):
220227
if isinstance(filename, dict):
221228
if "path" not in filename:
222229
raise ValueError(f"'path' is missing in the provided filespec: {filename}")
223-
options["filename"] = filename
230+
if HaveFileSpecSupport:
231+
options["filename"] = filename
232+
else:
233+
# log that we can't pass FileSpec to PDAL
234+
# because the library version is too old
235+
msg = "PDAL library version is too old for FileSpec support. " \
236+
"Defaulting to using filename only"
237+
logging.info(msg)
238+
options["filename"] = filename["path"]
224239

225240
else:
226-
filespec = {'path':str(filename)}
227-
options["filename"] = filespec
241+
if HaveFileSpecSupport:
242+
filespec = {'path':str(filename)}
243+
options["filename"] = filespec
244+
else:
245+
options["filename"] = filename
228246
super().__init__(**options)
229247

230248
@property
@@ -236,11 +254,14 @@ def type(self) -> str:
236254
if isinstance(filename, dict):
237255
if "path" not in filename:
238256
raise ValueError(f"'path' is missing in the provided filespec: {filename}")
239-
path = filename.get('path')
257+
if HaveFileSpecSupport:
258+
path = filename.get('path')
259+
else:
260+
path = filename
261+
240262
else:
241263
path = str(filename)
242264

243-
244265
return str(self._infer_type(path) if filename else "")
245266

246267
_infer_type = staticmethod(lambda filename: "")

0 commit comments

Comments
 (0)