snu-quiqcl / qiwis

QuIqcl Widget Integration Software
MIT License
6 stars 2 forks source link

[FEATURE] AppInfo and BusInfo for structuring the information of Apps and Buses #73

Closed kangz12345 closed 1 year ago

kangz12345 commented 1 year ago

Feature you want to implement

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.

BECATRUE commented 1 year ago

Now, may I start this issue?

@kangz12345

kangz12345 commented 1 year ago

I already started!

@BECATRUE

BECATRUE commented 1 year ago

I already started!

@BECATRUE

Ok! I will start another issue.