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/extra.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,20 +22,13 @@
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"
38
29
  """ The license for the module """
39
30
 
40
- from .extra_old import * #@UnusedWildImport
41
- if asynchronous.is_neo(): from .extra_neo import * #@UnusedWildImport
31
+ from .extra_old import * # @UnusedWildImport
32
+
33
+ if asynchronous.is_neo():
34
+ from .extra_neo import * # @UnusedWildImport
appier/extra_neo.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"
@@ -40,31 +31,37 @@ __license__ = "Apache License, Version 2.0"
40
31
  from . import http
41
32
  from . import asynchronous
42
33
 
34
+
43
35
  def get_a(*args, **kwargs):
44
36
  kwargs["async"] = True
45
37
  value = yield from asynchronous.to_coroutine(http.get, *args, **kwargs)
46
38
  return value
47
39
 
40
+
48
41
  def post_a(*args, **kwargs):
49
42
  kwargs["async"] = True
50
43
  value = yield from asynchronous.to_coroutine(http.post, *args, **kwargs)
51
44
  return value
52
45
 
46
+
53
47
  def put_a(*args, **kwargs):
54
48
  kwargs["async"] = True
55
49
  value = yield from asynchronous.to_coroutine(http.put, *args, **kwargs)
56
50
  return value
57
51
 
52
+
58
53
  def delete_a(*args, **kwargs):
59
54
  kwargs["async"] = True
60
55
  value = yield from asynchronous.to_coroutine(http.delete, *args, **kwargs)
61
56
  return value
62
57
 
58
+
63
59
  def patch_a(*args, **kwargs):
64
60
  kwargs["async"] = True
65
61
  value = yield from asynchronous.to_coroutine(http.patch, *args, **kwargs)
66
62
  return value
67
63
 
64
+
68
65
  get_w = lambda *args, **kwargs: asynchronous.await_wrap(get_a(*args, **kwargs))
69
66
  post_w = lambda *args, **kwargs: asynchronous.await_wrap(post_w(*args, **kwargs))
70
67
  put_w = lambda *args, **kwargs: asynchronous.await_wrap(put_w(*args, **kwargs))
appier/extra_old.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"
@@ -40,25 +31,36 @@ __license__ = "Apache License, Version 2.0"
40
31
  from . import http
41
32
  from . import asynchronous
42
33
 
34
+
43
35
  def get_a(*args, **kwargs):
44
36
  kwargs["async"] = True
45
- for value in asynchronous.to_coroutine(http.get, *args, **kwargs): yield value
37
+ for value in asynchronous.to_coroutine(http.get, *args, **kwargs):
38
+ yield value
39
+
46
40
 
47
41
  def post_a(*args, **kwargs):
48
42
  kwargs["async"] = True
49
- for value in asynchronous.to_coroutine(http.post, *args, **kwargs): yield value
43
+ for value in asynchronous.to_coroutine(http.post, *args, **kwargs):
44
+ yield value
45
+
50
46
 
51
47
  def put_a(*args, **kwargs):
52
48
  kwargs["async"] = True
53
- for value in asynchronous.to_coroutine(http.put, *args, **kwargs): yield value
49
+ for value in asynchronous.to_coroutine(http.put, *args, **kwargs):
50
+ yield value
51
+
54
52
 
55
53
  def delete_a(*args, **kwargs):
56
54
  kwargs["async"] = True
57
- for value in asynchronous.to_coroutine(http.delete, *args, **kwargs): yield value
55
+ for value in asynchronous.to_coroutine(http.delete, *args, **kwargs):
56
+ yield value
57
+
58
58
 
59
59
  def patch_a(*args, **kwargs):
60
60
  kwargs["async"] = True
61
- for value in asynchronous.to_coroutine(http.patch, *args, **kwargs): yield value
61
+ for value in asynchronous.to_coroutine(http.patch, *args, **kwargs):
62
+ yield value
63
+
62
64
 
63
65
  get_w = None
64
66
  post_w = None
appier/geo.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,8 +36,8 @@ from . import http
45
36
  from . import util
46
37
  from . import legacy
47
38
 
48
- class GeoResolver(object):
49
39
 
40
+ class GeoResolver(object):
50
41
  DB_NAME = "GeoLite2-City.mmdb"
51
42
  """ The name of the file that contains the GeoIP
52
43
  information database (to be used in execution) """
@@ -69,19 +60,24 @@ class GeoResolver(object):
69
60
  that is going to be used in the GeoIP resolution """
70
61
 
71
62
  @classmethod
72
- def resolve(cls, address, simplified = True):
63
+ def resolve(cls, address, simplified=True):
73
64
  db = cls._get_db()
74
- if not db: return None
65
+ if not db:
66
+ return None
75
67
  result = db.get(address)
76
- if simplified: result = cls._simplify(result)
68
+ if simplified:
69
+ result = cls._simplify(result)
77
70
  return result
78
71
 
79
72
  @classmethod
80
- def _simplify(cls, result, locale = "en", valid = VALID):
81
- if not result: return result
73
+ def _simplify(cls, result, locale="en", valid=VALID):
74
+ if not result:
75
+ return result
82
76
  for name, value in legacy.items(result):
83
- if not name in valid: del result[name]
84
- if not "names" in value: continue
77
+ if not name in valid:
78
+ del result[name]
79
+ if not "names" in value:
80
+ continue
85
81
  names = value["names"]
86
82
  value["name"] = names.get(locale, None)
87
83
  del value["names"]
@@ -89,62 +85,76 @@ class GeoResolver(object):
89
85
 
90
86
  @classmethod
91
87
  def _get_db(cls):
92
- if cls._db: return cls._db
88
+ if cls._db:
89
+ return cls._db
93
90
  maxminddb = util.import_pip("maxminddb")
94
- if not maxminddb: return None
91
+ if not maxminddb:
92
+ return None
95
93
  path = cls._try_all()
96
- if not path: return None
94
+ if not path:
95
+ return None
97
96
  cls._db = maxminddb.open_database(path)
98
97
  return cls._db
99
98
 
100
99
  @classmethod
101
- def _try_all(cls, prefixes = PREFIXES):
100
+ def _try_all(cls, prefixes=PREFIXES):
102
101
  for prefix in cls.PREFIXES:
103
- path = cls._try_db(path = prefix + cls.DB_NAME)
104
- if path: return path
105
- path = cls._try_db(path = cls.DB_NAME, download = True)
106
- if path: return path
102
+ path = cls._try_db(path=prefix + cls.DB_NAME)
103
+ if path:
104
+ return path
105
+ path = cls._try_db(path=cls.DB_NAME, download=True)
106
+ if path:
107
+ return path
107
108
  return None
108
109
 
109
110
  @classmethod
110
- def _try_db(cls, path = DB_NAME, download = False):
111
+ def _try_db(cls, path=DB_NAME, download=False):
111
112
  path = os.path.expanduser(path)
112
113
  path = os.path.normpath(path)
113
114
  exists = os.path.exists(path)
114
- if exists: return path
115
- if not download: return None
116
- cls._download_db(path = path)
115
+ if exists:
116
+ return path
117
+ if not download:
118
+ return None
119
+ cls._download_db(path=path)
117
120
  exists = os.path.exists(path)
118
- if not exists: return None
121
+ if not exists:
122
+ return None
119
123
  return path
120
124
 
121
125
  @classmethod
122
- def _download_db(cls, path = DB_NAME):
126
+ def _download_db(cls, path=DB_NAME):
123
127
  contents = http.get(cls.DOWNLOAD_URL)
124
- cls._store_db(contents, path = path)
128
+ cls._store_db(contents, path=path)
125
129
 
126
130
  @classmethod
127
- def _store_db(cls, contents, path = DB_NAME):
131
+ def _store_db(cls, contents, path=DB_NAME):
128
132
  path_gz = path + ".gz"
129
133
  file = open(path_gz, "wb")
130
- try: file.write(contents)
131
- finally: file.close()
134
+ try:
135
+ file.write(contents)
136
+ finally:
137
+ file.close()
132
138
  file = gzip.open(path_gz, "rb")
133
- try: contents = file.read()
134
- finally: file.close()
139
+ try:
140
+ contents = file.read()
141
+ finally:
142
+ file.close()
135
143
  file = open(path, "wb")
136
- try: file.write(contents)
137
- finally: file.close()
144
+ try:
145
+ file.write(contents)
146
+ finally:
147
+ file.close()
138
148
  os.remove(path_gz)
139
149
  return path
140
150
 
151
+
141
152
  if __name__ == "__main__":
142
153
  prefix = "~/"
143
- if len(sys.argv) > 1: prefix = sys.argv[1]
144
- if not prefix.endswith("/"): prefix += "/"
145
- GeoResolver._try_db(
146
- path = prefix + GeoResolver.DB_NAME,
147
- download = True
148
- )
154
+ if len(sys.argv) > 1:
155
+ prefix = sys.argv[1]
156
+ if not prefix.endswith("/"):
157
+ prefix += "/"
158
+ GeoResolver._try_db(path=prefix + GeoResolver.DB_NAME, download=True)
149
159
  else:
150
160
  __path__ = []