PyWSGIRef 1.1.8__tar.gz → 1.1.9__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.
Files changed (24) hide show
  1. {pywsgiref-1.1.8/src/PyWSGIRef.egg-info → pywsgiref-1.1.9}/PKG-INFO +5 -3
  2. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/README.md +4 -2
  3. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/pyproject.toml +1 -1
  4. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/__init__.py +2 -2
  5. pywsgiref-1.1.9/src/PyWSGIRef/patterns.py +13 -0
  6. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/pyhtml.py +43 -1
  7. {pywsgiref-1.1.8 → pywsgiref-1.1.9/src/PyWSGIRef.egg-info}/PKG-INFO +5 -3
  8. pywsgiref-1.1.8/src/PyWSGIRef/patterns.py +0 -9
  9. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/LICENSE +0 -0
  10. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/setup.cfg +0 -0
  11. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/__main__.py +0 -0
  12. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/beta.py +0 -0
  13. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/commons.py +0 -0
  14. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/defaults.py +0 -0
  15. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/exceptions.py +0 -0
  16. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/finished.py +0 -0
  17. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/loadContent.py +0 -0
  18. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/simpleServer.py +0 -0
  19. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef/templateDict.py +0 -0
  20. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef.egg-info/SOURCES.txt +0 -0
  21. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef.egg-info/dependency_links.txt +0 -0
  22. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef.egg-info/requires.txt +0 -0
  23. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/src/PyWSGIRef.egg-info/top_level.txt +0 -0
  24. {pywsgiref-1.1.8 → pywsgiref-1.1.9}/tests/testMainServer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyWSGIRef
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: easy server-setup
5
5
  Author-email: Leander Kafemann <leander@kafemann.berlin>
6
6
  Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
@@ -161,6 +161,8 @@ You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
161
161
  <code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
162
162
  With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
163
163
  you can add a script block anywhere inside your PyHTML file.<br/>
164
+ Using pretty much the same syntax, you can also add a style block using
165
+ <code><{{evalPyHTML-style: body { background-color: lightblue; } :style-}}></code>.
164
166
  ### Shutting down your server
165
167
  You can shut down your server by calling the <code>shutdown</code> method on the server object:
166
168
  ```python
@@ -190,8 +192,8 @@ from PyWSGIRef import BETA
190
192
  BETA.enable()
191
193
  ```
192
194
  Currently to be tested are:<br/>
193
- - PyHTML style blocks<br/>
194
- - PyHTML favicon support<br/>
195
+ - PyHTML python script blocks<br/>
196
+ - PyHTML python if clause blocks<br/>
195
197
  - PyHTML include static resource blocks<br/><br/>
196
198
 
197
199
  Thanks a lot for helping improving PyWSGIRef!
@@ -144,6 +144,8 @@ You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
144
144
  <code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
145
145
  With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
146
146
  you can add a script block anywhere inside your PyHTML file.<br/>
147
+ Using pretty much the same syntax, you can also add a style block using
148
+ <code><{{evalPyHTML-style: body { background-color: lightblue; } :style-}}></code>.
147
149
  ### Shutting down your server
148
150
  You can shut down your server by calling the <code>shutdown</code> method on the server object:
149
151
  ```python
@@ -173,8 +175,8 @@ from PyWSGIRef import BETA
173
175
  BETA.enable()
174
176
  ```
175
177
  Currently to be tested are:<br/>
176
- - PyHTML style blocks<br/>
177
- - PyHTML favicon support<br/>
178
+ - PyHTML python script blocks<br/>
179
+ - PyHTML python if clause blocks<br/>
178
180
  - PyHTML include static resource blocks<br/><br/>
179
181
 
180
182
  Thanks a lot for helping improving PyWSGIRef!
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "PyWSGIRef"
3
- version = "1.1.8"
3
+ version = "1.1.9"
4
4
  authors = [
5
5
  {name="Leander Kafemann", email="leander@kafemann.berlin" },
6
6
  ]
@@ -17,8 +17,8 @@ def about():
17
17
  """
18
18
  Returns information about your release and other projects by Leander Kafemann
19
19
  """
20
- return {"Version": (1, 1, 8), "Author": "Leander Kafemann", "date": "13.06.2025",\
21
- "recommend": ("Büro by LK", "pyimager by LK"), "feedbackTo": "leander@kafemann.berlin"}
20
+ return {"Version": (1, 1, 9), "Author": "Leander Kafemann", "date": "21.06.2025",\
21
+ "recommend": ("Buero by LK", "pyimager by LK"), "feedbackTo": "leander@kafemann.berlin"}
22
22
 
23
23
  SCHABLONEN = TemplateDict()
24
24
 
@@ -0,0 +1,13 @@
1
+ EVAL_PYHTML = "<{{evalPyHTML}}>"
2
+
3
+ MODERN_STYLING_PHRASE = "<{{evalPyHTML-modernStyling: true}}>"
4
+
5
+ INCLUDE_PATTERN = r"<\{\{evalPyHTML-include: (.*?) :include-\}\}\>"
6
+
7
+ SCRIPT_PATTERN = r"<\{\{evalPyHTML-script: (.*?) :script-\}\}\>"
8
+
9
+ STYLE_PATTERN = r"<\{\{evalPyHTML-style: (.*?) :style-\}\}\>"
10
+
11
+ EVAL_BLOCK_PATTERN = r"<\{\{evalPyHTML-eval: (.*?) :eval-\}\}\>"
12
+
13
+ IF_BLOCK_PATTERN = r"<\{\{evalPyHTML-if: (.*?)\}\}\>(.*?)((<\{\{evalPyHTML-else\}\}\>(.*?))?)<\{\{evalPyHTML-endif\}\}\>"
@@ -76,6 +76,46 @@ class PyHTML:
76
76
  replacement = f"<style>{style_content}</style>"
77
77
  self.html = self.html[:idx] + replacement + self.html[idxEnd:]
78
78
 
79
+ def _replace_eval_blocks(self, context=None):
80
+ """
81
+ Replaces eval replacement phrases with evaluated Python expressions.
82
+ WARNING: This method uses eval, which can execute arbitrary code.
83
+ """
84
+ if context is None:
85
+ context = {}
86
+ for match in re.finditer(EVAL_BLOCK_PATTERN, self.html, re.DOTALL):
87
+ idx, idxEnd = match.span()
88
+ code = match.group(1).strip()
89
+ try:
90
+ # eval f�r Ausdr�cke, exec f�r Statements
91
+ result = str(eval(code, {}, context))
92
+ except Exception as e:
93
+ result = f"<b>EvalError: {e}</b>"
94
+ self.html = self.html[:idx] + result + self.html[idxEnd:]
95
+
96
+ def _replace_if_blocks(self, context=None):
97
+ """
98
+ Replaces with html code based on the evaluation of conditions in if blocks.
99
+ """
100
+ if context is None:
101
+ context = {}
102
+ # re.DOTALL f�r mehrzeilige Bl�cke
103
+ while True:
104
+ match = re.search(IF_BLOCK_PATTERN, self.html, re.DOTALL)
105
+ if not match:
106
+ break
107
+ condition = match.group(1).strip()
108
+ if_content = match.group(2)
109
+ else_content = match.group(5) if match.group(5) is not None else ""
110
+ try:
111
+ if eval(condition, {}, context):
112
+ replacement = if_content
113
+ else:
114
+ replacement = else_content
115
+ except Exception as e:
116
+ replacement = f"<b>IfEvalError: {e}</b>"
117
+ self.html = self.html[:match.start()] + replacement + self.html[match.end():]
118
+
79
119
  def decode(self):
80
120
  """
81
121
  Decodes the HTML content by replacing specific phrases and applying modern styling.
@@ -84,9 +124,11 @@ class PyHTML:
84
124
  self._replace_eval_phrase()
85
125
  self._replace_modern_styling()
86
126
  self._replace_script_blocks()
127
+ self._replace_style_blocks()
87
128
  if BETA.value:
88
129
  self._replace_includes()
89
- self._replace_style_blocks()
130
+ self._replace_eval_blocks()
131
+ self._replace_if_blocks()
90
132
 
91
133
  def decoded(self) -> str:
92
134
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyWSGIRef
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: easy server-setup
5
5
  Author-email: Leander Kafemann <leander@kafemann.berlin>
6
6
  Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
@@ -161,6 +161,8 @@ You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
161
161
  <code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
162
162
  With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
163
163
  you can add a script block anywhere inside your PyHTML file.<br/>
164
+ Using pretty much the same syntax, you can also add a style block using
165
+ <code><{{evalPyHTML-style: body { background-color: lightblue; } :style-}}></code>.
164
166
  ### Shutting down your server
165
167
  You can shut down your server by calling the <code>shutdown</code> method on the server object:
166
168
  ```python
@@ -190,8 +192,8 @@ from PyWSGIRef import BETA
190
192
  BETA.enable()
191
193
  ```
192
194
  Currently to be tested are:<br/>
193
- - PyHTML style blocks<br/>
194
- - PyHTML favicon support<br/>
195
+ - PyHTML python script blocks<br/>
196
+ - PyHTML python if clause blocks<br/>
195
197
  - PyHTML include static resource blocks<br/><br/>
196
198
 
197
199
  Thanks a lot for helping improving PyWSGIRef!
@@ -1,9 +0,0 @@
1
- EVAL_PYHTML = "<{{evalPyHTML}}>"
2
-
3
- MODERN_STYLING_PHRASE = "<{{evalPyHTML-modernStyling: true}}>"
4
-
5
- INCLUDE_PATTERN = r"<\{\{evalPyHTML-include: (.*?) :include-\}\}\>"
6
-
7
- SCRIPT_PATTERN = r"<\{\{evalPyHTML-script: (.*?) :script-\}\}\>"
8
-
9
- STYLE_PATTERN = r"<\{\{evalPyHTML-style: (.*?) :style-\}\}\>"
File without changes
File without changes