appier 1.31.4__py2.py3-none-any.whl → 1.32.0__py2.py3-none-any.whl

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 (81) hide show
  1. appier/__init__.py +333 -52
  2. appier/amqp.py +29 -30
  3. appier/api.py +214 -212
  4. appier/asgi.py +54 -55
  5. appier/async_neo.py +46 -35
  6. appier/async_old.py +55 -42
  7. appier/asynchronous.py +7 -13
  8. appier/base.py +1762 -1429
  9. appier/bus.py +51 -52
  10. appier/cache.py +99 -84
  11. appier/common.py +9 -11
  12. appier/component.py +17 -19
  13. appier/compress.py +25 -28
  14. appier/config.py +96 -73
  15. appier/controller.py +9 -15
  16. appier/crypt.py +25 -21
  17. appier/data.py +73 -57
  18. appier/defines.py +191 -226
  19. appier/exceptions.py +103 -63
  20. appier/execution.py +94 -88
  21. appier/export.py +90 -88
  22. appier/extra.py +6 -13
  23. appier/extra_neo.py +8 -11
  24. appier/extra_old.py +18 -16
  25. appier/geo.py +57 -47
  26. appier/git.py +101 -90
  27. appier/graph.py +23 -24
  28. appier/http.py +520 -398
  29. appier/legacy.py +373 -180
  30. appier/log.py +90 -97
  31. appier/meta.py +42 -42
  32. appier/mock.py +32 -34
  33. appier/model.py +793 -681
  34. appier/model_a.py +208 -183
  35. appier/mongo.py +183 -107
  36. appier/observer.py +39 -31
  37. appier/part.py +23 -24
  38. appier/preferences.py +44 -47
  39. appier/queuing.py +78 -96
  40. appier/redisdb.py +40 -35
  41. appier/request.py +227 -175
  42. appier/scheduler.py +13 -18
  43. appier/serialize.py +37 -31
  44. appier/session.py +161 -147
  45. appier/settings.py +2 -11
  46. appier/smtp.py +53 -49
  47. appier/storage.py +39 -33
  48. appier/structures.py +50 -45
  49. appier/test/__init__.py +2 -11
  50. appier/test/base.py +111 -108
  51. appier/test/cache.py +28 -35
  52. appier/test/config.py +10 -19
  53. appier/test/crypt.py +3 -12
  54. appier/test/data.py +3 -12
  55. appier/test/exceptions.py +8 -17
  56. appier/test/export.py +16 -33
  57. appier/test/graph.py +27 -60
  58. appier/test/http.py +42 -54
  59. appier/test/legacy.py +20 -30
  60. appier/test/log.py +14 -35
  61. appier/test/mock.py +27 -123
  62. appier/test/model.py +79 -91
  63. appier/test/part.py +5 -14
  64. appier/test/preferences.py +5 -13
  65. appier/test/queuing.py +29 -37
  66. appier/test/request.py +61 -73
  67. appier/test/serialize.py +12 -23
  68. appier/test/session.py +10 -19
  69. appier/test/smtp.py +8 -14
  70. appier/test/structures.py +20 -24
  71. appier/test/typesf.py +14 -28
  72. appier/test/util.py +480 -438
  73. appier/typesf.py +251 -171
  74. appier/util.py +578 -407
  75. appier/validation.py +280 -143
  76. {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/METADATA +6 -1
  77. appier-1.32.0.dist-info/RECORD +86 -0
  78. appier-1.31.4.dist-info/RECORD +0 -86
  79. {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/LICENSE +0 -0
  80. {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/WHEEL +0 -0
  81. {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/top_level.txt +0 -0
appier/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  # Hive Appier Framework
5
- # Copyright (c) 2008-2022 Hive Solutions Lda.
5
+ # Copyright (c) 2008-2024 Hive Solutions Lda.
6
6
  #
7
7
  # This file is part of Hive Appier Framework.
8
8
  #
@@ -19,16 +19,7 @@
19
19
  # You should have received a copy of the Apache License along with
20
20
  # Hive Appier Framework. If not, see <http://www.apache.org/licenses/>.
21
21
 
22
- __version__ = "1.0.0"
23
- """ The version of the module """
24
-
25
- __revision__ = "$LastChangedRevision$"
26
- """ The revision number of the module """
27
-
28
- __date__ = "$LastChangedDate$"
29
- """ The last change date of the module """
30
-
31
- __copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
22
+ __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
32
23
  """ The copyright for the module """
33
24
 
34
25
  __license__ = "Apache License, Version 2.0"
@@ -80,14 +71,75 @@ from . import validation
80
71
 
81
72
  from .amqp import AMQP
82
73
  from .api import API, OAuthAPI, OAuth1API, OAuth2API
83
- from .asynchronous import ASYNC_HEADER, AsyncManager, SimpleManager, QueueManager, AwaitWrapper, CoroutineWrapper,\
84
- AyncgenWrapper, await_wrap, await_yield, ensure_generator, is_coroutine, is_coroutine_object, is_coroutine_native,\
85
- to_coroutine, wrap_silent, unavailable, is_neo, Future, coroutine, wakeup, sleep, wait, notify, build_future,\
86
- ensure_async, header_a, ensure_a
87
- from .base import APP, LEVEL, NAME, VERSION, PLATFORM, IDENTIFIER_SHORT, IDENTIFIER_LONG, IDENTIFIER,\
88
- API_VERSION, BUFFER_SIZE, MAX_LOG_SIZE, MAX_LOG_COUNT, App, APIApp, WebApp, Template, get_app, get_name,\
89
- get_base_path, get_cache, get_preferences, get_bus, get_request, get_session, get_model, get_controller, get_part,\
90
- get_adapter, get_manager, get_logger, get_level, is_loaded, is_devel, is_safe, to_locale, on_exit, build_asgi, build_asgi_i
74
+ from .asynchronous import (
75
+ ASYNC_HEADER,
76
+ AsyncManager,
77
+ SimpleManager,
78
+ QueueManager,
79
+ AwaitWrapper,
80
+ CoroutineWrapper,
81
+ AyncgenWrapper,
82
+ await_wrap,
83
+ await_yield,
84
+ ensure_generator,
85
+ is_coroutine,
86
+ is_coroutine_object,
87
+ is_coroutine_native,
88
+ to_coroutine,
89
+ wrap_silent,
90
+ unavailable,
91
+ is_neo,
92
+ Future,
93
+ coroutine,
94
+ wakeup,
95
+ sleep,
96
+ wait,
97
+ notify,
98
+ build_future,
99
+ ensure_async,
100
+ header_a,
101
+ ensure_a,
102
+ )
103
+ from .base import (
104
+ APP,
105
+ LEVEL,
106
+ NAME,
107
+ VERSION,
108
+ PLATFORM,
109
+ IDENTIFIER_SHORT,
110
+ IDENTIFIER_LONG,
111
+ IDENTIFIER,
112
+ API_VERSION,
113
+ BUFFER_SIZE,
114
+ MAX_LOG_SIZE,
115
+ MAX_LOG_COUNT,
116
+ App,
117
+ APIApp,
118
+ WebApp,
119
+ Template,
120
+ get_app,
121
+ get_name,
122
+ get_base_path,
123
+ get_cache,
124
+ get_preferences,
125
+ get_bus,
126
+ get_request,
127
+ get_session,
128
+ get_model,
129
+ get_controller,
130
+ get_part,
131
+ get_adapter,
132
+ get_manager,
133
+ get_logger,
134
+ get_level,
135
+ is_loaded,
136
+ is_devel,
137
+ is_safe,
138
+ to_locale,
139
+ on_exit,
140
+ build_asgi,
141
+ build_asgi_i,
142
+ )
91
143
  from .bus import Bus, MemoryBus, RedisBus
92
144
  from .cache import Cache, MemoryCache, FileCache, RedisCache, SerializedCache
93
145
  from .component import Component
@@ -95,56 +147,285 @@ from .compress import Compress
95
147
  from .config import conf, conf_prefix, conf_suffix, conf_s, conf_r, conf_d, conf_ctx
96
148
  from .controller import Controller
97
149
  from .crypt import Cipher, RC4, Spritz
98
- from .data import DataAdapter, MongoAdapter, TinyAdapter, Collection, MongoCollection, TinyCollection
99
- from .defines import ITERABLES, MOBILE_REGEX, TABLET_REGEX, MOBILE_PREFIX_REGEX, BODY_REGEX, TAG_REGEX,\
100
- EMAIL_REGEX, BROWSER_INFO, OS_INFO, WINDOWS_LOCALE, SLUG_PERMUTATIONS
101
- from .exceptions import AppierException, OperationalError, SecurityError, AssertionError,\
102
- ValidationError, NotFoundError, NotImplementedError, BaseInternalError, ValidationInternalError,\
103
- ValidationMultipleError, HTTPError, APIError, APIAccessError, OAuthAccessError
104
- from .execution import ExecutionThread, background, insert_work, interval_work, seconds_work,\
105
- minutes_work, hourly_work, daily_work, weekly_work, monthly_work, seconds_eval, minutes_eval,\
106
- hourly_eval, daily_eval, weekly_eval, monthly_eval
150
+ from .data import (
151
+ DataAdapter,
152
+ MongoAdapter,
153
+ TinyAdapter,
154
+ Collection,
155
+ MongoCollection,
156
+ TinyCollection,
157
+ )
158
+ from .defines import (
159
+ ITERABLES,
160
+ MOBILE_REGEX,
161
+ TABLET_REGEX,
162
+ MOBILE_PREFIX_REGEX,
163
+ BODY_REGEX,
164
+ TAG_REGEX,
165
+ EMAIL_REGEX,
166
+ BROWSER_INFO,
167
+ OS_INFO,
168
+ WINDOWS_LOCALE,
169
+ SLUG_PERMUTATIONS,
170
+ )
171
+ from .exceptions import (
172
+ AppierException,
173
+ OperationalError,
174
+ SecurityError,
175
+ AssertionError,
176
+ ValidationError,
177
+ NotFoundError,
178
+ NotImplementedError,
179
+ BaseInternalError,
180
+ ValidationInternalError,
181
+ ValidationMultipleError,
182
+ HTTPError,
183
+ APIError,
184
+ APIAccessError,
185
+ OAuthAccessError,
186
+ )
187
+ from .execution import (
188
+ ExecutionThread,
189
+ background,
190
+ insert_work,
191
+ interval_work,
192
+ seconds_work,
193
+ minutes_work,
194
+ hourly_work,
195
+ daily_work,
196
+ weekly_work,
197
+ monthly_work,
198
+ seconds_eval,
199
+ minutes_eval,
200
+ hourly_eval,
201
+ daily_eval,
202
+ weekly_eval,
203
+ monthly_eval,
204
+ )
107
205
  from .export import ExportManager
108
- from .extra import get_a, post_a, put_a, delete_a, patch_a, get_w, post_w, put_w, delete_w, patch_w
206
+ from .extra import (
207
+ get_a,
208
+ post_a,
209
+ put_a,
210
+ delete_a,
211
+ patch_a,
212
+ get_w,
213
+ post_w,
214
+ put_w,
215
+ delete_w,
216
+ patch_w,
217
+ )
109
218
  from .geo import GeoResolver
110
219
  from .git import Git
111
220
  from .graph import Graph
112
221
  from .http import file_g, get_f, get, post, put, delete, patch, basic_auth, HTTPResponse
113
- from .log import MemoryHandler, BaseFormatter, ThreadFormatter, DummyLogger, reload_format, rotating_handler,\
114
- smtp_handler, in_signature
222
+ from .log import (
223
+ MemoryHandler,
224
+ BaseFormatter,
225
+ ThreadFormatter,
226
+ DummyLogger,
227
+ reload_format,
228
+ rotating_handler,
229
+ smtp_handler,
230
+ in_signature,
231
+ )
115
232
  from .meta import Ordered, Indexed
116
233
  from .mock import MockObject, MockResponse, MockApp
117
- from .model import Model, LocalModel, Field, link, operation, view, field, type_d, is_unset
118
- from .mongo import Mongo, MongoAsync, MongoEncoder, get_connection, get_connection_a, reset_connection, reset_connection_a,\
119
- get_db, get_db_a, drop_db, drop_db_a, object_id, dumps
234
+ from .model import (
235
+ Model,
236
+ LocalModel,
237
+ Field,
238
+ link,
239
+ operation,
240
+ view,
241
+ field,
242
+ type_d,
243
+ is_unset,
244
+ )
245
+ from .mongo import (
246
+ Mongo,
247
+ MongoAsync,
248
+ MongoEncoder,
249
+ get_connection,
250
+ get_connection_a,
251
+ reset_connection,
252
+ reset_connection_a,
253
+ get_db,
254
+ get_db_a,
255
+ drop_db,
256
+ drop_db_a,
257
+ object_id,
258
+ dumps,
259
+ )
120
260
  from .observer import Observable
121
261
  from .part import Part
122
- from .preferences import Preferences, MemoryPreferences, FilePreferences, RedisPreferences
262
+ from .preferences import (
263
+ Preferences,
264
+ MemoryPreferences,
265
+ FilePreferences,
266
+ RedisPreferences,
267
+ )
123
268
  from .queuing import Queue, MemoryQueue, MultiprocessQueue, AMQPQueue
124
269
  from .redisdb import Redis
125
270
  from .request import CODE_STRINGS, Request, MockRequest
126
271
  from .scheduler import Scheduler
127
272
  from .serialize import serialize_csv, serialize_ics, build_encoder
128
- from .session import Session, MockSession, MemorySession, FileSession, RedisSession, ClientSession
273
+ from .session import (
274
+ Session,
275
+ MockSession,
276
+ MemorySession,
277
+ FileSession,
278
+ RedisSession,
279
+ ClientSession,
280
+ )
129
281
  from .settings import DEBUG, USERNAME, PASSWORD
130
- from .smtp import message, message_base, message_netius, smtp_engine, multipart, plain,\
131
- html, application, header
282
+ from .smtp import (
283
+ message,
284
+ message_base,
285
+ message_netius,
286
+ smtp_engine,
287
+ multipart,
288
+ plain,
289
+ html,
290
+ application,
291
+ header,
292
+ )
132
293
  from .storage import StorageEngine, BaseEngine, FsEngine
133
294
  from .structures import OrderedDict, LazyDict, LazyValue, GeneratorFile, lazy_dict, lazy
134
- from .typesf import AbstractType, Type, File, Files, ImageFile, ImageFiles, image, images, Reference,\
135
- reference, References, references, Encrypted, encrypted, secure
136
- from .util import to_limit, to_find, to_sort, is_iterable, is_mobile, is_tablet, is_browser, is_bot, browser_info,\
137
- email_parts, email_mime, email_name, email_base, date_to_timestamp, obfuscate, import_pip, ensure_pip, install_pip,\
138
- install_pip_s, request_json, get_context, get_object, resolve_alias, page_types, find_types, norm_object, set_object, leafs,\
139
- gather_errors, gen_token, html_to_text, camel_to_underscore, camel_to_readable, underscore_to_camel, underscore_to_readable, quote,\
140
- unquote, escape, unescape, count_unescape, split_unescape, call_safe, base_name, base_name_m, is_content_type, parse_content_type,\
141
- parse_cookie, parse_multipart, decode_params, load_form, check_login, check_user, check_token, check_tokens,\
142
- ensure_login, get_tokens_m, to_tokens_m, dict_merge, deprecated, cached, private, ensure, delayed, route, error_handler,\
143
- exception_handler, before_request, after_request, is_detached, sanitize, verify, verify_equal, verify_not_equal,\
144
- verify_type, verify_many, execute, ctx_locale, ctx_request, FileTuple, BaseThread, JSONEncoder
145
- from .validation import validate, validate_b, validate_e, safe, eq, gt, gte, lt, lte, not_null, not_empty, not_false,\
146
- is_in, is_upper, is_lower, is_simple, is_email, is_url, is_regex, field_eq, field_gt, field_gte, field_lt,\
147
- field_lte, string_gt, string_lt, string_eq, equals, not_past, not_duplicate, all_different, no_self
295
+ from .typesf import (
296
+ AbstractType,
297
+ Type,
298
+ File,
299
+ Files,
300
+ ImageFile,
301
+ ImageFiles,
302
+ image,
303
+ images,
304
+ Reference,
305
+ reference,
306
+ References,
307
+ references,
308
+ Encrypted,
309
+ encrypted,
310
+ secure,
311
+ )
312
+ from .util import (
313
+ to_limit,
314
+ to_find,
315
+ to_sort,
316
+ is_iterable,
317
+ is_mobile,
318
+ is_tablet,
319
+ is_browser,
320
+ is_bot,
321
+ browser_info,
322
+ email_parts,
323
+ email_mime,
324
+ email_name,
325
+ email_base,
326
+ date_to_timestamp,
327
+ obfuscate,
328
+ import_pip,
329
+ ensure_pip,
330
+ install_pip,
331
+ install_pip_s,
332
+ request_json,
333
+ get_context,
334
+ get_object,
335
+ resolve_alias,
336
+ page_types,
337
+ find_types,
338
+ norm_object,
339
+ set_object,
340
+ leafs,
341
+ gather_errors,
342
+ gen_token,
343
+ html_to_text,
344
+ camel_to_underscore,
345
+ camel_to_readable,
346
+ underscore_to_camel,
347
+ underscore_to_readable,
348
+ quote,
349
+ unquote,
350
+ escape,
351
+ unescape,
352
+ count_unescape,
353
+ split_unescape,
354
+ call_safe,
355
+ base_name,
356
+ base_name_m,
357
+ is_content_type,
358
+ parse_content_type,
359
+ parse_cookie,
360
+ parse_multipart,
361
+ decode_params,
362
+ load_form,
363
+ check_login,
364
+ check_user,
365
+ check_token,
366
+ check_tokens,
367
+ ensure_login,
368
+ get_tokens_m,
369
+ to_tokens_m,
370
+ dict_merge,
371
+ deprecated,
372
+ cached,
373
+ private,
374
+ ensure,
375
+ delayed,
376
+ route,
377
+ error_handler,
378
+ exception_handler,
379
+ before_request,
380
+ after_request,
381
+ is_detached,
382
+ sanitize,
383
+ verify,
384
+ verify_equal,
385
+ verify_not_equal,
386
+ verify_type,
387
+ verify_many,
388
+ execute,
389
+ ctx_locale,
390
+ ctx_request,
391
+ FileTuple,
392
+ BaseThread,
393
+ JSONEncoder,
394
+ )
395
+ from .validation import (
396
+ validate,
397
+ validate_b,
398
+ validate_e,
399
+ safe,
400
+ eq,
401
+ gt,
402
+ gte,
403
+ lt,
404
+ lte,
405
+ not_null,
406
+ not_empty,
407
+ not_false,
408
+ is_in,
409
+ is_upper,
410
+ is_lower,
411
+ is_simple,
412
+ is_email,
413
+ is_url,
414
+ is_regex,
415
+ field_eq,
416
+ field_gt,
417
+ field_gte,
418
+ field_lt,
419
+ field_lte,
420
+ string_gt,
421
+ string_lt,
422
+ string_eq,
423
+ equals,
424
+ not_past,
425
+ not_duplicate,
426
+ all_different,
427
+ no_self,
428
+ )
148
429
 
149
430
  from .amqp import get_connection as get_amqp
150
431
  from .amqp import properties as properties_amqp
appier/amqp.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  # Hive Appier Framework
5
- # Copyright (c) 2008-2022 Hive Solutions Lda.
5
+ # Copyright (c) 2008-2024 Hive Solutions Lda.
6
6
  #
7
7
  # This file is part of Hive Appier Framework.
8
8
  #
@@ -22,16 +22,7 @@
22
22
  __author__ = "João Magalhães <joamag@hive.pt>"
23
23
  """ The author(s) of the module """
24
24
 
25
- __version__ = "1.0.0"
26
- """ The version of the module """
27
-
28
- __revision__ = "$LastChangedRevision$"
29
- """ The revision number of the module """
30
-
31
- __date__ = "$LastChangedDate$"
32
- """ The last change date of the module """
33
-
34
- __copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
25
+ __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
35
26
  """ The copyright for the module """
36
27
 
37
28
  __license__ = "Apache License, Version 2.0"
@@ -42,8 +33,10 @@ from . import config
42
33
  from . import legacy
43
34
  from . import exceptions
44
35
 
45
- try: import pika
46
- except ImportError: pika = None
36
+ try:
37
+ import pika
38
+ except ImportError:
39
+ pika = None
47
40
 
48
41
  URL = "amqp://guest:guest@localhost"
49
42
  """ The default URL to be used for the connection when
@@ -58,14 +51,15 @@ connection = None
58
51
  """ The global wide connection to the AMQP server
59
52
  that is meant to be used across sessions """
60
53
 
61
- class AMQP(object):
62
54
 
63
- def __init__(self, url = None):
55
+ class AMQP(object):
56
+ def __init__(self, url=None):
64
57
  self.url = url
65
58
  self._connection = None
66
59
 
67
- def get_connection(self, url = None, timeout = TIMEOUT):
68
- if self._connection: return self._connection
60
+ def get_connection(self, url=None, timeout=TIMEOUT):
61
+ if self._connection:
62
+ return self._connection
69
63
  url_c = config.conf("AMQP_URL", None)
70
64
  url_c = config.conf("CLOUDAMQP_URL", url_c)
71
65
  url_c = config.conf("RABBITMQ_URL", url_c)
@@ -74,34 +68,37 @@ class AMQP(object):
74
68
  username = "guest" if url_p.username == None else url_p.username
75
69
  password = "guest" if url_p.password == None else url_p.password
76
70
  parameters = _pika().ConnectionParameters(
77
- host = url_p.hostname,
78
- virtual_host = url_p.path or "/",
79
- credentials = _pika().PlainCredentials(username, password)
71
+ host=url_p.hostname,
72
+ virtual_host=url_p.path or "/",
73
+ credentials=_pika().PlainCredentials(username, password),
80
74
  )
81
75
  parameters.socket_timeout = timeout
82
76
  self._connection = _pika().BlockingConnection(parameters)
83
77
  self._connection = _set_fixes(self._connection)
84
78
  return self._connection
85
79
 
86
- def get_connection(url = URL, timeout = TIMEOUT):
80
+
81
+ def get_connection(url=URL, timeout=TIMEOUT):
87
82
  global connection
88
83
  url = config.conf("AMQP_URL", url)
89
84
  url = config.conf("CLOUDAMQP_URL", url)
90
85
  url = config.conf("RABBITMQ_URL", url)
91
86
  url_p = legacy.urlparse(url)
92
87
  parameters = _pika().ConnectionParameters(
93
- host = url_p.hostname,
94
- virtual_host = url_p.path or "/",
95
- credentials = _pika().PlainCredentials(url_p.username, url_p.password)
88
+ host=url_p.hostname,
89
+ virtual_host=url_p.path or "/",
90
+ credentials=_pika().PlainCredentials(url_p.username, url_p.password),
96
91
  )
97
92
  parameters.socket_timeout = timeout
98
93
  connection = _pika().BlockingConnection(parameters)
99
94
  connection = _set_fixes(connection)
100
95
  return connection
101
96
 
97
+
102
98
  def properties(*args, **kwargs):
103
99
  return _pika().BasicProperties(*args, **kwargs)
104
100
 
101
+
105
102
  def _set_fixes(connection):
106
103
  def disconnect():
107
104
  connection.socket.close()
@@ -110,10 +107,12 @@ def _set_fixes(connection):
110
107
  connection.disconnect = disconnect
111
108
  return connection
112
109
 
113
- def _pika(verify = True):
114
- if verify: util.verify(
115
- not pika == None,
116
- message = "Pika library not available",
117
- exception = exceptions.OperationalError
118
- )
110
+
111
+ def _pika(verify=True):
112
+ if verify:
113
+ util.verify(
114
+ not pika == None,
115
+ message="Pika library not available",
116
+ exception=exceptions.OperationalError,
117
+ )
119
118
  return pika