MultiProxPy 0.0.1__tar.gz → 0.1.0__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.
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: MultiProxPy
3
+ Version: 0.1.0
4
+ Summary: An easy way to combine multiple objects into one
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Author: Eric aka CheesecakeTV
8
+ Author-email: eric@swiftgui.de
9
+ Requires-Python: >=3.10
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Project-URL: Documentation, https://github.com/CheesecakeTV/MultiProxPy
13
+ Project-URL: Repository, https://github.com/CheesecakeTV/MultiProxPy
14
+ Description-Content-Type: text/markdown
15
+
16
+ # MultiProxPy
17
+ A small python-package that allows you to "group" calls to objects.
18
+
19
+ The cool part is that the resulting "MultiProxy"-object can be used like the referenced objects:
20
+ ```py
21
+ from MultiProxPy import group_objects
22
+
23
+ list1 = [3,1,2]
24
+ list2 = [5,2]
25
+ list3 = [7,8,9]
26
+
27
+ list_proxy = group_objects(list1, list2, list3)
28
+
29
+ list_proxy.sort() # Sorts all lists
30
+ list_proxy.append(15) # Appends 15 to all lists
31
+ list_proxy[0] = -1 # Sets the first elemet to 0 for all lists
32
+
33
+ print(list1, list2, list3)
34
+ ```
35
+ The grouping is very abstract and should work with any type of object.
36
+
37
+ The best part is that your IDE will treat the proxy-object like one of the contained objects.
38
+ It will suggest methods/attributes bound to that class:\
39
+ ![img.png](assets/images/SuggestionsOnProxyObject.png)
40
+
41
+ Other examples can be found in the github-repository: https://github.com/CheesecakeTV/MultiProxPy
42
+
43
+ ## Limitations
44
+ There are a few downsides you should be aware of.
45
+
46
+ 1. Any return-value on proxy-calls will be lost
47
+ 2. Simmilarely, math operations like additions don't work for the proxy. However, inline-operations do, e.g.: `list_proxy += [5]`
48
+ 3. The proxy can't fool `isinstance`, e.g.: `isinstance(list_proxy, list)` will return `False`
49
+ 4. Objects inside the proxy should have the same type, or a derived one. This is only a suggestion. If you are careful enough, you can mix different types
50
+
51
+
@@ -0,0 +1,35 @@
1
+ # MultiProxPy
2
+ A small python-package that allows you to "group" calls to objects.
3
+
4
+ The cool part is that the resulting "MultiProxy"-object can be used like the referenced objects:
5
+ ```py
6
+ from MultiProxPy import group_objects
7
+
8
+ list1 = [3,1,2]
9
+ list2 = [5,2]
10
+ list3 = [7,8,9]
11
+
12
+ list_proxy = group_objects(list1, list2, list3)
13
+
14
+ list_proxy.sort() # Sorts all lists
15
+ list_proxy.append(15) # Appends 15 to all lists
16
+ list_proxy[0] = -1 # Sets the first elemet to 0 for all lists
17
+
18
+ print(list1, list2, list3)
19
+ ```
20
+ The grouping is very abstract and should work with any type of object.
21
+
22
+ The best part is that your IDE will treat the proxy-object like one of the contained objects.
23
+ It will suggest methods/attributes bound to that class:\
24
+ ![img.png](assets/images/SuggestionsOnProxyObject.png)
25
+
26
+ Other examples can be found in the github-repository: https://github.com/CheesecakeTV/MultiProxPy
27
+
28
+ ## Limitations
29
+ There are a few downsides you should be aware of.
30
+
31
+ 1. Any return-value on proxy-calls will be lost
32
+ 2. Simmilarely, math operations like additions don't work for the proxy. However, inline-operations do, e.g.: `list_proxy += [5]`
33
+ 3. The proxy can't fool `isinstance`, e.g.: `isinstance(list_proxy, list)` will return `False`
34
+ 4. Objects inside the proxy should have the same type, or a derived one. This is only a suggestion. If you are careful enough, you can mix different types
35
+
@@ -1,26 +1,27 @@
1
- [project]
2
- name = "MultiProxPy"
3
- version = "0.0.1"
4
- packages = [
5
- { include = "MultiProxPy", from = "src" }
6
- ]
7
- authors = [
8
- { name="Eric aka CheesecakeTV", email="eric@swiftgui.de" },
9
- ]
10
- description = "An easy way to combine multiple objects into one"
11
- readme = "README.md"
12
- requires-python = ">=3.10"
13
- classifiers = [
14
- "Programming Language :: Python :: 3",
15
- "Operating System :: OS Independent",
16
- ]
17
- license = "Apache-2.0"
18
- license-files = ["LICEN[CS]E*"]
19
- dependencies = []
20
- [project.urls]
21
- Repository = "https://github.com/CheesecakeTV/MultiProxy"
22
- Documentation = "https://github.com/CheesecakeTV/MultiProxy"
23
-
24
- [build-system]
25
- requires = ["poetry-core>=2.0.0,<3.0.0"]
26
- build-backend = "poetry.core.masonry.api"
1
+ [project]
2
+ name = "MultiProxPy"
3
+ version = "0.1.0"
4
+ packages = [
5
+ { include = "MultiProxPy", from = "src" }
6
+ ]
7
+ authors = [
8
+ { name="Eric aka CheesecakeTV", email="eric@swiftgui.de" },
9
+ ]
10
+ description = "An easy way to combine multiple objects into one"
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+ license = "Apache-2.0"
18
+ license-files = ["LICEN[CS]E*"]
19
+ dependencies = []
20
+ [project.urls]
21
+ Repository = "https://github.com/CheesecakeTV/MultiProxPy"
22
+ Documentation = "https://github.com/CheesecakeTV/MultiProxPy"
23
+
24
+ [build-system]
25
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
26
+ build-backend = "poetry.core.masonry.api"
27
+
@@ -12,7 +12,7 @@ class MultiProxy:
12
12
  Do not call directly!
13
13
  Use group_objects instead!
14
14
  """
15
- assert objects, "At least one object is required to create a grouped caller!"
15
+ assert objects, "At least one object is required to create a MultiProxy!"
16
16
 
17
17
  super().__setattr__("_objects", objects)
18
18
 
@@ -34,11 +34,11 @@ class MultiProxy:
34
34
 
35
35
  def __str__(self) -> str:
36
36
  objects = super().__getattribute__("_objects")
37
- return f"<GroupedCaller {tuple(map(str, objects))}>"
37
+ return f"<MultiProxy {tuple(map(str, objects))}>"
38
38
 
39
39
  def __repr__(self):
40
40
  objects = super().__getattribute__("_objects")
41
- return f"<GroupedCaller {id(self)} {tuple(map(repr, objects))}>"
41
+ return f"<MultiProxy {id(self)} {tuple(map(repr, objects))}>"
42
42
 
43
43
  def __await__(self):
44
44
  objects = super().__getattribute__("_objects")
@@ -102,6 +102,15 @@ def group_objects(
102
102
  primary: inner_type, *others: inner_type,
103
103
  check_type_mismatch: bool = True,
104
104
  ) -> inner_type:
105
+ """
106
+ Create a MultiProxy-object and fool the IDE about its type.
107
+ This is the proper way to create such an object.
108
+
109
+ :param primary: The "type" of the returned object
110
+ :param others: All the other elements inside that proxy
111
+ :param check_type_mismatch: False to go the dangerous route of mixing together types
112
+ :return:
113
+ """
105
114
 
106
115
  if check_type_mismatch:
107
116
  main_type = type(primary)
@@ -119,3 +128,5 @@ def group_objects(
119
128
 
120
129
  return my_caller
121
130
 
131
+
132
+
@@ -1,19 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: MultiProxPy
3
- Version: 0.0.1
4
- Summary: An easy way to combine multiple objects into one
5
- License-Expression: Apache-2.0
6
- License-File: LICENSE
7
- Author: Eric aka CheesecakeTV
8
- Author-email: eric@swiftgui.de
9
- Requires-Python: >=3.10
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: OS Independent
12
- Project-URL: Documentation, https://github.com/CheesecakeTV/MultiProxy
13
- Project-URL: Repository, https://github.com/CheesecakeTV/MultiProxy
14
- Description-Content-Type: text/markdown
15
-
16
- # MultiProxy
17
-
18
-
19
-
@@ -1,3 +0,0 @@
1
- # MultiProxy
2
-
3
-
File without changes