• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

Revision7e55144de32d31267101ad4732581e79b241a749 (tree)
Time2023-01-16 02:37:57
AuthorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

Added aux func to writers (Copy out IPython)

Change Summary

Incremental Difference

diff -r fb0a9029e898 -r 7e55144de32d Makefile
--- a/Makefile Sat Jan 14 16:47:28 2023 +0100
+++ b/Makefile Sun Jan 15 18:37:57 2023 +0100
@@ -1,6 +1,6 @@
11 default: all
22
3-CURRENT_TESTS = pytst/aux/test_1_pack_mk_tuple.py \
3+CURRENT_TESTS = pytst/auxiliary/test_1_pack_mk_tuple.py \
44
55
66 all: current demo test pyanalyse XXX missing
diff -r fb0a9029e898 -r 7e55144de32d castle/auxiliary/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/castle/auxiliary/__init__.py Sun Jan 15 18:37:57 2023 +0100
@@ -0,0 +1,5 @@
1+# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2+""" A collection of (small) auxiliary functions.,
3+
4+They are used py CCastle, part of the CCastle code; but further not related to CCastle"""
5+
diff -r fb0a9029e898 -r 7e55144de32d castle/auxiliary/pack.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/castle/auxiliary/pack.py Sun Jan 15 18:37:57 2023 +0100
@@ -0,0 +1,12 @@
1+# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2+"""
3+"""
4+from typing import Any
5+
6+def mk_tuple(tuple_list_or_element) -> list[Any]:
7+ """Expect a sequence of (ANY) element, or a single one, and make a tuple (RO-sequence) of it"""
8+
9+ return (tuple_list_or_element if isinstance(tuple_list_or_element, tuple)
10+ else tuple(tuple_list_or_element) if isinstance(tuple_list_or_element, list)
11+ else () if isinstance(tuple_list_or_element, type(None))
12+ else tuple((tuple_list_or_element,)) )
diff -r fb0a9029e898 -r 7e55144de32d pytst/auxiliary/test_1_pack_mk_tuple.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pytst/auxiliary/test_1_pack_mk_tuple.py Sun Jan 15 18:37:57 2023 +0100
@@ -0,0 +1,9 @@
1+# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2+
3+from castle.auxiliary.pack import mk_tuple
4+
5+def test_mk_tuple():
6+ assert mk_tuple(1) == (1,)
7+ assert mk_tuple((1,)) == (1,)
8+ assert mk_tuple([1,]) == (1,)
9+ assert mk_tuple(None) == ()