PyObjectInterface 0.1.1rc1__tar.gz → 0.1.2__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.
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PKG-INFO +32 -3
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/__init__.py +21 -3
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/PKG-INFO +32 -3
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/README.md +30 -1
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/setup.cfg +3 -3
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/tests/test_poi.py +28 -2
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/LICENSE +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/MANIFEST.in +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/WebController.py +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/examples/example.py +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/examples/robot.py +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/web_controller.tpl.html +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/SOURCES.txt +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/dependency_links.txt +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/requires.txt +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/top_level.txt +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/pyproject.toml +0 -0
- {PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/setup.py +0 -0
|
@@ -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.
|
|
@@ -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.
|
|
@@ -54,4 +54,33 @@ You can use PyObjectInterface without the WebController.
|
|
|
54
54
|
- `name: str`: Friendly name for object, generally the name of the variable that refers to the object
|
|
55
55
|
- `flask_app`: return value of flask.Flask()
|
|
56
56
|
- `recursion_depth = 5`: maximum layers of subobjects to include
|
|
57
|
-
- `create_private_interface = True`: if `True` creates a `/webcontroller/private` page that includes private methods and attributes
|
|
57
|
+
- `create_private_interface = True`: if `True` creates a `/webcontroller/private` page that includes private methods and attributes
|
|
58
|
+
|
|
59
|
+
### Modifying Attributes
|
|
60
|
+
|
|
61
|
+
By default, POI treats `NoneType, bool, int, float, str, list, dict, tuple, and set` as primitive types.
|
|
62
|
+
These show up in the attribute table instead of as recursive objects.
|
|
63
|
+
|
|
64
|
+
`numpy.ndarray`, `pandas.DataFrame`, and `pandas.Series` are also treated as primitives.
|
|
65
|
+
|
|
66
|
+
Note: numpy 2.0 arrays currently do not work with python's inspect library,
|
|
67
|
+
and therefore must be treated as a primitive.
|
|
68
|
+
|
|
69
|
+
If you would like to customize this behavior, you can modify
|
|
70
|
+
`PyObjectInterface.basic_attribute_types`
|
|
71
|
+
|
|
72
|
+
For example:
|
|
73
|
+
```python
|
|
74
|
+
from PyObjectInterface import basic_attribute_types
|
|
75
|
+
|
|
76
|
+
class My_Class_A: ...
|
|
77
|
+
class My_Class_B: ...
|
|
78
|
+
class My_Class_C: ...
|
|
79
|
+
|
|
80
|
+
basic_attribute_types[str(type(My_Class_A()))] = False
|
|
81
|
+
basic_attribute_types[str(type(My_Class_B()))] = True
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`My_Class_A` will be treated as a primitive and only show up in the attributes table.
|
|
85
|
+
`My_Class_B` will also show up in attributes table, but it still appears in the subobjects section.
|
|
86
|
+
`My_Class_C` will only appear in the subobjects section.
|
|
@@ -6,22 +6,22 @@ license = MIT
|
|
|
6
6
|
license_file = LICENSE
|
|
7
7
|
url = https://github.com/RobertJN64/PyObjectInterface
|
|
8
8
|
author_email = robertjnies@gmail.com
|
|
9
|
-
version = 0.1.
|
|
9
|
+
version = 0.1.2
|
|
10
10
|
long_description = file: README.md
|
|
11
11
|
long_description_content_type = text/markdown
|
|
12
12
|
classifiers =
|
|
13
13
|
Programming Language :: Python
|
|
14
14
|
Programming Language :: Python :: 3
|
|
15
15
|
Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Programming Language :: Python :: 3.8
|
|
17
16
|
Programming Language :: Python :: 3.9
|
|
18
17
|
Programming Language :: Python :: 3.10
|
|
19
18
|
Programming Language :: Python :: 3.11
|
|
20
19
|
Programming Language :: Python :: 3.12
|
|
20
|
+
Programming Language :: Python :: 3.13
|
|
21
21
|
|
|
22
22
|
[options]
|
|
23
23
|
packages = PyObjectInterface
|
|
24
|
-
python_requires = >=3.
|
|
24
|
+
python_requires = >=3.9
|
|
25
25
|
include_package_data = True
|
|
26
26
|
install_requires =
|
|
27
27
|
typing_extensions
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
from PyObjectInterface import PyObjectInterface, basic_attribute_types
|
|
1
2
|
from PyObjectInterface.WebController import generate_html
|
|
2
|
-
|
|
3
|
+
import numpy as np
|
|
3
4
|
import pytest
|
|
4
5
|
|
|
5
6
|
class Nested:
|
|
@@ -141,4 +142,29 @@ def test_html():
|
|
|
141
142
|
|
|
142
143
|
class Blank: pass
|
|
143
144
|
poi = PyObjectInterface(Blank(), 'Blank')
|
|
144
|
-
assert 'table' not in generate_html(poi)
|
|
145
|
+
assert 'table' not in generate_html(poi)
|
|
146
|
+
|
|
147
|
+
class np_special_case:
|
|
148
|
+
def __init__(self):
|
|
149
|
+
self.np_arr = np.array([1,2,3])
|
|
150
|
+
|
|
151
|
+
def test_np_special_case():
|
|
152
|
+
n = np_special_case()
|
|
153
|
+
|
|
154
|
+
poi = PyObjectInterface(n, 'b')
|
|
155
|
+
assert 'np_arr' in poi.attribute_list
|
|
156
|
+
assert 'np_arr' not in poi.subobj_dict
|
|
157
|
+
|
|
158
|
+
basic_attribute_types[str(type(n.np_arr))] = True
|
|
159
|
+
|
|
160
|
+
poi = PyObjectInterface(n, 'b')
|
|
161
|
+
assert 'np_arr' in poi.attribute_list
|
|
162
|
+
assert 'np_arr' in poi.subobj_dict
|
|
163
|
+
|
|
164
|
+
assert "is a builtin method and can't be accessed from WebController" in generate_html(poi)
|
|
165
|
+
|
|
166
|
+
basic_attribute_types.pop(str(type(n.np_arr)))
|
|
167
|
+
|
|
168
|
+
poi = PyObjectInterface(n, 'b')
|
|
169
|
+
assert 'np_arr' not in poi.attribute_list
|
|
170
|
+
assert 'np_arr' in poi.subobj_dict
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/examples/example.py
RENAMED
|
File without changes
|
|
File without changes
|
{PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface/web_controller.tpl.html
RENAMED
|
File without changes
|
{PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/requires.txt
RENAMED
|
File without changes
|
{PyObjectInterface-0.1.1rc1 → pyobjectinterface-0.1.2}/PyObjectInterface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|