tina4-python 0.2.83__tar.gz → 0.2.85__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 (46) hide show
  1. {tina4_python-0.2.83 → tina4_python-0.2.85}/PKG-INFO +4 -2
  2. {tina4_python-0.2.83 → tina4_python-0.2.85}/pyproject.toml +8 -4
  3. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Auth.py +1 -1
  4. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Database.py +2 -2
  5. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/ORM.py +3 -4
  6. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Queue.py +1 -1
  7. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Request.py +0 -2
  8. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Response.py +0 -1
  9. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Router.py +3 -3
  10. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Session.py +5 -6
  11. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Swagger.py +13 -13
  12. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Template.py +2 -1
  13. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Webserver.py +5 -4
  14. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/__init__.py +2 -2
  15. {tina4_python-0.2.83 → tina4_python-0.2.85}/README.md +0 -0
  16. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Constant.py +0 -0
  17. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/DatabaseResult.py +0 -0
  18. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Debug.py +0 -0
  19. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Env.py +0 -0
  20. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Localization.py +0 -0
  21. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Messages.py +0 -0
  22. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/MiddleWare.py +0 -0
  23. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Migration.py +0 -0
  24. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/ShellColors.py +0 -0
  25. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/Websocket.py +0 -0
  26. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/messages.pot +0 -0
  27. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/css/readme.md +0 -0
  28. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/favicon.ico +0 -0
  29. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/images/403.png +0 -0
  30. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/images/404.png +0 -0
  31. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/images/500.png +0 -0
  32. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/images/logo.png +0 -0
  33. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/images/readme.md +0 -0
  34. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/js/readme.md +0 -0
  35. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/js/reconnecting-websocket.js +0 -0
  36. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/js/tina4helper.js +0 -0
  37. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/swagger/index.html +0 -0
  38. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  39. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/templates/errors/403.twig +0 -0
  40. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/templates/errors/404.twig +0 -0
  41. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/templates/errors/500.twig +0 -0
  42. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/templates/readme.md +0 -0
  43. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  44. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  45. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  46. {tina4_python-0.2.83 → tina4_python-0.2.85}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
@@ -1,15 +1,17 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tina4-python
3
- Version: 0.2.83
3
+ Version: 0.2.85
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author: Andre van Zuydam
6
6
  Author-email: andrevanzuydam@gmail.com
7
- Requires-Python: >=3.12,<4.0
7
+ Requires-Python: >3.10,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
9
10
  Classifier: Programming Language :: Python :: 3.12
10
11
  Classifier: Programming Language :: Python :: 3.13
11
12
  Requires-Dist: bcrypt (>=4.2.1,<5.0.0)
12
13
  Requires-Dist: cryptography (>=44.0.0,<45.0.0)
14
+ Requires-Dist: flake8 (>=7.1.1,<8.0.0)
13
15
  Requires-Dist: hypercorn (>=0.17.3,<0.18.0)
14
16
  Requires-Dist: jinja2 (>=3.1.5,<4.0.0)
15
17
  Requires-Dist: libsass (>=0.23.0,<0.24.0)
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "tina4-python"
3
- version = "0.2.83"
3
+ version = "0.2.85"
4
4
  description = "Tina4Python - This is not another framework for Python"
5
5
  authors = [
6
6
  {name = "Andre van Zuydam",email = "andrevanzuydam@gmail.com"}
7
7
  ]
8
8
  readme = "README.md"
9
- requires-python = ">=3.12,<4.0"
9
+ requires-python = ">3.10,<4.0"
10
10
  dependencies = [
11
11
  "jinja2 (>=3.1.5,<4.0.0)",
12
12
  "libsass (>=0.23.0,<0.24.0)",
@@ -17,8 +17,9 @@ dependencies = [
17
17
  "bcrypt (>=4.2.1,<5.0.0)",
18
18
  "litequeue (>=0.9,<0.10)",
19
19
  "simple-websocket (>=1.1.0,<2.0.0)",
20
- "poetry-plugin-export (>=1.9.0,<2.0.0)",
21
- "hypercorn (>=0.17.3,<0.18.0)"
20
+ "hypercorn (>=0.17.3,<0.18.0)",
21
+ "flake8 (>=7.1.1,<8.0.0)",
22
+ "poetry-plugin-export (>=1.9.0,<2.0.0)"
22
23
  ]
23
24
 
24
25
 
@@ -26,6 +27,9 @@ dependencies = [
26
27
  requires = ["poetry-core>=2.0.0,<3.0.0"]
27
28
  build-backend = "poetry.core.masonry.api"
28
29
 
30
+ [tool.poetry.requires-plugins]
31
+ poetry-plugin-export = ">=1.8"
32
+
29
33
  [tool.poetry.group.dev.dependencies]
30
34
  flake8 = "^7.1.1"
31
35
  pytest = "^8.3.4"
@@ -140,7 +140,7 @@ class Auth:
140
140
  private_key = self.load_private_key()
141
141
  now = datetime.datetime.now()
142
142
 
143
- if not "expires" in payload_data:
143
+ if "expires" not in payload_data:
144
144
  token_limit_minutes = int(os.environ.get("TINA4_TOKEN_LIMIT", 2))
145
145
  if expiry_minutes != 0:
146
146
  token_limit_minutes = expiry_minutes
@@ -34,7 +34,7 @@ class Database:
34
34
 
35
35
  try:
36
36
  self.database_module = importlib.import_module(params[0])
37
- except Exception as e:
37
+ except Exception:
38
38
  install_message = "What driver are we working with?"
39
39
  if params[0] == Database.SQLITE:
40
40
  install_message = "Your python is missing the sqlite3 module, please reinstall or update"
@@ -219,7 +219,7 @@ class Database:
219
219
  """
220
220
  try:
221
221
  json.loads(myjson)
222
- except Exception as e:
222
+ except Exception:
223
223
  return False
224
224
  return True
225
225
 
@@ -7,11 +7,10 @@
7
7
  import base64
8
8
  from datetime import datetime, date
9
9
  import inspect
10
- import sys
11
10
  import ast
12
11
  import json
13
12
  import os
14
- from tina4_python.Constant import TINA4_LOG_ERROR, TINA4_LOG_INFO
13
+ from tina4_python.Constant import TINA4_LOG_ERROR
15
14
  from tina4_python.Debug import Debug
16
15
 
17
16
 
@@ -37,7 +36,7 @@ def orm(dba):
37
36
  Debug('from src.orm.' + mod_name + ' import ' + mod_name)
38
37
  exec('from src.orm.' + mod_name + ' import ' + mod_name+"\n"+mod_name + ".__dba__ = dba")
39
38
  except Exception as e:
40
- Debug("Failed to import " + mod_name)
39
+ Debug("Failed to import " + mod_name, str(e))
41
40
  classes = find_all_sub_classes(ORM)
42
41
  for a_class in classes:
43
42
  a_class.__dba__ = dba
@@ -134,7 +133,7 @@ class DateTimeField(BaseField):
134
133
  default_value = datetime.now()
135
134
 
136
135
  def get_definition(self):
137
- return self.column_name.lower() + " timestamp";
136
+ return self.column_name.lower() + " timestamp"
138
137
 
139
138
 
140
139
  class IntegerField(BaseField):
@@ -230,7 +230,7 @@ class Queue(object):
230
230
  )
231
231
  delivery_callback(self.consumer, err, response_msg_internal)
232
232
 
233
- self.producer.produce(self.topic, json.dumps(body), user_id, callback=kafka_delivery_callback)
233
+ self.producer.produce(prefix+self.topic, json.dumps(body), user_id, callback=kafka_delivery_callback)
234
234
  self.producer.poll(1000)
235
235
  self.producer.flush()
236
236
  except Exception as e:
@@ -4,8 +4,6 @@
4
4
  # License: MIT https://opensource.org/licenses/MIT
5
5
  #
6
6
  # flake8: noqa: E501
7
- import inspect
8
-
9
7
  request = None
10
8
  body = None
11
9
  params = {}
@@ -9,7 +9,6 @@ import inspect
9
9
  from types import ModuleType
10
10
  from tina4_python import Constant
11
11
  from tina4_python import DatabaseResult
12
- from tina4_python.Debug import Debug
13
12
  from tina4_python.ORM import ORM
14
13
 
15
14
  headers = {}
@@ -11,7 +11,7 @@ import os
11
11
  import sys
12
12
  import io
13
13
  import tina4_python
14
- from tina4_python import Constant,Auth
14
+ from tina4_python import Constant
15
15
  from tina4_python import Response
16
16
  from tina4_python import Request
17
17
  from tina4_python.Debug import Debug
@@ -206,7 +206,7 @@ class Router:
206
206
  if buffer.getvalue() != "":
207
207
  try:
208
208
  return Response.Response(json.loads(buffer.getvalue()), Constant.HTTP_OK, Constant.APPLICATION_JSON, result.headers)
209
- except:
209
+ except Exception:
210
210
  return Response.Response(buffer.getvalue(), Constant.HTTP_OK, Constant.TEXT_HTML, result.headers)
211
211
  else:
212
212
  result = Response
@@ -259,7 +259,7 @@ class Router:
259
259
  @staticmethod
260
260
  def add(method, route, callback):
261
261
  Debug("Adding a route: " + route, Constant.TINA4_LOG_DEBUG)
262
- if not callback in tina4_python.tina4_routes:
262
+ if callback not in tina4_python.tina4_routes:
263
263
  tina4_python.tina4_routes[callback] = {"route": route, "callback": callback, "method": method,
264
264
  "swagger": None, "cached": False}
265
265
  else:
@@ -5,7 +5,6 @@
5
5
  #
6
6
  # flake8: noqa: E501
7
7
  import os
8
- import json
9
8
  from http import cookies
10
9
  import sys
11
10
  import importlib
@@ -29,7 +28,7 @@ class SessionHandler(object):
29
28
  session.session_values[_key] = _value
30
29
  session.save()
31
30
  return True
32
- except:
31
+ except Exception:
33
32
  return False
34
33
 
35
34
  @staticmethod
@@ -85,7 +84,7 @@ class SessionFileHandler(SessionHandler):
85
84
  if os.path.isfile(session.session_path + os.sep + session.session_hash):
86
85
  os.remove(session.session_path + os.sep + session.session_hash)
87
86
  return True
88
- except:
87
+ except Exception:
89
88
  return False
90
89
 
91
90
  @staticmethod
@@ -109,7 +108,7 @@ class SessionRedisHandler(SessionHandler):
109
108
  try:
110
109
  redis = importlib.import_module("redis")
111
110
  except Exception as e:
112
- Debug("Redis not installed, install with pip install redis or poetry add redis", Constant.TINA4_LOG_ERROR)
111
+ Debug("Redis not installed, install with pip install redis or poetry add redis", str(e), Constant.TINA4_LOG_ERROR)
113
112
  sys.exit(1)
114
113
 
115
114
  redis_instance = redis.Redis(host=os.getenv("TINA4_SESSION_REDIS_HOST", "localhost"), port=os.getenv("TINA4_SESSION_REDIS_PORT",6379), decode_responses=True)
@@ -139,7 +138,7 @@ class SessionRedisHandler(SessionHandler):
139
138
  else:
140
139
  Debug("Session expired, starting a new one", Constant.TINA4_LOG_DEBUG)
141
140
  session.start(_hash)
142
- except:
141
+ except Exception:
143
142
  Debug("Redis not available, sessions will fail", Constant.TINA4_LOG_ERROR)
144
143
 
145
144
 
@@ -154,7 +153,7 @@ class SessionRedisHandler(SessionHandler):
154
153
  try:
155
154
  r.set(session.session_hash, "")
156
155
  return True
157
- except:
156
+ except Exception:
158
157
  return False
159
158
 
160
159
  @staticmethod
@@ -4,9 +4,10 @@
4
4
  # License: MIT https://opensource.org/licenses/MIT
5
5
  #
6
6
  # flake8: noqa: E501
7
- import os, re
7
+ import os
8
+ import re
8
9
  import tina4_python
9
- from tina4_python import Messages, Constant
10
+ from tina4_python import Constant, Debug
10
11
 
11
12
 
12
13
  class Swagger:
@@ -57,6 +58,7 @@ class Swagger:
57
58
  for variable in variables:
58
59
  params.append({"name": variable, "in": "path", "type": "string"})
59
60
  except Exception as e:
61
+ Debug.error("Failed to parse path inputs", str(e))
60
62
  return []
61
63
 
62
64
  return params
@@ -74,7 +76,7 @@ class Swagger:
74
76
 
75
77
  secure_annotation = [],
76
78
  if security:
77
- secure_annotation = [{"bearerAuth": []}];
79
+ secure_annotation = [{"bearerAuth": []}]
78
80
 
79
81
  new_params = []
80
82
  for param in params:
@@ -102,7 +104,7 @@ class Swagger:
102
104
  },
103
105
  "security": secure_annotation,
104
106
  "responses": responses
105
- };
107
+ }
106
108
 
107
109
  if method == Constant.TINA4_GET or example is None:
108
110
  del entry["requestBody"]
@@ -111,17 +113,17 @@ class Swagger:
111
113
 
112
114
  @staticmethod
113
115
  def parse_swagger(swagger):
114
- if not "tags" in swagger:
116
+ if "tags" not in swagger:
115
117
  swagger["tags"] = []
116
- if not "params" in swagger:
118
+ if "params" not in swagger:
117
119
  swagger["params"] = []
118
- if not "description" in swagger:
120
+ if "description" not in swagger:
119
121
  swagger["description"] = ""
120
- if not "summary" in swagger:
122
+ if "summary" not in swagger:
121
123
  swagger["summary"] = ""
122
- if not "example" in swagger:
124
+ if "example" not in swagger:
123
125
  swagger["example"] = None
124
- if not "secure" in swagger:
126
+ if "secure" not in swagger:
125
127
  swagger["secure"] = None
126
128
 
127
129
  if isinstance(swagger["tags"], str):
@@ -137,14 +139,12 @@ class Swagger:
137
139
  if "swagger" in route:
138
140
  if route["swagger"] is not None:
139
141
  swagger = Swagger.parse_swagger(route["swagger"])
140
- produces = {}
141
-
142
142
  responses = {
143
143
  "200": {"description": "Success"},
144
144
  "400": {"description": "Failed"}
145
145
  }
146
146
 
147
- if not route["route"] in paths:
147
+ if route["route"] not in paths:
148
148
  paths[route["route"]] = {}
149
149
  paths[route["route"]][route["method"].lower()] = Swagger.get_swagger_entry(route["route"],
150
150
  route["method"].lower(),
@@ -4,7 +4,8 @@
4
4
  # License: MIT https://opensource.org/licenses/MIT
5
5
  #
6
6
  # flake8: noqa: E501
7
- import os, json
7
+ import os
8
+ import json
8
9
  import tina4_python
9
10
  from tina4_python import Constant
10
11
  from tina4_python.Debug import Debug
@@ -23,7 +23,7 @@ from tina4_python.Template import Template
23
23
 
24
24
  def is_int(v):
25
25
  try:
26
- f = int(v)
26
+ int(v)
27
27
  except ValueError:
28
28
  return False
29
29
  return True
@@ -53,7 +53,7 @@ class Webserver:
53
53
  # print("CONTENT", content, self.request)
54
54
  try:
55
55
  return json.loads(content)
56
- except:
56
+ except Exception:
57
57
  return content.decode("utf-8")
58
58
  elif self.lowercase_headers["content-type"] == "text/plain":
59
59
  return content.decode("utf-8")
@@ -237,7 +237,7 @@ class Webserver:
237
237
  async def get_data(self, reader):
238
238
  try:
239
239
  raw_data = await reader.readuntil(b"\r\n\r\n")
240
- except:
240
+ except Exception:
241
241
  raw_data = await reader.read(128)
242
242
 
243
243
  protocol = raw_data.decode("utf-8").split("\r\n", 1)[0]
@@ -267,7 +267,7 @@ class Webserver:
267
267
  break
268
268
  try:
269
269
  content = content_data.decode("utf-8")
270
- except: # probably binary or multipart form?
270
+ except Exception: # probably binary or multipart form?
271
271
  content = content_data
272
272
 
273
273
  return protocol, headers, lowercase_headers, content, raw_data, content_data
@@ -353,6 +353,7 @@ class Webserver:
353
353
  await writer.drain()
354
354
  writer.close()
355
355
  except BrokenPipeError as e:
356
+ Debug.warning("Socket connection broken: " + str(e))
356
357
  # socket got terminated
357
358
  pass
358
359
  else:
@@ -20,7 +20,7 @@ from tina4_python import Messages, Constant
20
20
  from tina4_python.Swagger import Swagger
21
21
  from tina4_python.Env import load_env
22
22
  from tina4_python.Webserver import Webserver
23
- from tina4_python.Router import Router, get
23
+ from tina4_python.Router import Router
24
24
  from tina4_python.Localization import localize
25
25
  from tina4_python.Auth import Auth
26
26
  from tina4_python.Debug import Debug
@@ -344,7 +344,7 @@ def webserver(host_name, port):
344
344
  config = Config()
345
345
  config.bind = [host_name+":"+str(port)]
346
346
  asyncio.run(serve(app, config))
347
- except Exception:
347
+ except Exception as e:
348
348
  Debug("Not running Hypercorn webserver", str(e), Constant.TINA4_LOG_WARNING)
349
349
 
350
350
 
File without changes