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