Add AppInfo and BusInfo classes in swift.swift module to provide a helpful API to deal with the essential information of Apps and Buses.
This will support more confident creation of Apps and Buses, even for the other applications in the future.
How the feature is implemented
Use dataclass to easily express what attributes are required to create an App or a Bus.
A brief picture would be:
@dataclass
class AppInfo:
"""...Docstring for attributes..."""
module: str
class_: str # class is a reserved keyword
path: str | None = None
show: bool = True
pos: str = ""
bus: Iterable[str] = ()
args: Mapping[str, Any] | None = None
@dataclass
class BusInfo:
"""...Docstring for attributes..."""
timeout: float | None = None
def info_str(info: AppInfo | BusInfo) -> str:
"""Converts an Info into a JSON string."""
...
From a JSON string s, an AppInfo object can be created by:
info = AppInfo(**json.loads(s))
Additional context
This will be developed after #66 and #71.
This will resolve #72.
Feature you want to implement
Add
AppInfo
andBusInfo
classes inswift.swift
module to provide a helpful API to deal with the essential information of Apps and Buses. This will support more confident creation of Apps and Buses, even for the other applications in the future.How the feature is implemented
Use
dataclass
to easily express what attributes are required to create an App or a Bus.A brief picture would be:
From a JSON string
s
, anAppInfo
object can be created by:Additional context
This will be developed after #66 and #71. This will resolve #72.