Skip to content

Commit 682c59c

Browse files
committed
Add event creation API
- New event API added to SwcInternalBehavior - Various fixes and improvements
1 parent 8523c7c commit 682c59c

File tree

5 files changed

+909
-30
lines changed

5 files changed

+909
-30
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Below is a rough roadmap of planned releases.
247247
**v0.5.4:** SwcInternalBehavior - basics
248248

249249
* Runnables
250-
* Basic event support (Init, Periodic, ModeSwitch)
250+
* Events
251251

252252
**v0.5.5** SwcInternalBehavior - ports
253253

src/autosar/base.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66

77

88
def split_ref(ref: str) -> list[str] | None:
9-
"""Splits an autosar reference string into a list of strings"""
9+
"""Splits a string separated with slashes and automatially removes leading slash"""
10+
sep = "/"
1011
if isinstance(ref, str):
11-
return ref[1:].split('/') if ref[0] == '/' else ref.split('/')
12+
return ref[1:].split(sep) if ref[0] == sep else ref.split(sep)
1213
return None
1314

1415

16+
def split_ref_strict(ref: str) -> list[str] | None:
17+
"""Splits a strings separated with slashes but throws an error if the string starts with a slash"""
18+
sep = "/"
19+
if not isinstance(ref, str):
20+
raise TypeError("ref: Must be a string")
21+
if ref[0] == sep:
22+
raise ValueError("ref: String cannot start with '/'")
23+
return ref.split(sep)
24+
25+
1526
class Searchable(abc.ABC):
1627
"""
1728
Searchable interface

0 commit comments

Comments
 (0)