Skip to content

Commit dcf121b

Browse files
committed
Move AutowrapConfigYaml loading to common location
1 parent ba5d8b2 commit dcf121b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

robotpy_build/config/autowrap_yml.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pydantic import validator
1010
from .util import Model, _generating_documentation
11+
import yaml
1112

1213

1314
class ParamData(Model):
@@ -577,3 +578,13 @@ def validate_functions(cls, value):
577578
if v is None:
578579
value[k] = FunctionData()
579580
return value
581+
582+
@classmethod
583+
def from_file(cls, fname) -> "AutowrapConfigYaml":
584+
with open(fname) as fp:
585+
data = yaml.safe_load(fp)
586+
587+
if data is None:
588+
data = {}
589+
590+
return cls(**data)

robotpy_build/wrapper.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,6 @@ def get_type_casters(casters):
586586

587587
self._add_addl_data_file(fname)
588588

589-
def _load_generation_data(self, datafile):
590-
with open(datafile) as fp:
591-
data = yaml.safe_load(fp)
592-
593-
if data is None:
594-
data = {}
595-
596-
return AutowrapConfigYaml(**data)
597-
598589
def on_build_gen(
599590
self, cxx_gen_dir, missing_reporter: Optional[MissingReporter] = None
600591
):
@@ -637,7 +628,7 @@ def on_build_gen(
637628
datapath = join(self.setup_root, normpath(self.cfg.generation_data))
638629
per_header = isdir(datapath)
639630
if not per_header:
640-
data = self._load_generation_data(datapath)
631+
data = AutowrapConfigYaml.from_file(datapath)
641632
else:
642633
data = AutowrapConfigYaml()
643634

@@ -694,7 +685,7 @@ def on_build_gen(
694685
print("WARNING: could not find", data_fname)
695686
data = AutowrapConfigYaml()
696687
else:
697-
data = self._load_generation_data(data_fname)
688+
data = AutowrapConfigYaml.from_file(data_fname)
698689

699690
# split instantiation of each template to separate cpp files to reduce
700691
# compiler memory for really obscene objects

0 commit comments

Comments
 (0)