33 lines
745 B
Python
33 lines
745 B
Python
from dataclasses import dataclass, field
|
|
def return_list(txt: str) -> [str]:
|
|
_list = []
|
|
if type(txt) in (tuple, list):
|
|
_list = txt
|
|
elif type(txt) in (str, int):
|
|
_list = [str(txt)]
|
|
return _list
|
|
|
|
|
|
@dataclass
|
|
class CONFIG:
|
|
host_files: str or [str]
|
|
_host_files: str or [str] = field(init=False,default="F")
|
|
|
|
def __post_init__(self):
|
|
print(">>>",self._host_files)
|
|
self.host_files = self._host_files or CONFIG._host_files
|
|
|
|
@property
|
|
def host_files(self) -> str or [str]:
|
|
return self._host_files
|
|
|
|
@host_files.setter
|
|
def host_files(self, files):
|
|
self._host_files = return_list(files)
|
|
print(self._host_files)
|
|
|
|
|
|
|
|
x=CONFIG(host_files=2)
|
|
|
|
print(x.__dict__) |