pd-code-sanity 0.0.1__py3-none-any.whl
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.
pd_code_sanity/main.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
# 检查 pd_code 的合法性
|
|
3
|
+
def sanity(pd_code:list[list[int | str]]) -> bool:
|
|
4
|
+
cnt = dict()
|
|
5
|
+
|
|
6
|
+
# 检查外层对象类型
|
|
7
|
+
if not isinstance(pd_code, list):
|
|
8
|
+
return False
|
|
9
|
+
|
|
10
|
+
# 检查内层对象
|
|
11
|
+
for crossing in pd_code:
|
|
12
|
+
if not isinstance(crossing, list):
|
|
13
|
+
return False
|
|
14
|
+
|
|
15
|
+
# 检查元素个数合法
|
|
16
|
+
if len(crossing) != 4:
|
|
17
|
+
return False
|
|
18
|
+
|
|
19
|
+
# 检查元素类型合法
|
|
20
|
+
for term in crossing:
|
|
21
|
+
|
|
22
|
+
# 检查内层对象类型
|
|
23
|
+
if ((not isinstance(term, str))
|
|
24
|
+
and (not isinstance(term, int))):
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
# 统计每个对象出现次数
|
|
28
|
+
if cnt.get(term) is None:
|
|
29
|
+
cnt[term] = 0
|
|
30
|
+
cnt[term] += 1
|
|
31
|
+
|
|
32
|
+
# 每个元素恰好出现两次
|
|
33
|
+
for term in cnt:
|
|
34
|
+
if cnt[term] != 2:
|
|
35
|
+
return False
|
|
36
|
+
|
|
37
|
+
return True
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pd-code-sanity
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: check pd_code weak sanity.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: GGN_2015
|
|
8
|
+
Author-email: neko@jlulug.org
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# pd_code_sanity
|
|
20
|
+
check pd_code weak sanity.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install pd-code-sanity
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import pd_code_sanity
|
|
32
|
+
|
|
33
|
+
print(pd_code_sanity.sanity([[1, 5, 2, 4], [3, 1, 4, 6], [5, 3, 6, 2]]))
|
|
34
|
+
```
|
|
35
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pd_code_sanity/__init__.py,sha256=4mUw7krloadAeHA4_W2gFDubOeAcmlvnLsUWj2BVQYk,58
|
|
2
|
+
pd_code_sanity/main.py,sha256=vtbzVi1tFn3NKGcJYSmkb5GJHI7UWMMppMSEsKCqz48,978
|
|
3
|
+
pd_code_sanity-0.0.1.dist-info/licenses/LICENSE,sha256=gCKLErgKpA7XoLYEwL_UJkJQE_jTw7V4dD4dSns9fjI,1100
|
|
4
|
+
pd_code_sanity-0.0.1.dist-info/METADATA,sha256=phxPIkh6xsmjDf0u9-0M7NqKz6e-3nwpsRizPgSr2po,813
|
|
5
|
+
pd_code_sanity-0.0.1.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
6
|
+
pd_code_sanity-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TopologicalKnotIndexer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|