-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from DiamondLightSource/controller-nesting
Allow arbitrary nesting of SubControllers
- Loading branch information
Showing
8 changed files
with
97 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
def snake_to_pascal(input: str) -> str: | ||
"""Convert a snake_case or UPPER_SNAKE_CASE string to PascalCase.""" | ||
return input.lower().replace("_", " ").title().replace(" ", "") | ||
"""Convert a snake_case string to PascalCase.""" | ||
return "".join( | ||
part.title() if part.islower() else part for part in input.split("_") | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from fastcs.controller import Controller, SubController | ||
from fastcs.mapping import _get_single_mapping, _walk_mappings | ||
|
||
|
||
def test_controller_nesting(): | ||
controller = Controller() | ||
sub_controller = SubController(["a"]) | ||
sub_sub_controller = SubController(["a", "b"]) | ||
|
||
controller.register_sub_controller(sub_controller) | ||
sub_controller.register_sub_controller(sub_sub_controller) | ||
|
||
assert list(_walk_mappings(controller)) == [ | ||
_get_single_mapping(controller), | ||
_get_single_mapping(sub_controller), | ||
_get_single_mapping(sub_sub_controller), | ||
] |