jaseci 1.4.2.5__py3-none-any.whl → 2.0.0__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.

Potentially problematic release.


This version of jaseci might be problematic. Click here for more details.

Files changed (186) hide show
  1. jaseci/__init__.py +3 -37
  2. jaseci-2.0.0.dist-info/METADATA +65 -0
  3. jaseci-2.0.0.dist-info/RECORD +4 -0
  4. {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
  5. jaseci/VERSION +0 -1
  6. jaseci/cli_tools/__init__.py +0 -0
  7. jaseci/cli_tools/book_tools.py +0 -457
  8. jaseci/cli_tools/jsctl.py +0 -500
  9. jaseci/cli_tools/tests/__init__.py +0 -0
  10. jaseci/cli_tools/tests/test_jsctl.py +0 -556
  11. jaseci/extens/__init__.py +0 -0
  12. jaseci/extens/act_lib/__init__.py +0 -0
  13. jaseci/extens/act_lib/date.py +0 -117
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -76
  16. jaseci/extens/act_lib/file_handler.py +0 -189
  17. jaseci/extens/act_lib/internal.py +0 -18
  18. jaseci/extens/act_lib/jaseci.py +0 -61
  19. jaseci/extens/act_lib/mail.py +0 -10
  20. jaseci/extens/act_lib/maths.py +0 -168
  21. jaseci/extens/act_lib/net.py +0 -191
  22. jaseci/extens/act_lib/rand.py +0 -82
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -169
  25. jaseci/extens/act_lib/std.py +0 -235
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -337
  28. jaseci/extens/act_lib/task.py +0 -13
  29. jaseci/extens/act_lib/tests/__init__.py +0 -0
  30. jaseci/extens/act_lib/tests/std_test_code.py +0 -37
  31. jaseci/extens/act_lib/tests/test_date.py +0 -26
  32. jaseci/extens/act_lib/tests/test_elastic.py +0 -159
  33. jaseci/extens/act_lib/tests/test_file.py +0 -116
  34. jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
  35. jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
  36. jaseci/extens/act_lib/tests/test_maths.py +0 -147
  37. jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
  38. jaseci/extens/act_lib/tests/test_regex.py +0 -61
  39. jaseci/extens/act_lib/tests/test_std.py +0 -51
  40. jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
  41. jaseci/extens/act_lib/tests/test_url.py +0 -32
  42. jaseci/extens/act_lib/tests/test_vector.py +0 -36
  43. jaseci/extens/act_lib/tests/test_webtool.py +0 -44
  44. jaseci/extens/act_lib/tests/test_zlib.py +0 -24
  45. jaseci/extens/act_lib/url.py +0 -79
  46. jaseci/extens/act_lib/vector.py +0 -157
  47. jaseci/extens/act_lib/webtool.py +0 -28
  48. jaseci/extens/act_lib/zip.py +0 -33
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -170
  51. jaseci/extens/api/alias_api.py +0 -139
  52. jaseci/extens/api/architype_api.py +0 -196
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -84
  55. jaseci/extens/api/graph_api.py +0 -167
  56. jaseci/extens/api/health_api.py +0 -20
  57. jaseci/extens/api/interface.py +0 -268
  58. jaseci/extens/api/jac_api.py +0 -171
  59. jaseci/extens/api/jsorc_api.py +0 -316
  60. jaseci/extens/api/logger_api.py +0 -89
  61. jaseci/extens/api/master_api.py +0 -133
  62. jaseci/extens/api/object_api.py +0 -101
  63. jaseci/extens/api/prometheus_api.py +0 -74
  64. jaseci/extens/api/queue_api.py +0 -140
  65. jaseci/extens/api/sentinel_api.py +0 -270
  66. jaseci/extens/api/super_api.py +0 -64
  67. jaseci/extens/api/tests/__init__.py +0 -0
  68. jaseci/extens/api/tests/test_architype_api.py +0 -66
  69. jaseci/extens/api/tests/test_global_api.py +0 -179
  70. jaseci/extens/api/tests/test_graph_api.py +0 -64
  71. jaseci/extens/api/tests/test_logger_api.py +0 -43
  72. jaseci/extens/api/tests/test_object_api.py +0 -20
  73. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  74. jaseci/extens/api/tests/test_uncommon.py +0 -107
  75. jaseci/extens/api/tests/test_user_api.py +0 -32
  76. jaseci/extens/api/tests/test_walker_api.py +0 -316
  77. jaseci/extens/api/user_api.py +0 -144
  78. jaseci/extens/api/walker_api.py +0 -298
  79. jaseci/extens/api/webhook_api.py +0 -74
  80. jaseci/extens/svc/__init__.py +0 -0
  81. jaseci/extens/svc/elastic_svc.py +0 -366
  82. jaseci/extens/svc/kube_svc.py +0 -432
  83. jaseci/extens/svc/mail_svc.py +0 -156
  84. jaseci/extens/svc/prome_svc.py +0 -378
  85. jaseci/extens/svc/redis_svc.py +0 -63
  86. jaseci/extens/svc/storage_svc.py +0 -193
  87. jaseci/extens/svc/stripe_svc.py +0 -51
  88. jaseci/extens/svc/task_svc.py +0 -155
  89. jaseci/extens/svc/tasks.py +0 -302
  90. jaseci/jac/__init__.py +0 -0
  91. jaseci/jac/interpreter/__init__.py +0 -0
  92. jaseci/jac/interpreter/architype_interp.py +0 -214
  93. jaseci/jac/interpreter/interp.py +0 -1783
  94. jaseci/jac/interpreter/sentinel_interp.py +0 -257
  95. jaseci/jac/interpreter/tests/__init__.py +0 -0
  96. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  97. jaseci/jac/interpreter/walker_interp.py +0 -248
  98. jaseci/jac/ir/__init__.py +0 -0
  99. jaseci/jac/ir/ast.py +0 -73
  100. jaseci/jac/ir/ast_builder.py +0 -249
  101. jaseci/jac/ir/jac_code.py +0 -152
  102. jaseci/jac/ir/passes/__init__.py +0 -6
  103. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  104. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  105. jaseci/jac/ir/passes/ir_pass.py +0 -29
  106. jaseci/jac/ir/passes/printer_pass.py +0 -23
  107. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  108. jaseci/jac/ir/passes/schedule.py +0 -23
  109. jaseci/jac/ir/passes/stats_pass.py +0 -16
  110. jaseci/jac/jac.g4 +0 -450
  111. jaseci/jac/jac_parse/__init__.py +0 -0
  112. jaseci/jac/jac_parse/jacLexer.py +0 -809
  113. jaseci/jac/jac_parse/jacListener.py +0 -853
  114. jaseci/jac/jac_parse/jacParser.py +0 -9192
  115. jaseci/jac/jac_set.py +0 -119
  116. jaseci/jac/jsci_vm/__init__.py +0 -0
  117. jaseci/jac/jsci_vm/disasm.py +0 -94
  118. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  119. jaseci/jac/jsci_vm/machine.py +0 -188
  120. jaseci/jac/jsci_vm/op_codes.py +0 -82
  121. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  122. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  123. jaseci/jac/machine/__init__.py +0 -0
  124. jaseci/jac/machine/jac_scope.py +0 -85
  125. jaseci/jac/machine/jac_value.py +0 -226
  126. jaseci/jac/machine/machine_state.py +0 -383
  127. jaseci/jac/tests/__init__.py +0 -0
  128. jaseci/jac/tests/book_code.py +0 -624
  129. jaseci/jac/tests/test_book.py +0 -380
  130. jaseci/jac/tests/test_lang_14.py +0 -49
  131. jaseci/jsorc/__init__.py +0 -7
  132. jaseci/jsorc/jsorc.py +0 -642
  133. jaseci/jsorc/jsorc_settings.py +0 -211
  134. jaseci/jsorc/jsorc_utils.py +0 -298
  135. jaseci/jsorc/live_actions.py +0 -364
  136. jaseci/jsorc/manifests/__init__.py +0 -0
  137. jaseci/jsorc/manifests/database.yaml +0 -109
  138. jaseci/jsorc/manifests/elastic.yaml +0 -6024
  139. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  140. jaseci/jsorc/manifests/redis.yaml +0 -64
  141. jaseci/jsorc/memory.py +0 -258
  142. jaseci/jsorc/redis.py +0 -139
  143. jaseci/jsorc/remote_actions.py +0 -157
  144. jaseci/jsorc/tests/__init__.py +0 -0
  145. jaseci/jsorc/tests/test_actions.py +0 -542
  146. jaseci/jsorc/tests/test_jsorc.py +0 -112
  147. jaseci/prim/__init__.py +0 -0
  148. jaseci/prim/ability.py +0 -93
  149. jaseci/prim/architype.py +0 -89
  150. jaseci/prim/edge.py +0 -172
  151. jaseci/prim/element.py +0 -233
  152. jaseci/prim/graph.py +0 -26
  153. jaseci/prim/master.py +0 -64
  154. jaseci/prim/node.py +0 -532
  155. jaseci/prim/obj_mixins.py +0 -235
  156. jaseci/prim/sentinel.py +0 -281
  157. jaseci/prim/super_master.py +0 -31
  158. jaseci/prim/walker.py +0 -261
  159. jaseci/svc/__init__.py +0 -0
  160. jaseci/tests/__init__.py +0 -0
  161. jaseci/tests/infer.py +0 -39
  162. jaseci/tests/jac_test_code.py +0 -1293
  163. jaseci/tests/jac_test_progs.py +0 -774
  164. jaseci/tests/test_core.py +0 -153
  165. jaseci/tests/test_jac.py +0 -824
  166. jaseci/tests/test_node.py +0 -89
  167. jaseci/tests/test_progs.py +0 -702
  168. jaseci/tests/test_stack.py +0 -220
  169. jaseci/tests/test_stripe.py +0 -225
  170. jaseci/utils/__init__.py +0 -0
  171. jaseci/utils/actions/__init__.py +0 -0
  172. jaseci/utils/actions/actions_manager.py +0 -254
  173. jaseci/utils/actions/actions_optimizer.py +0 -516
  174. jaseci/utils/actions/actions_state.py +0 -95
  175. jaseci/utils/file_handler.py +0 -171
  176. jaseci/utils/gprof2dot.py +0 -3786
  177. jaseci/utils/id_list.py +0 -168
  178. jaseci/utils/json_handler.py +0 -70
  179. jaseci/utils/log_utils.py +0 -57
  180. jaseci/utils/test_core.py +0 -62
  181. jaseci/utils/utils.py +0 -387
  182. jaseci-1.4.2.5.dist-info/LICENSE +0 -21
  183. jaseci-1.4.2.5.dist-info/METADATA +0 -39
  184. jaseci-1.4.2.5.dist-info/RECORD +0 -184
  185. jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
  186. jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
@@ -1,191 +0,0 @@
1
- """
2
- Action library for graph network operations
3
-
4
- This library of actions cover the standard operations that can be
5
- run on graph elements (nodes and edges). A number of these actions
6
- accept lists that are exclusively composed of instances of defined
7
- architype node and/or edges. Keep in mind that a \\lstinline{jac_set}
8
- is simply a list that only contains such elements.
9
- """
10
- from jaseci.jsorc.live_actions import jaseci_action
11
- from jaseci.utils.utils import master_from_meta
12
- from jaseci.jac.jac_set import JacSet
13
- from jaseci.prim.node import Node
14
- from jaseci.prim.edge import Edge
15
- import uuid
16
-
17
-
18
- @jaseci_action()
19
- def max(item_set: JacSet):
20
- """
21
- Max based on anchor value
22
-
23
- This action will return the maximum element in a list of nodes
24
- and/or edges based on an anchor has variable. Since each node or edge can only
25
- specify a single anchor this action enables a handy short hand for utilizing the
26
- anchor variable as the representative field for performing the comparison in
27
- ranking. This action does not support arhcitypes lacking an anchor.
28
- \\par
29
- For example, if you have a node called \\lstinline{movie_review} with a
30
- field \\lstinline{has anchor score = .5;} that changes based on sentiment
31
- analysis, using this action will return the node with the highest score from the
32
- input list of nodes.
33
-
34
- :param item_set: A list of node and or edges to identify the
35
- maximum element based on their respective anchor values
36
- :return: A node or edge object
37
- """
38
- ret = None
39
- if not len(item_set):
40
- return None
41
- items = item_set.obj_list()
42
- max_val = items[0].anchor_value()
43
- ret = items[0]
44
- for i in items:
45
- if i.anchor_value() > max_val:
46
- ret = i
47
- max_val = i.anchor_value()
48
- return ret
49
-
50
-
51
- @jaseci_action()
52
- def min(item_set: JacSet):
53
- """
54
- Min based on anchor value
55
-
56
- This action will return the minimum element in a list of nodes
57
- and/or edges. This action exclusively utilizes the anchor variable
58
- of the node/edge arhcitype as the representative field for
59
- performing the comparison in ranking. This action does not support
60
- arhcitypes lacking an anchor. (see action max for an example)
61
-
62
- :param item_set: A list of node and or edges to identify the
63
- minimum element based on their respective anchor values
64
- :return: A node or edge object
65
- """
66
- ret = None
67
- if not len(item_set):
68
- return None
69
- items = item_set.obj_list()
70
- min_val = items[0].anchor_value()
71
- ret = items[0]
72
- for i in items:
73
- if i.anchor_value() < min_val:
74
- ret = i
75
- min_val = i.anchor_value()
76
- return ret
77
-
78
-
79
- @jaseci_action()
80
- def pack(item_set: JacSet, destroy: bool = False):
81
- """
82
- Convert a subgraph to a generalized dictionary format
83
-
84
- This action takes a subgraph as a collection of nodes in a list and
85
- creates a generic dictionary representation of the subgraph inclusive of
86
- all edges between nodes inside the collection. Note that any edges that are
87
- connecting nodes outside of the list of nodes are omitted from the packed
88
- subgraph representation. The complete context of all nodes and connecting edges
89
- are retained in the packed dictionary format. The unpack action can then be used
90
- to instantiate the identical subgraph back into a graph. Packed graphs are
91
- highly portable and can be used for many use cases such as exporting graphs and
92
- subgraphs to be imported using the unpack action.
93
-
94
- :param item_set: A list of nodes comprising the subgraph to be packed. Edges can be
95
- included in this list but is ultimately ignored. All edges from the actual nodes
96
- in the context of the source graph will be automatically included in the packed
97
- dictionary if it contects two nodes within this input list.
98
- :param destroy: A flag indicating whether the original graph nodes covered by pack
99
- operation should be destroyed.
100
- :returns: A generic and portable dictionary representation of the subgraph
101
- """
102
- graph_dict = {"nodes": [], "edges": []}
103
- idx_map = {}
104
- edge_set = JacSet()
105
- for i in item_set.obj_list():
106
- if isinstance(i, Node):
107
- node_pack = {"name": i.name, "ctx": i.context}
108
- idx_map[i.jid] = len(graph_dict["nodes"])
109
- graph_dict["nodes"].append(node_pack)
110
- for j in i.attached_edges():
111
- edge_set.add_obj(j)
112
- for i in edge_set:
113
- fnd = i.from_node()
114
- tnd = i.to_node()
115
- if fnd.jid in idx_map.keys() and tnd.jid in idx_map.keys():
116
- edge_pack = {
117
- "name": i.name,
118
- "ctx": i.context,
119
- "connect": [idx_map[fnd.jid], idx_map[tnd.jid]],
120
- "bi_dir": i.is_bidirected(),
121
- }
122
- graph_dict["edges"].append(edge_pack)
123
- if destroy:
124
- for i in item_set.obj_list():
125
- if isinstance(i, Node) and i.name != "root":
126
- i.destroy()
127
- return graph_dict
128
-
129
-
130
- @jaseci_action()
131
- def unpack(graph_dict: dict, meta):
132
- """
133
- Convert a packed dictionary to Jac graph elements
134
-
135
- This action takes a dictionary in the format produced by the packed action
136
- to instantiate a set of nodes and edges corresponding to the subgraph represented
137
- by the pack action. The original contexts that were pack will also be created.
138
- Important Note: When using this unpack action, the unpacked collections of elements
139
- returned must be connected to a source graph to avoid memory leaks.
140
-
141
- :param graph_dict: A dictionary in the format produced by the pack action.
142
- :returns: A list of the nodes and edges that were created corresponding to the
143
- input packed format. Note: Must be then connected to a source graph to avoid memory
144
- leak.
145
- """
146
- mast = master_from_meta(meta)
147
- item_set = JacSet()
148
- node_list = []
149
- for i in graph_dict["nodes"]:
150
- node_list.append(
151
- Node(
152
- m_id=mast._m_id,
153
- h=mast._h,
154
- kind="node",
155
- name=i["name"],
156
- )
157
- )
158
- node_list[-1].context = i["ctx"]
159
- item_set.add_obj(node_list[-1])
160
- node_list[-1].save()
161
- for i in graph_dict["edges"]:
162
- this_edge = Edge(
163
- m_id=mast._m_id,
164
- h=mast._h,
165
- kind="edge",
166
- name=i["name"],
167
- )
168
- this_edge.connect(
169
- node_list[i["connect"][0]], node_list[i["connect"][1]], i["bi_dir"]
170
- )
171
- item_set.add_obj(this_edge)
172
- this_edge.save()
173
- return item_set
174
-
175
-
176
- @jaseci_action()
177
- def root(meta):
178
- """
179
- Returns a user's root node
180
-
181
- This action returns the root node for the graph of a given user (master). A call
182
- to this action is only valid if the user has an active graph set, otherwise it
183
- return null. This is a handy way for any walker to get to the root node of a
184
- graph from anywhere.
185
-
186
- :returns: The root node of the active graph for a user. If none set, returns null.
187
- """
188
- mast = master_from_meta(meta)
189
- if mast.active_gph_id:
190
- return mast._h.get_obj(mast._m_id, mast.active_gph_id)
191
- return None
@@ -1,82 +0,0 @@
1
- """Built in actions for Jaseci"""
2
- import random
3
-
4
- # import faker
5
- from datetime import datetime
6
- from datetime import timedelta
7
- from jaseci.jsorc.live_actions import jaseci_action
8
-
9
- lorem_words = (
10
- "adipisci aliquam amet consectetur dolor dolore dolorem eius "
11
- "est et incidunt ipsum labore magnam modi neque non numquam "
12
- "porro quaerat qui quia quisquam sed sit tempora ut velit "
13
- "voluptatem"
14
- ).split()
15
-
16
-
17
- @jaseci_action()
18
- def seed(val: int):
19
- """Seed random num generator"""
20
- random.seed(val, version=2)
21
- # faker.Faker.seed(param_list[0])
22
-
23
-
24
- @jaseci_action()
25
- def integer(start: int, end: int):
26
- """Random integeter between range"""
27
- return random.randint(start, end)
28
-
29
-
30
- @jaseci_action()
31
- def choice(lst: list):
32
- """Random select and return item in list"""
33
- return random.choice(lst)
34
-
35
-
36
- @jaseci_action()
37
- def uniform(low: float, high: float):
38
- """Random select a float between low an high"""
39
- return random.uniform(low, high)
40
-
41
-
42
- @jaseci_action()
43
- def sentence(min_lenth: int = 4, max_length: int = 10, sep: str = " "):
44
- """Get a random sentence"""
45
- n = random.randint(min_lenth, max_length)
46
- s = sep.join(word() for _ in range(n))
47
- return s[0].upper() + s[1:] + "."
48
-
49
-
50
- @jaseci_action()
51
- def paragraph(min_lenth: int = 4, max_length: int = 8, sep: str = " "):
52
- """Get a random paragraph"""
53
- n = random.randint(min_lenth, max_length)
54
- p = sep.join(sentence() for _ in range(n))
55
- return p
56
-
57
-
58
- @jaseci_action()
59
- def text(min_lenth: int = 3, max_length: int = 6, sep: str = "\n\n"):
60
- """Get a random text"""
61
- n = random.randint(min_lenth, max_length)
62
- t = sep.join(paragraph() for _ in range(n))
63
- return t
64
-
65
-
66
- @jaseci_action()
67
- def word():
68
- """Get a random sentence"""
69
- return random.choice(lorem_words)
70
-
71
-
72
- @jaseci_action()
73
- def time(start_date: str, end_date: str):
74
- """Provide a random datetime between range"""
75
- start = datetime.fromisoformat(start_date)
76
- end = datetime.fromisoformat(end_date)
77
- return (
78
- start
79
- + timedelta(
80
- seconds=random.randint(0, int((end - start).total_seconds())),
81
- )
82
- ).isoformat()
@@ -1,85 +0,0 @@
1
- import re
2
-
3
- from jaseci.jsorc.live_actions import jaseci_action
4
-
5
-
6
- def compile(pattern: str, flags=0):
7
- return re.compile(pattern=pattern, flags=flags)
8
-
9
-
10
- @jaseci_action()
11
- def findall(pattern: str, string: str, flags=0):
12
- return re.findall(pattern=pattern, string=string, flags=flags)
13
-
14
-
15
- @jaseci_action()
16
- def search(pattern: str, string: str, flags=0):
17
- m = re.search(pattern=pattern, string=string, flags=flags)
18
- if m:
19
- span = m.span()
20
- match = m.group()
21
- return {"span": span, "match": match}
22
- else:
23
- return None
24
-
25
-
26
- @jaseci_action()
27
- def match(pattern: str, string: str, flags=0):
28
- m = re.match(pattern=pattern, string=string, flags=flags)
29
- if m:
30
- span = m.span()
31
- match = m.group()
32
- return {"span": span, "match": match}
33
- else:
34
- return None
35
-
36
-
37
- @jaseci_action()
38
- def fullmatch(pattern: str, string: str, flags=0):
39
- m = re.fullmatch(pattern=pattern, string=string, flags=flags)
40
- if m:
41
- span = m.span()
42
- match = m.group()
43
- return {"span": span, "match": match}
44
- else:
45
- return None
46
-
47
-
48
- @jaseci_action()
49
- def split(pattern: str, string: str, maxsplit=0, flags=0):
50
- return re.split(pattern=pattern, string=string, maxsplit=maxsplit, flags=flags)
51
-
52
-
53
- @jaseci_action()
54
- def finditer(pattern: str, string: str, flags=0):
55
- iter = re.finditer(pattern, string, flags=0)
56
- ret_list = []
57
- for item in iter:
58
- dicta = {"span": item.span(), "match": item.group()}
59
- ret_list.append(dicta)
60
-
61
- return ret_list
62
-
63
-
64
- @jaseci_action()
65
- def sub(pattern: str, replace: str, string: str, count=0, flags=0):
66
- return re.sub(
67
- pattern=pattern, repl=replace, string=string, count=count, flags=flags
68
- )
69
-
70
-
71
- @jaseci_action()
72
- def subn(pattern: str, replace: str, string: str, count=0, flags=0):
73
- return list(
74
- re.subn(pattern=pattern, repl=replace, string=string, count=count, flags=flags)
75
- )
76
-
77
-
78
- @jaseci_action()
79
- def escape(pattern: str):
80
- return re.escape(pattern=pattern)
81
-
82
-
83
- @jaseci_action()
84
- def purge():
85
- return re.purge()
@@ -1,169 +0,0 @@
1
- """Built in actions for Jaseci"""
2
- import requests
3
- from jaseci.jsorc.live_actions import jaseci_action
4
-
5
-
6
- @jaseci_action()
7
- def get(url: str, data: dict = {}, header: dict = {}):
8
- """
9
- Issue request
10
- Param 1 - url
11
- Param 2 - data
12
- Param 3 - header
13
-
14
- Return - response object
15
- """
16
- res = requests.get(url, json=data, headers=header)
17
- ret = {"status_code": res.status_code}
18
- try:
19
- ret["response"] = res.json()
20
- except Exception:
21
- ret["response"] = res.text
22
- return ret
23
-
24
-
25
- @jaseci_action()
26
- def post(url: str, data: dict = {}, header: dict = {}):
27
- """
28
- Issue request
29
- Param 1 - url
30
- Param 2 - data
31
- Param 3 - header
32
-
33
- Return - response object
34
- """
35
- res = requests.post(url, json=data, headers=header)
36
- ret = {"status_code": res.status_code}
37
- try:
38
- ret["response"] = res.json()
39
- except Exception:
40
- ret["response"] = res.text
41
- return ret
42
-
43
-
44
- @jaseci_action()
45
- def put(url: str, data: dict = {}, header: dict = {}):
46
- """
47
- Issue request
48
- Param 1 - url
49
- Param 2 - data
50
- Param 3 - header
51
-
52
- Return - response object
53
- """
54
- res = requests.put(url, json=data, headers=header)
55
- ret = {"status_code": res.status_code}
56
- try:
57
- ret["response"] = res.json()
58
- except Exception:
59
- ret["response"] = res.text
60
- return ret
61
-
62
-
63
- @jaseci_action()
64
- def delete(url: str, data: dict = {}, header: dict = {}):
65
- """
66
- Issue request
67
- Param 1 - url
68
- Param 2 - data
69
- Param 3 - header
70
-
71
- Return - response object
72
- """
73
- res = requests.delete(url, json=data, headers=header)
74
- ret = {"status_code": res.status_code}
75
- try:
76
- ret["response"] = res.json()
77
- except Exception:
78
- ret["response"] = res.text
79
- return ret
80
-
81
-
82
- @jaseci_action()
83
- def head(url: str, data: dict = {}, header: dict = {}):
84
- """
85
- Issue request
86
- Param 1 - url
87
- Param 2 - data
88
- Param 3 - header
89
-
90
- Return - response object
91
- """
92
- res = requests.head(url, json=data, headers=header)
93
- ret = {"status_code": res.status_code}
94
- try:
95
- ret["response"] = res.json()
96
- except Exception:
97
- ret["response"] = res.text
98
- return ret
99
-
100
-
101
- @jaseci_action()
102
- def options(url: str, data: dict = {}, header: dict = {}):
103
- """
104
- Issue request
105
- Param 1 - url
106
- Param 2 - data
107
- Param 3 - header
108
-
109
- Return - response object
110
- """
111
- res = requests.options(url, json=data, headers=header)
112
- ret = {"status_code": res.status_code}
113
- try:
114
- ret["response"] = res.json()
115
- except Exception:
116
- ret["response"] = res.text
117
- return ret
118
-
119
-
120
- @jaseci_action()
121
- def multipart(
122
- url: str, data: dict = {}, files: list = [], header: dict = {}, meta: dict = {}
123
- ):
124
- """
125
- Issue request
126
- Param 1 - url
127
- Param 2 - data (Optional) used for request body
128
- Param 3 - files (Optional) used for request files
129
- Param 4 - header
130
-
131
- Return - response object
132
- """
133
-
134
- hook = meta["h"]
135
-
136
- if not files:
137
- return {
138
- "status_code": 400,
139
- "error": "Please include base64 using this format "
140
- '{"field":val,"name":val,"base64":val} '
141
- "using parameter `file` and `files` for array file",
142
- }
143
-
144
- _files = []
145
- stream_to_be_close = []
146
-
147
- if files is not None:
148
- for f in files:
149
- file_handler = hook.get_file_handler(f)
150
- stream = file_handler.open("rb", None, True)
151
- stream_to_be_close.append(stream)
152
- _files.append(
153
- (
154
- file_handler.field or "file",
155
- (file_handler.name, stream, file_handler.content_type),
156
- )
157
- )
158
-
159
- res = requests.post(url, data=data, files=_files, headers=header)
160
- ret = {"status_code": res.status_code}
161
- try:
162
- ret["response"] = res.json()
163
- except Exception:
164
- ret["response"] = res.text
165
-
166
- for stream in stream_to_be_close:
167
- stream.close()
168
-
169
- return ret