webull-openapi-python-sdk 1.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.
Files changed (295) hide show
  1. samples/__init__.py +1 -0
  2. samples/data/__init__.py +1 -0
  3. samples/data/data_client.py +57 -0
  4. samples/data/data_streaming_client.py +86 -0
  5. samples/data/data_streaming_client_async.py +101 -0
  6. samples/trade/__init__.py +0 -0
  7. samples/trade/trade_client.py +163 -0
  8. samples/trade/trade_client_v2.py +181 -0
  9. samples/trade/trade_event_client.py +47 -0
  10. webull/__init__.py +1 -0
  11. webull/core/__init__.py +12 -0
  12. webull/core/auth/__init__.py +0 -0
  13. webull/core/auth/algorithm/__init__.py +0 -0
  14. webull/core/auth/algorithm/sha_hmac1.py +65 -0
  15. webull/core/auth/algorithm/sha_hmac256.py +75 -0
  16. webull/core/auth/composer/__init__.py +0 -0
  17. webull/core/auth/composer/default_signature_composer.py +125 -0
  18. webull/core/auth/credentials.py +46 -0
  19. webull/core/auth/signers/__init__.py +0 -0
  20. webull/core/auth/signers/app_key_signer.py +72 -0
  21. webull/core/auth/signers/signer.py +48 -0
  22. webull/core/auth/signers/signer_factory.py +58 -0
  23. webull/core/cache/__init__.py +225 -0
  24. webull/core/client.py +410 -0
  25. webull/core/common/__init__.py +0 -0
  26. webull/core/common/api_type.py +19 -0
  27. webull/core/common/easy_enum.py +35 -0
  28. webull/core/common/region.py +7 -0
  29. webull/core/compat.py +85 -0
  30. webull/core/context/__init__.py +0 -0
  31. webull/core/context/request_context_holder.py +33 -0
  32. webull/core/data/endpoints.json +22 -0
  33. webull/core/data/retry_config.json +15 -0
  34. webull/core/endpoint/__init__.py +8 -0
  35. webull/core/endpoint/chained_endpoint_resolver.py +57 -0
  36. webull/core/endpoint/default_endpoint_resolver.py +60 -0
  37. webull/core/endpoint/local_config_regional_endpoint_resolver.py +77 -0
  38. webull/core/endpoint/resolver_endpoint_request.py +46 -0
  39. webull/core/endpoint/user_customized_endpoint_resolver.py +55 -0
  40. webull/core/exception/__init__.py +0 -0
  41. webull/core/exception/error_code.py +23 -0
  42. webull/core/exception/error_msg.py +21 -0
  43. webull/core/exception/exceptions.py +53 -0
  44. webull/core/headers.py +57 -0
  45. webull/core/http/__init__.py +0 -0
  46. webull/core/http/initializer/__init__.py +0 -0
  47. webull/core/http/initializer/client_initializer.py +79 -0
  48. webull/core/http/initializer/token/__init__.py +0 -0
  49. webull/core/http/initializer/token/bean/__init__.py +0 -0
  50. webull/core/http/initializer/token/bean/access_token.py +40 -0
  51. webull/core/http/initializer/token/bean/check_token_request.py +44 -0
  52. webull/core/http/initializer/token/bean/create_token_request.py +45 -0
  53. webull/core/http/initializer/token/bean/refresh_token_request.py +44 -0
  54. webull/core/http/initializer/token/token_manager.py +208 -0
  55. webull/core/http/initializer/token/token_operation.py +72 -0
  56. webull/core/http/method_type.py +43 -0
  57. webull/core/http/protocol_type.py +43 -0
  58. webull/core/http/request.py +121 -0
  59. webull/core/http/response.py +166 -0
  60. webull/core/request.py +278 -0
  61. webull/core/retry/__init__.py +0 -0
  62. webull/core/retry/backoff_strategy.py +102 -0
  63. webull/core/retry/retry_condition.py +214 -0
  64. webull/core/retry/retry_policy.py +63 -0
  65. webull/core/retry/retry_policy_context.py +51 -0
  66. webull/core/utils/__init__.py +0 -0
  67. webull/core/utils/common.py +62 -0
  68. webull/core/utils/data.py +25 -0
  69. webull/core/utils/desensitize.py +33 -0
  70. webull/core/utils/validation.py +49 -0
  71. webull/core/vendored/__init__.py +0 -0
  72. webull/core/vendored/requests/__init__.py +94 -0
  73. webull/core/vendored/requests/__version__.py +28 -0
  74. webull/core/vendored/requests/_internal_utils.py +56 -0
  75. webull/core/vendored/requests/adapters.py +539 -0
  76. webull/core/vendored/requests/api.py +166 -0
  77. webull/core/vendored/requests/auth.py +307 -0
  78. webull/core/vendored/requests/certs.py +34 -0
  79. webull/core/vendored/requests/compat.py +85 -0
  80. webull/core/vendored/requests/cookies.py +555 -0
  81. webull/core/vendored/requests/exceptions.py +136 -0
  82. webull/core/vendored/requests/help.py +134 -0
  83. webull/core/vendored/requests/hooks.py +48 -0
  84. webull/core/vendored/requests/models.py +960 -0
  85. webull/core/vendored/requests/packages/__init__.py +17 -0
  86. webull/core/vendored/requests/packages/certifi/__init__.py +17 -0
  87. webull/core/vendored/requests/packages/certifi/__main__.py +16 -0
  88. webull/core/vendored/requests/packages/certifi/cacert.pem +4433 -0
  89. webull/core/vendored/requests/packages/certifi/core.py +51 -0
  90. webull/core/vendored/requests/packages/chardet/__init__.py +53 -0
  91. webull/core/vendored/requests/packages/chardet/big5freq.py +400 -0
  92. webull/core/vendored/requests/packages/chardet/big5prober.py +61 -0
  93. webull/core/vendored/requests/packages/chardet/chardistribution.py +247 -0
  94. webull/core/vendored/requests/packages/chardet/charsetgroupprober.py +120 -0
  95. webull/core/vendored/requests/packages/chardet/charsetprober.py +159 -0
  96. webull/core/vendored/requests/packages/chardet/cli/__init__.py +1 -0
  97. webull/core/vendored/requests/packages/chardet/cli/chardetect.py +99 -0
  98. webull/core/vendored/requests/packages/chardet/codingstatemachine.py +102 -0
  99. webull/core/vendored/requests/packages/chardet/compat.py +48 -0
  100. webull/core/vendored/requests/packages/chardet/cp949prober.py +63 -0
  101. webull/core/vendored/requests/packages/chardet/enums.py +90 -0
  102. webull/core/vendored/requests/packages/chardet/escprober.py +115 -0
  103. webull/core/vendored/requests/packages/chardet/escsm.py +260 -0
  104. webull/core/vendored/requests/packages/chardet/eucjpprober.py +106 -0
  105. webull/core/vendored/requests/packages/chardet/euckrfreq.py +209 -0
  106. webull/core/vendored/requests/packages/chardet/euckrprober.py +61 -0
  107. webull/core/vendored/requests/packages/chardet/euctwfreq.py +401 -0
  108. webull/core/vendored/requests/packages/chardet/euctwprober.py +60 -0
  109. webull/core/vendored/requests/packages/chardet/gb2312freq.py +297 -0
  110. webull/core/vendored/requests/packages/chardet/gb2312prober.py +60 -0
  111. webull/core/vendored/requests/packages/chardet/hebrewprober.py +306 -0
  112. webull/core/vendored/requests/packages/chardet/jisfreq.py +339 -0
  113. webull/core/vendored/requests/packages/chardet/jpcntx.py +247 -0
  114. webull/core/vendored/requests/packages/chardet/langbulgarianmodel.py +242 -0
  115. webull/core/vendored/requests/packages/chardet/langcyrillicmodel.py +347 -0
  116. webull/core/vendored/requests/packages/chardet/langgreekmodel.py +239 -0
  117. webull/core/vendored/requests/packages/chardet/langhebrewmodel.py +214 -0
  118. webull/core/vendored/requests/packages/chardet/langhungarianmodel.py +239 -0
  119. webull/core/vendored/requests/packages/chardet/langthaimodel.py +213 -0
  120. webull/core/vendored/requests/packages/chardet/langturkishmodel.py +207 -0
  121. webull/core/vendored/requests/packages/chardet/latin1prober.py +159 -0
  122. webull/core/vendored/requests/packages/chardet/mbcharsetprober.py +105 -0
  123. webull/core/vendored/requests/packages/chardet/mbcsgroupprober.py +68 -0
  124. webull/core/vendored/requests/packages/chardet/mbcssm.py +586 -0
  125. webull/core/vendored/requests/packages/chardet/sbcharsetprober.py +146 -0
  126. webull/core/vendored/requests/packages/chardet/sbcsgroupprober.py +87 -0
  127. webull/core/vendored/requests/packages/chardet/sjisprober.py +106 -0
  128. webull/core/vendored/requests/packages/chardet/universaldetector.py +300 -0
  129. webull/core/vendored/requests/packages/chardet/utf8prober.py +96 -0
  130. webull/core/vendored/requests/packages/chardet/version.py +23 -0
  131. webull/core/vendored/requests/packages/urllib3/__init__.py +114 -0
  132. webull/core/vendored/requests/packages/urllib3/_collections.py +346 -0
  133. webull/core/vendored/requests/packages/urllib3/connection.py +405 -0
  134. webull/core/vendored/requests/packages/urllib3/connectionpool.py +910 -0
  135. webull/core/vendored/requests/packages/urllib3/contrib/__init__.py +0 -0
  136. webull/core/vendored/requests/packages/urllib3/contrib/_appengine_environ.py +44 -0
  137. webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/__init__.py +0 -0
  138. webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/bindings.py +607 -0
  139. webull/core/vendored/requests/packages/urllib3/contrib/_securetransport/low_level.py +360 -0
  140. webull/core/vendored/requests/packages/urllib3/contrib/appengine.py +303 -0
  141. webull/core/vendored/requests/packages/urllib3/contrib/ntlmpool.py +125 -0
  142. webull/core/vendored/requests/packages/urllib3/contrib/pyopenssl.py +484 -0
  143. webull/core/vendored/requests/packages/urllib3/contrib/securetransport.py +818 -0
  144. webull/core/vendored/requests/packages/urllib3/contrib/socks.py +206 -0
  145. webull/core/vendored/requests/packages/urllib3/exceptions.py +260 -0
  146. webull/core/vendored/requests/packages/urllib3/fields.py +192 -0
  147. webull/core/vendored/requests/packages/urllib3/filepost.py +112 -0
  148. webull/core/vendored/requests/packages/urllib3/packages/__init__.py +19 -0
  149. webull/core/vendored/requests/packages/urllib3/packages/backports/__init__.py +0 -0
  150. webull/core/vendored/requests/packages/urllib3/packages/backports/makefile.py +67 -0
  151. webull/core/vendored/requests/packages/urllib3/packages/ordered_dict.py +273 -0
  152. webull/core/vendored/requests/packages/urllib3/packages/six.py +882 -0
  153. webull/core/vendored/requests/packages/urllib3/packages/socks.py +887 -0
  154. webull/core/vendored/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py +19 -0
  155. webull/core/vendored/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py +170 -0
  156. webull/core/vendored/requests/packages/urllib3/poolmanager.py +467 -0
  157. webull/core/vendored/requests/packages/urllib3/request.py +164 -0
  158. webull/core/vendored/requests/packages/urllib3/response.py +721 -0
  159. webull/core/vendored/requests/packages/urllib3/util/__init__.py +68 -0
  160. webull/core/vendored/requests/packages/urllib3/util/connection.py +148 -0
  161. webull/core/vendored/requests/packages/urllib3/util/queue.py +35 -0
  162. webull/core/vendored/requests/packages/urllib3/util/request.py +132 -0
  163. webull/core/vendored/requests/packages/urllib3/util/response.py +101 -0
  164. webull/core/vendored/requests/packages/urllib3/util/retry.py +426 -0
  165. webull/core/vendored/requests/packages/urllib3/util/selectors.py +601 -0
  166. webull/core/vendored/requests/packages/urllib3/util/ssl_.py +396 -0
  167. webull/core/vendored/requests/packages/urllib3/util/timeout.py +256 -0
  168. webull/core/vendored/requests/packages/urllib3/util/url.py +252 -0
  169. webull/core/vendored/requests/packages/urllib3/util/wait.py +164 -0
  170. webull/core/vendored/requests/packages.py +28 -0
  171. webull/core/vendored/requests/sessions.py +750 -0
  172. webull/core/vendored/requests/status_codes.py +105 -0
  173. webull/core/vendored/requests/structures.py +119 -0
  174. webull/core/vendored/requests/utils.py +916 -0
  175. webull/core/vendored/six.py +905 -0
  176. webull/data/__init__.py +3 -0
  177. webull/data/common/__init__.py +0 -0
  178. webull/data/common/category.py +26 -0
  179. webull/data/common/connect_ack.py +29 -0
  180. webull/data/common/direction.py +25 -0
  181. webull/data/common/exchange_code.py +33 -0
  182. webull/data/common/exercise_style.py +22 -0
  183. webull/data/common/expiration_cycle.py +26 -0
  184. webull/data/common/instrument_status.py +23 -0
  185. webull/data/common/option_type.py +20 -0
  186. webull/data/common/subscribe_type.py +22 -0
  187. webull/data/common/timespan.py +29 -0
  188. webull/data/data_client.py +35 -0
  189. webull/data/data_streaming_client.py +89 -0
  190. webull/data/internal/__init__.py +0 -0
  191. webull/data/internal/default_retry_policy.py +84 -0
  192. webull/data/internal/exceptions.py +60 -0
  193. webull/data/internal/quotes_client.py +314 -0
  194. webull/data/internal/quotes_decoder.py +40 -0
  195. webull/data/internal/quotes_payload_decoder.py +35 -0
  196. webull/data/internal/quotes_topic.py +36 -0
  197. webull/data/quotes/__init__.py +0 -0
  198. webull/data/quotes/instrument.py +33 -0
  199. webull/data/quotes/market_data.py +187 -0
  200. webull/data/quotes/market_streaming_data.py +66 -0
  201. webull/data/quotes/subscribe/__init__.py +0 -0
  202. webull/data/quotes/subscribe/ask_bid_result.py +49 -0
  203. webull/data/quotes/subscribe/basic_result.py +45 -0
  204. webull/data/quotes/subscribe/broker_result.py +33 -0
  205. webull/data/quotes/subscribe/message_pb2.py +37 -0
  206. webull/data/quotes/subscribe/order_result.py +30 -0
  207. webull/data/quotes/subscribe/payload_type.py +19 -0
  208. webull/data/quotes/subscribe/quote_decoder.py +28 -0
  209. webull/data/quotes/subscribe/quote_result.py +47 -0
  210. webull/data/quotes/subscribe/snapshot_decoder.py +30 -0
  211. webull/data/quotes/subscribe/snapshot_result.py +69 -0
  212. webull/data/quotes/subscribe/tick_decoder.py +29 -0
  213. webull/data/quotes/subscribe/tick_result.py +47 -0
  214. webull/data/request/__init__.py +0 -0
  215. webull/data/request/get_batch_historical_bars_request.py +43 -0
  216. webull/data/request/get_corp_action_request.py +47 -0
  217. webull/data/request/get_eod_bars_request.py +32 -0
  218. webull/data/request/get_historical_bars_request.py +43 -0
  219. webull/data/request/get_instruments_request.py +30 -0
  220. webull/data/request/get_quotes_request.py +35 -0
  221. webull/data/request/get_snapshot_request.py +38 -0
  222. webull/data/request/get_tick_request.py +37 -0
  223. webull/data/request/subscribe_request.py +43 -0
  224. webull/data/request/unsubscribe_request.py +42 -0
  225. webull/trade/__init__.py +2 -0
  226. webull/trade/common/__init__.py +0 -0
  227. webull/trade/common/account_type.py +22 -0
  228. webull/trade/common/category.py +29 -0
  229. webull/trade/common/combo_ticker_type.py +23 -0
  230. webull/trade/common/combo_type.py +31 -0
  231. webull/trade/common/currency.py +24 -0
  232. webull/trade/common/forbid_reason.py +27 -0
  233. webull/trade/common/instrument_type.py +27 -0
  234. webull/trade/common/markets.py +27 -0
  235. webull/trade/common/order_entrust_type.py +21 -0
  236. webull/trade/common/order_side.py +23 -0
  237. webull/trade/common/order_status.py +25 -0
  238. webull/trade/common/order_tif.py +24 -0
  239. webull/trade/common/order_type.py +30 -0
  240. webull/trade/common/trade_policy.py +22 -0
  241. webull/trade/common/trading_date_type.py +24 -0
  242. webull/trade/common/trailing_type.py +23 -0
  243. webull/trade/events/__init__.py +0 -0
  244. webull/trade/events/default_retry_policy.py +64 -0
  245. webull/trade/events/events_pb2.py +43 -0
  246. webull/trade/events/events_pb2_grpc.py +66 -0
  247. webull/trade/events/signature_composer.py +61 -0
  248. webull/trade/events/types.py +21 -0
  249. webull/trade/request/__init__.py +0 -0
  250. webull/trade/request/cancel_order_request.py +28 -0
  251. webull/trade/request/get_account_balance_request.py +28 -0
  252. webull/trade/request/get_account_positions_request.py +30 -0
  253. webull/trade/request/get_account_profile_request.py +26 -0
  254. webull/trade/request/get_app_subscriptions.py +28 -0
  255. webull/trade/request/get_open_orders_request.py +30 -0
  256. webull/trade/request/get_order_detail_request.py +27 -0
  257. webull/trade/request/get_today_orders_request.py +31 -0
  258. webull/trade/request/get_trade_calendar_request.py +30 -0
  259. webull/trade/request/get_trade_instrument_detail_request.py +24 -0
  260. webull/trade/request/get_trade_security_detail_request.py +42 -0
  261. webull/trade/request/get_tradeable_instruments_request.py +27 -0
  262. webull/trade/request/palce_order_request.py +91 -0
  263. webull/trade/request/place_order_request_v2.py +58 -0
  264. webull/trade/request/replace_order_request.py +73 -0
  265. webull/trade/request/replace_order_request_v2.py +38 -0
  266. webull/trade/request/v2/__init__.py +0 -0
  267. webull/trade/request/v2/cancel_option_request.py +28 -0
  268. webull/trade/request/v2/cancel_order_request.py +28 -0
  269. webull/trade/request/v2/get_account_balance_request.py +28 -0
  270. webull/trade/request/v2/get_account_list.py +23 -0
  271. webull/trade/request/v2/get_account_positions_request.py +24 -0
  272. webull/trade/request/v2/get_order_detail_request.py +26 -0
  273. webull/trade/request/v2/get_order_history_request.py +35 -0
  274. webull/trade/request/v2/palce_order_request.py +87 -0
  275. webull/trade/request/v2/place_option_request.py +64 -0
  276. webull/trade/request/v2/preview_option_request.py +28 -0
  277. webull/trade/request/v2/preview_order_request.py +59 -0
  278. webull/trade/request/v2/replace_option_request.py +28 -0
  279. webull/trade/request/v2/replace_order_request.py +57 -0
  280. webull/trade/trade/__init__.py +0 -0
  281. webull/trade/trade/account_info.py +83 -0
  282. webull/trade/trade/order_operation.py +246 -0
  283. webull/trade/trade/trade_calendar.py +37 -0
  284. webull/trade/trade/trade_instrument.py +72 -0
  285. webull/trade/trade/v2/__init__.py +0 -0
  286. webull/trade/trade/v2/account_info_v2.py +55 -0
  287. webull/trade/trade/v2/order_operation_v2.py +206 -0
  288. webull/trade/trade_client.py +43 -0
  289. webull/trade/trade_events_client.py +233 -0
  290. webull_openapi_python_sdk-1.0.0.dist-info/METADATA +28 -0
  291. webull_openapi_python_sdk-1.0.0.dist-info/RECORD +295 -0
  292. webull_openapi_python_sdk-1.0.0.dist-info/WHEEL +5 -0
  293. webull_openapi_python_sdk-1.0.0.dist-info/licenses/LICENSE +202 -0
  294. webull_openapi_python_sdk-1.0.0.dist-info/licenses/NOTICE +56 -0
  295. webull_openapi_python_sdk-1.0.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,102 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ######################## BEGIN LICENSE BLOCK ########################
16
+ # The Original Code is mozilla.org code.
17
+ #
18
+ # The Initial Developer of the Original Code is
19
+ # Netscape Communications Corporation.
20
+ # Portions created by the Initial Developer are Copyright (C) 1998
21
+ # the Initial Developer. All Rights Reserved.
22
+ #
23
+ # Contributor(s):
24
+ # Mark Pilgrim - port to Python
25
+ #
26
+ # This library is free software; you can redistribute it and/or
27
+ # modify it under the terms of the GNU Lesser General Public
28
+ # License as published by the Free Software Foundation; either
29
+ # version 2.1 of the License, or (at your option) any later version.
30
+ #
31
+ # This library is distributed in the hope that it will be useful,
32
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34
+ # Lesser General Public License for more details.
35
+ #
36
+ # You should have received a copy of the GNU Lesser General Public
37
+ # License along with this library; if not, write to the Free Software
38
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
39
+ # 02110-1301 USA
40
+ ######################### END LICENSE BLOCK #########################
41
+
42
+ import logging
43
+
44
+ from .enums import MachineState
45
+
46
+
47
+ class CodingStateMachine(object):
48
+ """
49
+ A state machine to verify a byte sequence for a particular encoding. For
50
+ each byte the detector receives, it will feed that byte to every active
51
+ state machine available, one byte at a time. The state machine changes its
52
+ state based on its previous state and the byte it receives. There are 3
53
+ states in a state machine that are of interest to an auto-detector:
54
+
55
+ START state: This is the state to start with, or a legal byte sequence
56
+ (i.e. a valid code point) for character has been identified.
57
+
58
+ ME state: This indicates that the state machine identified a byte sequence
59
+ that is specific to the charset it is designed for and that
60
+ there is no other possible encoding which can contain this byte
61
+ sequence. This will to lead to an immediate positive answer for
62
+ the detector.
63
+
64
+ ERROR state: This indicates the state machine identified an illegal byte
65
+ sequence for that encoding. This will lead to an immediate
66
+ negative answer for this encoding. Detector will exclude this
67
+ encoding from consideration from here on.
68
+ """
69
+ def __init__(self, sm):
70
+ self._model = sm
71
+ self._curr_byte_pos = 0
72
+ self._curr_char_len = 0
73
+ self._curr_state = None
74
+ self.logger = logging.getLogger(__name__)
75
+ self.reset()
76
+
77
+ def reset(self):
78
+ self._curr_state = MachineState.START
79
+
80
+ def next_state(self, c):
81
+ # for each byte we get its class
82
+ # if it is first byte, we also get byte length
83
+ byte_class = self._model['class_table'][c]
84
+ if self._curr_state == MachineState.START:
85
+ self._curr_byte_pos = 0
86
+ self._curr_char_len = self._model['char_len_table'][byte_class]
87
+ # from byte's class and state_table, we get its next state
88
+ curr_state = (self._curr_state * self._model['class_factor']
89
+ + byte_class)
90
+ self._curr_state = self._model['state_table'][curr_state]
91
+ self._curr_byte_pos += 1
92
+ return self._curr_state
93
+
94
+ def get_current_charlen(self):
95
+ return self._curr_char_len
96
+
97
+ def get_coding_state_machine(self):
98
+ return self._model['name']
99
+
100
+ @property
101
+ def language(self):
102
+ return self._model['language']
@@ -0,0 +1,48 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ######################## BEGIN LICENSE BLOCK ########################
16
+ # Contributor(s):
17
+ # Dan Blanchard
18
+ # Ian Cordasco
19
+ #
20
+ # This library is free software; you can redistribute it and/or
21
+ # modify it under the terms of the GNU Lesser General Public
22
+ # License as published by the Free Software Foundation; either
23
+ # version 2.1 of the License, or (at your option) any later version.
24
+ #
25
+ # This library is distributed in the hope that it will be useful,
26
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
27
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28
+ # Lesser General Public License for more details.
29
+ #
30
+ # You should have received a copy of the GNU Lesser General Public
31
+ # License along with this library; if not, write to the Free Software
32
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
33
+ # 02110-1301 USA
34
+ ######################### END LICENSE BLOCK #########################
35
+
36
+ import sys
37
+
38
+
39
+ if sys.version_info < (3, 0):
40
+ PY2 = True
41
+ PY3 = False
42
+ base_str = (str, unicode)
43
+ text_type = unicode
44
+ else:
45
+ PY2 = False
46
+ PY3 = True
47
+ base_str = (bytes, str)
48
+ text_type = str
@@ -0,0 +1,63 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ######################## BEGIN LICENSE BLOCK ########################
16
+ # The Original Code is mozilla.org code.
17
+ #
18
+ # The Initial Developer of the Original Code is
19
+ # Netscape Communications Corporation.
20
+ # Portions created by the Initial Developer are Copyright (C) 1998
21
+ # the Initial Developer. All Rights Reserved.
22
+ #
23
+ # Contributor(s):
24
+ # Mark Pilgrim - port to Python
25
+ #
26
+ # This library is free software; you can redistribute it and/or
27
+ # modify it under the terms of the GNU Lesser General Public
28
+ # License as published by the Free Software Foundation; either
29
+ # version 2.1 of the License, or (at your option) any later version.
30
+ #
31
+ # This library is distributed in the hope that it will be useful,
32
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34
+ # Lesser General Public License for more details.
35
+ #
36
+ # You should have received a copy of the GNU Lesser General Public
37
+ # License along with this library; if not, write to the Free Software
38
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
39
+ # 02110-1301 USA
40
+ ######################### END LICENSE BLOCK #########################
41
+
42
+ from .chardistribution import EUCKRDistributionAnalysis
43
+ from .codingstatemachine import CodingStateMachine
44
+ from .mbcharsetprober import MultiByteCharSetProber
45
+ from .mbcssm import CP949_SM_MODEL
46
+
47
+
48
+ class CP949Prober(MultiByteCharSetProber):
49
+ def __init__(self):
50
+ super(CP949Prober, self).__init__()
51
+ self.coding_sm = CodingStateMachine(CP949_SM_MODEL)
52
+ # NOTE: CP949 is a superset of EUC-KR, so the distribution should be
53
+ # not different.
54
+ self.distribution_analyzer = EUCKRDistributionAnalysis()
55
+ self.reset()
56
+
57
+ @property
58
+ def charset_name(self):
59
+ return "CP949"
60
+
61
+ @property
62
+ def language(self):
63
+ return "Korean"
@@ -0,0 +1,90 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ All of the Enums that are used throughout the chardet package.
17
+
18
+ :author: Dan Blanchard (dan.blanchard@gmail.com)
19
+ """
20
+
21
+
22
+ class InputState(object):
23
+ """
24
+ This enum represents the different states a universal detector can be in.
25
+ """
26
+ PURE_ASCII = 0
27
+ ESC_ASCII = 1
28
+ HIGH_BYTE = 2
29
+
30
+
31
+ class LanguageFilter(object):
32
+ """
33
+ This enum represents the different language filters we can apply to a
34
+ ``UniversalDetector``.
35
+ """
36
+ CHINESE_SIMPLIFIED = 0x01
37
+ CHINESE_TRADITIONAL = 0x02
38
+ JAPANESE = 0x04
39
+ KOREAN = 0x08
40
+ NON_CJK = 0x10
41
+ ALL = 0x1F
42
+ CHINESE = CHINESE_SIMPLIFIED | CHINESE_TRADITIONAL
43
+ CJK = CHINESE | JAPANESE | KOREAN
44
+
45
+
46
+ class ProbingState(object):
47
+ """
48
+ This enum represents the different states a prober can be in.
49
+ """
50
+ DETECTING = 0
51
+ FOUND_IT = 1
52
+ NOT_ME = 2
53
+
54
+
55
+ class MachineState(object):
56
+ """
57
+ This enum represents the different states a state machine can be in.
58
+ """
59
+ START = 0
60
+ ERROR = 1
61
+ ITS_ME = 2
62
+
63
+
64
+ class SequenceLikelihood(object):
65
+ """
66
+ This enum represents the likelihood of a character following the previous one.
67
+ """
68
+ NEGATIVE = 0
69
+ UNLIKELY = 1
70
+ LIKELY = 2
71
+ POSITIVE = 3
72
+
73
+ @classmethod
74
+ def get_num_categories(cls):
75
+ """:returns: The number of likelihood categories in the enum."""
76
+ return 4
77
+
78
+
79
+ class CharacterCategory(object):
80
+ """
81
+ This enum represents the different categories language models for
82
+ ``SingleByteCharsetProber`` put characters into.
83
+
84
+ Anything less than CONTROL is considered a letter.
85
+ """
86
+ UNDEFINED = 255
87
+ LINE_BREAK = 254
88
+ SYMBOL = 253
89
+ DIGIT = 252
90
+ CONTROL = 251
@@ -0,0 +1,115 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ######################## BEGIN LICENSE BLOCK ########################
16
+ # The Original Code is mozilla.org code.
17
+ #
18
+ # The Initial Developer of the Original Code is
19
+ # Netscape Communications Corporation.
20
+ # Portions created by the Initial Developer are Copyright (C) 1998
21
+ # the Initial Developer. All Rights Reserved.
22
+ #
23
+ # Contributor(s):
24
+ # Mark Pilgrim - port to Python
25
+ #
26
+ # This library is free software; you can redistribute it and/or
27
+ # modify it under the terms of the GNU Lesser General Public
28
+ # License as published by the Free Software Foundation; either
29
+ # version 2.1 of the License, or (at your option) any later version.
30
+ #
31
+ # This library is distributed in the hope that it will be useful,
32
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34
+ # Lesser General Public License for more details.
35
+ #
36
+ # You should have received a copy of the GNU Lesser General Public
37
+ # License along with this library; if not, write to the Free Software
38
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
39
+ # 02110-1301 USA
40
+ ######################### END LICENSE BLOCK #########################
41
+
42
+ from .charsetprober import CharSetProber
43
+ from .codingstatemachine import CodingStateMachine
44
+ from .enums import LanguageFilter, ProbingState, MachineState
45
+ from .escsm import (HZ_SM_MODEL, ISO2022CN_SM_MODEL, ISO2022JP_SM_MODEL,
46
+ ISO2022KR_SM_MODEL)
47
+
48
+
49
+ class EscCharSetProber(CharSetProber):
50
+ """
51
+ This CharSetProber uses a "code scheme" approach for detecting encodings,
52
+ whereby easily recognizable escape or shift sequences are relied on to
53
+ identify these encodings.
54
+ """
55
+
56
+ def __init__(self, lang_filter=None):
57
+ super(EscCharSetProber, self).__init__(lang_filter=lang_filter)
58
+ self.coding_sm = []
59
+ if self.lang_filter & LanguageFilter.CHINESE_SIMPLIFIED:
60
+ self.coding_sm.append(CodingStateMachine(HZ_SM_MODEL))
61
+ self.coding_sm.append(CodingStateMachine(ISO2022CN_SM_MODEL))
62
+ if self.lang_filter & LanguageFilter.JAPANESE:
63
+ self.coding_sm.append(CodingStateMachine(ISO2022JP_SM_MODEL))
64
+ if self.lang_filter & LanguageFilter.KOREAN:
65
+ self.coding_sm.append(CodingStateMachine(ISO2022KR_SM_MODEL))
66
+ self.active_sm_count = None
67
+ self._detected_charset = None
68
+ self._detected_language = None
69
+ self._state = None
70
+ self.reset()
71
+
72
+ def reset(self):
73
+ super(EscCharSetProber, self).reset()
74
+ for coding_sm in self.coding_sm:
75
+ if not coding_sm:
76
+ continue
77
+ coding_sm.active = True
78
+ coding_sm.reset()
79
+ self.active_sm_count = len(self.coding_sm)
80
+ self._detected_charset = None
81
+ self._detected_language = None
82
+
83
+ @property
84
+ def charset_name(self):
85
+ return self._detected_charset
86
+
87
+ @property
88
+ def language(self):
89
+ return self._detected_language
90
+
91
+ def get_confidence(self):
92
+ if self._detected_charset:
93
+ return 0.99
94
+ else:
95
+ return 0.00
96
+
97
+ def feed(self, byte_str):
98
+ for c in byte_str:
99
+ for coding_sm in self.coding_sm:
100
+ if not coding_sm or not coding_sm.active:
101
+ continue
102
+ coding_state = coding_sm.next_state(c)
103
+ if coding_state == MachineState.ERROR:
104
+ coding_sm.active = False
105
+ self.active_sm_count -= 1
106
+ if self.active_sm_count <= 0:
107
+ self._state = ProbingState.NOT_ME
108
+ return self.state
109
+ elif coding_state == MachineState.ITS_ME:
110
+ self._state = ProbingState.FOUND_IT
111
+ self._detected_charset = coding_sm.get_coding_state_machine()
112
+ self._detected_language = coding_sm.language
113
+ return self.state
114
+
115
+ return self.state
@@ -0,0 +1,260 @@
1
+ # Copyright 2022 Webull
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ######################## BEGIN LICENSE BLOCK ########################
16
+ # The Original Code is mozilla.org code.
17
+ #
18
+ # The Initial Developer of the Original Code is
19
+ # Netscape Communications Corporation.
20
+ # Portions created by the Initial Developer are Copyright (C) 1998
21
+ # the Initial Developer. All Rights Reserved.
22
+ #
23
+ # Contributor(s):
24
+ # Mark Pilgrim - port to Python
25
+ #
26
+ # This library is free software; you can redistribute it and/or
27
+ # modify it under the terms of the GNU Lesser General Public
28
+ # License as published by the Free Software Foundation; either
29
+ # version 2.1 of the License, or (at your option) any later version.
30
+ #
31
+ # This library is distributed in the hope that it will be useful,
32
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34
+ # Lesser General Public License for more details.
35
+ #
36
+ # You should have received a copy of the GNU Lesser General Public
37
+ # License along with this library; if not, write to the Free Software
38
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
39
+ # 02110-1301 USA
40
+ ######################### END LICENSE BLOCK #########################
41
+
42
+ from .enums import MachineState
43
+
44
+ HZ_CLS = (
45
+ 1,0,0,0,0,0,0,0, # 00 - 07
46
+ 0,0,0,0,0,0,0,0, # 08 - 0f
47
+ 0,0,0,0,0,0,0,0, # 10 - 17
48
+ 0,0,0,1,0,0,0,0, # 18 - 1f
49
+ 0,0,0,0,0,0,0,0, # 20 - 27
50
+ 0,0,0,0,0,0,0,0, # 28 - 2f
51
+ 0,0,0,0,0,0,0,0, # 30 - 37
52
+ 0,0,0,0,0,0,0,0, # 38 - 3f
53
+ 0,0,0,0,0,0,0,0, # 40 - 47
54
+ 0,0,0,0,0,0,0,0, # 48 - 4f
55
+ 0,0,0,0,0,0,0,0, # 50 - 57
56
+ 0,0,0,0,0,0,0,0, # 58 - 5f
57
+ 0,0,0,0,0,0,0,0, # 60 - 67
58
+ 0,0,0,0,0,0,0,0, # 68 - 6f
59
+ 0,0,0,0,0,0,0,0, # 70 - 77
60
+ 0,0,0,4,0,5,2,0, # 78 - 7f
61
+ 1,1,1,1,1,1,1,1, # 80 - 87
62
+ 1,1,1,1,1,1,1,1, # 88 - 8f
63
+ 1,1,1,1,1,1,1,1, # 90 - 97
64
+ 1,1,1,1,1,1,1,1, # 98 - 9f
65
+ 1,1,1,1,1,1,1,1, # a0 - a7
66
+ 1,1,1,1,1,1,1,1, # a8 - af
67
+ 1,1,1,1,1,1,1,1, # b0 - b7
68
+ 1,1,1,1,1,1,1,1, # b8 - bf
69
+ 1,1,1,1,1,1,1,1, # c0 - c7
70
+ 1,1,1,1,1,1,1,1, # c8 - cf
71
+ 1,1,1,1,1,1,1,1, # d0 - d7
72
+ 1,1,1,1,1,1,1,1, # d8 - df
73
+ 1,1,1,1,1,1,1,1, # e0 - e7
74
+ 1,1,1,1,1,1,1,1, # e8 - ef
75
+ 1,1,1,1,1,1,1,1, # f0 - f7
76
+ 1,1,1,1,1,1,1,1, # f8 - ff
77
+ )
78
+
79
+ HZ_ST = (
80
+ MachineState.START,MachineState.ERROR, 3,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07
81
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f
82
+ MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.START,MachineState.START, 4,MachineState.ERROR,# 10-17
83
+ 5,MachineState.ERROR, 6,MachineState.ERROR, 5, 5, 4,MachineState.ERROR,# 18-1f
84
+ 4,MachineState.ERROR, 4, 4, 4,MachineState.ERROR, 4,MachineState.ERROR,# 20-27
85
+ 4,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 28-2f
86
+ )
87
+
88
+ HZ_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
89
+
90
+ HZ_SM_MODEL = {'class_table': HZ_CLS,
91
+ 'class_factor': 6,
92
+ 'state_table': HZ_ST,
93
+ 'char_len_table': HZ_CHAR_LEN_TABLE,
94
+ 'name': "HZ-GB-2312",
95
+ 'language': 'Chinese'}
96
+
97
+ ISO2022CN_CLS = (
98
+ 2,0,0,0,0,0,0,0, # 00 - 07
99
+ 0,0,0,0,0,0,0,0, # 08 - 0f
100
+ 0,0,0,0,0,0,0,0, # 10 - 17
101
+ 0,0,0,1,0,0,0,0, # 18 - 1f
102
+ 0,0,0,0,0,0,0,0, # 20 - 27
103
+ 0,3,0,0,0,0,0,0, # 28 - 2f
104
+ 0,0,0,0,0,0,0,0, # 30 - 37
105
+ 0,0,0,0,0,0,0,0, # 38 - 3f
106
+ 0,0,0,4,0,0,0,0, # 40 - 47
107
+ 0,0,0,0,0,0,0,0, # 48 - 4f
108
+ 0,0,0,0,0,0,0,0, # 50 - 57
109
+ 0,0,0,0,0,0,0,0, # 58 - 5f
110
+ 0,0,0,0,0,0,0,0, # 60 - 67
111
+ 0,0,0,0,0,0,0,0, # 68 - 6f
112
+ 0,0,0,0,0,0,0,0, # 70 - 77
113
+ 0,0,0,0,0,0,0,0, # 78 - 7f
114
+ 2,2,2,2,2,2,2,2, # 80 - 87
115
+ 2,2,2,2,2,2,2,2, # 88 - 8f
116
+ 2,2,2,2,2,2,2,2, # 90 - 97
117
+ 2,2,2,2,2,2,2,2, # 98 - 9f
118
+ 2,2,2,2,2,2,2,2, # a0 - a7
119
+ 2,2,2,2,2,2,2,2, # a8 - af
120
+ 2,2,2,2,2,2,2,2, # b0 - b7
121
+ 2,2,2,2,2,2,2,2, # b8 - bf
122
+ 2,2,2,2,2,2,2,2, # c0 - c7
123
+ 2,2,2,2,2,2,2,2, # c8 - cf
124
+ 2,2,2,2,2,2,2,2, # d0 - d7
125
+ 2,2,2,2,2,2,2,2, # d8 - df
126
+ 2,2,2,2,2,2,2,2, # e0 - e7
127
+ 2,2,2,2,2,2,2,2, # e8 - ef
128
+ 2,2,2,2,2,2,2,2, # f0 - f7
129
+ 2,2,2,2,2,2,2,2, # f8 - ff
130
+ )
131
+
132
+ ISO2022CN_ST = (
133
+ MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07
134
+ MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f
135
+ MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17
136
+ MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,# 18-1f
137
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 20-27
138
+ 5, 6,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 28-2f
139
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 30-37
140
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,# 38-3f
141
+ )
142
+
143
+ ISO2022CN_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0)
144
+
145
+ ISO2022CN_SM_MODEL = {'class_table': ISO2022CN_CLS,
146
+ 'class_factor': 9,
147
+ 'state_table': ISO2022CN_ST,
148
+ 'char_len_table': ISO2022CN_CHAR_LEN_TABLE,
149
+ 'name': "ISO-2022-CN",
150
+ 'language': 'Chinese'}
151
+
152
+ ISO2022JP_CLS = (
153
+ 2,0,0,0,0,0,0,0, # 00 - 07
154
+ 0,0,0,0,0,0,2,2, # 08 - 0f
155
+ 0,0,0,0,0,0,0,0, # 10 - 17
156
+ 0,0,0,1,0,0,0,0, # 18 - 1f
157
+ 0,0,0,0,7,0,0,0, # 20 - 27
158
+ 3,0,0,0,0,0,0,0, # 28 - 2f
159
+ 0,0,0,0,0,0,0,0, # 30 - 37
160
+ 0,0,0,0,0,0,0,0, # 38 - 3f
161
+ 6,0,4,0,8,0,0,0, # 40 - 47
162
+ 0,9,5,0,0,0,0,0, # 48 - 4f
163
+ 0,0,0,0,0,0,0,0, # 50 - 57
164
+ 0,0,0,0,0,0,0,0, # 58 - 5f
165
+ 0,0,0,0,0,0,0,0, # 60 - 67
166
+ 0,0,0,0,0,0,0,0, # 68 - 6f
167
+ 0,0,0,0,0,0,0,0, # 70 - 77
168
+ 0,0,0,0,0,0,0,0, # 78 - 7f
169
+ 2,2,2,2,2,2,2,2, # 80 - 87
170
+ 2,2,2,2,2,2,2,2, # 88 - 8f
171
+ 2,2,2,2,2,2,2,2, # 90 - 97
172
+ 2,2,2,2,2,2,2,2, # 98 - 9f
173
+ 2,2,2,2,2,2,2,2, # a0 - a7
174
+ 2,2,2,2,2,2,2,2, # a8 - af
175
+ 2,2,2,2,2,2,2,2, # b0 - b7
176
+ 2,2,2,2,2,2,2,2, # b8 - bf
177
+ 2,2,2,2,2,2,2,2, # c0 - c7
178
+ 2,2,2,2,2,2,2,2, # c8 - cf
179
+ 2,2,2,2,2,2,2,2, # d0 - d7
180
+ 2,2,2,2,2,2,2,2, # d8 - df
181
+ 2,2,2,2,2,2,2,2, # e0 - e7
182
+ 2,2,2,2,2,2,2,2, # e8 - ef
183
+ 2,2,2,2,2,2,2,2, # f0 - f7
184
+ 2,2,2,2,2,2,2,2, # f8 - ff
185
+ )
186
+
187
+ ISO2022JP_ST = (
188
+ MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 00-07
189
+ MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 08-0f
190
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 10-17
191
+ MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,# 18-1f
192
+ MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 20-27
193
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 6,MachineState.ITS_ME,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,# 28-2f
194
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,# 30-37
195
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 38-3f
196
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ERROR,MachineState.START,MachineState.START,# 40-47
197
+ )
198
+
199
+ ISO2022JP_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
200
+
201
+ ISO2022JP_SM_MODEL = {'class_table': ISO2022JP_CLS,
202
+ 'class_factor': 10,
203
+ 'state_table': ISO2022JP_ST,
204
+ 'char_len_table': ISO2022JP_CHAR_LEN_TABLE,
205
+ 'name': "ISO-2022-JP",
206
+ 'language': 'Japanese'}
207
+
208
+ ISO2022KR_CLS = (
209
+ 2,0,0,0,0,0,0,0, # 00 - 07
210
+ 0,0,0,0,0,0,0,0, # 08 - 0f
211
+ 0,0,0,0,0,0,0,0, # 10 - 17
212
+ 0,0,0,1,0,0,0,0, # 18 - 1f
213
+ 0,0,0,0,3,0,0,0, # 20 - 27
214
+ 0,4,0,0,0,0,0,0, # 28 - 2f
215
+ 0,0,0,0,0,0,0,0, # 30 - 37
216
+ 0,0,0,0,0,0,0,0, # 38 - 3f
217
+ 0,0,0,5,0,0,0,0, # 40 - 47
218
+ 0,0,0,0,0,0,0,0, # 48 - 4f
219
+ 0,0,0,0,0,0,0,0, # 50 - 57
220
+ 0,0,0,0,0,0,0,0, # 58 - 5f
221
+ 0,0,0,0,0,0,0,0, # 60 - 67
222
+ 0,0,0,0,0,0,0,0, # 68 - 6f
223
+ 0,0,0,0,0,0,0,0, # 70 - 77
224
+ 0,0,0,0,0,0,0,0, # 78 - 7f
225
+ 2,2,2,2,2,2,2,2, # 80 - 87
226
+ 2,2,2,2,2,2,2,2, # 88 - 8f
227
+ 2,2,2,2,2,2,2,2, # 90 - 97
228
+ 2,2,2,2,2,2,2,2, # 98 - 9f
229
+ 2,2,2,2,2,2,2,2, # a0 - a7
230
+ 2,2,2,2,2,2,2,2, # a8 - af
231
+ 2,2,2,2,2,2,2,2, # b0 - b7
232
+ 2,2,2,2,2,2,2,2, # b8 - bf
233
+ 2,2,2,2,2,2,2,2, # c0 - c7
234
+ 2,2,2,2,2,2,2,2, # c8 - cf
235
+ 2,2,2,2,2,2,2,2, # d0 - d7
236
+ 2,2,2,2,2,2,2,2, # d8 - df
237
+ 2,2,2,2,2,2,2,2, # e0 - e7
238
+ 2,2,2,2,2,2,2,2, # e8 - ef
239
+ 2,2,2,2,2,2,2,2, # f0 - f7
240
+ 2,2,2,2,2,2,2,2, # f8 - ff
241
+ )
242
+
243
+ ISO2022KR_ST = (
244
+ MachineState.START, 3,MachineState.ERROR,MachineState.START,MachineState.START,MachineState.START,MachineState.ERROR,MachineState.ERROR,# 00-07
245
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ITS_ME,# 08-0f
246
+ MachineState.ITS_ME,MachineState.ITS_ME,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 4,MachineState.ERROR,MachineState.ERROR,# 10-17
247
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR, 5,MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,# 18-1f
248
+ MachineState.ERROR,MachineState.ERROR,MachineState.ERROR,MachineState.ITS_ME,MachineState.START,MachineState.START,MachineState.START,MachineState.START,# 20-27
249
+ )
250
+
251
+ ISO2022KR_CHAR_LEN_TABLE = (0, 0, 0, 0, 0, 0)
252
+
253
+ ISO2022KR_SM_MODEL = {'class_table': ISO2022KR_CLS,
254
+ 'class_factor': 6,
255
+ 'state_table': ISO2022KR_ST,
256
+ 'char_len_table': ISO2022KR_CHAR_LEN_TABLE,
257
+ 'name': "ISO-2022-KR",
258
+ 'language': 'Korean'}
259
+
260
+