physicsLab 2.0.5__tar.gz → 2.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {physicslab-2.0.5 → physicslab-2.0.6}/PKG-INFO +2 -3
- {physicslab-2.0.5 → physicslab-2.0.6}/README.md +5 -2
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/__init__.py +7 -1
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_colorUtils.py +47 -29
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_core.py +356 -228
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_tools.py +4 -3
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_typing.py +1 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_unwind.py +16 -12
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/_warn.py +5 -1
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/celestial/__init__.py +1 -1
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/celestial/_planetbase.py +53 -29
- physicslab-2.0.6/physicsLab/celestial/planets.py +1549 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/chart.py +28 -20
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/circuit/__init__.py +2 -1
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/circuit/_circuit_core.py +178 -88
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/circuit/elements/__init__.py +4 -0
- physicslab-2.0.6/physicsLab/circuit/elements/artificialCircuit.py +1521 -0
- physicslab-2.0.6/physicsLab/circuit/elements/basicCircuit.py +1018 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/circuit/elements/logicCircuit.py +567 -378
- physicslab-2.0.6/physicsLab/circuit/elements/otherCircuit.py +790 -0
- physicslab-2.0.6/physicsLab/circuit/elements/sensor.py +460 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/electromagnetism/_electromagnetismBase.py +52 -28
- physicslab-2.0.6/physicsLab/electromagnetism/elements.py +199 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/element.py +204 -104
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/enums.py +19 -9
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/errors.py +98 -58
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/analog_circuit/analog.py +438 -184
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/logic_circuit/edge_trigger.py +50 -33
- physicslab-2.0.6/physicsLab/lib/logic_circuit/logic.py +989 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/logic_circuit/super_logic_gate.py +165 -92
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/logic_circuit/wires.py +30 -19
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/music.py +298 -180
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/physicsLab_version.py +4 -4
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/plAR.py +12 -6
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/savTemplate.py +25 -38
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/utils.py +2 -2
- physicslab-2.0.6/physicsLab/vendor/__init__.py +4 -0
- physicslab-2.0.6/physicsLab/vendor/executing/__init__.py +26 -0
- physicslab-2.0.6/physicsLab/vendor/executing/_exceptions.py +22 -0
- physicslab-2.0.6/physicsLab/vendor/executing/_position_node_finder.py +992 -0
- physicslab-2.0.6/physicsLab/vendor/executing/executing.py +1160 -0
- physicslab-2.0.6/physicsLab/vendor/executing/py.typed +0 -0
- physicslab-2.0.6/physicsLab/vendor/executing/version.py +1 -0
- physicslab-2.0.6/physicsLab/web/_api.py +1303 -0
- physicslab-2.0.6/physicsLab/web/_request.py +174 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/web/_threadpool.py +27 -20
- physicslab-2.0.6/physicsLab/web/api.py +376 -0
- physicslab-2.0.6/physicsLab/web/webutils.py +727 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab.egg-info/PKG-INFO +2 -3
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab.egg-info/SOURCES.txt +8 -0
- physicslab-2.0.6/physicsLab.egg-info/requires.txt +2 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/setup.py +1 -1
- physicslab-2.0.5/physicsLab/celestial/planets.py +0 -819
- physicslab-2.0.5/physicsLab/circuit/elements/artificialCircuit.py +0 -1220
- physicslab-2.0.5/physicsLab/circuit/elements/basicCircuit.py +0 -796
- physicslab-2.0.5/physicsLab/circuit/elements/otherCircuit.py +0 -546
- physicslab-2.0.5/physicsLab/circuit/elements/sensor.py +0 -388
- physicslab-2.0.5/physicsLab/electromagnetism/elements.py +0 -164
- physicslab-2.0.5/physicsLab/lib/logic_circuit/logic.py +0 -916
- physicslab-2.0.5/physicsLab/web/_api.py +0 -948
- physicslab-2.0.5/physicsLab/web/api.py +0 -313
- physicslab-2.0.5/physicsLab/web/webutils.py +0 -566
- physicslab-2.0.5/physicsLab.egg-info/requires.txt +0 -3
- {physicslab-2.0.5 → physicslab-2.0.6}/LICENSE +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/electromagnetism/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/analog_circuit/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/lib/logic_circuit/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/frozen.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/checks.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/decode.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/encode.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/messages.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/specs.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/messages/strings.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/midifiles/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/midifiles/meta.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/midifiles/midifiles.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/midifiles/tracks.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/midifiles/units.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/parser.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/ports.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/scripts/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/scripts/mido_connect.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/scripts/mido_play.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/scripts/mido_ports.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/scripts/mido_serve.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/sockets.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/syx.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/music/mido/tokenizer.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab/web/__init__.py +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab.egg-info/dependency_links.txt +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/physicsLab.egg-info/top_level.txt +0 -0
- {physicslab-2.0.5 → physicslab-2.0.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: physicsLab
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
4
4
|
Summary: Python API for Quantum-Physics App
|
|
5
5
|
Home-page: https://github.com/GoodenoughPhysicsLab/physicsLab
|
|
6
6
|
Author: Arendelle
|
|
@@ -14,8 +14,7 @@ Requires-Python: >=3.8
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: typing-extensions
|
|
17
|
-
Requires-Dist: requests
|
|
18
|
-
Requires-Dist: executing==2.2.0
|
|
17
|
+
Requires-Dist: requests
|
|
19
18
|
Dynamic: author
|
|
20
19
|
Dynamic: author-email
|
|
21
20
|
Dynamic: classifier
|
|
@@ -115,7 +115,10 @@ sys.path.append("/your/path/of/physicsLab") # 将字符串替换为你想添加
|
|
|
115
115
|
* 主仓库(github): https://github.com/GoodenoughPhysicsLab/physicsLab
|
|
116
116
|
* 备份仓库(gitee): https://gitee.com/script2000/physicsLab
|
|
117
117
|
|
|
118
|
-
##
|
|
119
|
-
`physicsLab
|
|
118
|
+
## 贡献代码
|
|
119
|
+
`physicsLab`使用`black`工具自动格式化代码风格
|
|
120
|
+
```sh
|
|
121
|
+
black physicsLab --exclude="mido|vendor"
|
|
122
|
+
```
|
|
120
123
|
|
|
121
124
|
你可以从更新文档、bugfix、写[测试代码](./test_pl)开始入手
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
2
|
+
"""Python API for Physics-Lab-AR"""
|
|
3
3
|
|
|
4
4
|
from .physicsLab_version import __version__
|
|
5
|
+
|
|
5
6
|
# 操作实验
|
|
6
7
|
from .element import search_experiment, Experiment
|
|
7
8
|
from ._core import (
|
|
@@ -11,14 +12,19 @@ from ._core import (
|
|
|
11
12
|
native_to_elementXYZ,
|
|
12
13
|
ElementXYZ,
|
|
13
14
|
)
|
|
15
|
+
|
|
14
16
|
# 实验, 标签类型
|
|
15
17
|
from .enums import ExperimentType, Category, Tag, OpenMode, WireColor, GetUserMode
|
|
18
|
+
|
|
16
19
|
# 电学实验
|
|
17
20
|
from .circuit import *
|
|
21
|
+
|
|
18
22
|
# 天体物理实验
|
|
19
23
|
from .celestial import *
|
|
24
|
+
|
|
20
25
|
# 电与磁实验
|
|
21
26
|
from .electromagnetism import *
|
|
27
|
+
|
|
22
28
|
# `physicsLab`自定义异常类
|
|
23
29
|
from .errors import *
|
|
24
30
|
from . import _warn
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
"""在命令行打印出有颜色的字
|
|
3
|
+
为physicsLab最基础, 最底层的设施,
|
|
4
|
+
所以不能依赖physicsLab的任何其他设施, 包括 errors.py
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
>>> from physicsLab._colorUtils import *
|
|
8
|
+
>>> cprint(Red("test")) # 输出红色字
|
|
9
|
+
# 支持变参函数, 一次性打印多个不同颜色的Object
|
|
10
|
+
# 但不像python的print一样支持sep参数 [设计如此]
|
|
11
|
+
>>> cprint(Green("test"), "test", Yellow("test"), 1111, 3.14)
|
|
12
|
+
>>> cprint(Blue("test")) # 还支持以下颜色
|
|
13
|
+
>>> cprint(Magenta("test"))
|
|
14
|
+
>>> cprint(Cyan("test"))
|
|
15
|
+
>>> cprint(White("test"))
|
|
16
|
+
>>> cprint(Black("test"))
|
|
17
|
+
>>> cprint(Red("test"), file=sys.stderr) # 输出到stderr
|
|
18
|
+
>>> cprint(Red("test"), end='') # 支持print那样指定end
|
|
19
|
+
# 如果你不希望打印出颜色字 (即使使用了Red("xxx")之类的), 请使用python原生print
|
|
20
|
+
>>> print(Green("test"), "test", Yellow("test")) # 此时打印无颜色
|
|
21
|
+
"""
|
|
22
22
|
|
|
23
23
|
import platform
|
|
24
24
|
from physicsLab._typing import final
|
|
@@ -26,12 +26,17 @@ from physicsLab._typing import final
|
|
|
26
26
|
# 设置终端的编码为UTF-8
|
|
27
27
|
import io
|
|
28
28
|
import sys
|
|
29
|
+
|
|
29
30
|
sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding="utf-8")
|
|
30
31
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
|
|
31
32
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8")
|
|
32
33
|
|
|
33
34
|
# Windows 11 默认支持ANSI转义, 因此只有Windows 10及以下才使用Win32 API
|
|
34
|
-
_USE_WIN32_COLOR_API = platform.system() == "Windows" and (
|
|
35
|
+
_USE_WIN32_COLOR_API = platform.system() == "Windows" and (
|
|
36
|
+
sys.getwindowsversion().major,
|
|
37
|
+
sys.getwindowsversion().minor,
|
|
38
|
+
sys.getwindowsversion().build,
|
|
39
|
+
) < (10, 0, 22000)
|
|
35
40
|
|
|
36
41
|
if _USE_WIN32_COLOR_API:
|
|
37
42
|
import ctypes
|
|
@@ -68,8 +73,9 @@ if _USE_WIN32_COLOR_API:
|
|
|
68
73
|
]
|
|
69
74
|
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
|
70
75
|
|
|
71
|
-
_stdout_handle = _GetStdHandle(-11)
|
|
72
|
-
_stderr_handle = _GetStdHandle(-12)
|
|
76
|
+
_stdout_handle = _GetStdHandle(-11) # STD_OUTPUT_HANDLE
|
|
77
|
+
_stderr_handle = _GetStdHandle(-12) # STD_ERROR_HANDLE
|
|
78
|
+
|
|
73
79
|
|
|
74
80
|
class _Color:
|
|
75
81
|
fore: int
|
|
@@ -78,7 +84,9 @@ class _Color:
|
|
|
78
84
|
if type(self) is _Color:
|
|
79
85
|
raise NotImplementedError("_Color class can't be instantiated directly")
|
|
80
86
|
if not isinstance(msg, str):
|
|
81
|
-
raise TypeError(
|
|
87
|
+
raise TypeError(
|
|
88
|
+
f"Parameter msg must be of type `str`, but got value `{msg}` of type {type(msg).__name__}"
|
|
89
|
+
)
|
|
82
90
|
|
|
83
91
|
self.msg = msg
|
|
84
92
|
|
|
@@ -89,6 +97,7 @@ class _Color:
|
|
|
89
97
|
def cprint(self, file):
|
|
90
98
|
if _USE_WIN32_COLOR_API:
|
|
91
99
|
import ctypes
|
|
100
|
+
|
|
92
101
|
# 临时更改终端打印字符的属性
|
|
93
102
|
csbi = _CONSOLE_SCREEN_BUFFER_INFO()
|
|
94
103
|
if file is sys.stdout:
|
|
@@ -99,7 +108,7 @@ class _Color:
|
|
|
99
108
|
_SetConsoleTextAttribute(_stderr_handle, self.fore)
|
|
100
109
|
else:
|
|
101
110
|
assert False
|
|
102
|
-
print(self.msg, flush=True, end=
|
|
111
|
+
print(self.msg, flush=True, end="", file=file)
|
|
103
112
|
# 恢复终端打印字符的属性
|
|
104
113
|
if file is sys.stdout:
|
|
105
114
|
_SetConsoleTextAttribute(_stdout_handle, csbi.wAttributes)
|
|
@@ -108,7 +117,8 @@ class _Color:
|
|
|
108
117
|
else:
|
|
109
118
|
assert False
|
|
110
119
|
else:
|
|
111
|
-
print(f"\033[{self.fore}m{self.msg}\033[0m", end=
|
|
120
|
+
print(f"\033[{self.fore}m{self.msg}\033[0m", end="", file=file)
|
|
121
|
+
|
|
112
122
|
|
|
113
123
|
class Black(_Color):
|
|
114
124
|
if _USE_WIN32_COLOR_API:
|
|
@@ -116,49 +126,57 @@ class Black(_Color):
|
|
|
116
126
|
else:
|
|
117
127
|
fore = 30
|
|
118
128
|
|
|
129
|
+
|
|
119
130
|
class Red(_Color):
|
|
120
131
|
if _USE_WIN32_COLOR_API:
|
|
121
132
|
fore = 4
|
|
122
133
|
else:
|
|
123
134
|
fore = 31
|
|
124
135
|
|
|
136
|
+
|
|
125
137
|
class Green(_Color):
|
|
126
138
|
if _USE_WIN32_COLOR_API:
|
|
127
139
|
fore = 2
|
|
128
140
|
else:
|
|
129
141
|
fore = 32
|
|
130
142
|
|
|
143
|
+
|
|
131
144
|
class Yellow(_Color):
|
|
132
145
|
if _USE_WIN32_COLOR_API:
|
|
133
146
|
fore = 6
|
|
134
147
|
else:
|
|
135
148
|
fore = 33
|
|
136
149
|
|
|
150
|
+
|
|
137
151
|
class Blue(_Color):
|
|
138
152
|
if _USE_WIN32_COLOR_API:
|
|
139
153
|
fore = 1
|
|
140
154
|
else:
|
|
141
155
|
fore = 34
|
|
142
156
|
|
|
157
|
+
|
|
143
158
|
class Magenta(_Color):
|
|
144
159
|
if _USE_WIN32_COLOR_API:
|
|
145
160
|
fore = 5
|
|
146
161
|
else:
|
|
147
162
|
fore = 35
|
|
148
163
|
|
|
164
|
+
|
|
149
165
|
class Cyan(_Color):
|
|
150
166
|
if _USE_WIN32_COLOR_API:
|
|
151
167
|
fore = 3
|
|
152
168
|
else:
|
|
153
169
|
fore = 36
|
|
154
170
|
|
|
171
|
+
|
|
155
172
|
class White(_Color):
|
|
156
173
|
if _USE_WIN32_COLOR_API:
|
|
157
174
|
fore = 7
|
|
158
175
|
else:
|
|
159
176
|
fore = 37
|
|
160
177
|
|
|
161
|
-
|
|
178
|
+
|
|
179
|
+
def cprint(*args, end="\n", file=sys.stdout) -> None:
|
|
162
180
|
# 先刷新再打印, 避免在Windows下打印缓冲区的内容还未输出就被改变了Attribute
|
|
163
181
|
# e.g.
|
|
164
182
|
# print("test")
|
|
@@ -174,8 +192,8 @@ def cprint(*args, end='\n', file = sys.stdout) -> None:
|
|
|
174
192
|
if isinstance(arg, _Color):
|
|
175
193
|
arg.cprint(file=file)
|
|
176
194
|
else:
|
|
177
|
-
print(arg, end=
|
|
178
|
-
print(end, end=
|
|
195
|
+
print(arg, end="", file=file)
|
|
196
|
+
print(end, end="", file=file)
|
|
179
197
|
# 再次刷新,确保终端的输出已经输出
|
|
180
198
|
# e.g.
|
|
181
199
|
# cprint(Green("test"), file=sys.stderr)
|