velocity-python 0.0.2__tar.gz → 0.0.3__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.

Potentially problematic release.


This version of velocity-python might be problematic. Click here for more details.

Files changed (43) hide show
  1. {velocity-python-0.0.2 → velocity-python-0.0.3}/PKG-INFO +1 -1
  2. {velocity-python-0.0.2 → velocity-python-0.0.3}/pyproject.toml +1 -1
  3. velocity-python-0.0.3/src/velocity/aws/handlers/response.py +158 -0
  4. velocity-python-0.0.3/src/velocity/misc/merge.py +35 -0
  5. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity_python.egg-info/PKG-INFO +1 -1
  6. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity_python.egg-info/SOURCES.txt +2 -0
  7. {velocity-python-0.0.2 → velocity-python-0.0.3}/LICENSE +0 -0
  8. {velocity-python-0.0.2 → velocity-python-0.0.3}/README.md +0 -0
  9. {velocity-python-0.0.2 → velocity-python-0.0.3}/setup.cfg +0 -0
  10. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/__init__.py +0 -0
  11. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/aws/__init__.py +0 -0
  12. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/aws/context.py +0 -0
  13. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/aws/handlers/__init__.py +0 -0
  14. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/aws/handlers/lambda_handler.py +0 -0
  15. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/aws/handlers/sqs_handler.py +0 -0
  16. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/__init__.py +0 -0
  17. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/__init__.py +0 -0
  18. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/column.py +0 -0
  19. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/database.py +0 -0
  20. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/decorators.py +0 -0
  21. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/engine.py +0 -0
  22. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/exceptions.py +0 -0
  23. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/result.py +0 -0
  24. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/row.py +0 -0
  25. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/sequence.py +0 -0
  26. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/table.py +0 -0
  27. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/core/transaction.py +0 -0
  28. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/__init__.py +0 -0
  29. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/mysql.py +0 -0
  30. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/postgres.py +0 -0
  31. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/sql.py +0 -0
  32. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/sqlite.py +0 -0
  33. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/db/servers/sqlserver.py +0 -0
  34. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/__init__.py +0 -0
  35. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/conv.py +0 -0
  36. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/db.py +0 -0
  37. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/export.py +0 -0
  38. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/format.py +0 -0
  39. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/mail.py +0 -0
  40. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity/misc/timer.py +0 -0
  41. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity_python.egg-info/dependency_links.txt +0 -0
  42. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity_python.egg-info/requires.txt +0 -0
  43. {velocity-python-0.0.2 → velocity-python-0.0.3}/src/velocity_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: velocity-python
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A rapid application development library for interfacing with data storage
5
5
  Author-email: Paul Perez <pperez@codeclubs.org>
6
6
  Project-URL: Homepage, https://codeclubs.org/projects/velocity
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "velocity-python"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  authors = [
5
5
  { name="Paul Perez", email="pperez@codeclubs.org" },
6
6
  ]
@@ -0,0 +1,158 @@
1
+ from velocity.misc.format import to_json
2
+ import sys
3
+ import traceback
4
+ import os
5
+
6
+ DEBUG = (os.environ.get('ENV') != 'production') or \
7
+ (os.environ.get('DEBUG') == 'Y')
8
+
9
+ variants = [
10
+ 'success',
11
+ 'error',
12
+ 'warning',
13
+ 'info'
14
+ ]
15
+
16
+
17
+ class Response:
18
+ def __init__(self):
19
+ self.actions = []
20
+ self.body = {
21
+ 'actions': self.actions
22
+ }
23
+ self.raw = {
24
+ 'statusCode': 200,
25
+ 'body': '{}',
26
+ 'headers': {
27
+ 'Content-Type': 'application/json',
28
+ 'Access-Control-Allow-Headers': '*',
29
+ 'Access-Control-Allow-Origin': '*',
30
+ 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
31
+ },
32
+ }
33
+
34
+ def render(self):
35
+ self.raw['body'] = to_json(self.body)
36
+ return self.raw
37
+
38
+ def alert(self, message, title="Notification"):
39
+ self.actions.append({
40
+ 'action': 'alert',
41
+ 'payload': {
42
+ 'title': title,
43
+ 'message': message,
44
+ }
45
+ })
46
+ return self
47
+
48
+ def toast(self, message, variant='success'):
49
+ variant = variant.lower()
50
+ if variant not in variants:
51
+ raise Exception(f"Notistack variant {variant} not in {variants}")
52
+ self.actions.append({
53
+ 'action': 'toast',
54
+ 'payload': {
55
+ 'options': {
56
+ 'variant': variant,
57
+ },
58
+ 'message': message
59
+ }
60
+ })
61
+ return self
62
+
63
+ def load_object(self, payload):
64
+ self.actions.append({
65
+ 'action': 'load-object',
66
+ 'payload': payload
67
+ })
68
+ return self
69
+
70
+ def update_store(self, payload):
71
+ self.actions.append({
72
+ 'action': 'update-store',
73
+ 'payload': payload
74
+ })
75
+ return self
76
+
77
+ def file_download(self, payload):
78
+ self.actions.append({
79
+ 'action': 'file-download',
80
+ 'payload': payload
81
+ })
82
+ return self
83
+
84
+ def status(self, code=None):
85
+ if code:
86
+ self.raw['statusCode'] = int(code)
87
+ return self.raw['statusCode']
88
+
89
+ def headers(self, headers=None):
90
+ if headers:
91
+ new = {}
92
+ for key in headers.keys():
93
+ new["-".join(w.capitalize()
94
+ for w in key.split('-'))] = headers[key]
95
+ self.raw['headers'].update(new)
96
+ return self.raw['headers']
97
+
98
+ def set_status(self, code):
99
+ self.status(code)
100
+ return self
101
+
102
+ def set_headers(self, headers):
103
+ self.headers(headers)
104
+ return self
105
+
106
+ def set_body(self, body):
107
+ self.body.update(body)
108
+ return self
109
+
110
+ def exception(self):
111
+ t, v, tb = sys.exc_info()
112
+ self.set_status(500)
113
+ self.set_body({
114
+ 'python_exception': {
115
+ 'type': str(t),
116
+ 'value': str(v),
117
+ 'traceback': traceback.format_exc() if DEBUG else None,
118
+ 'tb': traceback.format_tb(tb) if DEBUG else None
119
+ }
120
+ })
121
+
122
+ def console(self, message, title="Notification"):
123
+ self.actions.append({
124
+ 'action': 'console',
125
+ 'payload': {
126
+ 'title': title,
127
+ 'message': message,
128
+ }
129
+ })
130
+ return self
131
+
132
+ def redirect(self, location):
133
+ self.actions.append({
134
+ 'action': 'redirect',
135
+ 'payload': {'location': location}
136
+ })
137
+ return self
138
+
139
+ def signout(self, location):
140
+ self.actions.append({
141
+ 'action': 'signout',
142
+
143
+ })
144
+ return self
145
+
146
+ def set_table(self, payload):
147
+ self.actions.append({
148
+ 'action': 'set-table',
149
+ 'payload': payload
150
+ })
151
+ return self
152
+
153
+ def set_repo(self, payload):
154
+ self.actions.append({
155
+ 'action': 'set-repo',
156
+ 'payload': payload
157
+ })
158
+ return self
@@ -0,0 +1,35 @@
1
+ from copy import deepcopy
2
+ from functools import reduce
3
+
4
+
5
+ def deep_merge(*dicts, update=False):
6
+ """
7
+ Merges dicts deeply.
8
+ Parameters
9
+ ----------
10
+ dicts : list[dict]
11
+ List of dicts.
12
+ update : bool
13
+ Whether to update the first dict or create a new dict.
14
+ Returns
15
+ -------
16
+ merged : dict
17
+ Merged dict.
18
+ """
19
+ def merge_into(d1, d2):
20
+ for key in d2:
21
+ if key not in d1:
22
+ d1[key] = deepcopy(d2[key])
23
+ elif isinstance(d1[key], dict):
24
+ d1[key] = merge_into(d1[key], d2[key])
25
+ elif isinstance(d1[key], list) and isinstance(d2[key], list):
26
+ d1[key].extend(d2[key])
27
+ else:
28
+ d1[key] = deepcopy(d2[key])
29
+
30
+ return d1
31
+
32
+ if update:
33
+ return reduce(merge_into, dicts[1:], dicts[0])
34
+ else:
35
+ return reduce(merge_into, dicts, {})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: velocity-python
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A rapid application development library for interfacing with data storage
5
5
  Author-email: Paul Perez <pperez@codeclubs.org>
6
6
  Project-URL: Homepage, https://codeclubs.org/projects/velocity
@@ -6,6 +6,7 @@ src/velocity/aws/__init__.py
6
6
  src/velocity/aws/context.py
7
7
  src/velocity/aws/handlers/__init__.py
8
8
  src/velocity/aws/handlers/lambda_handler.py
9
+ src/velocity/aws/handlers/response.py
9
10
  src/velocity/aws/handlers/sqs_handler.py
10
11
  src/velocity/db/__init__.py
11
12
  src/velocity/db/core/__init__.py
@@ -31,6 +32,7 @@ src/velocity/misc/db.py
31
32
  src/velocity/misc/export.py
32
33
  src/velocity/misc/format.py
33
34
  src/velocity/misc/mail.py
35
+ src/velocity/misc/merge.py
34
36
  src/velocity/misc/timer.py
35
37
  src/velocity_python.egg-info/PKG-INFO
36
38
  src/velocity_python.egg-info/SOURCES.txt
File without changes