22
33import glob
44import json
5- import subprocess
65from abc import ABC , abstractmethod
76from typing import Any , Container , Dict , Iterator , List , Optional , Sequence , Union , cast
87
98import numpy as np
109
1110from . import libpdalpython
1211
13- _PDAL_DRIVERS = json .loads (
14- subprocess .run (["pdal" , "--drivers" , "--showjson" ], capture_output = True ).stdout
15- )
16-
1712
1813class Pipeline (libpdalpython .Pipeline ):
1914 def __init__ (
@@ -73,13 +68,6 @@ def _json(self) -> str:
7368
7469
7570class Stage :
76- def __init_subclass__ (cls , type_prefix : Optional [str ] = None ) -> None :
77- for driver in _PDAL_DRIVERS :
78- name = driver ["name" ]
79- prefix , _ , suffix = name .partition ("." )
80- if prefix == type_prefix :
81- cls ._add_constructor (name , suffix , driver ["description" ])
82-
8371 def __init__ (self , ** options : Any ):
8472 self ._options = options
8573
@@ -106,14 +94,6 @@ def pipeline(self, *arrays: np.ndarray) -> Pipeline:
10694 def __or__ (self , other : Union [Stage , Pipeline ]) -> Pipeline :
10795 return Pipeline ((self , other ))
10896
109- @classmethod
110- def _add_constructor (cls , type : str , name : str , description : str ) -> None :
111- constructor = lambda cls , * args , ** kwargs : cls (* args , ** kwargs , type = type )
112- constructor .__name__ = name
113- constructor .__qualname__ = f"{ cls .__name__ } .{ name } "
114- constructor .__doc__ = description
115- setattr (cls , name , classmethod (constructor ))
116-
11797
11898class InferableTypeStage (ABC , Stage ):
11999 @staticmethod
@@ -129,19 +109,19 @@ def type(self) -> str:
129109 return self .infer_type (self ._options ["filename" ])
130110
131111
132- class Reader (InferableTypeStage , type_prefix = "readers" ):
112+ class Reader (InferableTypeStage ):
133113 infer_type = staticmethod (libpdalpython .infer_reader_driver )
134114
135115 def __init__ (self , filename : str , ** options : Any ):
136116 super ().__init__ (filename = filename , ** options )
137117
138118
139- class Filter (Stage , type_prefix = "filters" ):
119+ class Filter (Stage ):
140120 def __init__ (self , type : str , ** options : Any ):
141121 super ().__init__ (type = type , ** options )
142122
143123
144- class Writer (InferableTypeStage , type_prefix = "writers" ):
124+ class Writer (InferableTypeStage ):
145125 infer_type = staticmethod (libpdalpython .infer_writer_driver )
146126
147127 def __init__ (self , filename : Optional [str ] = None , ** options : Any ):
0 commit comments