2121
2222import attrs
2323import copy
24- from typing import Literal , Optional , Union
24+ from typing import ClassVar , Literal , Optional , Union
2525
2626
2727# TODO: Right now, everything is just lumped into one WaitCondition class, which means
@@ -292,6 +292,65 @@ def unstructure_hook(inst):
292292)
293293
294294
295+ @attrs .define
296+ class ScheduleStop (Exportable ):
297+ station : str = attrs .field (validator = instance_of (str ))
298+ """
299+ The name of the station or planet that this train or space platform
300+ should stop at.
301+ """
302+ wait_conditions : WaitConditions = attrs .field (
303+ factory = WaitConditions ,
304+ converter = WaitConditions ,
305+ validator = instance_of (WaitConditions ),
306+ )
307+ """
308+ A list of :py:class:`.WaitCondition` objects to evaluate at this
309+ particular stop.
310+ """
311+ allows_unloading : Optional [bool ] = attrs .field (
312+ default = True , validator = instance_of (Optional [bool ])
313+ )
314+ """
315+ Whether or not this stop permits this space platform to fulfill any
316+ requests at the planet it's stopped above. Only applies to space
317+ platform schedules.
318+ """
319+
320+
321+ @attrs .define
322+ class ScheduleInterrupt (Exportable ):
323+ name : str = attrs .field (validator = instance_of (str ))
324+ """
325+ The name of this particular interrupt.
326+ """
327+ conditions : WaitConditions = attrs .field (
328+ factory = WaitConditions ,
329+ converter = WaitConditions ,
330+ validator = instance_of (WaitConditions ),
331+ )
332+ """
333+ The set of conditions that need to pass in order for this interrupt
334+ to be triggered.
335+ """
336+ targets : list [ScheduleStop ] = attrs .field (
337+ factory = list ,
338+ # TODO: converter
339+ validator = instance_of (list [ScheduleStop ]),
340+ )
341+ """
342+ The target schedule that the interrupt should execute if it's
343+ triggered.
344+ """
345+ inside_interrupt : bool = attrs .field (
346+ default = False ,
347+ )
348+ """
349+ Whether or not this interrupt can be triggered midway through an
350+ already executing interrupt.
351+ """
352+
353+
295354@attrs .define
296355class Schedule (Exportable ):
297356 """
@@ -301,62 +360,66 @@ class Schedule(Exportable):
301360 interrupts.
302361 """
303362
304- @attrs .define
305- class Stop (Exportable ):
306- station : str = attrs .field (validator = instance_of (str ))
307- """
308- The name of the station or planet that this train or space platform
309- should stop at.
310- """
311- wait_conditions : WaitConditions = attrs .field (
312- factory = WaitConditions ,
313- converter = WaitConditions ,
314- validator = instance_of (WaitConditions ),
315- )
316- """
317- A list of :py:class:`.WaitCondition` objects to evaluate at this
318- particular stop.
319- """
320- allows_unloading : Optional [bool ] = attrs .field (
321- default = True , validator = instance_of (Optional [bool ])
322- )
323- """
324- Whether or not this stop permits this space platform to fulfill any
325- requests at the planet it's stopped above. Only applies to space
326- platform schedules.
327- """
328-
329- @attrs .define
330- class Interrupt (Exportable ):
331- name : str = attrs .field (validator = instance_of (str ))
332- """
333- The name of this particular interrupt.
334- """
335- conditions : WaitConditions = attrs .field (
336- factory = WaitConditions ,
337- converter = WaitConditions ,
338- validator = instance_of (WaitConditions ),
339- )
340- """
341- The set of conditions that need to pass in order for this interrupt
342- to be triggered.
343- """
344- targets : list ["Schedule.Stop" ] = attrs .field (
345- factory = list ,
346- # TODO: converter
347- validator = instance_of (list ["Schedule.Stop" ]),
348- )
349- """
350- The target schedule that the interrupt should execute if it's
351- triggered.
352- """
353- inside_interrupt : bool = attrs .field (
354- default = False ,
355- )
356- """
357- Whether or not this interrupt can be triggered midway through an
358- already executing interrupt.
359- """
363+ Stop : ClassVar = ScheduleStop
364+
365+ # @attrs.define
366+ # class Stop(Exportable):
367+ # station: str = attrs.field(validator=instance_of(str))
368+ # """
369+ # The name of the station or planet that this train or space platform
370+ # should stop at.
371+ # """
372+ # wait_conditions: WaitConditions = attrs.field(
373+ # factory=WaitConditions,
374+ # converter=WaitConditions,
375+ # validator=instance_of(WaitConditions),
376+ # )
377+ # """
378+ # A list of :py:class:`.WaitCondition` objects to evaluate at this
379+ # particular stop.
380+ # """
381+ # allows_unloading: Optional[bool] = attrs.field(
382+ # default=True, validator=instance_of(Optional[bool])
383+ # )
384+ # """
385+ # Whether or not this stop permits this space platform to fulfill any
386+ # requests at the planet it's stopped above. Only applies to space
387+ # platform schedules.
388+ # """
389+
390+ Interrupt : ClassVar = ScheduleInterrupt
391+
392+ # @attrs.define
393+ # class Interrupt(Exportable):
394+ # name: str = attrs.field(validator=instance_of(str))
395+ # """
396+ # The name of this particular interrupt.
397+ # """
398+ # conditions: WaitConditions = attrs.field(
399+ # factory=WaitConditions,
400+ # converter=WaitConditions,
401+ # validator=instance_of(WaitConditions),
402+ # )
403+ # """
404+ # The set of conditions that need to pass in order for this interrupt
405+ # to be triggered.
406+ # """
407+ # targets: list["Schedule.Stop"] = attrs.field(
408+ # factory=list,
409+ # # TODO: converter
410+ # validator=instance_of(list["Schedule.Stop"]),
411+ # )
412+ # """
413+ # The target schedule that the interrupt should execute if it's
414+ # triggered.
415+ # """
416+ # inside_interrupt: bool = attrs.field(
417+ # default=False,
418+ # )
419+ # """
420+ # Whether or not this interrupt can be triggered midway through an
421+ # already executing interrupt.
422+ # """
360423
361424 # =========================================================================
362425
@@ -375,9 +438,9 @@ class Interrupt(Exportable):
375438
376439 # =========================================================================
377440
378- stops : list [Stop ] = attrs .field (
441+ stops : list [ScheduleStop ] = attrs .field (
379442 factory = list ,
380- validator = instance_of (list [Stop ]),
443+ validator = instance_of (list [ScheduleStop ]),
381444 )
382445 """
383446 The list of all stops that this schedule uses.
@@ -388,9 +451,9 @@ class Interrupt(Exportable):
388451
389452 # =========================================================================
390453
391- interrupts : list [Interrupt ] = attrs .field (
454+ interrupts : list [ScheduleInterrupt ] = attrs .field (
392455 factory = list ,
393- validator = instance_of (list [Interrupt ]),
456+ validator = instance_of (list [ScheduleInterrupt ]),
394457 )
395458 """
396459 The list of all interrupts that apply to this schedule.
@@ -519,7 +582,7 @@ def add_interrupt(
519582 self ,
520583 name : str ,
521584 conditions : Union [WaitCondition , WaitConditions ],
522- targets : list [Stop ],
585+ targets : list [ScheduleStop ],
523586 inside_interrupt : bool = False ,
524587 ):
525588 """
0 commit comments