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/scheduler.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"
@@ -49,6 +40,7 @@ loop between ticks, this value should not be too small
49
40
  to spend many resources or to high to create a long set
50
41
  of time between external interactions """
51
42
 
43
+
52
44
  class Scheduler(threading.Thread):
53
45
  """
54
46
  Scheduler class that handles all the async tasks
@@ -58,11 +50,11 @@ class Scheduler(threading.Thread):
58
50
  new task may be added to it through a queue system.
59
51
  """
60
52
 
61
- def __init__(self, owner, timeout = LOOP_TIMEOUT, daemon = True):
62
- threading.Thread.__init__(self, name = "Scheduler")
53
+ def __init__(self, owner, timeout=LOOP_TIMEOUT, daemon=True):
54
+ threading.Thread.__init__(self, name="Scheduler")
63
55
  self.owner = owner
64
- self.timeout = config.conf("SCHEDULER_TIMEOUT", timeout, cast = float)
65
- self.daemon = config.conf("SCHEDULER_DAEMON", daemon, cast = bool)
56
+ self.timeout = config.conf("SCHEDULER_TIMEOUT", timeout, cast=float)
57
+ self.daemon = config.conf("SCHEDULER_DAEMON", daemon, cast=bool)
66
58
  self._condition = threading.Condition()
67
59
 
68
60
  def run(self):
@@ -75,7 +67,8 @@ class Scheduler(threading.Thread):
75
67
  self.logger.critical("Unhandled scheduler exception raised")
76
68
  self.logger.error(exception)
77
69
  lines = traceback.format_exc().splitlines()
78
- for line in lines: self.logger.warning(line)
70
+ for line in lines:
71
+ self.logger.warning(line)
79
72
  self._condition.acquire()
80
73
  self._condition.wait(self.timeout)
81
74
  self._condition.release()
@@ -96,5 +89,7 @@ class Scheduler(threading.Thread):
96
89
 
97
90
  @property
98
91
  def logger(self):
99
- if self.owner: return self.owner.logger
100
- else: return logging.getLogger()
92
+ if self.owner:
93
+ return self.owner.logger
94
+ else:
95
+ return logging.getLogger()
appier/serialize.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"
@@ -45,25 +36,34 @@ from . import legacy
45
36
  from . import typesf
46
37
  from . import exceptions
47
38
 
39
+
48
40
  def serialize(obj):
49
- if isinstance(obj, model.Model): return obj.model
50
- if isinstance(obj, typesf.AbstractType): return obj.json_v()
51
- if type(obj) == type(None): return ""
41
+ if isinstance(obj, model.Model):
42
+ return obj.model
43
+ if isinstance(obj, typesf.AbstractType):
44
+ return obj.json_v()
45
+ if type(obj) == type(None):
46
+ return ""
52
47
  return legacy.UNICODE(obj)
53
48
 
54
- def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";", strict = False):
49
+
50
+ def serialize_csv(
51
+ items, encoding="utf-8", errors="strict", delimiter=";", strict=False
52
+ ):
55
53
  # verifies if the strict mode is active and there're no items defined
56
54
  # if that's the case an operational error is raised, otherwise an in
57
55
  # case the items are not provided the default (empty string) is returned
58
- if strict and not items: raise exceptions.OperationalError(
59
- message = "Empty items object provided, no keys available"
60
- )
61
- if not items: return str()
56
+ if strict and not items:
57
+ raise exceptions.OperationalError(
58
+ message="Empty items object provided, no keys available"
59
+ )
60
+ if not items:
61
+ return str()
62
62
 
63
63
  # builds the encoder taking into account the provided encoding string
64
64
  # value, this encoder will be used to encode each of the partial values
65
65
  # that is going to be set in the target CSV buffer
66
- encoder = build_encoder(encoding, errors = errors)
66
+ encoder = build_encoder(encoding, errors=errors)
67
67
 
68
68
  # retrieves the first element and uses it to determine if the current
69
69
  # sequence to be serialized is map or sequence based
@@ -76,18 +76,19 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
76
76
  # that in case the sequence is not map based the first element is ignored
77
77
  keys = first.keys() if is_map else first
78
78
  keys = legacy.eager(keys)
79
- if is_map: keys.sort()
80
- else: items = items[1:]
79
+ if is_map:
80
+ keys.sort()
81
+ else:
82
+ items = items[1:]
81
83
 
82
84
  # constructs the first row (names/keys row) using the gathered sequence of keys
83
85
  # and encoding them using the currently build encoder
84
- keys_row = [encoder(key) if type(key) == legacy.UNICODE else\
85
- key for key in keys]
86
+ keys_row = [encoder(key) if type(key) == legacy.UNICODE else key for key in keys]
86
87
 
87
88
  # creates the new string buffer and uses it as the basis for the construction of
88
89
  # the CSV writer object, writing then the already build first row
89
90
  buffer = legacy.StringIO()
90
- writer = csv.writer(buffer, delimiter = delimiter)
91
+ writer = csv.writer(buffer, delimiter=delimiter)
91
92
  writer.writerow(keys_row)
92
93
 
93
94
  # iterates over the complete set of items to serialize each of it's attribute values
@@ -111,7 +112,8 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
111
112
  # them in case they are defined as unicode based values
112
113
  for value in row:
113
114
  is_unicode = isinstance(value, legacy.UNICODE)
114
- if is_unicode: value = encoder(value)
115
+ if is_unicode:
116
+ value = encoder(value)
115
117
  row_e.append(value)
116
118
 
117
119
  # writes the encoded based row sequence to the writer in order to output the
@@ -123,8 +125,9 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
123
125
  result = buffer.getvalue()
124
126
  return result
125
127
 
126
- def serialize_ics(items, encoding = "utf-8", errors = "strict"):
127
- encoder = build_encoder(encoding, errors = errors)
128
+
129
+ def serialize_ics(items, encoding="utf-8", errors="strict"):
130
+ encoder = build_encoder(encoding, errors=errors)
128
131
 
129
132
  buffer = legacy.StringIO()
130
133
  buffer.write("BEGIN:VCALENDAR\r\n")
@@ -165,6 +168,9 @@ def serialize_ics(items, encoding = "utf-8", errors = "strict"):
165
168
  result = buffer.getvalue()
166
169
  return result
167
170
 
168
- def build_encoder(encoding, errors = "strict"):
169
- if legacy.PYTHON_3: return lambda v: v
170
- else: return lambda v: v if v == None else v.encode(encoding, errors = errors)
171
+
172
+ def build_encoder(encoding, errors="strict"):
173
+ if legacy.PYTHON_3:
174
+ return lambda v: v
175
+ else:
176
+ return lambda v: v if v == None else v.encode(encoding, errors=errors)