Skip to content

Commit 1682184

Browse files
committed
feature: gui and docs can be None in a transport
Allows for optional creation of gui and docs.
1 parent 1cce8ea commit 1682184

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

src/fastcs/launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def __init__(
8383

8484
def create_docs(self) -> None:
8585
for transport in self._transports:
86-
if hasattr(transport.options, "docs"):
86+
if getattr(transport.options, "docs", None) is not None:
8787
transport.create_docs()
8888

8989
def create_gui(self) -> None:
9090
for transport in self._transports:
91-
if hasattr(transport.options, "gui"):
91+
if getattr(transport.options, "gui", None) is not None:
9292
transport.create_gui()
9393

9494
def run(self):

src/fastcs/transport/epics/ca/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
class EpicsCAOptions:
1212
"""Options for the EPICS CA transport."""
1313

14-
docs: EpicsDocsOptions = field(default_factory=EpicsDocsOptions)
15-
gui: EpicsGUIOptions = field(default_factory=EpicsGUIOptions)
14+
docs: EpicsDocsOptions | None = None
15+
gui: EpicsGUIOptions | None = None
1616
ioc: EpicsIOCOptions = field(default_factory=EpicsIOCOptions)

src/fastcs/transport/epics/gui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from fastcs.attributes import Attribute, AttrR, AttrRW, AttrW
2626
from fastcs.controller_api import ControllerAPI
2727
from fastcs.cs_methods import Command
28-
from fastcs.datatypes import Bool, Enum, Float, Int, String, Waveform
28+
from fastcs.datatypes import Bool, Enum, Float, Int, String, Table, Waveform
2929
from fastcs.exceptions import FastCSException
3030
from fastcs.util import snake_to_pascal
3131

@@ -56,6 +56,8 @@ def _get_read_widget(attribute: AttrR) -> ReadWidgetUnion | None:
5656
return TextRead(format=TextFormat.string)
5757
case Waveform():
5858
return None
59+
case Table():
60+
return None
5961
case datatype:
6062
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")
6163

@@ -74,6 +76,8 @@ def _get_write_widget(attribute: AttrW) -> WriteWidgetUnion | None:
7476
)
7577
case Waveform():
7678
return None
79+
case Table():
80+
return None
7781
case datatype:
7882
raise FastCSException(f"Unsupported type {type(datatype)}: {datatype}")
7983

src/fastcs/transport/epics/pva/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
class EpicsPVAOptions:
1212
"""Options for the EPICS PVA transport."""
1313

14-
docs: EpicsDocsOptions = field(default_factory=EpicsDocsOptions)
15-
gui: EpicsGUIOptions = field(default_factory=EpicsGUIOptions)
14+
docs: EpicsDocsOptions | None = None
15+
gui: EpicsGUIOptions | None = None
1616
ioc: EpicsIOCOptions = field(default_factory=EpicsIOCOptions)

tests/data/schema.json

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
"EpicsCAOptions": {
44
"properties": {
55
"docs": {
6-
"$ref": "#/$defs/EpicsDocsOptions"
6+
"anyOf": [
7+
{
8+
"$ref": "#/$defs/EpicsDocsOptions"
9+
},
10+
{
11+
"type": "null"
12+
}
13+
],
14+
"default": null
715
},
816
"gui": {
9-
"$ref": "#/$defs/EpicsGUIOptions"
17+
"anyOf": [
18+
{
19+
"$ref": "#/$defs/EpicsGUIOptions"
20+
},
21+
{
22+
"type": "null"
23+
}
24+
],
25+
"default": null
1026
},
1127
"ioc": {
1228
"$ref": "#/$defs/EpicsIOCOptions"
@@ -83,10 +99,26 @@
8399
"EpicsPVAOptions": {
84100
"properties": {
85101
"docs": {
86-
"$ref": "#/$defs/EpicsDocsOptions"
102+
"anyOf": [
103+
{
104+
"$ref": "#/$defs/EpicsDocsOptions"
105+
},
106+
{
107+
"type": "null"
108+
}
109+
],
110+
"default": null
87111
},
88112
"gui": {
89-
"$ref": "#/$defs/EpicsGUIOptions"
113+
"anyOf": [
114+
{
115+
"$ref": "#/$defs/EpicsGUIOptions"
116+
},
117+
{
118+
"type": "null"
119+
}
120+
],
121+
"default": null
90122
},
91123
"ioc": {
92124
"$ref": "#/$defs/EpicsIOCOptions"
@@ -234,4 +266,4 @@
234266
],
235267
"title": "IsHinted",
236268
"type": "object"
237-
}
269+
}

0 commit comments

Comments
 (0)