deepfos 1.1.60__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 (175) hide show
  1. deepfos/__init__.py +6 -0
  2. deepfos/_version.py +21 -0
  3. deepfos/algo/__init__.py +0 -0
  4. deepfos/algo/graph.py +171 -0
  5. deepfos/algo/segtree.py +31 -0
  6. deepfos/api/V1_1/__init__.py +0 -0
  7. deepfos/api/V1_1/business_model.py +119 -0
  8. deepfos/api/V1_1/dimension.py +599 -0
  9. deepfos/api/V1_1/models/__init__.py +0 -0
  10. deepfos/api/V1_1/models/business_model.py +1033 -0
  11. deepfos/api/V1_1/models/dimension.py +2768 -0
  12. deepfos/api/V1_2/__init__.py +0 -0
  13. deepfos/api/V1_2/dimension.py +285 -0
  14. deepfos/api/V1_2/models/__init__.py +0 -0
  15. deepfos/api/V1_2/models/dimension.py +2923 -0
  16. deepfos/api/__init__.py +0 -0
  17. deepfos/api/account.py +167 -0
  18. deepfos/api/accounting_engines.py +147 -0
  19. deepfos/api/app.py +626 -0
  20. deepfos/api/approval_process.py +198 -0
  21. deepfos/api/base.py +983 -0
  22. deepfos/api/business_model.py +160 -0
  23. deepfos/api/consolidation.py +129 -0
  24. deepfos/api/consolidation_process.py +106 -0
  25. deepfos/api/datatable.py +341 -0
  26. deepfos/api/deep_pipeline.py +61 -0
  27. deepfos/api/deepconnector.py +36 -0
  28. deepfos/api/deepfos_task.py +92 -0
  29. deepfos/api/deepmodel.py +188 -0
  30. deepfos/api/dimension.py +486 -0
  31. deepfos/api/financial_model.py +319 -0
  32. deepfos/api/journal_model.py +119 -0
  33. deepfos/api/journal_template.py +132 -0
  34. deepfos/api/memory_financial_model.py +98 -0
  35. deepfos/api/models/__init__.py +3 -0
  36. deepfos/api/models/account.py +483 -0
  37. deepfos/api/models/accounting_engines.py +756 -0
  38. deepfos/api/models/app.py +1338 -0
  39. deepfos/api/models/approval_process.py +1043 -0
  40. deepfos/api/models/base.py +234 -0
  41. deepfos/api/models/business_model.py +805 -0
  42. deepfos/api/models/consolidation.py +711 -0
  43. deepfos/api/models/consolidation_process.py +248 -0
  44. deepfos/api/models/datatable_mysql.py +427 -0
  45. deepfos/api/models/deep_pipeline.py +55 -0
  46. deepfos/api/models/deepconnector.py +28 -0
  47. deepfos/api/models/deepfos_task.py +386 -0
  48. deepfos/api/models/deepmodel.py +308 -0
  49. deepfos/api/models/dimension.py +1576 -0
  50. deepfos/api/models/financial_model.py +1796 -0
  51. deepfos/api/models/journal_model.py +341 -0
  52. deepfos/api/models/journal_template.py +854 -0
  53. deepfos/api/models/memory_financial_model.py +478 -0
  54. deepfos/api/models/platform.py +178 -0
  55. deepfos/api/models/python.py +221 -0
  56. deepfos/api/models/reconciliation_engine.py +411 -0
  57. deepfos/api/models/reconciliation_report.py +161 -0
  58. deepfos/api/models/role_strategy.py +884 -0
  59. deepfos/api/models/smartlist.py +237 -0
  60. deepfos/api/models/space.py +1137 -0
  61. deepfos/api/models/system.py +1065 -0
  62. deepfos/api/models/variable.py +463 -0
  63. deepfos/api/models/workflow.py +946 -0
  64. deepfos/api/platform.py +199 -0
  65. deepfos/api/python.py +90 -0
  66. deepfos/api/reconciliation_engine.py +181 -0
  67. deepfos/api/reconciliation_report.py +64 -0
  68. deepfos/api/role_strategy.py +234 -0
  69. deepfos/api/smartlist.py +69 -0
  70. deepfos/api/space.py +582 -0
  71. deepfos/api/system.py +372 -0
  72. deepfos/api/variable.py +154 -0
  73. deepfos/api/workflow.py +264 -0
  74. deepfos/boost/__init__.py +6 -0
  75. deepfos/boost/py_jstream.py +89 -0
  76. deepfos/boost/py_pandas.py +20 -0
  77. deepfos/cache.py +121 -0
  78. deepfos/config.py +6 -0
  79. deepfos/core/__init__.py +27 -0
  80. deepfos/core/cube/__init__.py +10 -0
  81. deepfos/core/cube/_base.py +462 -0
  82. deepfos/core/cube/constants.py +21 -0
  83. deepfos/core/cube/cube.py +408 -0
  84. deepfos/core/cube/formula.py +707 -0
  85. deepfos/core/cube/syscube.py +532 -0
  86. deepfos/core/cube/typing.py +7 -0
  87. deepfos/core/cube/utils.py +238 -0
  88. deepfos/core/dimension/__init__.py +11 -0
  89. deepfos/core/dimension/_base.py +506 -0
  90. deepfos/core/dimension/dimcreator.py +184 -0
  91. deepfos/core/dimension/dimension.py +472 -0
  92. deepfos/core/dimension/dimexpr.py +271 -0
  93. deepfos/core/dimension/dimmember.py +155 -0
  94. deepfos/core/dimension/eledimension.py +22 -0
  95. deepfos/core/dimension/filters.py +99 -0
  96. deepfos/core/dimension/sysdimension.py +168 -0
  97. deepfos/core/logictable/__init__.py +5 -0
  98. deepfos/core/logictable/_cache.py +141 -0
  99. deepfos/core/logictable/_operator.py +663 -0
  100. deepfos/core/logictable/nodemixin.py +673 -0
  101. deepfos/core/logictable/sqlcondition.py +609 -0
  102. deepfos/core/logictable/tablemodel.py +497 -0
  103. deepfos/db/__init__.py +36 -0
  104. deepfos/db/cipher.py +660 -0
  105. deepfos/db/clickhouse.py +191 -0
  106. deepfos/db/connector.py +195 -0
  107. deepfos/db/daclickhouse.py +171 -0
  108. deepfos/db/dameng.py +101 -0
  109. deepfos/db/damysql.py +189 -0
  110. deepfos/db/dbkits.py +358 -0
  111. deepfos/db/deepengine.py +99 -0
  112. deepfos/db/deepmodel.py +82 -0
  113. deepfos/db/deepmodel_kingbase.py +83 -0
  114. deepfos/db/edb.py +214 -0
  115. deepfos/db/gauss.py +83 -0
  116. deepfos/db/kingbase.py +83 -0
  117. deepfos/db/mysql.py +184 -0
  118. deepfos/db/oracle.py +131 -0
  119. deepfos/db/postgresql.py +192 -0
  120. deepfos/db/sqlserver.py +99 -0
  121. deepfos/db/utils.py +135 -0
  122. deepfos/element/__init__.py +89 -0
  123. deepfos/element/accounting.py +348 -0
  124. deepfos/element/apvlprocess.py +215 -0
  125. deepfos/element/base.py +398 -0
  126. deepfos/element/bizmodel.py +1269 -0
  127. deepfos/element/datatable.py +2467 -0
  128. deepfos/element/deep_pipeline.py +186 -0
  129. deepfos/element/deepconnector.py +59 -0
  130. deepfos/element/deepmodel.py +1806 -0
  131. deepfos/element/dimension.py +1254 -0
  132. deepfos/element/fact_table.py +427 -0
  133. deepfos/element/finmodel.py +1485 -0
  134. deepfos/element/journal.py +840 -0
  135. deepfos/element/journal_template.py +943 -0
  136. deepfos/element/pyscript.py +412 -0
  137. deepfos/element/reconciliation.py +553 -0
  138. deepfos/element/rolestrategy.py +243 -0
  139. deepfos/element/smartlist.py +457 -0
  140. deepfos/element/variable.py +756 -0
  141. deepfos/element/workflow.py +560 -0
  142. deepfos/exceptions/__init__.py +239 -0
  143. deepfos/exceptions/hook.py +86 -0
  144. deepfos/lazy.py +104 -0
  145. deepfos/lazy_import.py +84 -0
  146. deepfos/lib/__init__.py +0 -0
  147. deepfos/lib/_javaobj.py +366 -0
  148. deepfos/lib/asynchronous.py +879 -0
  149. deepfos/lib/concurrency.py +107 -0
  150. deepfos/lib/constant.py +39 -0
  151. deepfos/lib/decorator.py +310 -0
  152. deepfos/lib/deepchart.py +778 -0
  153. deepfos/lib/deepux.py +477 -0
  154. deepfos/lib/discovery.py +273 -0
  155. deepfos/lib/edb_lexer.py +789 -0
  156. deepfos/lib/eureka.py +156 -0
  157. deepfos/lib/filterparser.py +751 -0
  158. deepfos/lib/httpcli.py +106 -0
  159. deepfos/lib/jsonstreamer.py +80 -0
  160. deepfos/lib/msg.py +394 -0
  161. deepfos/lib/nacos.py +225 -0
  162. deepfos/lib/patch.py +92 -0
  163. deepfos/lib/redis.py +241 -0
  164. deepfos/lib/serutils.py +181 -0
  165. deepfos/lib/stopwatch.py +99 -0
  166. deepfos/lib/subtask.py +572 -0
  167. deepfos/lib/sysutils.py +703 -0
  168. deepfos/lib/utils.py +1003 -0
  169. deepfos/local.py +160 -0
  170. deepfos/options.py +670 -0
  171. deepfos/translation.py +237 -0
  172. deepfos-1.1.60.dist-info/METADATA +33 -0
  173. deepfos-1.1.60.dist-info/RECORD +175 -0
  174. deepfos-1.1.60.dist-info/WHEEL +5 -0
  175. deepfos-1.1.60.dist-info/top_level.txt +1 -0
@@ -0,0 +1,366 @@
1
+ import enum
2
+ import os
3
+ import struct
4
+ from io import BytesIO
5
+
6
+ from loguru import logger
7
+
8
+
9
+ # Magic bytes of any serialized files
10
+ STREAM_MAGIC = 0xACED
11
+
12
+ # Only protocol version supported by javaobj
13
+ STREAM_VERSION = 0x05
14
+
15
+
16
+ def is_java_serialized(input_stream: bytes) -> bool:
17
+ """判断是否为java序列化后的值
18
+
19
+ Args:
20
+ input_stream: 需判断的值
21
+
22
+ Returns:
23
+ bool
24
+
25
+ """
26
+ input_stream = BytesIO(input_stream)
27
+
28
+ length = struct.calcsize(">HH")
29
+ ba = input_stream.read(length)
30
+
31
+ if len(ba) != length:
32
+ return False
33
+
34
+ (magic, version) = struct.unpack(">HH", ba)
35
+
36
+ if magic != STREAM_MAGIC or version != STREAM_VERSION:
37
+ return False
38
+
39
+ return True
40
+
41
+
42
+ def to_str(data, encoding="UTF-8"):
43
+ """
44
+ Converts the given parameter to a string.
45
+ Returns the first parameter if it is already an instance of ``str``.
46
+
47
+ Args:
48
+ data: A string
49
+ encoding: The encoding of data
50
+
51
+ Returns:
52
+ The corresponding string
53
+
54
+ """
55
+ if isinstance(data, str):
56
+ # Nothing to do
57
+ return data
58
+
59
+ return str(data, encoding)
60
+
61
+
62
+ def hexdump(src: bytes, start_offset: int = 0, length: int = 16) -> str:
63
+ """
64
+ Prepares an hexadecimal dump string
65
+
66
+ Args:
67
+ src: A string containing binary data
68
+ start_offset: The start offset of the source
69
+ length: Length of a dump line
70
+
71
+ Returns:
72
+ A dump string
73
+
74
+ """
75
+ hex_filter = "".join(
76
+ (len(repr(chr(x))) == 3) and chr(x) or "." for x in range(256)
77
+ )
78
+ pattern = "{{0:04X}} {{1:<{0}}} {{2}}\n".format(length * 3)
79
+
80
+ # Convert raw data to str (Python 3 compatibility)
81
+ src = to_str(src, "latin-1")
82
+
83
+ result = []
84
+ for i in range(0, len(src), length):
85
+ s = src[i: i + length]
86
+ hexa = " ".join("{0:02X}".format(ord(x)) for x in s)
87
+ printable = s.translate(hex_filter)
88
+ result.append(pattern.format(i + start_offset, hexa, printable))
89
+ return "".join(result)
90
+
91
+
92
+ class StreamCodeDebug:
93
+ """
94
+ Codes utility methods
95
+ """
96
+
97
+ @staticmethod
98
+ def op_id(op_id: int) -> str:
99
+ """
100
+ Returns the name of the given OP Code
101
+
102
+ Args:
103
+ op_id: OP Code
104
+
105
+ Returns:
106
+ Name of the OP Code
107
+ """
108
+ try:
109
+ return TerminalCode(op_id).name
110
+ except ValueError:
111
+ return "<unknown TC:{0}>".format(op_id)
112
+
113
+
114
+ class TerminalCode(enum.IntEnum):
115
+ """
116
+ Stream type Codes
117
+ """
118
+
119
+ TC_NULL = 0x70
120
+ TC_STRING = 0x74
121
+ TC_ENDBLOCKDATA = 0x78
122
+ TC_LONGSTRING = 0x7C
123
+
124
+
125
+ class TypeCode(enum.IntEnum):
126
+ """
127
+ Type definition chars (typecode)
128
+ """
129
+
130
+ # Primitive types
131
+ TYPE_BYTE = ord("B") # 0x42
132
+ TYPE_CHAR = ord("C") # 0x43
133
+ TYPE_DOUBLE = ord("D") # 0x44
134
+ TYPE_FLOAT = ord("F") # 0x46
135
+ TYPE_INTEGER = ord("I") # 0x49
136
+ TYPE_LONG = ord("J") # 0x4A
137
+ TYPE_SHORT = ord("S") # 0x53
138
+ TYPE_BOOLEAN = ord("Z") # 0x5A
139
+ # Object types
140
+ TYPE_OBJECT = ord("L") # 0x4C
141
+ TYPE_ARRAY = ord("[") # 0x5B
142
+
143
+
144
+ class JavaString(str):
145
+ """
146
+ Represents a Java String
147
+ """
148
+
149
+ def __hash__(self):
150
+ return str.__hash__(self)
151
+
152
+ def __eq__(self, other):
153
+ if not isinstance(other, str):
154
+ return False
155
+ return str.__eq__(self, other)
156
+
157
+
158
+ class JavaDeSerializeHelper:
159
+ """
160
+ Deserializes a Java serialization stream
161
+ """
162
+
163
+ def __init__(self, stream: bytes, encoding: str):
164
+ """
165
+
166
+ Args:
167
+ stream: bytes, stream to be deserialized
168
+ encoding: if not utf-8 encoded, provided for specific encoding
169
+
170
+ """
171
+ # Check stream
172
+ if stream is None:
173
+ raise IOError("No input stream given")
174
+ # Prepare the association Terminal Symbol -> Reading method
175
+ self.opmap = {
176
+ TerminalCode.TC_NULL: self.do_null,
177
+ TerminalCode.TC_STRING: self.do_string,
178
+ TerminalCode.TC_LONGSTRING: self.do_string_long,
179
+ TerminalCode.TC_ENDBLOCKDATA: self.do_null,
180
+ }
181
+ self.object_stream = BytesIO(stream)
182
+ self.encoding = encoding or 'UTF-8'
183
+ self.read_magic_bytes()
184
+
185
+ def read_magic_bytes(self):
186
+ length = struct.calcsize(">HH")
187
+ self.object_stream.read(length)
188
+
189
+ def _read_struct(self, unpack):
190
+ """
191
+ Reads from the input stream, using struct
192
+
193
+ Args:
194
+ unpack: An unpack format string
195
+
196
+ Returns:
197
+ The result of struct.unpack (tuple)
198
+
199
+ Raises:
200
+ RuntimeError: End of stream reached during unpacking
201
+
202
+ """
203
+ length = struct.calcsize(unpack)
204
+ ba = self.object_stream.read(length)
205
+
206
+ if len(ba) != length:
207
+ raise RuntimeError(
208
+ "Stream has been ended unexpectedly while unmarshaling."
209
+ )
210
+
211
+ return struct.unpack(unpack, ba)
212
+
213
+ def read_object(self, ignore_remaining_data=False):
214
+ """
215
+ Reads an object from the input stream
216
+
217
+ Args:
218
+ ignore_remaining_data: If True, don't log an debug when
219
+ unused trailing bytes are remaining
220
+
221
+ Returns:
222
+ The unmarshalled object
223
+
224
+ Raises:
225
+ Exception: Any exception that occurred during unmarshalling
226
+
227
+ """
228
+ try:
229
+ _, res = self._read_and_exec_opcode()
230
+
231
+ position_bak = self.object_stream.tell()
232
+ the_rest = self.object_stream.read()
233
+ if not ignore_remaining_data and len(the_rest) != 0: # pragma: no cover
234
+ logger.warning(
235
+ "Warning!!!!: Stream still has {0} bytes left. "
236
+ "Enable debug mode of logging to see the hexdump.".format(
237
+ len(the_rest)
238
+ )
239
+ )
240
+ logger.warning("\n{0}".format(hexdump(the_rest)))
241
+ else:
242
+ logger.warning("Java Object unmarshalled successfully!")
243
+
244
+ self.object_stream.seek(position_bak)
245
+ return res
246
+ except Exception:
247
+ self._oops_dump_state(ignore_remaining_data)
248
+ raise
249
+
250
+ def _read_and_exec_opcode(self, expect=None):
251
+ """
252
+ Reads the next opcode, and executes its handler
253
+
254
+ Args:
255
+ expect: A list of expected opcodes
256
+
257
+ Returns:
258
+ A tuple: (opcode, result of the handler)
259
+
260
+ Raises:
261
+ IOError: Read opcode is not one of the expected ones
262
+ RuntimeError: Unknown opcode
263
+
264
+ """
265
+ position = self.object_stream.tell()
266
+ (opid,) = self._read_struct(">B")
267
+
268
+ if expect and opid not in expect: # pragma: no cover
269
+ raise IOError(
270
+ "Unexpected opcode 0x{0:X} -- {1} "
271
+ "(at offset 0x{2:X})".format(
272
+ opid, StreamCodeDebug.op_id(opid), position
273
+ )
274
+ )
275
+
276
+ try:
277
+ handler = self.opmap[opid]
278
+ except KeyError:
279
+ raise RuntimeError(
280
+ "Unknown OpCode in the stream: 0x{0:X} "
281
+ "(at offset 0x{1:X})".format(opid, position)
282
+ )
283
+ else:
284
+ return opid, handler()
285
+
286
+ def _read_string(self, length_fmt="H"):
287
+ """
288
+ Reads a serialized string
289
+
290
+ Args:
291
+ length_fmt: Structure format of the string length (H or Q)
292
+
293
+ Returns:
294
+ The deserialized string
295
+
296
+ Raises:
297
+ RuntimeError: Unexpected end of stream
298
+
299
+ """
300
+ (length,) = self._read_struct(">{0}".format(length_fmt))
301
+ ba = self.object_stream.read(length)
302
+ return to_str(ba, self.encoding)
303
+
304
+ def do_string(self) -> str:
305
+ """
306
+ Handles a TC_STRING opcode
307
+
308
+ Returns:
309
+ A String
310
+
311
+ """
312
+ logger.warning("[string]")
313
+ ba = JavaString(self._read_string())
314
+ return ba
315
+
316
+ def do_string_long(self) -> str:
317
+ """
318
+ Handles a TC_LONGSTRING opcode
319
+
320
+ Returns:
321
+ A String
322
+
323
+ """
324
+ logger.warning("[long string]")
325
+ ba = JavaString(self._read_string("Q"))
326
+ return ba
327
+
328
+ @staticmethod
329
+ def do_null() -> None:
330
+ """
331
+ Handles a TC_NULL opcode
332
+
333
+ Returns:
334
+ Always None
335
+
336
+ """
337
+ return None
338
+
339
+ def _oops_dump_state(self, ignore_remaining_data=False):
340
+ """
341
+ Log a deserialization debug
342
+
343
+ Args:
344
+ ignore_remaining_data: If True, don't log an debug when
345
+ unused trailing bytes are remaining
346
+
347
+ """
348
+ logger.warning("==Oops state dump" + "=" * (30 - 17))
349
+ logger.warning(
350
+ "Stream seeking back at -16 byte "
351
+ "(2nd line is an actual position!):"
352
+ )
353
+
354
+ # Do not use a keyword argument
355
+ self.object_stream.seek(-16, os.SEEK_CUR)
356
+ position = self.object_stream.tell()
357
+ the_rest = self.object_stream.read()
358
+
359
+ if not ignore_remaining_data and len(the_rest) != 0:
360
+ logger.warning(
361
+ "Warning!!!!: Stream still has {0} bytes left:\n{1}".format(
362
+ len(the_rest), hexdump(the_rest, position)
363
+ )
364
+ )
365
+
366
+ logger.warning("=" * 30)