iris-pex-embedded-python 3.1.4b1__tar.gz → 3.1.4b2__tar.gz
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 iris-pex-embedded-python might be problematic. Click here for more details.
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/PKG-INFO +1 -1
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/pyproject.toml +1 -1
- iris_pex_embedded_python-3.1.4b2/setup.py +3 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_BufferReader.py +10 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_BufferWriter.py +32 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_ConnectionInformation.py +56 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_ConnectionParameters.py +18 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_Constant.py +38 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_DBList.py +506 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_Device.py +69 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_GatewayContext.py +25 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_GatewayException.py +4 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_GatewayUtility.py +74 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRIS.py +1294 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISConnection.py +516 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISEmbedded.py +85 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISGlobalNode.py +273 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISGlobalNodeView.py +25 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISIterator.py +143 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISList.py +360 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISNative.py +208 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISOREF.py +9 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISObject.py +424 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_IRISReference.py +133 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_InStream.py +149 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_LegacyIterator.py +135 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_ListItem.py +15 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_ListReader.py +84 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_ListWriter.py +161 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_LogFileStream.py +115 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_MessageHeader.py +51 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_OutStream.py +25 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_PrintStream.py +65 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_PythonGateway.py +850 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/_SharedMemorySocket.py +87 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/__init__.py +79 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/__main__.py +7 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_Column.py +56 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_DBAPI.py +2631 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_Descriptor.py +46 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_IRISStream.py +65 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_Message.py +158 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_Parameter.py +171 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_ParameterCollection.py +141 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_ResultSetRow.py +361 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/_SQLType.py +32 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/__init__.py +0 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/preparser/_PreParser.py +1674 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/preparser/_Scanner.py +391 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/preparser/_Token.py +81 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/preparser/_TokenList.py +251 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/dbapi/preparser/__init__.py +0 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_BusinessHost.py +101 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_BusinessOperation.py +105 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_BusinessProcess.py +214 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_BusinessService.py +95 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_Common.py +228 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_Director.py +24 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_IRISBusinessOperation.py +5 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_IRISBusinessService.py +18 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_IRISInboundAdapter.py +5 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_IRISOutboundAdapter.py +17 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_InboundAdapter.py +57 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_Message.py +6 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/_OutboundAdapter.py +46 -0
- iris_pex_embedded_python-3.1.4b2/src/intersystems_iris/pex/__init__.py +25 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iris_pex_embedded_python.egg-info/PKG-INFO +1 -1
- iris_pex_embedded_python-3.1.4b2/src/iris_pex_embedded_python.egg-info/SOURCES.txt +141 -0
- iris_pex_embedded_python-3.1.4b2/src/iris_pex_embedded_python.egg-info/top_level.txt +4 -0
- iris_pex_embedded_python-3.1.4b2/src/irisnative/_IRISNative.py +9 -0
- iris_pex_embedded_python-3.1.4b2/src/irisnative/__init__.py +10 -0
- iris_pex_embedded_python-3.1.4b1/setup.py +0 -7
- iris_pex_embedded_python-3.1.4b1/src/iris_pex_embedded_python.egg-info/SOURCES.txt +0 -76
- iris_pex_embedded_python-3.1.4b1/src/iris_pex_embedded_python.egg-info/top_level.txt +0 -2
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/LICENSE +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/README.md +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/setup.cfg +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/__init__.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/BusinessOperation.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/BusinessProcess.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/BusinessService.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Common.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Director.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Duplex/Operation.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Duplex/Process.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Duplex/Service.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/InboundAdapter.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Message.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/OutboundAdapter.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PickleMessage.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Test.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/PEX/Utils.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/cls/Grongier/Service/WSGI.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/__init__.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/__main__.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/_business_host.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/_cli.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/_common.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/_director.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/_utils.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/grongier/pex/wsgi/handlers.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/__init__.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/__main__.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_business_host.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_business_operation.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_business_process.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_business_service.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_cli.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_common.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_director.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_inbound_adapter.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_message.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_outbound_adapter.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_pickle_message.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_private_session_duplex.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_private_session_process.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/_utils.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/BusinessOperation.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/BusinessProcess.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/BusinessService.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Common.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Director.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Duplex/Operation.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Duplex/Process.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Duplex/Service.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/InboundAdapter.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Message.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/OutboundAdapter.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PickleMessage.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PrivateSession/Duplex.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PrivateSession/Message/Ack.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PrivateSession/Message/Poll.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PrivateSession/Message/Start.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/PrivateSession/Message/Stop.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Service/WSGI.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Test.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/cls/IOP/Utils.cls +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iop/wsgi/handlers.py +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iris_pex_embedded_python.egg-info/dependency_links.txt +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iris_pex_embedded_python.egg-info/entry_points.txt +0 -0
- {iris_pex_embedded_python-3.1.4b1 → iris_pex_embedded_python-3.1.4b2}/src/iris_pex_embedded_python.egg-info/requires.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import intersystems_iris._ListReader
|
|
2
|
+
|
|
3
|
+
class _BufferReader(intersystems_iris._ListReader._ListReader):
|
|
4
|
+
|
|
5
|
+
def __init__(self, header, buffer, locale):
|
|
6
|
+
self.header = header
|
|
7
|
+
super().__init__(buffer, locale)
|
|
8
|
+
|
|
9
|
+
def _get_header_count(self):
|
|
10
|
+
return self.header._get_count()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import intersystems_iris._ListWriter
|
|
2
|
+
import intersystems_iris._MessageHeader
|
|
3
|
+
|
|
4
|
+
class _BufferWriter(intersystems_iris._ListWriter._ListWriter):
|
|
5
|
+
|
|
6
|
+
def __init__(self, locale, is_unicode, compact_double):
|
|
7
|
+
super().__init__(locale, is_unicode, compact_double)
|
|
8
|
+
self.offset = intersystems_iris._MessageHeader._MessageHeader.HEADER_SIZE
|
|
9
|
+
|
|
10
|
+
def _write_header(self, function_code):
|
|
11
|
+
self.buffer[12] = function_code[0]
|
|
12
|
+
self.buffer[13] = function_code[1]
|
|
13
|
+
self.offset = intersystems_iris._MessageHeader._MessageHeader.HEADER_SIZE
|
|
14
|
+
|
|
15
|
+
def _write_header_sysio(self, sysio_code):
|
|
16
|
+
code_int = sysio_code + 49728
|
|
17
|
+
code_bytes = code_int.to_bytes(2, 'little')
|
|
18
|
+
self.buffer[12] = code_bytes[0]
|
|
19
|
+
self.buffer[13] = code_bytes[1]
|
|
20
|
+
self.offset = intersystems_iris._MessageHeader._MessageHeader.HEADER_SIZE
|
|
21
|
+
|
|
22
|
+
def _set_connection_info(self, connection_info):
|
|
23
|
+
self._locale = connection_info._locale
|
|
24
|
+
self._is_unicode = connection_info._is_unicode
|
|
25
|
+
self._compact_double = connection_info._compact_double
|
|
26
|
+
|
|
27
|
+
def _get_header_buffer(self):
|
|
28
|
+
return self.buffer[0:intersystems_iris._MessageHeader._MessageHeader.HEADER_SIZE]
|
|
29
|
+
|
|
30
|
+
def _get_data_buffer(self):
|
|
31
|
+
return self.buffer[intersystems_iris._MessageHeader._MessageHeader.HEADER_SIZE:self.offset]
|
|
32
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import intersystems_iris._Constant
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _ConnectionInformation(object):
|
|
5
|
+
def __init__(self):
|
|
6
|
+
self.protocol_version = intersystems_iris._Constant._Constant.PROTOCOL_VERSION
|
|
7
|
+
self._is_unicode = True
|
|
8
|
+
self._compact_double = False
|
|
9
|
+
self._locale = "latin-1"
|
|
10
|
+
self._delimited_ids = 0
|
|
11
|
+
self._server_version = ""
|
|
12
|
+
self._server_version_major = 0
|
|
13
|
+
self._server_version_minor = 0
|
|
14
|
+
self._iris_install_dir = ""
|
|
15
|
+
self._server_job_number = -1
|
|
16
|
+
|
|
17
|
+
def _set_server_locale(self, locale):
|
|
18
|
+
self._locale = self._map_server_locale(locale)
|
|
19
|
+
|
|
20
|
+
def _parse_server_version(self, server_version):
|
|
21
|
+
split_1 = server_version.split("|")
|
|
22
|
+
self._server_version = split_1[0]
|
|
23
|
+
if len(split_1) > 1:
|
|
24
|
+
self._iris_install_dir = split_1[1]
|
|
25
|
+
if self._server_version.find("Version") > 0:
|
|
26
|
+
version = server_version[server_version.find("Version") + 8 :]
|
|
27
|
+
self._server_version_major = version.split(".")[0]
|
|
28
|
+
self._server_version_minor = version.split(".")[1]
|
|
29
|
+
return
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def _map_server_locale(locale):
|
|
33
|
+
# we need to map IRIS locale literals to Python locale literals
|
|
34
|
+
_locales = {
|
|
35
|
+
"LATIN1": "latin_1",
|
|
36
|
+
"LATIN2": "iso8859_2",
|
|
37
|
+
"LATINC": "iso8859_5",
|
|
38
|
+
"LATINA": "iso8859_6",
|
|
39
|
+
"LATING": "iso8859_7",
|
|
40
|
+
"LATINH": "iso8859_8",
|
|
41
|
+
"LATINT": "iso8859_11",
|
|
42
|
+
"LATIN9": "iso8859_15",
|
|
43
|
+
"CP1250": "cp1250",
|
|
44
|
+
"CP1251": "cp1251",
|
|
45
|
+
"CP1252": "cp1252",
|
|
46
|
+
"CP1253": "cp1253",
|
|
47
|
+
"CP1255": "cp1255",
|
|
48
|
+
"CP1256": "cp1256",
|
|
49
|
+
"CP1257": "cp1257",
|
|
50
|
+
"CP874": "cp874",
|
|
51
|
+
"UNICODE": "utf-8",
|
|
52
|
+
}
|
|
53
|
+
return _locales[locale.upper()] if locale.upper() in _locales else locale
|
|
54
|
+
|
|
55
|
+
def __repr__(self) -> str:
|
|
56
|
+
return f"<{self._server_version}>"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class _ConnectionParameters(object):
|
|
2
|
+
"""_ConnectionParameters represents the properties that are implicit to a URL."""
|
|
3
|
+
def __init__(self):
|
|
4
|
+
self.hostname = None
|
|
5
|
+
self.port = None
|
|
6
|
+
self.namespace = None
|
|
7
|
+
self.timeout = None
|
|
8
|
+
self.sharedmemory = False
|
|
9
|
+
self.logfile = None
|
|
10
|
+
self.sslcontext = None
|
|
11
|
+
self.isolationLevel = None
|
|
12
|
+
self.featureOptions = None
|
|
13
|
+
|
|
14
|
+
def _set_sharedmemory(self, sharedmemory):
|
|
15
|
+
self.sharedmemory = sharedmemory
|
|
16
|
+
|
|
17
|
+
def _get_sharedmemory(self):
|
|
18
|
+
return self.sharedmemory
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class _Constant():
|
|
2
|
+
|
|
3
|
+
PROTOCOL_VERSION = 65
|
|
4
|
+
|
|
5
|
+
# Message function code
|
|
6
|
+
MESSAGE_CONNECT = b'Y0'
|
|
7
|
+
MESSAGE_DISCONNECT = b'Y4'
|
|
8
|
+
MESSAGE_SHUTDOWN = b'Y6'
|
|
9
|
+
MESSAGE_PING = b'YQ'
|
|
10
|
+
MESSAGE_BENCHMARK_ECHO = b'YY'
|
|
11
|
+
MESSAGE_LOAD_MODULES = b'YP'
|
|
12
|
+
MESSAGE_DYNAMIC_EXECUTE_CONSTRUCTOR = b'YA'
|
|
13
|
+
MESSAGE_DYNAMIC_EXECUTE_METHOD = b'YU'
|
|
14
|
+
MESSAGE_DYNAMIC_EXECUTE_GET = b'YV'
|
|
15
|
+
MESSAGE_DYNAMIC_EXECUTE_SET = b'YB'
|
|
16
|
+
MESSAGE_CREATE_OBJECT = b'Y9'
|
|
17
|
+
MESSAGE_EXCEPTION_RAISED = b'Y5'
|
|
18
|
+
MESSAGE_GET_LIST = b'YG'
|
|
19
|
+
MESSAGE_GET_STREAM = b'YH'
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def __convert(code):
|
|
23
|
+
return code[0]*256+code[1]-22832
|
|
24
|
+
|
|
25
|
+
ENUM_MESSAGE_PASSPHRASE = -48
|
|
26
|
+
ENUM_MESSAGE_CONNECT = __convert.__func__(MESSAGE_CONNECT)
|
|
27
|
+
ENUM_MESSAGE_DISCONNECT = __convert.__func__(MESSAGE_DISCONNECT)
|
|
28
|
+
ENUM_MESSAGE_SHUTDOWN = __convert.__func__(MESSAGE_SHUTDOWN)
|
|
29
|
+
ENUM_MESSAGE_PING = __convert.__func__(MESSAGE_PING)
|
|
30
|
+
ENUM_MESSAGE_BENCHMARK_ECHO = __convert.__func__(MESSAGE_BENCHMARK_ECHO)
|
|
31
|
+
ENUM_MESSAGE_LOAD_MODULES = __convert.__func__(MESSAGE_LOAD_MODULES)
|
|
32
|
+
ENUM_MESSAGE_DYNAMIC_EXECUTE_CONSTRUCTOR = __convert.__func__(MESSAGE_DYNAMIC_EXECUTE_CONSTRUCTOR)
|
|
33
|
+
ENUM_MESSAGE_DYNAMIC_EXECUTE_METHOD = __convert.__func__(MESSAGE_DYNAMIC_EXECUTE_METHOD)
|
|
34
|
+
ENUM_MESSAGE_DYNAMIC_EXECUTE_GET = __convert.__func__(MESSAGE_DYNAMIC_EXECUTE_GET)
|
|
35
|
+
ENUM_MESSAGE_DYNAMIC_EXECUTE_SET = __convert.__func__(MESSAGE_DYNAMIC_EXECUTE_SET)
|
|
36
|
+
|
|
37
|
+
# IRISNative messages
|
|
38
|
+
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import struct
|
|
2
|
+
import decimal
|
|
3
|
+
import functools
|
|
4
|
+
import uuid
|
|
5
|
+
import math
|
|
6
|
+
import intersystems_iris._IRISOREF
|
|
7
|
+
import datetime
|
|
8
|
+
|
|
9
|
+
class _DBList(object):
|
|
10
|
+
|
|
11
|
+
ITEM_UNDEF = -1;
|
|
12
|
+
ITEM_PLACEHOLDER = 0;
|
|
13
|
+
ITEM_ASCII = 1;
|
|
14
|
+
ITEM_UNICODE = 2;
|
|
15
|
+
ITEM_POSINT = 4;
|
|
16
|
+
ITEM_NEGINT = 5;
|
|
17
|
+
ITEM_POSNUM = 6;
|
|
18
|
+
ITEM_NEGNUM = 7;
|
|
19
|
+
ITEM_DOUBLE = 8;
|
|
20
|
+
ITEM_COMPACT_DOUBLE = 9;
|
|
21
|
+
ITEM_OREF_ASCII = 25;
|
|
22
|
+
ITEM_OREF_UNICODE = 26;
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def _get_list_element(cls, item):
|
|
26
|
+
buffer = item.buffer
|
|
27
|
+
offset = item.next_offset
|
|
28
|
+
item.by_reference = False
|
|
29
|
+
# if first byte is 0, then length is next 2 bytes
|
|
30
|
+
if buffer[offset] == 0:
|
|
31
|
+
length = buffer[offset + 1] | (buffer[offset + 2] << 8);
|
|
32
|
+
offset += 3
|
|
33
|
+
# if the length is still 0, then the length is the next 4 bytes
|
|
34
|
+
if length == 0:
|
|
35
|
+
length = buffer[offset] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24);
|
|
36
|
+
offset += 4
|
|
37
|
+
item.type = buffer[offset]
|
|
38
|
+
if item.type >= 32 and item.type < 64:
|
|
39
|
+
item.type = item.type-32
|
|
40
|
+
item.by_reference = True
|
|
41
|
+
item.data_offset = offset + 1
|
|
42
|
+
item.data_length = length - 1
|
|
43
|
+
item.next_offset = item.data_offset + item.data_length
|
|
44
|
+
item.is_null = False
|
|
45
|
+
item.is_undefined = False
|
|
46
|
+
elif buffer[offset] == 1:
|
|
47
|
+
item.type = cls.ITEM_UNDEF
|
|
48
|
+
if item.type >= 32 and item.type < 64:
|
|
49
|
+
item.type = item.type-32
|
|
50
|
+
item.by_reference = True
|
|
51
|
+
item.data_offset = offset + 1
|
|
52
|
+
item.data_length = 0
|
|
53
|
+
item.next_offset = item.data_offset
|
|
54
|
+
item.is_null = True
|
|
55
|
+
item.is_undefined = True
|
|
56
|
+
else:
|
|
57
|
+
item.type = buffer[offset + 1]
|
|
58
|
+
if item.type >= 32 and item.type < 64:
|
|
59
|
+
item.type = item.type-32
|
|
60
|
+
item.by_reference = True
|
|
61
|
+
item.data_offset = offset + 2
|
|
62
|
+
item.data_length = buffer[offset] - 2
|
|
63
|
+
item.next_offset = item.data_offset + item.data_length
|
|
64
|
+
item.is_null = (item.type == cls.ITEM_PLACEHOLDER) or ((item.type == cls.ITEM_ASCII) and (item.data_length == 0))
|
|
65
|
+
item.is_undefined = False
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def _get_data_offset(cls, buffer, offset):
|
|
70
|
+
if buffer[offset] != 0:
|
|
71
|
+
next_offset = offset + buffer[offset]
|
|
72
|
+
elif buffer[offset + 1] == 0 and buffer[offset + 2] == 0:
|
|
73
|
+
if offset + 6 < len(buffer):
|
|
74
|
+
next_offset = offset + (buffer[offset + 3] | (buffer[offset + 4] << 8) | (buffer[offset + 5] << 16)) + 7
|
|
75
|
+
elif offset + 2 < len(buffer):
|
|
76
|
+
next_offset = offset + (buffer[offset + 1] | (buffer[offset + 2] << 8)) + 3
|
|
77
|
+
return next_offset
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def _get(cls, item, locale, asBytes = False, retainAsciiZero = False):
|
|
81
|
+
if item.is_null:
|
|
82
|
+
return None
|
|
83
|
+
func = cls._get_switcher.get(item.type, None)
|
|
84
|
+
if func is None:
|
|
85
|
+
raise Exception("Incorrect list format, unknown type: " + item.type)
|
|
86
|
+
else:
|
|
87
|
+
return func(item.buffer, item.data_offset, item.data_length, locale, asBytes, retainAsciiZero)
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def _grab_ascii_string(cls, buffer, offset, length, locale, asBytes = False, retainAsciiZero = False):
|
|
91
|
+
byte_array = buffer[offset:offset+length]
|
|
92
|
+
if not retainAsciiZero and byte_array == b'\x00':
|
|
93
|
+
return ""
|
|
94
|
+
if asBytes:
|
|
95
|
+
return bytes(byte_array)
|
|
96
|
+
else:
|
|
97
|
+
try:
|
|
98
|
+
return byte_array.decode(locale)
|
|
99
|
+
except:
|
|
100
|
+
return byte_array.decode('latin-1')
|
|
101
|
+
|
|
102
|
+
@classmethod
|
|
103
|
+
def _grab_unicode_string(cls, buffer, offset, length, *args):
|
|
104
|
+
return buffer[offset:offset+length].decode("utf-16LE")
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def _grab_pos_integer(cls, buffer, offset, length, *args):
|
|
108
|
+
number = 0
|
|
109
|
+
for i in range(length):
|
|
110
|
+
number = number*256 + buffer[offset+length-i-1]
|
|
111
|
+
return number
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def _grab_neg_integer(cls, buffer, offset, length, *args):
|
|
115
|
+
if length == 0:
|
|
116
|
+
return -1
|
|
117
|
+
if length == 1:
|
|
118
|
+
return (buffer[offset]) - 0x100
|
|
119
|
+
if length == 2:
|
|
120
|
+
return (buffer[offset] | buffer[offset+1]<<8) - 0x10000
|
|
121
|
+
if length == 3:
|
|
122
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16) - 0x1000000
|
|
123
|
+
if length == 4:
|
|
124
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24) - 0x100000000
|
|
125
|
+
if length == 5:
|
|
126
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32) - 0x10000000000
|
|
127
|
+
if length == 6:
|
|
128
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40) - 0x1000000000000
|
|
129
|
+
if length == 7:
|
|
130
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40 | buffer[offset+6]<<48) - 0x100000000000000
|
|
131
|
+
if length == 8:
|
|
132
|
+
return (buffer[offset] | buffer[offset+1]<<8 | buffer[offset+2]<<16 | buffer[offset+3]<<24 | buffer[offset+4]<<32 | buffer[offset+5]<<40 | buffer[offset+6]<<48 | buffer[offset+7]<<56) - 0x10000000000000000
|
|
133
|
+
raise Exception("Integer out of range")
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def _grab_pos_number(cls, buffer, offset, length, *args):
|
|
137
|
+
num = cls._grab_pos_integer(buffer, offset + 1, length - 1)
|
|
138
|
+
scale = buffer[offset]
|
|
139
|
+
if scale > 127:
|
|
140
|
+
scale -= 256
|
|
141
|
+
return cls.__parse_decimal(scale, num)
|
|
142
|
+
|
|
143
|
+
@classmethod
|
|
144
|
+
def _grab_neg_number(cls, buffer, offset, length, *args):
|
|
145
|
+
num = cls._grab_neg_integer(buffer, offset + 1, length - 1)
|
|
146
|
+
scale = buffer[offset]
|
|
147
|
+
if scale > 127:
|
|
148
|
+
scale -= 256
|
|
149
|
+
return cls.__parse_decimal(scale, num)
|
|
150
|
+
|
|
151
|
+
@classmethod
|
|
152
|
+
def _grab_double(cls, buffer, offset, length, *args):
|
|
153
|
+
if length != 8: return cls.__grab_compact_float(buffer, offset, length)
|
|
154
|
+
return struct.unpack('d', buffer[offset:offset+length])[0]
|
|
155
|
+
|
|
156
|
+
@classmethod
|
|
157
|
+
def _grab_compact_double(cls, buffer, offset, length, *args):
|
|
158
|
+
return struct.unpack('d',b'\x00\x00\x00\x00\x00\x00\x00\x00'[length:]+buffer[offset:offset+length])[0]
|
|
159
|
+
|
|
160
|
+
@classmethod
|
|
161
|
+
def __grab_compact_float(cls, buffer, offset, length):
|
|
162
|
+
return struct.unpack('f',b'\x00\x00\x00\x00'[length:]+buffer[offset:offset+length])[0]
|
|
163
|
+
|
|
164
|
+
@classmethod
|
|
165
|
+
def _grab_oref_ascii(cls, buffer, offset, length, locale, *args):
|
|
166
|
+
return intersystems_iris._IRISOREF._IRISOREF(cls._grab_ascii_string(buffer, offset, length, locale, False))
|
|
167
|
+
|
|
168
|
+
@classmethod
|
|
169
|
+
def _grab_oref_unicode(cls, buffer, offset, length, *args):
|
|
170
|
+
return intersystems_iris._IRISOREF._IRISOREF(cls._grab_unicode_string(buffer, offset, length))
|
|
171
|
+
|
|
172
|
+
@classmethod
|
|
173
|
+
def _set(cls, buffer, offset, data, locale, is_unicode, compact_double):
|
|
174
|
+
func = cls._set_switcher.get(type(data), None)
|
|
175
|
+
if func is None:
|
|
176
|
+
# raise Exception("Unsupported argument type: " + str(type(data)))
|
|
177
|
+
return cls._stuff_str(buffer, offset, str(data), locale, is_unicode, compact_double)
|
|
178
|
+
else:
|
|
179
|
+
return func(buffer, offset, data, locale, is_unicode, compact_double)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def _set_undefined(cls, buffer, offset):
|
|
183
|
+
buffer[offset] = 1
|
|
184
|
+
return offset + 1
|
|
185
|
+
|
|
186
|
+
@classmethod
|
|
187
|
+
def _set_null(cls, buffer, offset):
|
|
188
|
+
return cls._stuff_null(buffer, offset)
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def _stuff_null(cls, buffer, offset, data = None, *args):
|
|
192
|
+
buffer[offset] = 2
|
|
193
|
+
buffer[offset+1] = cls.ITEM_ASCII
|
|
194
|
+
return offset+2
|
|
195
|
+
|
|
196
|
+
@classmethod
|
|
197
|
+
def _stuff_bytes(cls, buffer, offset, data, *args):
|
|
198
|
+
length = len(data)
|
|
199
|
+
offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_ASCII)
|
|
200
|
+
buffer[offset:offset+length] = data[0:length]
|
|
201
|
+
offset += length
|
|
202
|
+
return offset
|
|
203
|
+
|
|
204
|
+
@classmethod
|
|
205
|
+
def _stuff_int(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
206
|
+
if data > 0x7fffffffffffffff or data < -0x8000000000000000:
|
|
207
|
+
return cls._stuff_str(buffer, offset, str(data), locale=locale, is_unicode=is_unicode)
|
|
208
|
+
if data == 0:
|
|
209
|
+
return cls.__set_list_length_type(buffer, offset, 0, cls.ITEM_POSINT)
|
|
210
|
+
elif data > 0:
|
|
211
|
+
length = cls.__get_pos_int_length(data)
|
|
212
|
+
offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_POSINT)
|
|
213
|
+
offset = cls.__stuff_raw_int(buffer, offset, data, length)
|
|
214
|
+
return offset
|
|
215
|
+
else:
|
|
216
|
+
length = cls.__get_neg_int_length(data)
|
|
217
|
+
offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_NEGINT)
|
|
218
|
+
offset = cls.__stuff_raw_int(buffer, offset, data, length)
|
|
219
|
+
return offset
|
|
220
|
+
|
|
221
|
+
@classmethod
|
|
222
|
+
def _stuff_double(cls, buffer, offset, data, locale, is_unicode, compact_double):
|
|
223
|
+
if compact_double:
|
|
224
|
+
if data == 0 and math.copysign(1,data) > 0:
|
|
225
|
+
return cls.__set_list_length_type(buffer, offset, 0, cls.ITEM_DOUBLE)
|
|
226
|
+
# check if value can be corced to a single-precision value
|
|
227
|
+
# pack('<f') can throw OverFlowError
|
|
228
|
+
if struct.unpack('f', struct.pack('f', data))[0] == data:
|
|
229
|
+
lt = cls.ITEM_DOUBLE
|
|
230
|
+
data_bytes = struct.pack('<f',data)
|
|
231
|
+
else:
|
|
232
|
+
lt = cls.ITEM_COMPACT_DOUBLE
|
|
233
|
+
data_bytes = struct.pack('<d',data)
|
|
234
|
+
length = len(data_bytes)
|
|
235
|
+
#skip zeros
|
|
236
|
+
for i in range(length):
|
|
237
|
+
if data_bytes[i] != 0:
|
|
238
|
+
break
|
|
239
|
+
offset = cls.__set_list_length_type(buffer, offset, length-i, lt)
|
|
240
|
+
for j in range(i,length):
|
|
241
|
+
buffer[offset] = data_bytes[j]
|
|
242
|
+
offset += 1
|
|
243
|
+
return offset
|
|
244
|
+
else: # not compact_double
|
|
245
|
+
data_bytes = struct.pack('<d', data)
|
|
246
|
+
length = len(data_bytes)
|
|
247
|
+
offset = cls.__set_list_length_type(buffer, offset, length, cls.ITEM_DOUBLE)
|
|
248
|
+
for i in range(length):
|
|
249
|
+
buffer[offset] = data_bytes[i]
|
|
250
|
+
offset += 1
|
|
251
|
+
return offset
|
|
252
|
+
|
|
253
|
+
@classmethod
|
|
254
|
+
def _stuff_decimal(cls, buffer, offset, data, *args):
|
|
255
|
+
try:
|
|
256
|
+
if math.isnan(data) or math.isinf(data):
|
|
257
|
+
return cls._stuff_double(buffer, offset, data, *args)
|
|
258
|
+
except ValueError as e:
|
|
259
|
+
if str(data).lower() == "snan":
|
|
260
|
+
return cls._stuff_double(buffer, offset, decimal.Decimal('nan'), *args)
|
|
261
|
+
elif str(data).lower() == "-snan":
|
|
262
|
+
return cls._stuff_double(buffer, offset, decimal.Decimal('-nan'), *args)
|
|
263
|
+
else:
|
|
264
|
+
raise e
|
|
265
|
+
bd = data
|
|
266
|
+
scale = -bd.as_tuple()[2]
|
|
267
|
+
unscaled_value = int(bd.scaleb(scale))
|
|
268
|
+
# Truncate the magnitude if it does not fit into a 63 bit value
|
|
269
|
+
if cls.__get_bitlength(unscaled_value) > 63:
|
|
270
|
+
bd_rnd = decimal.Context(prec=19, rounding=decimal.ROUND_HALF_UP).create_decimal(bd)
|
|
271
|
+
scale = -bd_rnd.as_tuple()[2]
|
|
272
|
+
unscaled_value = int(bd_rnd.scaleb(scale))
|
|
273
|
+
if cls.__get_bitlength(unscaled_value) > 63:
|
|
274
|
+
bd_rnd = decimal.Context(prec=18, rounding=decimal.ROUND_HALF_UP).create_decimal(bd)
|
|
275
|
+
scale = -bd_rnd.as_tuple()[2]
|
|
276
|
+
unscaled_value = int(bd_rnd.scaleb(scale))
|
|
277
|
+
if unscaled_value < 922337203685477581 and unscaled_value > -922337203685477581:
|
|
278
|
+
unscaled_value = int((decimal.Decimal(unscaled_value)*10).to_integral_exact(rounding=decimal.ROUND_HALF_UP))
|
|
279
|
+
scale += 1
|
|
280
|
+
if cls.__get_bitlength(unscaled_value) > 63:
|
|
281
|
+
raise Exception("Decimal out of range")
|
|
282
|
+
# Round the extend scale values in the 128-145 range
|
|
283
|
+
if scale < -127 or scale > 128:
|
|
284
|
+
if scale > 128:
|
|
285
|
+
prec_adj = -scale + 128
|
|
286
|
+
else:
|
|
287
|
+
prec_adj = -scale - 127
|
|
288
|
+
unscaled_value = int(decimal.Decimal(unscaled_value).scaleb(prec_adj).to_integral(rounding=decimal.ROUND_HALF_UP))
|
|
289
|
+
scale += prec_adj
|
|
290
|
+
if unscaled_value == 0:
|
|
291
|
+
scale = 0
|
|
292
|
+
if cls.__get_bitlength(unscaled_value) > 63:
|
|
293
|
+
raise Exception("Decimal out of range")
|
|
294
|
+
# If can store in type 6, 7
|
|
295
|
+
if scale < 129 and scale > -128:
|
|
296
|
+
if unscaled_value >= 0:
|
|
297
|
+
length = cls.__get_pos_int_length(unscaled_value)
|
|
298
|
+
offset = cls.__set_list_length_type(buffer, offset, length + 1, cls.ITEM_POSNUM)
|
|
299
|
+
else:
|
|
300
|
+
length = cls.__get_neg_int_length(unscaled_value)
|
|
301
|
+
offset = cls.__set_list_length_type(buffer, offset, length + 1, cls.ITEM_NEGNUM)
|
|
302
|
+
scale = -scale
|
|
303
|
+
if scale < 0:
|
|
304
|
+
scale += 256
|
|
305
|
+
buffer[offset] = scale
|
|
306
|
+
offset += 1
|
|
307
|
+
offset = cls.__stuff_raw_int(buffer, offset, unscaled_value, length)
|
|
308
|
+
return offset
|
|
309
|
+
# Out of range for IRIS Numeric SQLType
|
|
310
|
+
return cls._stuff_double(buffer, offset, data, *args)
|
|
311
|
+
|
|
312
|
+
@classmethod
|
|
313
|
+
def _stuff_str(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
314
|
+
if type(data)==str and len(data) == 0:
|
|
315
|
+
return cls.__stuff_empty_string(buffer, offset)
|
|
316
|
+
is_oref = False
|
|
317
|
+
if type(data) == intersystems_iris._IRISOREF._IRISOREF:
|
|
318
|
+
data = data._oref
|
|
319
|
+
is_oref = True
|
|
320
|
+
offset_saved = offset
|
|
321
|
+
offset = cls.__stuff_8bit_ascii(buffer, offset, data, is_oref)
|
|
322
|
+
if offset == -1:
|
|
323
|
+
offset = offset_saved
|
|
324
|
+
if is_unicode:
|
|
325
|
+
offset = cls.__stuff_unicode(buffer, offset, data, is_oref)
|
|
326
|
+
else:
|
|
327
|
+
offset = cls.__stuff_multibyte(buffer, offset, data, is_oref, locale)
|
|
328
|
+
return offset
|
|
329
|
+
|
|
330
|
+
@classmethod
|
|
331
|
+
def _stuff_uuid(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
332
|
+
return cls._stuff_str(buffer, offset, str(data), locale=locale, is_unicode=is_unicode)
|
|
333
|
+
|
|
334
|
+
@classmethod
|
|
335
|
+
def _stuff_datetime(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
336
|
+
return cls._stuff_str(buffer, offset, data.strftime('%Y-%m-%d %H:%M:%S.%f'), locale=locale, is_unicode=is_unicode)
|
|
337
|
+
|
|
338
|
+
@classmethod
|
|
339
|
+
def _stuff_date(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
340
|
+
return cls._stuff_str(buffer, offset, data.strftime('%Y-%m-%d'), locale=locale, is_unicode=is_unicode)
|
|
341
|
+
|
|
342
|
+
@classmethod
|
|
343
|
+
def _stuff_time(cls, buffer, offset, data, locale, is_unicode, *args):
|
|
344
|
+
return cls._stuff_str(buffer, offset, data.strftime('%H:%M:%S.%f'), locale=locale, is_unicode=is_unicode)
|
|
345
|
+
|
|
346
|
+
@classmethod
|
|
347
|
+
def __set_list_length_type(cls, buffer, offset, length, type):
|
|
348
|
+
length += 1
|
|
349
|
+
if length < 0xFF:
|
|
350
|
+
length += 1;
|
|
351
|
+
buffer[offset] = length
|
|
352
|
+
buffer[offset + 1] = type
|
|
353
|
+
return offset + 2
|
|
354
|
+
if length <= 0xFFFF:
|
|
355
|
+
buffer[offset] = 0
|
|
356
|
+
buffer[offset + 1] = length & 0xFF
|
|
357
|
+
buffer[offset + 2] = (length >> 8) & 0xFF
|
|
358
|
+
buffer[offset + 3] = type
|
|
359
|
+
return offset + 4
|
|
360
|
+
buffer[offset] = 0;
|
|
361
|
+
buffer[offset + 1] = 0;
|
|
362
|
+
buffer[offset + 2] = 0;
|
|
363
|
+
buffer[offset + 3] = length & 0xFF
|
|
364
|
+
buffer[offset + 4] = (length >> 8) & 0xFF
|
|
365
|
+
buffer[offset + 5] = (length >> 16) & 0xFF
|
|
366
|
+
buffer[offset + 6] = (length >> 24) & 0xFF
|
|
367
|
+
buffer[offset + 7] = type
|
|
368
|
+
return offset + 8
|
|
369
|
+
|
|
370
|
+
@classmethod
|
|
371
|
+
def __get_pos_int_length(cls, data):
|
|
372
|
+
if data <= 0xFF:
|
|
373
|
+
return 1
|
|
374
|
+
if data <= 0xFFFF:
|
|
375
|
+
return 2
|
|
376
|
+
if data <= 0xFFFFFF:
|
|
377
|
+
return 3
|
|
378
|
+
if data <= 0xFFFFFFFF:
|
|
379
|
+
return 4
|
|
380
|
+
if data <= 0xFFFFFFFFFF:
|
|
381
|
+
return 5
|
|
382
|
+
if data <= 0xFFFFFFFFFFFF:
|
|
383
|
+
return 6
|
|
384
|
+
if data <= 0xFFFFFFFFFFFFFF:
|
|
385
|
+
return 7
|
|
386
|
+
if data <= 0xFFFFFFFFFFFFFFFF:
|
|
387
|
+
return 8
|
|
388
|
+
raise Exception("Integer out of range")
|
|
389
|
+
|
|
390
|
+
@classmethod
|
|
391
|
+
def __get_neg_int_length(cls, data):
|
|
392
|
+
if data == -1:
|
|
393
|
+
return 0
|
|
394
|
+
if data >= -0x100:
|
|
395
|
+
return 1
|
|
396
|
+
if data >= -0x10000:
|
|
397
|
+
return 2
|
|
398
|
+
if data >= -0x1000000:
|
|
399
|
+
return 3
|
|
400
|
+
if data >= -0x100000000:
|
|
401
|
+
return 4
|
|
402
|
+
if data >= -0x10000000000:
|
|
403
|
+
return 5
|
|
404
|
+
if data >= -0x1000000000000:
|
|
405
|
+
return 6
|
|
406
|
+
if data >= -0x100000000000000:
|
|
407
|
+
return 7
|
|
408
|
+
if data >= -0x10000000000000000:
|
|
409
|
+
return 8
|
|
410
|
+
raise Exception("Integer out of range")
|
|
411
|
+
|
|
412
|
+
@classmethod
|
|
413
|
+
def __stuff_raw_int(cls, buffer, offset, data, length):
|
|
414
|
+
for i in range(length):
|
|
415
|
+
one_byte = data & 255
|
|
416
|
+
data = data >> 8
|
|
417
|
+
buffer[offset+i] = one_byte
|
|
418
|
+
return offset+length
|
|
419
|
+
|
|
420
|
+
@classmethod
|
|
421
|
+
def __stuff_empty_string(cls, buffer, offset):
|
|
422
|
+
buffer[offset] = 3
|
|
423
|
+
buffer[offset+1] = cls.ITEM_ASCII
|
|
424
|
+
buffer[offset+2] = 0
|
|
425
|
+
return offset+3
|
|
426
|
+
|
|
427
|
+
@classmethod
|
|
428
|
+
def __stuff_8bit_ascii(cls, buffer, offset, data, is_oref):
|
|
429
|
+
try:
|
|
430
|
+
list_type = cls.ITEM_OREF_ASCII if is_oref else cls.ITEM_ASCII
|
|
431
|
+
length = len(data)
|
|
432
|
+
offset = cls.__set_list_length_type(buffer, offset, length, list_type)
|
|
433
|
+
buffer[offset:offset+length] = data.encode("latin-1")
|
|
434
|
+
return offset+length
|
|
435
|
+
except Exception as e:
|
|
436
|
+
return -1
|
|
437
|
+
|
|
438
|
+
@classmethod
|
|
439
|
+
def __stuff_unicode(cls, buffer, offset, data, is_oref):
|
|
440
|
+
list_type = cls.ITEM_OREF_UNICODE if is_oref else cls.ITEM_UNICODE
|
|
441
|
+
byte_array = bytearray(data,"utf-16LE")
|
|
442
|
+
length = len(byte_array)
|
|
443
|
+
offset = cls.__set_list_length_type(buffer, offset, length, list_type)
|
|
444
|
+
buffer[offset:offset+length] = byte_array[0:length]
|
|
445
|
+
return offset+length
|
|
446
|
+
|
|
447
|
+
@classmethod
|
|
448
|
+
def __stuff_multibyte(cls, buffer, offset, data, is_oref, locale):
|
|
449
|
+
list_type = cls.ITEM_OREF_ASCII if is_oref else cls.ITEM_ASCII
|
|
450
|
+
ascii = data.encode(locale)
|
|
451
|
+
length = len(ascii)
|
|
452
|
+
offset = cls.__set_list_length_type(buffer, offset, length, list_type)
|
|
453
|
+
buffer[offset:offset+length] = ascii
|
|
454
|
+
return offset + length
|
|
455
|
+
|
|
456
|
+
@classmethod
|
|
457
|
+
def __parse_decimal(cls, scale, num):
|
|
458
|
+
decstr = str(num) + "E" + str(scale)
|
|
459
|
+
dec = decimal.Decimal(decstr)
|
|
460
|
+
return dec
|
|
461
|
+
|
|
462
|
+
@classmethod
|
|
463
|
+
def __get_bitlength(cls, value):
|
|
464
|
+
if value < 0:
|
|
465
|
+
return (value + 1).bit_length()
|
|
466
|
+
else:
|
|
467
|
+
return value.bit_length()
|
|
468
|
+
|
|
469
|
+
@classmethod
|
|
470
|
+
def _set_type_as_pass_by_reference(cls, buffer, offset):
|
|
471
|
+
if buffer[offset] == 0:
|
|
472
|
+
buffer[offset+3] = buffer[offset+3]+32
|
|
473
|
+
elif buffer[offset] == 1:
|
|
474
|
+
pass
|
|
475
|
+
else:
|
|
476
|
+
buffer[offset+1] = buffer[offset+1]+32
|
|
477
|
+
return
|
|
478
|
+
|
|
479
|
+
_DBList._get_switcher = {
|
|
480
|
+
_DBList.ITEM_ASCII: _DBList._grab_ascii_string,
|
|
481
|
+
_DBList.ITEM_UNICODE: _DBList._grab_unicode_string,
|
|
482
|
+
_DBList.ITEM_POSINT: _DBList._grab_pos_integer,
|
|
483
|
+
_DBList.ITEM_NEGINT: _DBList._grab_neg_integer,
|
|
484
|
+
_DBList.ITEM_POSNUM: _DBList._grab_pos_number,
|
|
485
|
+
_DBList.ITEM_NEGNUM: _DBList._grab_neg_number,
|
|
486
|
+
_DBList.ITEM_DOUBLE: _DBList._grab_double,
|
|
487
|
+
_DBList.ITEM_COMPACT_DOUBLE: _DBList._grab_compact_double,
|
|
488
|
+
_DBList.ITEM_OREF_ASCII: _DBList._grab_oref_ascii,
|
|
489
|
+
_DBList.ITEM_OREF_UNICODE: _DBList._grab_oref_unicode
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
_DBList._set_switcher = {
|
|
493
|
+
type(None): _DBList._stuff_null,
|
|
494
|
+
datetime.time: _DBList._stuff_time,
|
|
495
|
+
datetime.date: _DBList._stuff_date,
|
|
496
|
+
datetime.datetime: _DBList._stuff_datetime,
|
|
497
|
+
bytes: _DBList._stuff_bytes,
|
|
498
|
+
bytearray: _DBList._stuff_bytes,
|
|
499
|
+
bool: _DBList._stuff_int,
|
|
500
|
+
int: _DBList._stuff_int,
|
|
501
|
+
float: _DBList._stuff_double,
|
|
502
|
+
decimal.Decimal: _DBList._stuff_decimal,
|
|
503
|
+
str: _DBList._stuff_str,
|
|
504
|
+
uuid.UUID: _DBList._stuff_uuid,
|
|
505
|
+
intersystems_iris._IRISOREF._IRISOREF: _DBList._stuff_str,
|
|
506
|
+
}
|