@@ -75,13 +75,25 @@ def __init__(
7575 True if files are on the local machine, False if they have already
7676 been uploaded to the DPF server..
7777 """
78- if isinstance (rst , (str , pathlib .Path )):
79- rst = [rst ]
8078 self .rst = rst # type: ignore
8179 self .composite = composite
8280 self .engineering_data = engineering_data
8381 self .files_are_local = files_are_local
8482
83+ # The constructor pretends that rst can also be just a path
84+ # but the property rst must be a list
85+ def __setattr__ (self , prop , val ): # type: ignore
86+ """Convert values if needed."""
87+ if prop == "rst" :
88+ val = self ._get_rst_list (val )
89+ super ().__setattr__ (prop , val )
90+
91+ @staticmethod
92+ def _get_rst_list (value : Union [List [_PATH ], _PATH ]) -> List [_PATH ]:
93+ if isinstance (value , (str , pathlib .Path )):
94+ value = [value ]
95+ return value # type: ignore
96+
8597
8698@dataclass
8799class ShortFiberCompositesFiles :
@@ -116,13 +128,25 @@ def __init__(
116128 True if files are on the local machine, False if they have already
117129 been uploaded to the DPF server..
118130 """
119- if isinstance (rst , (str , pathlib .Path )):
120- rst = [rst ]
121131 self .rst = rst # type: ignore
122132 self .dsdat = dsdat
123133 self .engineering_data = engineering_data
124134 self .files_are_local = files_are_local
125135
136+ # The constructor pretends that rst can also be just a path
137+ # but the property rst must be a list.
138+ def __setattr__ (self , prop , val ): # type: ignore
139+ """Convert values if needed."""
140+ if prop == "rst" :
141+ val = self ._get_rst_list (val )
142+ super ().__setattr__ (prop , val )
143+
144+ @staticmethod
145+ def _get_rst_list (value : Union [List [_PATH ], _PATH ]) -> List [_PATH ]:
146+ if isinstance (value , (str , pathlib .Path )):
147+ value = [value ]
148+ return value # type: ignore
149+
126150
127151# roosre June 2023: todo add deprecation warning where composite definition label is used
128152@dataclass (frozen = True )
0 commit comments