PyObjectInterface 0.1.1rc1__py3-none-any.whl → 0.1.2__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.
- PyObjectInterface/__init__.py +21 -3
- {PyObjectInterface-0.1.1rc1.dist-info → PyObjectInterface-0.1.2.dist-info}/METADATA +32 -3
- PyObjectInterface-0.1.2.dist-info/RECORD +10 -0
- {PyObjectInterface-0.1.1rc1.dist-info → PyObjectInterface-0.1.2.dist-info}/WHEEL +1 -1
- PyObjectInterface-0.1.1rc1.dist-info/RECORD +0 -10
- {PyObjectInterface-0.1.1rc1.dist-info → PyObjectInterface-0.1.2.dist-info}/LICENSE +0 -0
- {PyObjectInterface-0.1.1rc1.dist-info → PyObjectInterface-0.1.2.dist-info}/top_level.txt +0 -0
PyObjectInterface/__init__.py
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
from typing_extensions import Self
|
|
2
2
|
import inspect
|
|
3
3
|
|
|
4
|
+
# {type: examine_recursively}
|
|
5
|
+
basic_attribute_types = {
|
|
6
|
+
str(type(None)): False, #NoneType
|
|
7
|
+
str(type(True)): False, #bool
|
|
8
|
+
str(type(1)): False, #int
|
|
9
|
+
str(type(1.0)): False, #float
|
|
10
|
+
str(type('1')): False, #str
|
|
11
|
+
str(type([1])): False, #list
|
|
12
|
+
str(type({1:1})): False, #dict
|
|
13
|
+
str(type((1,1))): False, #tuple
|
|
14
|
+
str(type({1})): False, #set
|
|
15
|
+
"<class 'numpy.ndarray'>": False,
|
|
16
|
+
"<class 'pandas.core.frame.DataFrame'>": False,
|
|
17
|
+
"<class 'pandas.core.series.Series'>": False
|
|
18
|
+
}
|
|
19
|
+
|
|
4
20
|
class FunctionDesc:
|
|
5
21
|
def __init__(self, func):
|
|
6
22
|
self.func = func
|
|
@@ -48,12 +64,14 @@ class PyObjectInterface:
|
|
|
48
64
|
all_attrs = [x for x in inspect.getmembers(obj) if x[0][0:1] != '_'] #ignore private
|
|
49
65
|
|
|
50
66
|
for (attr_name, instance) in all_attrs:
|
|
67
|
+
if str(type(instance)) in basic_attribute_types:
|
|
68
|
+
self.attribute_list.append(attr_name)
|
|
69
|
+
if not basic_attribute_types[str(type(instance))]:
|
|
70
|
+
continue #skip the rest of the checks, we don't want to examine this item recursively
|
|
71
|
+
|
|
51
72
|
if hasattr(instance, '__call__'):
|
|
52
73
|
self.method_dict[attr_name] = FunctionDesc(instance)
|
|
53
74
|
|
|
54
|
-
elif isinstance(instance, (int, float, str, bool, list, dict)) or instance is None:
|
|
55
|
-
self.attribute_list.append(attr_name)
|
|
56
|
-
|
|
57
75
|
elif recursion_depth > 0: #stop adding subobjects at recursion depth 0
|
|
58
76
|
# using .__class__ allows superclassing
|
|
59
77
|
# noinspection PyTypeChecker
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyObjectInterface
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Create a web interface to interact with a class
|
|
5
5
|
Home-page: https://github.com/RobertJN64/PyObjectInterface
|
|
6
6
|
Author: Robert Nies
|
|
@@ -9,12 +9,12 @@ License: MIT
|
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: typing-extensions
|
|
@@ -77,3 +77,32 @@ You can use PyObjectInterface without the WebController.
|
|
|
77
77
|
- `flask_app`: return value of flask.Flask()
|
|
78
78
|
- `recursion_depth = 5`: maximum layers of subobjects to include
|
|
79
79
|
- `create_private_interface = True`: if `True` creates a `/webcontroller/private` page that includes private methods and attributes
|
|
80
|
+
|
|
81
|
+
### Modifying Attributes
|
|
82
|
+
|
|
83
|
+
By default, POI treats `NoneType, bool, int, float, str, list, dict, tuple, and set` as primitive types.
|
|
84
|
+
These show up in the attribute table instead of as recursive objects.
|
|
85
|
+
|
|
86
|
+
`numpy.ndarray`, `pandas.DataFrame`, and `pandas.Series` are also treated as primitives.
|
|
87
|
+
|
|
88
|
+
Note: numpy 2.0 arrays currently do not work with python's inspect library,
|
|
89
|
+
and therefore must be treated as a primitive.
|
|
90
|
+
|
|
91
|
+
If you would like to customize this behavior, you can modify
|
|
92
|
+
`PyObjectInterface.basic_attribute_types`
|
|
93
|
+
|
|
94
|
+
For example:
|
|
95
|
+
```python
|
|
96
|
+
from PyObjectInterface import basic_attribute_types
|
|
97
|
+
|
|
98
|
+
class My_Class_A: ...
|
|
99
|
+
class My_Class_B: ...
|
|
100
|
+
class My_Class_C: ...
|
|
101
|
+
|
|
102
|
+
basic_attribute_types[str(type(My_Class_A()))] = False
|
|
103
|
+
basic_attribute_types[str(type(My_Class_B()))] = True
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`My_Class_A` will be treated as a primitive and only show up in the attributes table.
|
|
107
|
+
`My_Class_B` will also show up in attributes table, but it still appears in the subobjects section.
|
|
108
|
+
`My_Class_C` will only appear in the subobjects section.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
PyObjectInterface/WebController.py,sha256=yLiOsR-FE01omdw2DHVQhltMvAhvWus3eP1zPQ2vM34,4034
|
|
2
|
+
PyObjectInterface/__init__.py,sha256=CBCFR8yJkR7WvEjCjUS3n8UoWijvx89ZpF0yrrYMPeE,4496
|
|
3
|
+
PyObjectInterface/web_controller.tpl.html,sha256=KiNOmUGwsyAmkV9yol2X15G6uoAPjf2JHa6tnoCe_kw,2432
|
|
4
|
+
PyObjectInterface/examples/example.py,sha256=QhAcJJnh6LU923TL7MHwYU5keur1hgfn7Elt5nh8c-E,196
|
|
5
|
+
PyObjectInterface/examples/robot.py,sha256=qvDhIwvCtseA0AlEdZbR7RJkpbOMMw0F1C3UWNMs--M,655
|
|
6
|
+
PyObjectInterface-0.1.2.dist-info/LICENSE,sha256=_UXYaTVmtWrJCpKEgCz66EUsoFfLfn0CY4mEmuI5_zA,1054
|
|
7
|
+
PyObjectInterface-0.1.2.dist-info/METADATA,sha256=WQjYp-G6-WR5bxbREz9FnmBWx6PNZPaPUGRkwqq2AII,3580
|
|
8
|
+
PyObjectInterface-0.1.2.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
9
|
+
PyObjectInterface-0.1.2.dist-info/top_level.txt,sha256=5kOSl8l5D5IGWoWz9nkn_lQispA3D8qyPM9SvIC4LSU,18
|
|
10
|
+
PyObjectInterface-0.1.2.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
PyObjectInterface/WebController.py,sha256=yLiOsR-FE01omdw2DHVQhltMvAhvWus3eP1zPQ2vM34,4034
|
|
2
|
-
PyObjectInterface/__init__.py,sha256=iyUGcdEkMTwd6kZyqO-fgtasXdnx5ZYJstEI8UzI-_c,3842
|
|
3
|
-
PyObjectInterface/web_controller.tpl.html,sha256=KiNOmUGwsyAmkV9yol2X15G6uoAPjf2JHa6tnoCe_kw,2432
|
|
4
|
-
PyObjectInterface/examples/example.py,sha256=QhAcJJnh6LU923TL7MHwYU5keur1hgfn7Elt5nh8c-E,196
|
|
5
|
-
PyObjectInterface/examples/robot.py,sha256=qvDhIwvCtseA0AlEdZbR7RJkpbOMMw0F1C3UWNMs--M,655
|
|
6
|
-
PyObjectInterface-0.1.1rc1.dist-info/LICENSE,sha256=_UXYaTVmtWrJCpKEgCz66EUsoFfLfn0CY4mEmuI5_zA,1054
|
|
7
|
-
PyObjectInterface-0.1.1rc1.dist-info/METADATA,sha256=92OzpR4wPsQ6dcGG1o4G1Zb-T457efjnPGUf5e_PYTs,2562
|
|
8
|
-
PyObjectInterface-0.1.1rc1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
9
|
-
PyObjectInterface-0.1.1rc1.dist-info/top_level.txt,sha256=5kOSl8l5D5IGWoWz9nkn_lQispA3D8qyPM9SvIC4LSU,18
|
|
10
|
-
PyObjectInterface-0.1.1rc1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|