Skip to content

Commit 0f408b7

Browse files
committed
Simplify inject_pdal_drivers a bit
1 parent 765abc8 commit 0f408b7

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pdal/drivers.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Option:
1111
name: str
1212
description: str
13-
default: Optional[str]
13+
default: Optional[str] = None
1414

1515
def __repr__(self) -> str:
1616
if self.default is not None:
@@ -25,7 +25,7 @@ class Driver:
2525
short_name: str = field(init=False)
2626
type: Type[Stage] = field(init=False)
2727
description: str
28-
options: Optional[Sequence[Option]]
28+
options: Sequence[Option]
2929

3030
def __post_init__(self) -> None:
3131
prefix, _, suffix = self.name.partition(".")
@@ -69,16 +69,12 @@ def inject_pdal_drivers() -> None:
6969
)
7070
for d in drivers:
7171
name = d["name"]
72-
d_options = options.get(name)
73-
if d_options is not None:
74-
d_options = [
75-
Option(o["name"], o["description"], o.get("default")) for o in d_options
76-
]
77-
# move filename option first
78-
try:
79-
i = next(i for i, opt in enumerate(d_options) if opt.name == "filename")
80-
d_options.insert(0, d_options.pop(i))
81-
except StopIteration:
82-
pass
72+
d_options = [Option(**option_dict) for option_dict in (options.get(name) or ())]
73+
# move filename option first
74+
try:
75+
i = next(i for i, opt in enumerate(d_options) if opt.name == "filename")
76+
d_options.insert(0, d_options.pop(i))
77+
except StopIteration:
78+
pass
8379
driver = Driver(name, d["description"], d_options)
8480
setattr(driver.type, driver.short_name, staticmethod(driver.factory))

0 commit comments

Comments
 (0)