diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..3011024 --- /dev/null +++ b/License.txt @@ -0,0 +1,23 @@ +All files Copyright 2012 Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this proprietary software and associated documentation files (the "Software"), +to use, publish, or distribute copies of the Software, and to permit persons to +whom the Software is furnished to do so. + +Any other use, including modifying, adapting, reverse engineering, decompiling, +or disassembling, is not permitted. + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..de74c32 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +include README.md changelog.txt License.txt +exclude pyproject.toml + +recursive-include examples *.py README.md diagram.png +recursive-exclude examples/demoapps-internal * + +prune cpp-licenses diff --git a/NOTES b/NOTES deleted file mode 100644 index 04ccd62..0000000 --- a/NOTES +++ /dev/null @@ -1,234 +0,0 @@ -This document outlines most obvious differences between Bloomberg C++ SDK and -this Python SDK. - - -Different APIs -============== - -Below is a list of APIs that have different parameters or enhanced -functionality: - -class 'Constant' ----------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of type 'Constant' are destroyed before the relevant sessions. - - -C++: overloaded methods with name 'getValueAs', together with methods -'getValueAsChar', 'getValueAsInt32', 'getValueAsInt64', 'getValueAsFloat32', -'getValueAsFloat64', 'getValueAsDatetime', 'getValueAsString'. - -Python: methods 'getValueAsInteger', 'getValueAsFloat', 'getValueAsDatetime', -'getValueAsString', that return integers, floats, datetime objects, strings, -and method 'getValue' that returns value of the constant as it is stored, -without conversion. - - -class 'ConstantList' --------------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of type 'Constant' are destroyed before the relevant sessions. - -In addition, in Python, objects of type ConstantList support iterator -interface, to iterate over constants they store. - - -class 'CorrelationId' ---------------------- - -C++: method 'swap' that swaps two CorrelationID objects. - -Python: none. - - -C++: method 'valueType'. - -Python: method that does the same has different name, 'type'. - - -class Datetime --------------- - -In Python SDK, two methods exist to convert between objects of this type and -standard Python classes from datetime module, -blpapi._DatetimeUtil.convertToNative, and -blpapi._DatetimeUtil.convertToBlpapi. No separate Datetime class is defined. - -class 'Element' ---------------- - -C++: overloaded methods with name 'GetElement' that return an element based on -its name or position for sequences or choices. - -Python: two separate methods: 'GetElement' that returns an element by its name -and method 'GetElementAt' that returns an element at the specified position. - - -C++: overloaded methods with name 'getValueAs', together with methods -'getValueAsBool', 'getValueAsChar', 'getValueAsInt32', 'getValueAsInt64', -'getValueAsFloat32', 'getValueAsFloat64', 'getValueAsDatetime', -'getValueAsString', 'getValueAsElement', 'getValueAsName'. - -Python: methods 'getValueAsBool', 'getValueAsInteger', 'getValueAsFloat', -'getValueAsDatetime', 'getValueAsString', 'getValueAsName', -'getValueAsElement' that return value of the element converted to the relevant -data types, and method 'getValue' that returns value of the (sub)element as it -is stored, without conversion. - - -C++: methods 'getElementAsBool', 'getElementAsChar', 'getElementAsInt32', -'getElementAsInt64', 'getElementAsFloat32', 'getElementAsFloat64', -'getElementAsDatetime', 'getElementAsString', 'getElementAsName'. - -Python: methods 'getElementAsBool', 'getElementAsString', -'getElementAsDatetime', 'getElementAsInteger', 'getElementAsFloat', -'getElementAsName' that return a value of the specified subelement converted -to the relevant data types, and method 'getElementValue' that returns the -value without conversion. - - -C++: overloaded methods 'setElement', 'setValue', 'appendValue' for bool, -char, Int32, Int64, Float32, Float64, Datetime, const char*, Name date types. - -Python: methods 'setElement', 'setValue', 'appendValue' that treat bools as -BLPAPI_DATATYPE_BOOL, ints as BLPAPI_DATATYPE_INT32, longs as -BLPAPI_DATATYPE_INT64, floats as BLPAPI_DATATYPE_FLOAT64, Datetimes as -BLPAPI_DATATYPE_DATETIME. Everything else is treated as/converted to -BLPAPI_DATATYPE_STRING. - - -Also, this class in the Python implementation support methods 'elements' and -'values' to iterate over elements in this object and values stored in it. - - -class 'Event' -------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -In addition, in Python, objects of this type support iterator interface, to -iterate over messages they store. - - -class 'EventHandler' --------------------- - -Not defined in Python code. Examples of event handlers can be found in -'MktdataPublisher.py' and 'PagePublisherExample.py' files in examples -directory. - - -class 'Identity' ----------------- - -C++: constructor accepts a handle - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -class 'Message' ---------------- - -C++: methods 'numCorrelationIds', 'correlationId'. - -Python: method 'correlationIds', that return a list of correlation IDs. - - -class 'Name' ------------- - -C++: class method 'findName' returns 'Name()' when it cannot find the name. - -Python: class method 'findName' returns None when it cannot find the name. - - -class 'Request' ---------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -class 'SchemaElementDefinition' -------------------------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -C++: methods 'numAlternateNames', 'getAlternateName'. - -Python: method 'alternateNames', that returns a list of Name objects. - - -class 'SchemaTypeDefinition' ---------------------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -class 'Operation' ------------------ - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -C++: method 'responseDefinition'. - -Python: method 'getResponseDefinitionAt'. - - -In addition, in Python, objects of this type support iterator interface, to -iterate over responses they store. - - -class 'Service' ---------------- - -C++: constructor accepts a handle. - -Python: constructor accepts a handle and a list of relevant sessions, to make -sure objects of this type are destroyed before the relevant sessions. - - -C++: overloaded methods 'getOperation'. - -Python: methods 'getOperation' and 'getOperationAt'. - - -C++: overloaded method 'getEventDefinition'. - -Python: methods 'getEventDefinition' and 'getEventDefinitionAt'. - - -In addition, in Python, objects of this type support iterator interface. - - -General notes -------------- - -In most cases, where a class defines method print() that sends formatted -output to a stream, a replacement method is defined in the Python SDK, -toString(), that returns a formatted string. - diff --git a/PKG-INFO b/PKG-INFO index ca3af1a..ed6ac7c 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,15 +1,14 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: blpapi -Version: 3.9.2 -Summary: Python SDK for Bloomberg BLPAPI (<=3.9) +Version: 3.24.11 +Summary: Python SDK for Bloomberg BLPAPI Home-page: http://www.bloomberglabs.com/api/ Author: Bloomberg L.P. Author-email: open-tech@bloomberg.net -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Financial and Insurance Industry Classifier: License :: Other/Proprietary License Classifier: Topic :: Office/Business :: Financial +Requires-Python: >=3.8 +License-File: License.txt diff --git a/README b/README.md similarity index 64% rename from README rename to README.md index 33f4713..68b2a55 100644 --- a/README +++ b/README.md @@ -1,28 +1,40 @@ -Bloomberg Python API version 3.9 -================================ +# Bloomberg Python API This directory contains an interface for interacting with Bloomberg API services using the Python programming language. This package is the source -installer, and requires a C compilation environment compatible with Python's -`distutils` package. Windows users without such an environment are encourage to -instead use the appropriate binary installer, available from -. +installer, and requires a C/C++ compilation environment compatible with +Python's `setuptools` package. +Users are encouraged to install using `pip` directly, as documented in + -Dependencies ------------- +## Dependencies This SDK requires the following products: -- CPython version 2.6 or higher +- CPython version 3.8 or higher -- Bloomberg C++ SDK version 3.9 or later +- Bloomberg C++ SDK same major and minor version as the Python SDK -- Visual C++ 2008 or 2010 (Windows) or GCC 4.1+ (Linux) +- Optionally, C/C++ compiler for your CPython installation +- On Windows, the VC redistributable package for the Python install -Installation ------------- +The C/C++ compilers are only needed for building the binary part of the module. +We provide pre-built binaries for different versions of CPython on Windows, but +you may need to have the compiler to build on other operating systems or +unsupported versions of CPython. + +On Windows, the VS redistributable package for the compiler used in the target +CPython installation is needed. You can find the compiler version for a +CPython version [here](https://wiki.python.org/moin/WindowsCompilers) and the VC redistributable package [here](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads). + +## Installation from sources + +Installation using pip is strongly recommended, and can handle installing from +sources by building the Python SDK binaries locally. The C++ SDK and setting +the `BLPAPI_ROOT` environment is still needed to build with `pip`, but the rest +of the steps are equivalent to a normal installation. Note that installation requires a working C compiler and the C headers distributed as part of the Bloomberg C++ SDK. @@ -30,19 +42,23 @@ distributed as part of the Bloomberg C++ SDK. 1. Set the `BLPAPI_ROOT` environment variable to the location at which the Bloomberg C++ SDK is installed. (This is the directory containing the `include` directory. On linux this may be of the form - `$HOME/blpapi_cpp_3.9.5.1`; on Windows, this location may be of the - form `C:\blp\API\APIv3\C++API\v3.9.5.1\`.) Note that this is environment + `$HOME/blpapi_cpp_3.x.y.z`; on Windows, this location may be of the + form `C:\blp\API\APIv3\C++API\v3.x.y.z\`.) Note that this is environment variable is required only for *installing* the `blpapi` package, not for running blpapi python applications. 2. To compile and install the `blpapi` Python package for all users, run - > python setup.py install + ```bash + > python setup.py install + ``` To compile and install the `blpapi` Python package for only the current user, run - > python setup.py install --user + ```bash + > python setup.py install --user + ``` (Note that the former command requires root/administrator access, while the latter does not.) @@ -50,19 +66,21 @@ distributed as part of the Bloomberg C++ SDK. Documentation on additional build and installation options is available by running - > python setup.py --help + ```bash + > python setup.py --help + ``` 3. (optional) Copy the C++ SDK shared library/DLL to a standard library location (e.g. `/usr/lib` on Linux), or update the system-wide library path (configured by `/etc/ld.so.conf` on Linux and by setting the `PATH` environment variable on Windows) to include the directory containing the C++ SDK library. Note that this step is not necessary for users who already - have a system-wide installation of the C++ SDK, including Windows users who - have the Bloomberg Terminal software installed. + have a system-wide installation of the C++ SDK with the same or newer + version, including Windows users who have the Bloomberg Terminal software + installed. -Writing Bloomberg API Programs in Python ----------------------------------------- +## Writing Bloomberg API Programs in Python In order for python scripts to call Bloomberg API functions, the libraries distributed as part of the Bloomberg C++ SDK must be available to the Python @@ -78,12 +96,14 @@ these libraries in their `PATH`.) After installation, the `blpapi` module can be imported by a Python script or within the CPython interpreter: - >>> import blpapi - >>> options = blpapi.SessionOptions() - >>> options.setServerHost('localhost') - >>> options.setServerPort(8194) - >>> session = blpapi.Session(options) - >>> session.start() +```python +>>> import blpapi +>>> options = blpapi.SessionOptions() +>>> options.setServerHost('localhost') +>>> options.setServerPort(8194) +>>> session = blpapi.Session(options) +>>> session.start() +``` Note that many Python installations add the current directory to the module search path. If the Python interpreter is invoked from the installer directory, @@ -96,22 +116,21 @@ Documentation for individual Bloomberg API classes and functions is provided through Python's built-in help system. Further documentation on programming the Bloomberg API is available in the -Developer's Guide, available at . +Developer's Guide, available at +. -Examples --------- +## Examples A collection of complete Python programs covering a wide range of typical API -usage is available in the `examples` directory, located in the same directory +usage is available in the [`examples` directory](examples/), located in the same directory as this `README` file. Note that many examples make use of command-line arguments to specify server and authentication configuration; in most cases usage information can be obtained by passing the `--help` option on the command line. -Implementation Notes --------------------- +## Implementation Notes - The Bloomberg SDK for Python 2 does not provide direct support for Python `unicode` objects. Clients can pass unicode data to SDK functions accepting @@ -119,12 +138,11 @@ Implementation Notes `u`; a string `s` received from an SDK function can be converted to a `unicode` object by calling `s.decode('utf-8')`. -- Python Bloomberg SDK types do not provide support for the Python `copy` or - `pickle` modules. +- Python Bloomberg SDK types do not support directly for the Python `copy` or + `pickle` modules. However, `.toPy` method for messages is available. -Copyright and License ---------------------- +## Copyright and License All files Copyright 2012 Bloomberg Finance L.P. @@ -146,4 +164,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/blpapi/abstractsession.py b/blpapi/abstractsession.py deleted file mode 100644 index 3f9fed2..0000000 --- a/blpapi/abstractsession.py +++ /dev/null @@ -1,290 +0,0 @@ -# abstractsession.py - -"""A common interface shared between publish and consumer sessions. - -This file defines a class 'AbstractSession' - an interface which is shared -between its concrete implementations 'Session' and 'ProviderSession'. - -SERVICE IDENTIFIER ------------------- -A service identifier is the fully qualified service name which uniquely -identifies the service in the API infrastructure. A service must be of the -form "///" where '' and '' are -non-empty strings of characters from the set '[-_.a-zA-Z0-9]'. Service -identifiers are case-insensitive, but clients are encouraged to prefer -identifiers without upper-case characters. Note that the and - cannot contain the character '/'. -""" - - - -from .exception import _ExceptionUtil -from .identity import Identity -from .service import Service -from . import internals -from .internals import CorrelationId -from . import utils -from .compat import with_metaclass - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class AbstractSession(object): - """A common interface shared between publish and consumer sessions. - - This class provides an abstract session which defines shared interface - between publish and consumer requests for Bloomberg - - Sessions manage access to services either by requests and - responses or subscriptions. A Session can dispatch events and - replies in either a synchronous or asynchronous mode. The mode - of a Session is determined when it is constructed and cannot be - changed subsequently. - - A Session is asynchronous if an EventHandler object is - supplied when it is constructed. The nextEvent() method may not be called. - All incoming events are delivered to the EventHandler supplied on - construction. - - If supplied, EventHandler is a callable object that takes two arguments: - received event and related session. - - A Session is synchronous if an EventHandler object is not - supplied when it is constructed. The nextEvent() method must be - called to read incoming events. - - Several methods in Session take a CorrelationId parameter. The - application may choose to supply its own CorrelationId values - or allow the Session to create values. If the application - supplies its own CorrelationId values it must manage their - lifetime such that the same value is not reused for more than - one operation at a time. The lifetime of a CorrelationId begins - when it is supplied in a method invoked on a Session and ends - either when it is explicitly cancelled using cancel() or - unsubscribe(), when a RESPONSE Event (not a PARTIAL_RESPONSE) - containing it is received or when a SUBSCRIPTION_STATUS Event - which indicates that the subscription it refers to has been - terminated is received. - - When using an asynchronous Session the application must be - aware that because the callbacks are generated from another - thread they may be processed before the call which generates - them has returned. For example, the SESSION_STATUS Event - generated by a startAsync() may be processed before - startAsync() has returned (even though startAsync() itself will - not block). - - This becomes more significant when Session generated - CorrelationIds are in use. For example, if a call to - subscribe() which returns a Session generated CorrelationId has - not completed before the first Events which contain that - CorrelationId arrive the application may not be able to - interpret those events correctly. For this reason, it is - preferable to use user generated CorrelationIds when using - asynchronous Sessions. This issue does not arise when using a - synchronous Session as long as the calls to subscribe() etc are - made on the same thread as the calls to nextEvent(). - """ - - def __init__(self, handle=None): - """Instantiate an 'AbstractSession' with the specified handle. - - This function is for internal use only. Clients should create sessions - using one of the concrete subclasses of 'AbstractSession'. - - """ - - if self.__class__ is AbstractSession: - raise NotImplementedError("Don't instantiate this class directly.\ - Create sessions using one of the concrete subclasses of this class.") - self.__handle = handle - - def openService(self, serviceName): - """Open the service identified by the specified 'serviceName'. - - Attempt to open the service identified by the specified - 'serviceName' and block until the service is either opened - successfully or has failed to be opened. Return 'True' if - the service is opened successfully and 'False' if the - service cannot be successfully opened. - - The 'serviceName' must contain a fully qualified service name. That - is, it must be of the form "///". - - Before openService() returns a SERVICE_STATUS Event is - generated. If this is an asynchronous Session then this - Event may be processed by the registered EventHandler - before openService() has returned. - """ - return internals.blpapi_AbstractSession_openService( - self.__handle, - serviceName) == 0 - - def openServiceAsync(self, serviceName, correlationId=None): - """Begin the process to open the service and return immediately. - - Begin the process to open the service identified by the - specified 'serviceName' and return immediately. The optional - specified 'correlationId' is used to track Events generated - as a result of this call. The actual correlationId which - will identify Events generated as a result of this call is - returned. - - The 'serviceName' must contain a fully qualified service name. That - is, it must be of the form "///". - - The application must monitor events for a SERVICE_STATUS - Event which will be generated once the service has been - successfully opened or the opening has failed. - """ - if correlationId is None: - correlationId = CorrelationId() - _ExceptionUtil.raiseOnError( - internals.blpapi_AbstractSession_openServiceAsync( - self.__handle, - serviceName, - correlationId._handle())) - return correlationId - - def sendAuthorizationRequest(self, - request, - identity, - correlationId=None, - eventQueue=None): - """Send the specified 'authorizationRequest'. - - Send the specified 'authorizationRequest' and update the - specified 'identity' with the results. If the optionally - specified 'correlationId' is supplied, it is used; otherwise - create a CorrelationId. The actual CorrelationId used is - returned. If the optionally specified 'eventQueue' is - supplied all Events relating to this Request will arrive on - that EventQueue. - - The underlying user information must remain valid until the - Request has completed successfully or failed. - - A successful request will generate zero or more - PARTIAL_RESPONSE Messages followed by exactly one RESPONSE - Message. Once the final RESPONSE Message has been received - the specified 'identity' will have been updated to contain - the users entitlement information and the CorrelationId - associated with the request may be re-used. If the request - fails at any stage a REQUEST_STATUS will be generated, the - specified 'identity' will not be modified and the - CorrelationId may be re-used. - - The 'identity' supplied must have been returned from this - Session's createIdentity() method. - - """ - - if correlationId is None: - correlationId = CorrelationId() - _ExceptionUtil.raiseOnError( - internals.blpapi_AbstractSession_sendAuthorizationRequest( - self.__handle, - request._handle(), - identity._handle(), - correlationId._handle(), - None if eventQueue is None else eventQueue._handle(), - None, # no request label - 0)) # request label length 0 - if eventQueue is not None: - eventQueue._registerSession(self) - return correlationId - - def cancel(self, correlationId): - """Cancel 'correlationId' request. - - If the specified 'correlationId' identifies a current - request then cancel that request. - - Once this call returns the specified 'correlationId' will - not be seen in any subsequent Message obtained from a - MessageIterator by calling next(). However, any Message - currently pointed to by a MessageIterator when - cancel() is called is not affected even if it has the - specified 'correlationId'. Also any Message where a - reference has been retained by the application may still - contain the 'correlationId'. For these reasons, although - technically an application is free to re-use - 'correlationId' as soon as this method returns it is - preferable not to aggressively re-use correlation IDs, - particularly with an asynchronous Session. - - 'correlationId' should be either a correlation Id or a list of - correlation Ids. - - """ - - _ExceptionUtil.raiseOnError(internals.blpapi_AbstractSession_cancel( - self.__handle, - correlationId._handle(), - 1, # number of correlation IDs supplied - None, # no request label - 0)) # request label length 0 - - def generateToken(self, correlationId=None, eventQueue=None): - """Generate a token to be used for authorization. - - If invalid authentication option is specified in session option or - there is failure to get authentication information based on - authentication option, then an InvalidArgumentException is raised. - """ - if correlationId is None: - correlationId = CorrelationId() - _ExceptionUtil.raiseOnError( - internals.blpapi_AbstractSession_generateToken( - self.__handle, - correlationId._handle(), - None if eventQueue is None else eventQueue._handle())) - if eventQueue is not None: - eventQueue._registerSession(self) - return correlationId - - def getService(self, serviceName): - """Return a Service object representing the service. - - Return a Service object representing the service identified by the - specified 'serviceName'. - - The 'serviceName' must contain a fully qualified service name. That - is, it must be of the form "///". - - If the service identified by the specified 'serviceName' is not open - already then an InvalidStateException is raised. - """ - errorCode, service = internals.blpapi_AbstractSession_getService( - self.__handle, - serviceName) - _ExceptionUtil.raiseOnError(errorCode) - return Service(service, self) - - def createIdentity(self): - """Return a Identity which is valid but has not been authorized.""" - return Identity( - internals.blpapi_AbstractSession_createIdentity(self.__handle), - self) - - # Protect enumeration constant(s) defined in this class and in classes - # derived from this class from changes: - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/compat.py b/blpapi/compat.py deleted file mode 100644 index 1f40390..0000000 --- a/blpapi/compat.py +++ /dev/null @@ -1,73 +0,0 @@ -# compat.py - -import sys - -""" Different compatibility tools. Needed to support both -2.x and 3.x python versions.""" - -def with_metaclass(metaclass): - """Python 2 and 3 different metaclass syntax workaround. Should be used as a decorator.""" - def wrapper(cls): - vars = cls.__dict__.copy() - slots = vars.get('__slots__') - if slots is not None: - if isinstance(slots, str): - slots = [slots] - for slots_var in slots: - vars.pop(slots_var) - vars.pop('__dict__', None) - vars.pop('__weakref__', None) - return metaclass(cls.__name__, cls.__bases__, vars) - return wrapper - -# NOTE: this function should be used to convert integer values to long -# values in both python2 and 3. - -if sys.version.startswith('2'): - def tolong(val): - return long(val) -else: - def tolong(val): - return int(val) - -# NOTE: python2 wrapper uses byte strings (str type) to pass strings to C-functions, -# unicode type is not supported so we need to encode all strings first. -# On the other hand, python3 wrapper uses unicode strings (str type) for this so we need -# to decode byte-strings first to get unicode strings. Rule of thumb: to pass string to any -# wrapper function convert it using `conv2str` function first, to check that type of the -# string is correct - use `isstr` function. - -if sys.version.startswith('2'): - def conv2str(s): - """Convert unicode string to byte string.""" - if isinstance(s, str): - return s - elif isinstance(s, unicode): - return s.encode('utf-8') - else: - return None - - def isstr(s): - if isinstance(s, (str, unicode)): - return True - return False -else: - def conv2str(s): - """Convert byte string to unicode string.""" - if isinstance(s, bytes): - return s.decode() - elif isinstance(s, str): - return s - else: - return None - - def isstr(s): - if isinstance(s, (bytes, str)): - return True - return False - -# NOTE: integer typelist for different python versions to use with isinstance builtin function -if sys.version.startswith('2'): - int_typelist = (int, long) -else: - int_typelist = (int,) diff --git a/blpapi/constant.py b/blpapi/constant.py deleted file mode 100644 index aa9b1ac..0000000 --- a/blpapi/constant.py +++ /dev/null @@ -1,261 +0,0 @@ -# constant.py - -"""Provide a representation for schema-level enumeration constants. - -This file defines these classes: - 'Constant' - schema enumeration constant - 'ConstantList' - list of schema enumeration constants - -This component provides a representation of a schema enumeration constant, and -a representation for lists of such constants -""" - - - -from .exception import _ExceptionUtil, NotFoundException, \ - IndexOutOfRangeException -from .name import Name, getNamePair -from .datatype import DataType -from .datetime import _DatetimeUtil -from . import utils -from . import internals - - -class Constant: - """Represents the value of a schema enumeration constant. - - Constants can be any of the following DataTypes: BOOL, CHAR, BYTE, INT32, - INT64, FLOAT32, FLOAT64, STRING, DATE, TIME, DATETIME. This class provides - access not only to to the constant value, but also to the symbolic name, - the description, and the status of the constant. - - 'Constant' objects are read-only. - - Application clients never create 'Constant' object directly; applications - will typically work with 'Constant' objects returned by other 'blpapi' - components. - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def name(self): - """Return the symbolic name of this 'Constant'.""" - return Name._createInternally( - internals.blpapi_Constant_name(self.__handle)) - - def description(self): - """Return a human readable description of this 'Constant'.""" - return internals.blpapi_Constant_description(self.__handle) - - def status(self): - """Return the status of this 'Constant'. - - The possible return values are enumerated in 'SchemaStatus' class. - """ - return internals.blpapi_Constant_status(self.__handle) - - def datatype(self): - """Return the data type used to represent the value of this 'Constant'. - - The possible return values are enumerated in 'DataType' class. - """ - return internals.blpapi_Constant_datatype(self.__handle) - - def getValueAsInteger(self): - """Return the value of this object as an integer. - - If the value cannot be converted to an integer an exception is raised. - """ - errCode, value = internals.blpapi_Constant_getValueAsInt64( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return value - - def getValueAsFloat(self): - """Return the value of this object as a float. - - If the value cannot be converted to a float an exception is raised. - """ - errCode, value = internals.blpapi_Constant_getValueAsFloat64( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return value - - def getValueAsDatetime(self): - """Return the value of this object as one of the datetime types. - - Possible result types are: datetime.time, datetime.date or - datetime.datetime. - - If the value cannot be converted to one of these types an exception is - raised. - """ - errCode, value = internals.blpapi_Constant_getValueAsDatetime( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return _DatetimeUtil.convertToNative(value) - - def getValueAsString(self): - """Return the value of this object as a string. - - If the value cannot be converted to a string an exception is raised. - """ - errCode, value = internals.blpapi_Constant_getValueAsString( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return value - - def getValue(self): - """Return the value of this object as it is stored in the object.""" - datatype = self.datatype() - valueGetter = _CONSTANT_VALUE_GETTER.get( - datatype, - Constant.getValueAsString) - return valueGetter(self) - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - - -class ConstantList: - """Represents a list of schema enumeration constants. - - As well as the list of 'Constant' objects, this class also provides access - to the symbolic name, description and status of the list as a whole. All - 'Constant' objects in a 'ConstantsList' are of the same DataType. - - 'ConstantList' objects are read-only. - - Application clients never create 'ConstantList' object directly; - applications will typically work with 'ConstantList' objects returned by - other 'blpapi' components. - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def __iter__(self): - """Return the iterator over constants contained in this ConstantsList. - """ - return utils.Iterator(self, - ConstantList.numConstants, - ConstantList.getConstantAt) - - def name(self): - """Return the symbolic name of this 'ConstantList'.""" - return Name._createInternally( - internals.blpapi_ConstantList_name(self.__handle)) - - def description(self): - """Return a human readable description of this 'ConstantList'.""" - return internals.blpapi_ConstantList_description(self.__handle) - - def status(self): - """Return the status of this 'ConstantList'. - - The possible return values are enumerated in 'SchemaStatus' class. - """ - return internals.blpapi_ConstantList_status(self.__handle) - - def numConstants(self): - """Return the number of 'Constant' objects. - - Return the number of 'Constant' objects contained in this - 'ConstantsList'. - """ - return internals.blpapi_ConstantList_numConstants(self.__handle) - - def datatype(self): - """Return the data type used to represent the value of this constant. - - The possible return values are enumerated in 'DataType' class. - """ - return internals.blpapi_ConstantList_datatype(self.__handle) - - def hasConstant(self, name): - """True if this 'ConstantList' contains an item with this 'name'. - - Return True if this 'ConstantList' contains an item with the specified - 'name', and False otherwise. - - Exception is raised if 'name' is neither a Name nor a string. - """ - names = getNamePair(name) - return internals.blpapi_ConstantList_hasConstant(self.__handle, - names[0], - names[1]) - - def getConstant(self, name): - """Return the 'Constant' with the specified 'name'. - - Return the 'Constant' in this 'ConstantsList' identified by the - specified 'name'. If this 'ConstantsList' does not contain a 'Constant' - with the specified 'name' then an exception is raised. - """ - names = getNamePair(name) - res = internals.blpapi_ConstantList_getConstant(self.__handle, - names[0], - names[1]) - if res is None: - errMessage = \ - "Constant '{0!s}' is not found in '{1!s}'.".\ - format(name, self.name()) - raise NotFoundException(errMessage, 0) - return Constant(res, self.__sessions) - - def getConstantAt(self, position): - """Return the 'Constant' at the specified 'position'. - - Return the 'Constant' at the specified 'position' in this - 'ConstantList'. If 'position' is not in the range from 0 to - 'numConstants() - 1' then an exception is raised. - """ - res = internals.blpapi_ConstantList_getConstantAt(self.__handle, - position) - if res is None: - errMessage = "Index '{0}' out of bounds.".format(position) - raise IndexOutOfRangeException(errMessage, 0) - return Constant(res, self.__sessions) - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - - -_CONSTANT_VALUE_GETTER = { - DataType.CHAR: Constant.getValueAsString, - DataType.BYTE: Constant.getValueAsInteger, - DataType.INT32: Constant.getValueAsInteger, - DataType.INT64: Constant.getValueAsInteger, - DataType.FLOAT32: Constant.getValueAsFloat, - DataType.FLOAT64: Constant.getValueAsFloat, - DataType.STRING: Constant.getValueAsString, - DataType.DATE: Constant.getValueAsDatetime, - DataType.TIME: Constant.getValueAsDatetime, - DataType.DATETIME: Constant.getValueAsDatetime, -} - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/datetime.py b/blpapi/datetime.py deleted file mode 100644 index 70abe38..0000000 --- a/blpapi/datetime.py +++ /dev/null @@ -1,188 +0,0 @@ -# datetime.py - -"""Utilities that deal with blpapi.Datetime data type""" - -from __future__ import absolute_import -from __future__ import division - -from . import internals -from . import utils -from .compat import with_metaclass - -import datetime as _dt - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class FixedOffset(_dt.tzinfo): - """Time zone information. - - Represents time zone information to be used with Python standard library - datetime classes. - - FixedOffset(offsetInMinutes) creates an object that implements - datetime.tzinfo interface and represents a timezone with the specified - 'offsetInMinutes' from UTC. - - This class is intended to be used as 'tzinfo' for Python standard library - datetime.datetime and datetime.time classes. These classes are accepted by - the blpapi package to set DATE, TIME or DATETIME elements. For example, the - DATETIME element of a request could be set as: - - value = datetime.datetime(1941, 6, 22, 4, 0, tzinfo=FixedOffset(4*60)) - request.getElement("last_trade").setValue(value) - - The TIME element could be set in a similar way: - - value = datetime.time(9, 0, 1, tzinfo=FixedOffset(-5*60)) - request.getElement("session_open").setValue(value) - - Note that you could use any other implementations of datetime.tzinfo with - BLPAPI-Py, for example the widely used 'pytz' package - (http://pypi.python.org/pypi/pytz/). - - For more details see datetime module documentation at - http://docs.python.org/library/datetime.html - - """ - - def __init__(self, offsetInMinutes=0): - self.__offset = _dt.timedelta(minutes=offsetInMinutes) - - def utcoffset(self, unused): - return self.__offset - - def dst(self, unused): - return _dt.timedelta(0) - - def getOffsetInMinutes(self): - return self.__offset.days * 24 * 60 + self.__offset.seconds // 60 - - def __hash__(self): - """x.__hash__() <==> hash(x)""" - return self.getOffsetInMinutes() - - def __cmp__(self, other): - """Let the comparison operations work based on the time delta. - NOTE: (compatibility) this method have no special meaning in python3, - we should use __eq__, __lt__ and __le__ instead. Built-in cmp function - is also gone. This method can be called only from python2.""" - return cmp(self.getOffsetInMinutes(), other.getOffsetInMinutes()) - - def __eq__(self, other): - """Let the equality operator work based on the time delta.""" - return self.getOffsetInMinutes() == other.getOffsetInMinutes() - - def __lt__(self, other): - """Let the comparison operator work based on the time delta.""" - return self.getOffsetInMinutes() < other.getOffsetInMinutes() - - def __le__(self, other): - """Let the comparison operator work based on the time delta.""" - return self.getOffsetInMinutes() <= other.getOffsetInMinutes() - - -# UTC timezone -UTC = FixedOffset(0) - - -class _DatetimeUtil(object): - """Utility methods that deal with BLPAPI dates and times.""" - @staticmethod - def convertToNative(blpapiDatetime): - """Convert BLPAPI Datetime object to a suitable Python object.""" - parts = blpapiDatetime.parts - hasDate = parts & internals.DATETIME_DATE_PART == \ - internals.DATETIME_DATE_PART - hasTime = parts & internals.DATETIME_TIME_PART == \ - internals.DATETIME_TIME_PART - mlsecs = blpapiDatetime.milliSeconds * 1000 if parts & \ - internals.DATETIME_MILLISECONDS_PART else 0 - tzinfo = FixedOffset(blpapiDatetime.offset) if parts & \ - internals.DATETIME_OFFSET_PART else None - if hasDate: - if hasTime: - return _dt.datetime(blpapiDatetime.year, - blpapiDatetime.month, - blpapiDatetime.day, - blpapiDatetime.hours, - blpapiDatetime.minutes, - blpapiDatetime.seconds, - mlsecs, - tzinfo) - else: - # Skip an offset, because it's not informative in case of - # there is a date without the time - return _dt.date(blpapiDatetime.year, - blpapiDatetime.month, - blpapiDatetime.day) - else: - if not hasTime: - raise ValueError("Datetime object misses both time and date \ -parts", blpapiDatetime) - return _dt.time(blpapiDatetime.hours, - blpapiDatetime.minutes, - blpapiDatetime.seconds, - mlsecs, - tzinfo) - - @staticmethod - def isDatetime(dtime): - """Return True if the parameter is one of Python date/time objects.""" - return isinstance(dtime, (_dt.datetime, _dt.date, _dt.time)) - - @staticmethod - def convertToBlpapi(dtime): - "Convert a Python date/time object to a BLPAPI Datetime object.""" - res = internals.blpapi_Datetime_tag() - offset = None - if isinstance(dtime, _dt.datetime): - offset = dtime.utcoffset() - res.year = dtime.year - res.month = dtime.month - res.day = dtime.day - res.hours = dtime.hour - res.minutes = dtime.minute - res.seconds = dtime.second - res.milliSeconds = dtime.microsecond // 1000 - res.parts = internals.DATETIME_DATE_PART | \ - internals.DATETIME_TIMEMILLI_PART - elif isinstance(dtime, _dt.date): - res.year = dtime.year - res.month = dtime.month - res.day = dtime.day - res.parts = internals.DATETIME_DATE_PART - elif isinstance(dtime, _dt.time): - offset = dtime.utcoffset() - res.hours = dtime.hour - res.minutes = dtime.minute - res.seconds = dtime.second - res.milliSeconds = dtime.microsecond // 1000 - res.parts = internals.DATETIME_TIMEMILLI_PART - else: - raise TypeError("Datetime could be created only from \ -datetime.datetime, datetime.date or datetime.time") - if offset is not None: - res.offset = offset.seconds // 60 - res.parts |= internals.DATETIME_OFFSET_PART - return res - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/diagnosticsutil.py b/blpapi/diagnosticsutil.py deleted file mode 100644 index 207c938..0000000 --- a/blpapi/diagnosticsutil.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding: utf-8 - -#@PURPOSE: Provide api to access diagnostics information on the blpapi library -# -#@DESCRIPTION: This component provide a collection of functions which give -# access to various sets of diagnostics information on the 'blpapi' library. - -import internals - - -def memoryInfo(): - """Return the string describing the 'blpapi' library's memory usage; the - format of the string is platform-specific.""" - return internals.blpapi_DiagnosticsUtil_memoryInfo_wrapper() diff --git a/blpapi/element.py b/blpapi/element.py deleted file mode 100644 index e2e71bf..0000000 --- a/blpapi/element.py +++ /dev/null @@ -1,764 +0,0 @@ -# element.py - -"""Provide a representation of an item in a message or request. - -This file defines these classes: - 'Element' - represents an item in a message. - -""" - - - -from .exception import _ExceptionUtil -from .exception import UnsupportedOperationException -from .datetime import _DatetimeUtil -from .datatype import DataType -from .name import Name, getNamePair -from .schema import SchemaElementDefinition -from .compat import conv2str, isstr, int_typelist -from . import utils -from . import internals - -import sys - - -class Element(object): - """Element represents an item in a message. - - An Element can represent: a single value of any data type supported by the - Bloomberg API; an array of values; a sequence or a choice. - - The value(s) in an Element can be queried in a number of ways. For an - Element which represents a single value or an array of values use the - 'getValueAs()' functions or 'getValueAsBool()' etc. For an Element which - represents a sequence or choice use 'getElementAsBool()' etc. In addition, - for choices and sequences, 'hasElement()' and 'getElement()' are useful. - - This example shows how to access the value of a scalar element 's' as a - floating point number: - - f = s.getValueAsFloat() - - Similarly, this example shows how to retrieve the third value in an array - element 'a', as a floating point number: - - f = a.getValueAsFloat(2) - - Use 'numValues()' to determine the number of values available. For single - values, it will return either 0 or 1. For arrays it will return the actual - number of values in the array. - - To retrieve values from a complex element types (sequnces and choices) use - the 'getElementAs...()' family of methods. This example shows how to get the - value of the the element 'city' in the sequence element 'address': - - city = address.getElementAsString("city") - - Note that 'getElementAsXYZ(name)' method is a shortcut to - 'getElement(name).getValueAsXYZ()'. - - The value(s) of an Element can be set in a number of ways. For an Element - which represents a single value or an array of values use the 'setValue()' or - 'appendValue()' functions. For an element which represents a seqeunce or a - choice use the 'setElement()' functions. - - This example shows how to set the value of an Element 's': - - value=5 - s.setValue(value) - - This example shows how to append a value to an array element 'a': - - value=5; - s.appendValue(value); - - To set values in a complex element (a sequence or a choice) use the - 'setElement()' family of functions. This example shows how to set the value - of the element 'city' in the sequence element 'address' to a string. - - address.setElement("city", "New York") - - Methods which specify an Element name accept name in two forms: 'blpapi.Name' - or a string. Passing 'blpapi.Name' is more efficient. However, it requires - the Name to have been created in the global name table. - - The form which takes a string is less efficient but will not cause a new - Name to be created in the global Name table. Because all valid Element - names will have already been placed in the global name table by the API if - the supplied string cannot be found in the global name table the - appropriate error or exception can be returned. - - The API will convert data types as long as there is no loss of precision - involved. - - Element objects are always created by the API, never directly by the - application. - - """ - - __boolTraits = ( - internals.blpapi_Element_setElementBool, - internals.blpapi_Element_setValueBool, - None) - - __datetimeTraits = ( - internals.blpapi_Element_setElementDatetime, - internals.blpapi_Element_setValueDatetime, - _DatetimeUtil.convertToBlpapi) - - __int32Traits = ( - internals.blpapi_Element_setElementInt32, - internals.blpapi_Element_setValueInt32, - None) - - __int64Traits = ( - internals.blpapi_Element_setElementInt64, - internals.blpapi_Element_setValueInt64, - None) - - __floatTraits = ( - internals.blpapi_Element_setElementFloat, - internals.blpapi_Element_setValueFloat, - None) - - __nameTraits = ( - internals.blpapi_Element_setElementFromName, - internals.blpapi_Element_setValueFromName, - Name._handle) - - __stringTraits = ( - internals.blpapi_Element_setElementString, - internals.blpapi_Element_setValueString, - conv2str) - - __defaultTraits = ( - internals.blpapi_Element_setElementString, - internals.blpapi_Element_setValueString, - str) - - @staticmethod - def __getTraits(value): - if isstr(value): - return Element.__stringTraits - elif isinstance(value, bool): - return Element.__boolTraits - elif isinstance(value, int_typelist): - if value >= -(2 ** 31) and value <= (2 ** 31 - 1): - return Element.__int32Traits - elif value >= -(2 ** 63) and value <= (2 ** 63 - 1): - return Element.__int64Traits - else: - raise ValueError("value is out of element's supported range") - elif isinstance(value, float): - return Element.__floatTraits - elif _DatetimeUtil.isDatetime(value): - return Element.__datetimeTraits - elif isinstance(value, Name): - return Element.__nameTraits - else: - return Element.__defaultTraits - - def __assertIsValid(self): - if not self.isValid(): - raise RuntimeError("Element is not valid") - - def __init__(self, handle, dataHolder): - self.__handle = handle - self.__dataHolder = dataHolder - - def _getDataHolder(self): - """Return the owner of underlying data. For internal use.""" - return self if self.__dataHolder is None else self.__dataHolder - - def _sessions(self): - """Return session(s) that this 'Element' is related to. - - For internal use.""" - if self.__dataHolder is None: - return list() - else: - return self.__dataHolder._sessions() - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string representation of this Element. Call of 'str(element)' is - equivalent to 'element.toString()' called with default parameters. - - """ - - return self.toString() - - def name(self): - """Return the name of this Element. - - If this Element is part of a sequence or choice Element then return the - Name of this Element within the sequence or choice Element that owns - it. If this Element is not part of a sequence Element (that is it is an - entire Request or Message) then return the Name of the Request or - Message. - - """ - - self.__assertIsValid() - return Name._createInternally( - internals.blpapi_Element_name(self.__handle)) - - def datatype(self): - """Return the basic data type of this Element. - - Return the basic data type used to represent a value in this Element. - - The possible return values are enumerated in DataType class. - - """ - - self.__assertIsValid() - return internals.blpapi_Element_datatype(self.__handle) - - def isComplexType(self): - """Return True is this Element is a SEQUENCE or CHOICE. - - Return True if 'datatype()==DataType.SEQUENCE' or - 'datatype()==DataType.CHOICE' and False otherwise. - - """ - - self.__assertIsValid() - return bool(internals.blpapi_Element_isComplexType(self.__handle)) - - def isArray(self): - """Return True is this element is an array. - - Return True if 'elementDefinition().maxValues()>1' or if - 'elementDefinition().maxValues()==UNBOUNDED', and False otherwise. - - """ - - self.__assertIsValid() - return bool(internals.blpapi_Element_isArray(self.__handle)) - - def isValid(self): - """Return True if this Element is valid.""" - return self.__handle is not None - - def isNull(self): - """Return True if this Element has a null value.""" - self.__assertIsValid() - return bool(internals.blpapi_Element_isNull(self.__handle)) - - def isReadOnly(self): - """Return True if this element cannot be modified.""" - self.__assertIsValid() - return bool(internals.blpapi_Element_isReadOnly(self.__handle)) - - def elementDefinition(self): - """Return a read-only SchemaElementDefinition for this Element. - - Return a reference to the read-only element definition object that - defines the properties of this elements value. - - """ - self.__assertIsValid() - return SchemaElementDefinition( - internals.blpapi_Element_definition(self.__handle), - self._sessions()) - - def numValues(self): - """Return the number of values contained by this element. - - Return the number of values contained by this element. The number of - values is 0 if 'isNull()' returns True, and no greater than 1 if - 'isComplexType()' returns True. The value returned will always be in - the range defined by 'elementDefinition().minValues()' and - 'elementDefinition().maxValues()'. - - """ - - self.__assertIsValid() - return internals.blpapi_Element_numValues(self.__handle) - - def numElements(self): - """Return the number of elements in this Element. - - Return the number of elements contained by this element. The number - of elements is 0 if 'isComplex()' returns False, and no greater than - 1 if the Datatype is CHOICE; if the DataType is SEQUENCE this may - return any number (including 0). - - """ - - self.__assertIsValid() - return internals.blpapi_Element_numElements(self.__handle) - - def isNullValue(self, position=0): - """Return True if the value at the 'position' is a null value. - - Return True if the value of the sub-element at the specified 'position' - in a sequence or choice element is a null value. An exception is raised - if 'position >= numElements()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_isNullValue(self.__handle, position) - if res == 0 or res == 1: - return bool(res) - _ExceptionUtil.raiseOnError(res) - - def toString(self, level=0, spacesPerLevel=4): - """Format this Element to the string. - - Format this Element to the string at the specified indentation level. - - You could optionally specify 'spacesPerLevel' - the number of spaces - per indentation level for this and all of its nested objects. If - 'level' is negative, suppress indentation of the first line. If - 'spacesPerLevel' is negative, format the entire output on one line, - suppressing all but the initial indentation (as governed by 'level'). - - """ - - self.__assertIsValid() - return internals.blpapi_Element_printHelper(self.__handle, - level, - spacesPerLevel) - - def getElement(self, nameOrIndex): - """Return a specified subelement. - - Return a subelement identified by the specified 'nameOrIndex', which - must be either a string, a Name, or an integer. If 'nameOrIndex' is a - string or a Name and 'hasElement(nameOrIndex) != True', or if - 'nameOrIndex' is an integer and 'nameOrIndex >= numElements()', then - an exception is raised. - - An exception is also raised if this Element is neither a sequence nor - a choice. - - """ - - if not isinstance(nameOrIndex, int): - self.__assertIsValid() - name = getNamePair(nameOrIndex) - res = internals.blpapi_Element_getElement(self.__handle, - name[0], - name[1]) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - self.__assertIsValid() - res = internals.blpapi_Element_getElementAt(self.__handle, nameOrIndex) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - - def elements(self): - """Return an iterator over elements contained in this Element. - - An exception is raised if this 'Element' is not a sequence. - """ - - if (self.datatype() != DataType.SEQUENCE): - raise UnsupportedOperationException() - return utils.Iterator(self, Element.numElements, Element.getElement) - - def hasElement(self, name, excludeNullElements=False): - """Return True if this Element contains sub-element with this 'name'. - - Return True if this Element is a choice or sequence ('isComplexType() - == True') and it contains an Element with the specified 'name'. - - Exception is raised if 'name' is neither a Name nor a string. - - """ - - self.__assertIsValid() - name = getNamePair(name) - res = internals.blpapi_Element_hasElementEx( - self.__handle, - name[0], - name[1], - 1 if excludeNullElements else 0, - 0) - return bool(res) - - def getChoice(self): - """Return the selection name of this element as Element. - - Return the selection name of this element if - 'datatype() == DataType.CHOICE'; otherwise, an exception is raised. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getChoice(self.__handle) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - - def getValueAsBool(self, index=0): - """Return the specified 'index'th entry in the Element as a boolean. - - An exception is raised if the data type of this Element cannot be - converted to a boolean or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsBool(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return bool(res[1]) - - def getValueAsString(self, index=0): - """Return the specified 'index'th entry in the Element as a string. - - An exception is raised if the data type of this Element cannot be - converted to a string or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsString(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return res[1] - - def getValueAsDatetime(self, index=0): - """Return the specified 'index'th entry as one of the datetime types. - - The possible result types are 'datetime.time', 'datetime.date' or - 'datetime.datetime'. - - An exception is raised if the data type of this Element cannot be - converted to one of these types or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsDatetime(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return _DatetimeUtil.convertToNative(res[1]) - - def getValueAsInteger(self, index=0): - """Return the specified 'index'th entry in the Element as an integer. - - An exception is raised if the data type of this Element cannot be - converted to an integer or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsInt64(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return res[1] - - def getValueAsFloat(self, index=0): - """Return the specified 'index'th entry in the Element as a float. - - An exception is raised if the data type of this Element cannot be - converted to a float or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsFloat64(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return res[1] - - def getValueAsName(self, index=0): - """Return the specified 'index'th entry in the Element as a Name. - - An exception is raised if the data type of this Element cannot be - converted to a Name or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsName(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return Name._createInternally(res[1]) - - def getValueAsElement(self, index=0): - """Return the specified 'index'th entry in the Element as an Element. - - An exception is raised if the data type of this Element cannot be - converted to an Element or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_getValueAsElement(self.__handle, index) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - - def getValue(self, index=0): - """Return the specified 'index'th entry in the Element. - - Return the specified 'index'th entry in the Element in the format - defined by this Element datatype. - - An exception is raised if this Element either a sequence or a choice or - if 'index >= numValues()'. - - """ - - datatype = self.datatype() - valueGetter = _ELEMENT_VALUE_GETTER.get(datatype, - Element.getValueAsString) - return valueGetter(self, index) - - def values(self): - """Return an iterator over values contained in this Element. - - If 'isComplexType()' returns True for this Element, the empty iterator is - returned. - - """ - - if self.isComplexType(): - return iter(()) # empty tuple - datatype = self.datatype() - valueGetter = _ELEMENT_VALUE_GETTER.get(datatype, - Element.getValueAsString) - return utils.Iterator(self, Element.numValues, valueGetter) - - def getElementAsBool(self, name): - """Return this Element's sub-element with 'name' as a boolean. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as a boolean. - - """ - - return self.getElement(name).getValueAsBool() - - def getElementAsString(self, name): - """Return this Element's sub-element with 'name' as a string. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as a string. - - """ - - return self.getElement(name).getValueAsString() - - def getElementAsDatetime(self, name): - """Return this Element's sub-element with 'name' as a datetime type. - - The possible result types are datetime.time, datetime.date or - datetime.datetime. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as one of datetype types. - - """ - - return self.getElement(name).getValueAsDatetime() - - def getElementAsInteger(self, name): - """Return this Element's sub-element with 'name' as an integer. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as an integer. - - """ - - return self.getElement(name).getValueAsInteger() - - def getElementAsFloat(self, name): - """Return this Element's sub-element with 'name' as a float. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as a float. - - """ - - return self.getElement(name).getValueAsFloat() - - def getElementAsName(self, name): - """Return this Element's sub-element with 'name' as a Name. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name', or in case the Element's value - can't be returned as a Name. - - """ - - return self.getElement(name).getValueAsName() - - def getElementValue(self, name): - """Return this Element's sub-element with 'name'. - - The value is returned in the format defined by this Element datatype. - - Exception is raised if 'name' is neither a Name nor a string, or if - this Element is neither a sequence nor a choice, or in case it has no - sub-element with the specified 'name'. - - """ - - return self.getElement(name).getValue() - - def setElement(self, name, value): - """Set this Element's sub-element with 'name' to the specified 'value'. - - This method can process the following types of 'value' without - conversion: - - - boolean - - integers - - float - - string - - datetypes ('datetime.time', 'datetime.date' or 'datetime.datetime') - - Name - - Any other 'value' will be converted to a string with 'str' function and - then processed in the same way as string 'value'. - - An exception is raised if 'name' is neither a Name nor a string, or if - this element has no sub-elemen with the specified 'name', or if the - Element identified by the specified 'name' cannot be initialized from - the type of the specified 'value'. - - """ - - self.__assertIsValid() - - traits = Element.__getTraits(value) - name = getNamePair(name) - if traits[2] is not None: - value = traits[2](value) - _ExceptionUtil.raiseOnError( - traits[0](self.__handle, name[0], name[1], value)) - - def setValue(self, value, index=0): - """Set the specified 'index'th entry in this Element to the 'value'. - - This method can process the following types of 'value' without - conversion: - - - boolean - - integers - - float - - string - - datetypes ('datetime.time', 'datetime.date' or 'datetime.datetime') - - Name - - Any other 'value' will be converted to a string with 'str' function and - then processed in the same way as string 'value'. - - An exception is raised if this Element's datatype can't be initialized - with the type of the specified 'value', or if 'index >= numValues()'. - - """ - - self.__assertIsValid() - traits = Element.__getTraits(value) - if traits[2] is not None: - value = traits[2](value) - _ExceptionUtil.raiseOnError(traits[1](self.__handle, value, index)) - - def appendValue(self, value): - """Append the specified 'value' to this Element's entries at the end. - - This method can process the following types of 'value' without - conversion: - - - boolean - - integers - - float - - string - - datetypes ('datetime.time', 'datetime.date' or 'datetime.datetime') - - Name - - Any other 'value' will be converted to a string with 'str' function and - then processed in the same way as string 'value'. - - An exception is raised if this Element's datatype can't be initialized - from the type of the specified 'value', or if the current size of this - Element ('numValues()') is equal to the maximum defined by - 'elementDefinition().maxValues()'. - - """ - - self.setValue(value, internals.ELEMENT_INDEX_END) - - def appendElement(self): - """Append a new element to this array Element, return the new Element. - - An exception is raised if this Element is not an array of sequence or - choice Elements. - - """ - - self.__assertIsValid() - res = internals.blpapi_Element_appendElement(self.__handle) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - - def setChoice(self, selectionName): - """Set this Element's active Element to 'selectionName'. - - Exception is raised if 'selectionName' is neither a Name nor a string, - or if this Element is not a choice. - - """ - - self.__assertIsValid() - name = getNamePair(selectionName) - res = internals.blpapi_Element_setChoice(self.__handle, - name[0], - name[1], - 0) - _ExceptionUtil.raiseOnError(res[0]) - return Element(res[1], self._getDataHolder()) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -_ELEMENT_VALUE_GETTER = { - DataType.BOOL: Element.getValueAsBool, - DataType.CHAR: Element.getValueAsString, - DataType.BYTE: Element.getValueAsInteger, - DataType.INT32: Element.getValueAsInteger, - DataType.INT64: Element.getValueAsInteger, - DataType.FLOAT32: Element.getValueAsFloat, - DataType.FLOAT64: Element.getValueAsFloat, - DataType.STRING: Element.getValueAsString, - DataType.DATE: Element.getValueAsDatetime, - DataType.TIME: Element.getValueAsDatetime, - DataType.DATETIME: Element.getValueAsDatetime, - DataType.ENUMERATION: Element.getValueAsName, - DataType.SEQUENCE: Element.getValueAsElement, - DataType.CHOICE: Element.getValueAsElement -} - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/event.py b/blpapi/event.py deleted file mode 100644 index a7b21a1..0000000 --- a/blpapi/event.py +++ /dev/null @@ -1,290 +0,0 @@ -# event.py - -"""A module which defines events related operations. - -This file defines an 'Event'. One or more 'Event's are generated as a result of -a subscription or a request. 'Event's contain 'Message' objects which can be -accessed using a 'MessageIterator'. This file also defines a 'EventQueue' for -handling replies synchronously. - -Usage ------ -The following code snippet shows how a 'EventQueue' is used with a -'generateToken' request. For any established session 'session' pass an -'EventQueue' object 'tokenEventQueue' when calling 'generateToken'. All -'Event's in responses to 'generateToken' request will be returned in -'tokenEventQueue'. - - tokenEventQueue = EventQueue() - session.generateToken(eventQueue=tokenEventQueue) - -Synchronously read the response 'event' and parse over messages using 'token' - - ev = tokenEventStatus.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS: - for msg in ev: - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - raise Exception("Failed to get token") - -""" - - - -from .message import Message -from . import internals -from . import utils -from .compat import with_metaclass - -import sys - -#sys.modules[__name__] = utils._Constants() - - -class MessageIterator(object): - """An iterator over the 'Message' objects within an Event. - - Few clients will ever make direct use of 'MessageIterator' objects; Python - 'for' loops allow clients to operate directly in terms of 'Event' and - 'Message' objects'. (See the usage example above.) - """ - - def __init__(self, event): - self.__handle = \ - internals.blpapi_MessageIterator_create(event._handle()) - self.__event = event - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_MessageIterator_destroy(self.__handle) - self.__handle = None - - def __iter__(self): - return self - - def __next__(self): - retCode, message = internals.blpapi_MessageIterator_next(self.__handle) - if retCode: - raise StopIteration() - else: - return Message(message, self.__event) - - next = __next__ - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class Event(object): - """A single event resulting from a subscription or a request. - - 'Event' objects are created by the API and passed to the application either - through a registered 'EventHandler' or 'EventQueue' or returned either from - the 'Session.nextEvent()' or 'Session.tryNextEvent()' methods. 'Event' - objects contain 'Message' objects which can be accessed using an iteration - over 'Event': - - for message in event: - ... - - The 'Event' object is a handle to an event. The event is the basic unit of - work provided to applications. Each 'Event' object consists of an - 'EventType' attribute and zero or more 'Message' objects. - - Event objects are always created by the API, never directly by the - application. - - Class attributes: - The possible types of event: - ADMIN Admin event - SESSION_STATUS Status updates for a session - SUBSCRIPTION_STATUS Status updates for a subscription - REQUEST_STATUS Status updates for a request - RESPONSE The final (possibly only) response to a request - PARTIAL_RESPONSE A partial response to a request - SUBSCRIPTION_DATA Data updates resulting from a subscription - SERVICE_STATUS Status updates for a service - TIMEOUT An Event returned from nextEvent() if it - timed out - AUTHORIZATION_STATUS Status updates for user authorization - RESOLUTION_STATUS Status updates for a resolution operation - TOPIC_STATUS Status updates about topics for service providers - ROKEN_STATUS Status updates for a generate token request - REQUEST Request event - UNKNOWN Unknown event - """ - - ADMIN = internals.EVENTTYPE_ADMIN - """Admin event""" - SESSION_STATUS = internals.EVENTTYPE_SESSION_STATUS - """Status updates for a session""" - SUBSCRIPTION_STATUS = internals.EVENTTYPE_SUBSCRIPTION_STATUS - """Status updates for a subscription""" - REQUEST_STATUS = internals.EVENTTYPE_REQUEST_STATUS - """Status updates for a request""" - RESPONSE = internals.EVENTTYPE_RESPONSE - """The final (possibly only) response to a request""" - PARTIAL_RESPONSE = internals.EVENTTYPE_PARTIAL_RESPONSE - """A partial response to a request""" - SUBSCRIPTION_DATA = internals.EVENTTYPE_SUBSCRIPTION_DATA - """Data updates resulting from a subscription""" - SERVICE_STATUS = internals.EVENTTYPE_SERVICE_STATUS - """Status updates for a service""" - TIMEOUT = internals.EVENTTYPE_TIMEOUT - """An Event returned from nextEvent() if it timed out""" - AUTHORIZATION_STATUS = internals.EVENTTYPE_AUTHORIZATION_STATUS - """Status updates for user authorization""" - RESOLUTION_STATUS = internals.EVENTTYPE_RESOLUTION_STATUS - """Status updates for a resolution operation""" - TOPIC_STATUS = internals.EVENTTYPE_TOPIC_STATUS - """Status updates about topics for service providers""" - TOKEN_STATUS = internals.EVENTTYPE_TOKEN_STATUS - """Status updates for a generate token request""" - REQUEST = internals.EVENTTYPE_REQUEST - """Request event""" - UNKNOWN = -1 - """Unknown event""" - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_Event_release(self.__handle) - self.__handle = None - - def eventType(self): - """Return the type of messages contained by this 'Event'.""" - return internals.blpapi_Event_eventType(self.__handle) - - def __iter__(self): - """Return the iterator over messages contained in this 'Event'.""" - return MessageIterator(self) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - def _sessions(self): - """Return session(s) that this 'Event' is related to. - - For internal use.""" - return self.__sessions - - # Protect enumeration constant(s) defined in this class and in classes - # derived from this class from changes: - - -class EventQueue(object): - """A construct used to handle replies to request synchronously. - - 'EventQueue()' construct an empty 'EventQueue' which can be passed to - 'Session.sendRequest()' and 'Session.sendAuthorizationRequest()' methods. - - When a request is submitted an application can either handle the responses - asynchronously as they arrive or use an 'EventQueue' to handle all - responses for a given request or requests synchronously. The 'EventQueue' - will only deliver responses to the request(s) it is associated with. - """ - def __init__(self): - self.__handle = internals.blpapi_EventQueue_create() - self.__sessions = set() - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_EventQueue_destroy(self.__handle) - self.__handle = None - - def nextEvent(self, timeout=0): - """Return the next Event available from the 'EventQueue'. - - If the specified 'timeout' is zero this method will wait forever for - the next event. If the specified 'timeout' is non zero then if no - 'Event' is available within the specified 'timeout' an 'Event' with - type of 'TIMEOUT' will be returned. - - The 'timeout' is specified in milliseconds. - """ - res = internals.blpapi_EventQueue_nextEvent(self.__handle, timeout) - return Event(res, self._getSessions()) - - def tryNextEvent(self): - """If the 'EventQueue' is non-empty, return the next Event available. - - If the 'EventQueue' is non-empty, return the next 'Event' available. If - the 'EventQueue' is empty, return None with no effect the state of - 'EventQueue'. - """ - res = internals.blpapi_EventQueue_tryNextEvent(self.__handle) - if res[0]: - return None - else: - return Event(res[1], self._getSessions()) - - def purge(self): - """Purge any 'Event' objects in this 'EventQueue'. - - Purges any 'Event' objects in this 'EventQueue' which have not been - processed and cancel any pending requests linked to this 'EventQueue'. - The 'EventQueue' can subsequently be re-used for a subsequent request. - """ - internals.blpapi_EventQueue_purge(self.__handle) - self.__sessions.clear() - - def _handle(self): - """Return the internal implementation. For internal use.""" - return self.__handle - - def _registerSession(self, session): - """Add a new session to this 'EventQueue'. For internal use.""" - self.__sessions.add(session) - - def _getSessions(self): - """Get a list of sessions this EventQueue related to. - - For internal use. - """ - sessions = list(self.__sessions) - return sessions - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/eventdispatcher.py b/blpapi/eventdispatcher.py deleted file mode 100644 index 7cf218a..0000000 --- a/blpapi/eventdispatcher.py +++ /dev/null @@ -1,101 +0,0 @@ -# eventdispatcher.py - -"""Provide a dispatcher to dispatch events. - -This component implements a dispatcher to dispatch events from one or more -Sessions through callbacks. -""" - - - - -from . import internals - - -class EventDispatcher(object): - """Dispatches events from one or more Sessions through callbacks - - EventDispatcher objects are optionally specified when Session objects are - created. A single EventDispatcher can be shared by multiple Session - objects. - - The EventDispatcher provides an event-driven interface, generating - callbacks from one or more internal threads for one or more sessions. - """ - - __handle = None - - def __init__(self, numDispatcherThreads=1): - """Construct an EventDispatcher. - - If 'numDispatcherThreads' is 1 (the default) then a single internal - thread is created to dispatch events. If 'numDispatcherThreads' is - greater than 1 then an internal pool of 'numDispatcherThreads' threads - is created to dispatch events. The behavior is undefined if - 'numDispatcherThreads' is 0. - """ - - self.__handle = internals.blpapi_EventDispatcher_create( - numDispatcherThreads) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destructor.""" - if self.__handle: - internals.blpapi_EventDispatcher_destroy(self.__handle) - self.__handle = None - - def start(self): - """Start generating callbacks. - - Start generating callbacks for events from sessions associated with - this EventDispatcher. - """ - - return internals.blpapi_EventDispatcher_start(self.__handle) - - def stop(self, async=False): - """Stop generating callbacks. - - Stop generating callbacks for events from sessions associated with this - EventDispatcher. If the specified 'async' is False (the default) then - this method blocks until all current callbacks which were dispatched - through this EventDispatcher have completed. If 'async' is True, this - method returns immediately and no further callbacks will be dispatched. - - Note: If stop is called with 'async' of False from within a callback - dispatched by this EventDispatcher then the 'async' parameter is - overridden to True. - """ - - return internals.blpapi_EventDispatcher_stop(self.__handle, async) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/eventformatter.py b/blpapi/eventformatter.py deleted file mode 100644 index e73580c..0000000 --- a/blpapi/eventformatter.py +++ /dev/null @@ -1,307 +0,0 @@ -# eventformatter.py - -"""Add messages to an Event for publishing - -This component adds messages to an Event which can be later published. -""" - - - -from .exception import _ExceptionUtil -from .datetime import _DatetimeUtil -from .message import Message -from .name import Name, getNamePair -from . import internals -from .internals import CorrelationId - - -class EventFormatter(object): - """EventFormatter is used to populate 'Event's for publishing. - - An EventFormatter is created from an Event obtained from - createPublishEvent() on Service. Once the Message or Messages have been - appended to the Event using the EventFormatter the Event can be published - using 'publish()' on the ProviderSession. - - EventFormatter objects cannot be copied or as to ensure there is no - ambiguity about what happens if two 'EventFormatter's are both formatting - the same 'Event'. - - The EventFormatter supportes appending message of the same type multiple - time in the same 'Event'. However the 'EventFormatter' supports write once - only to each field. It is an error to call 'setElement()' or 'pushElement()' - for the same name more than once at a particular level of the schema when - creating a message. - - """ - - __boolTraits = ( - internals.blpapi_EventFormatter_setValueBool, - internals.blpapi_EventFormatter_appendValueBool, - None) - - __datetimeTraits = ( - internals.blpapi_EventFormatter_setValueDatetime, - internals.blpapi_EventFormatter_appendValueDatetime, - _DatetimeUtil.convertToBlpapi) - - __int32Traits = ( - internals.blpapi_EventFormatter_setValueInt32, - internals.blpapi_EventFormatter_appendValueInt32, - None) - - __int64Traits = ( - internals.blpapi_EventFormatter_setValueInt64, - internals.blpapi_EventFormatter_appendValueInt64, - None) - - __floatTraits = ( - internals.blpapi_EventFormatter_setValueFloat, - internals.blpapi_EventFormatter_appendValueFloat, - None) - - __nameTraits = ( - internals.blpapi_EventFormatter_setValueFromName, - internals.blpapi_EventFormatter_appendValueFromName, - Name._handle) - - __stringTraits = ( - internals.blpapi_EventFormatter_setValueString, - internals.blpapi_EventFormatter_appendValueString, - None) - - __defaultTraits = ( - internals.blpapi_EventFormatter_setValueString, - internals.blpapi_EventFormatter_appendValueString, - str) - - @staticmethod - def __getTraits(value): - if isinstance(value, str): - return EventFormatter.__stringTraits - elif isinstance(value, bool): - return EventFormatter.__boolTraits - elif isinstance(value, int): - if value >= -(2 ** 31) and value <= (2 ** 31 - 1): - return EventFormatter.__int32Traits - elif value >= -(2 ** 63) and value <= (2 ** 63 - 1): - return EventFormatter.__int64Traits - else: - raise ValueError("value is out of supported range") - elif isinstance(value, float): - return EventFormatter.__floatTraits - elif _DatetimeUtil.isDatetime(value): - return EventFormatter.__datetimeTraits - elif isinstance(value, Name): - return EventFormatter.__nameTraits - else: - return EventFormatter.__defaultTraits - - def __init__(self, event): - """Create an EventFormatter to create Messages in the specified 'event' - - Create an EventFormatter to create Messages in the specified 'event'. - An Event may only be reference by one EventFormatter at any time. - Attempting to create a second EventFormatter referencing the same - Event will result in an exception being raised. - """ - - self.__handle = internals.blpapi_EventFormatter_create(event._handle()) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this EventFormatter object.""" - if self.__handle: - internals.blpapi_EventFormatter_destroy(self.__handle) - self.__handle = None - - def appendMessage(self, messageType, topic, sequenceNumber=None): - """Append an (empty) message of the specified 'messageType'. - - Append an (empty) message of the specified 'messageType' - that will be published under the specified 'topic' with the - specified 'sequenceNumber' to the Event referenced by this - EventFormatter. It is expected that 'sequenceNumber' is - greater (unless the value wrapped or None is specified) than the last - value used in any previous message on this 'topic', otherwise the - behavior is undefined. - After a message has been appended its elements - can be set using the various 'setElement()' methods. - """ - name = getNamePair(messageType) - - if sequenceNumber is None: - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendMessage( - self.__handle, - name[0], - name[1], - topic._handle())) - else: - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendMessageSeq( - self.__handle, - name[0], - name[1], - topic._handle(), - sequenceNumber, - 0)) - - def appendResponse(self, opType): - """Append an (empty) response message of the specified 'opType'. - - Append an (empty) response message of the specified 'opType' - that will be sent in response to previously received - operation request. After a message has been appended its - elements can be set using the various 'setElement()' methods. - Only one response can be appended. - """ - name = getNamePair(opType) - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendResponse( - self.__handle, - name[0], - name[1])) - - def appendRecapMessage(self, topic, correlationId=None, - sequenceNumber=None): - """Append a (empty) recap message that will be published. - - Append a (empty) recap message that will be published under the - specified 'topic' with the specified 'sequenceNumber' to the Publish - Event referenced by this EventFormatter. Specify the optional - 'correlationId' if this recap message is added in - response to a TOPIC_RECAP message. It is expected that - 'sequenceNumber' is greater (unless the value wrapped or None is - specified) than the last value used in any previous message on this - 'topic', otherwise the behavior is undefined. - After a message has been appended its elements can be set using - the various 'setElement()' methods. It is an error to create append - a recap message to an Admin event. - """ - cIdHandle = None if correlationId is None else correlationId._handle() - - if sequenceNumber is None: - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendRecapMessage( - self.__handle, - topic._handle(), - cIdHandle)) - else: - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendRecapMessageSeq( - self.__handle, - topic._handle(), - cIdHandle, - sequenceNumber, - 0)) - - def setElement(self, name, value): - """Set the element with the specified 'name' to the specified 'value'. - - Set the element with the specified 'name' to the specified 'value' in - the current message in the Event referenced by this EventFormatter. If - the 'name' is invalid for the current message, if 'appendMessage()' has - never been called or if the element identified by 'name' has already - been set an exception is raised. - - Clients wishing to format and publish null values (e.g. for the purpose - of cache management) should *not* use this function; use - 'setElementNull' instead. - """ - traits = EventFormatter.__getTraits(value) - name = getNamePair(name) - if traits[2] is not None: - value = traits[2](value) - _ExceptionUtil.raiseOnError( - traits[0](self.__handle, name[0], name[1], value)) - - def setElementNull(self, name): - """Create a null element with the specified 'name'. - - Create a null element with the specified 'name'. Note that whether or - not fields containing null values are published to subscribers is - dependent upon details of the service and schema configuration. - """ - name = getNamePair(name) - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_setValueNull( - self.__handle, - name[0], - name[1])) - - def pushElement(self, name): - """Change the level at which this EventFormatter is operating. - - Change the level at which this EventFormatter is operating to the - specified element 'name'. The element 'name' must identify either a - choice, a sequence or an array at the current level of the schema or - the behavior is undefined. If the 'name' is invalid for the current - message, if 'appendMessage()' has never been called or if the element - identified by 'name' has already been set an exception is raised. After - this returns the context of the EventFormatter is set to the element - 'name' in the schema and any calls to 'setElement()' or 'pushElement()' - are applied at that level. If 'name' represents an array of scalars then - 'appendValue()' must be used to add values. If 'name' represents an array - of complex types then 'appendElement()' creates the first entry and set - the context of the EventFormatter to that element. Calling - 'appendElement()' again will create another entry. - """ - name = getNamePair(name) - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_pushElement( - self.__handle, - name[0], - name[1])) - - def popElement(self): - """Undo the most recent call to 'pushLevel()' on this EventFormatter. - - Undo the most recent call to 'pushLevel()' on this - EventFormatter and return the context of the - EventFormatter to where it was before the call to - 'pushElement()'. Once 'popElement()' has been called it is - invalid to attempt to re-visit the same context. - """ - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_popElement(self.__handle)) - - def appendValue(self, value): - traits = EventFormatter.__getTraits(value) - if traits[2] is not None: - value = traits[2](value) - _ExceptionUtil.raiseOnError(traits[1](self.__handle, value)) - - def appendElement(self): - _ExceptionUtil.raiseOnError( - internals.blpapi_EventFormatter_appendElement(self.__handle)) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/identity.py b/blpapi/identity.py deleted file mode 100644 index dd5f6da..0000000 --- a/blpapi/identity.py +++ /dev/null @@ -1,191 +0,0 @@ -# identity.py - -"""Provide access to the entitlements for a user. - -This component provides an identification of a user and implements the access -to the entitlements. -""" - - - - -from .element import Element -from .exception import _ExceptionUtil -from . import internals -from . import utils -from .compat import with_metaclass - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class Identity(object): - """Provides access to the entitlements for a specific user. - - An unauthorized Identity is created using 'Session.createIdentity()'. Once - a Identity has been created it can be authorized using - 'Session.sendAuthorizationRequest()'. The authorized Identity can then be - queried or used in 'Session.subscribe()' or 'Session.sendRequest()' calls. - - Once authorized a Identity has access to the entitlements of the user which - it was validated for. - - - Seat types: - - INVALID_SEAT - Unknown seat type - BPS - Bloomberg Professional Service - NONBPS - Non-BPS - """ - - INVALID_SEAT = internals.SEATTYPE_INVALID_SEAT - """Unknown seat type""" - BPS = internals.SEATTYPE_BPS - """Bloomberg Professional Service""" - NONBPS = internals.SEATTYPE_NONBPS - """Non-BPS""" - - def __init__(self, handle, sessions): - """Create an Identity associated with the 'sessions'""" - self.__handle = handle - self.__sessions = sessions - internals.blpapi_Identity_addRef(self.__handle) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destuctor. - - Destroying the last Identity for a specific user cancels any - authorizations associated with it. - """ - if self.__handle: - internals.blpapi_Identity_release(self.__handle) - self.__handle = None - - def hasEntitlements(self, service, entitlements): - """Return True if authorized for the specified Service and EIDs. - - Return True if this 'Identity' is authorized for the specified - 'service' and for each of the entitlement IDs contained in the - specified 'entitlements', which must be a list of integers, or - an 'Element' which is an array of integers. - """ - if isinstance(entitlements, Element): - res = internals.blpapi_Identity_hasEntitlements( - self.__handle, - service._handle(), - entitlements._handle(), - None, - 0, - None, - None) - else: - # Otherwise, assume entitlements is a list, or tuple, etc - numberOfEIDs = len(entitlements) - carrayOfEIDs = internals.intArray(numberOfEIDs) - for i, eid in enumerate(entitlements): - carrayOfEIDs[i] = eid - res = internals.blpapi_Identity_hasEntitlements( - self.__handle, - service._handle(), - None, - carrayOfEIDs, - numberOfEIDs, - None, - None) - return True if res else False - - def getFailedEntitlements(self, service, entitlements): - """Return a tuple containing a boolean and a list of integers. - - Return a tuple containing a boolean and a list of integers, where - the returned boolean is True if this 'Identity' is authorized for the - specified 'service' and all of the specified 'entitlements', which must - be either a list of integers or an 'Element' which is an array of - integers, and the returned list is the subset of 'entitlements' for - which this identity is not authorized. The contents of the returned - list are not specified if this identity is not authorized for - 'service'. - """ - if isinstance(entitlements, Element): - maxFailedEIDs = entitlements.numValues() - failedEIDs = internals.intArray(maxFailedEIDs) - failedEIDsSize = internals.intArray(1) - failedEIDsSize[0] = maxFailedEIDs - res = internals.blpapi_Identity_hasEntitlements( - self.__handle, - service._handle(), - entitlements._handle(), - None, - 0, - failedEIDs, - failedEIDsSize) - else: - # Otherwise, assume entitlements is a list, or tuple, etc - numberOfEIDs = len(entitlements) - carrayOfEIDs = internals.intArray(numberOfEIDs) - for i, eid in enumerate(entitlements): - carrayOfEIDs[i] = eid - maxFailedEIDs = numberOfEIDs - failedEIDs = internals.intArray(maxFailedEIDs) - failedEIDsSize = internals.intArray(1) - failedEIDsSize[0] = maxFailedEIDs - res = internals.blpapi_Identity_hasEntitlements( - self.__handle, - service._handle(), - None, - carrayOfEIDs, - numberOfEIDs, - failedEIDs, - failedEIDsSize) - result = [] - for i in range(failedEIDsSize[0]): - result.append(failedEIDs[i]) - return (True if res else False, result) - - def isAuthorized(self, service): - """Return True if the handle is authorized for the specified Service. - - Return True if this 'Identity' is authorized for the specified - 'service'; otherwise return False. - """ - res = internals.blpapi_Identity_isAuthorized(self.__handle, - service._handle()) - return True if res else False - - def getSeatType(self): - """Return the seat type of this identity.""" - res = internals.blpapi_Identity_getSeatType(self.__handle) - _ExceptionUtil.raiseOnError(res[0]) - return res[1] - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - # Protect enumeration constant(s) defined in this class and in classes - # derived from this class from changes: - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/internals.py b/blpapi/internals.py deleted file mode 100644 index c82689c..0000000 --- a/blpapi/internals.py +++ /dev/null @@ -1,1906 +0,0 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 3.0.12 -# -# Do not make changes to this file unless you know what you are doing--modify -# the SWIG interface file instead. - -""" -This module defines internals of BLPAPI-Py and the following classes: -- CorrelationId: a key to track requests and subscriptions - -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" - - -from sys import version_info as _swig_python_version_info -if _swig_python_version_info >= (2, 7, 0): - def swig_import_helper(): - import importlib - pkg = __name__.rpartition('.')[0] - mname = '.'.join((pkg, '_internals')).lstrip('.') - try: - return importlib.import_module(mname) - except ImportError: - return importlib.import_module('_internals') - _internals = swig_import_helper() - del swig_import_helper -elif _swig_python_version_info >= (2, 6, 0): - def swig_import_helper(): - from os.path import dirname - import imp - fp = None - try: - fp, pathname, description = imp.find_module('_internals', [dirname(__file__)]) - except ImportError: - import _internals - return _internals - try: - _mod = imp.load_module('_internals', fp, pathname, description) - finally: - if fp is not None: - fp.close() - return _mod - _internals = swig_import_helper() - del swig_import_helper -else: - import _internals -del _swig_python_version_info - -try: - _swig_property = property -except NameError: - pass # Python < 2.2 doesn't have 'property'. - -try: - import builtins as __builtin__ -except ImportError: - import __builtin__ - -def _swig_setattr_nondynamic(self, class_type, name, value, static=1): - if (name == "thisown"): - return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'SwigPyObject': - self.__dict__[name] = value - return - method = class_type.__swig_setmethods__.get(name, None) - if method: - return method(self, value) - if (not static): - if _newclass: - object.__setattr__(self, name, value) - else: - self.__dict__[name] = value - else: - raise AttributeError("You cannot add attributes to %s" % self) - - -def _swig_setattr(self, class_type, name, value): - return _swig_setattr_nondynamic(self, class_type, name, value, 0) - - -def _swig_getattr(self, class_type, name): - if (name == "thisown"): - return self.this.own() - method = class_type.__swig_getmethods__.get(name, None) - if method: - return method(self) - raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) - - -def _swig_repr(self): - try: - strthis = "proxy of " + self.this.__repr__() - except __builtin__.Exception: - strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - -try: - _object = object - _newclass = 1 -except __builtin__.Exception: - class _object: - pass - _newclass = 0 - -TOPICLIST_NOT_CREATED = _internals.TOPICLIST_NOT_CREATED -TOPICLIST_CREATED = _internals.TOPICLIST_CREATED -TOPICLIST_FAILURE = _internals.TOPICLIST_FAILURE -RESOLUTIONLIST_UNRESOLVED = _internals.RESOLUTIONLIST_UNRESOLVED -RESOLUTIONLIST_RESOLVED = _internals.RESOLUTIONLIST_RESOLVED -RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE = _internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE -RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED = _internals.RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED -RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC = _internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC -RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED = _internals.RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED -MESSAGE_FRAGMENT_NONE = _internals.MESSAGE_FRAGMENT_NONE -MESSAGE_FRAGMENT_START = _internals.MESSAGE_FRAGMENT_START -MESSAGE_FRAGMENT_INTERMEDIATE = _internals.MESSAGE_FRAGMENT_INTERMEDIATE -MESSAGE_FRAGMENT_END = _internals.MESSAGE_FRAGMENT_END -ELEMENTDEFINITION_UNBOUNDED = _internals.ELEMENTDEFINITION_UNBOUNDED -ELEMENT_INDEX_END = _internals.ELEMENT_INDEX_END -SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM = _internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM -SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH = _internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH -CORRELATION_TYPE_UNSET = _internals.CORRELATION_TYPE_UNSET -CORRELATION_TYPE_INT = _internals.CORRELATION_TYPE_INT -CORRELATION_TYPE_POINTER = _internals.CORRELATION_TYPE_POINTER -CORRELATION_TYPE_AUTOGEN = _internals.CORRELATION_TYPE_AUTOGEN -CORRELATION_MAX_CLASS_ID = _internals.CORRELATION_MAX_CLASS_ID -MANAGEDPTR_COPY = _internals.MANAGEDPTR_COPY -MANAGEDPTR_DESTROY = _internals.MANAGEDPTR_DESTROY -DATETIME_YEAR_PART = _internals.DATETIME_YEAR_PART -DATETIME_MONTH_PART = _internals.DATETIME_MONTH_PART -DATETIME_DAY_PART = _internals.DATETIME_DAY_PART -DATETIME_OFFSET_PART = _internals.DATETIME_OFFSET_PART -DATETIME_HOURS_PART = _internals.DATETIME_HOURS_PART -DATETIME_MINUTES_PART = _internals.DATETIME_MINUTES_PART -DATETIME_SECONDS_PART = _internals.DATETIME_SECONDS_PART -DATETIME_MILLISECONDS_PART = _internals.DATETIME_MILLISECONDS_PART -DATETIME_FRACSECONDS_PART = _internals.DATETIME_FRACSECONDS_PART -DATETIME_DATE_PART = _internals.DATETIME_DATE_PART -DATETIME_TIME_PART = _internals.DATETIME_TIME_PART -DATETIME_TIMEMILLI_PART = _internals.DATETIME_TIMEMILLI_PART -DATETIME_TIMEFRACSECONDS_PART = _internals.DATETIME_TIMEFRACSECONDS_PART -EVENTTYPE_ADMIN = _internals.EVENTTYPE_ADMIN -EVENTTYPE_SESSION_STATUS = _internals.EVENTTYPE_SESSION_STATUS -EVENTTYPE_SUBSCRIPTION_STATUS = _internals.EVENTTYPE_SUBSCRIPTION_STATUS -EVENTTYPE_REQUEST_STATUS = _internals.EVENTTYPE_REQUEST_STATUS -EVENTTYPE_RESPONSE = _internals.EVENTTYPE_RESPONSE -EVENTTYPE_PARTIAL_RESPONSE = _internals.EVENTTYPE_PARTIAL_RESPONSE -EVENTTYPE_SUBSCRIPTION_DATA = _internals.EVENTTYPE_SUBSCRIPTION_DATA -EVENTTYPE_SERVICE_STATUS = _internals.EVENTTYPE_SERVICE_STATUS -EVENTTYPE_TIMEOUT = _internals.EVENTTYPE_TIMEOUT -EVENTTYPE_AUTHORIZATION_STATUS = _internals.EVENTTYPE_AUTHORIZATION_STATUS -EVENTTYPE_RESOLUTION_STATUS = _internals.EVENTTYPE_RESOLUTION_STATUS -EVENTTYPE_TOPIC_STATUS = _internals.EVENTTYPE_TOPIC_STATUS -EVENTTYPE_TOKEN_STATUS = _internals.EVENTTYPE_TOKEN_STATUS -EVENTTYPE_REQUEST = _internals.EVENTTYPE_REQUEST -STATUS_ACTIVE = _internals.STATUS_ACTIVE -STATUS_DEPRECATED = _internals.STATUS_DEPRECATED -STATUS_INACTIVE = _internals.STATUS_INACTIVE -STATUS_PENDING_DEPRECATION = _internals.STATUS_PENDING_DEPRECATION -SUBSCRIPTIONSTATUS_UNSUBSCRIBED = _internals.SUBSCRIPTIONSTATUS_UNSUBSCRIBED -SUBSCRIPTIONSTATUS_SUBSCRIBING = _internals.SUBSCRIPTIONSTATUS_SUBSCRIBING -SUBSCRIPTIONSTATUS_SUBSCRIBED = _internals.SUBSCRIPTIONSTATUS_SUBSCRIBED -SUBSCRIPTIONSTATUS_CANCELLED = _internals.SUBSCRIPTIONSTATUS_CANCELLED -SUBSCRIPTIONSTATUS_PENDING_CANCELLATION = _internals.SUBSCRIPTIONSTATUS_PENDING_CANCELLATION -CLIENTMODE_AUTO = _internals.CLIENTMODE_AUTO -CLIENTMODE_DAPI = _internals.CLIENTMODE_DAPI -CLIENTMODE_SAPI = _internals.CLIENTMODE_SAPI -CLIENTMODE_COMPAT_33X = _internals.CLIENTMODE_COMPAT_33X -RESOLVEMODE_DONT_REGISTER_SERVICES = _internals.RESOLVEMODE_DONT_REGISTER_SERVICES -RESOLVEMODE_AUTO_REGISTER_SERVICES = _internals.RESOLVEMODE_AUTO_REGISTER_SERVICES -SEATTYPE_INVALID_SEAT = _internals.SEATTYPE_INVALID_SEAT -SEATTYPE_BPS = _internals.SEATTYPE_BPS -SEATTYPE_NONBPS = _internals.SEATTYPE_NONBPS -SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW = _internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW -REGISTRATIONPARTS_DEFAULT = _internals.REGISTRATIONPARTS_DEFAULT -REGISTRATIONPARTS_PUBLISHING = _internals.REGISTRATIONPARTS_PUBLISHING -REGISTRATIONPARTS_OPERATIONS = _internals.REGISTRATIONPARTS_OPERATIONS -REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION = _internals.REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION -REGISTRATIONPARTS_PUBLISHER_RESOLUTION = _internals.REGISTRATIONPARTS_PUBLISHER_RESOLUTION -DATATYPE_BOOL = _internals.DATATYPE_BOOL -DATATYPE_CHAR = _internals.DATATYPE_CHAR -DATATYPE_BYTE = _internals.DATATYPE_BYTE -DATATYPE_INT32 = _internals.DATATYPE_INT32 -DATATYPE_INT64 = _internals.DATATYPE_INT64 -DATATYPE_FLOAT32 = _internals.DATATYPE_FLOAT32 -DATATYPE_FLOAT64 = _internals.DATATYPE_FLOAT64 -DATATYPE_STRING = _internals.DATATYPE_STRING -DATATYPE_BYTEARRAY = _internals.DATATYPE_BYTEARRAY -DATATYPE_DATE = _internals.DATATYPE_DATE -DATATYPE_TIME = _internals.DATATYPE_TIME -DATATYPE_DECIMAL = _internals.DATATYPE_DECIMAL -DATATYPE_DATETIME = _internals.DATATYPE_DATETIME -DATATYPE_ENUMERATION = _internals.DATATYPE_ENUMERATION -DATATYPE_SEQUENCE = _internals.DATATYPE_SEQUENCE -DATATYPE_CHOICE = _internals.DATATYPE_CHOICE -DATATYPE_CORRELATION_ID = _internals.DATATYPE_CORRELATION_ID -blpapi_Logging_SEVERITY_OFF = _internals.blpapi_Logging_SEVERITY_OFF -blpapi_Logging_SEVERITY_FATAL = _internals.blpapi_Logging_SEVERITY_FATAL -blpapi_Logging_SEVERITY_ERROR = _internals.blpapi_Logging_SEVERITY_ERROR -blpapi_Logging_SEVERITY_WARN = _internals.blpapi_Logging_SEVERITY_WARN -blpapi_Logging_SEVERITY_INFO = _internals.blpapi_Logging_SEVERITY_INFO -blpapi_Logging_SEVERITY_DEBUG = _internals.blpapi_Logging_SEVERITY_DEBUG -blpapi_Logging_SEVERITY_TRACE = _internals.blpapi_Logging_SEVERITY_TRACE - -def setLoggerCallbackWrapper(cb, severity): - return _internals.setLoggerCallbackWrapper(cb, severity) -setLoggerCallbackWrapper = _internals.setLoggerCallbackWrapper - -def blpapi_Logging_registerCallback(callback, thresholdSeverity): - return _internals.blpapi_Logging_registerCallback(callback, thresholdSeverity) -blpapi_Logging_registerCallback = _internals.blpapi_Logging_registerCallback - -def blpapi_Logging_logTestMessage(severity): - return _internals.blpapi_Logging_logTestMessage(severity) -blpapi_Logging_logTestMessage = _internals.blpapi_Logging_logTestMessage - -def blpapi_DiagnosticsUtil_memoryInfo_wrapper(): - return _internals.blpapi_DiagnosticsUtil_memoryInfo_wrapper() -blpapi_DiagnosticsUtil_memoryInfo_wrapper = _internals.blpapi_DiagnosticsUtil_memoryInfo_wrapper - -def blpapi_Message_timeReceived_wrapper(message): - return _internals.blpapi_Message_timeReceived_wrapper(message) -blpapi_Message_timeReceived_wrapper = _internals.blpapi_Message_timeReceived_wrapper - -def blpapi_HighResolutionClock_now_wrapper(): - return _internals.blpapi_HighResolutionClock_now_wrapper() -blpapi_HighResolutionClock_now_wrapper = _internals.blpapi_HighResolutionClock_now_wrapper - -def blpapi_Service_printHelper(service, level, spacesPerLevel): - return _internals.blpapi_Service_printHelper(service, level, spacesPerLevel) -blpapi_Service_printHelper = _internals.blpapi_Service_printHelper - -def blpapi_SchemaElementDefinition_printHelper(item, level, spacesPerLevel): - return _internals.blpapi_SchemaElementDefinition_printHelper(item, level, spacesPerLevel) -blpapi_SchemaElementDefinition_printHelper = _internals.blpapi_SchemaElementDefinition_printHelper - -def blpapi_SchemaTypeDefinition_printHelper(item, level, spacesPerLevel): - return _internals.blpapi_SchemaTypeDefinition_printHelper(item, level, spacesPerLevel) -blpapi_SchemaTypeDefinition_printHelper = _internals.blpapi_SchemaTypeDefinition_printHelper - -def blpapi_SchemaTypeDefinition_hasElementDefinition(type, nameString, name): - return _internals.blpapi_SchemaTypeDefinition_hasElementDefinition(type, nameString, name) -blpapi_SchemaTypeDefinition_hasElementDefinition = _internals.blpapi_SchemaTypeDefinition_hasElementDefinition - -def blpapi_ConstantList_hasConstant(list, nameString, name): - return _internals.blpapi_ConstantList_hasConstant(list, nameString, name) -blpapi_ConstantList_hasConstant = _internals.blpapi_ConstantList_hasConstant - -def blpapi_Service_hasEventDefinition(service, nameString, name): - return _internals.blpapi_Service_hasEventDefinition(service, nameString, name) -blpapi_Service_hasEventDefinition = _internals.blpapi_Service_hasEventDefinition - -def blpapi_Service_hasOperation(service, nameString, name): - return _internals.blpapi_Service_hasOperation(service, nameString, name) -blpapi_Service_hasOperation = _internals.blpapi_Service_hasOperation - -def blpapi_SubscriptionList_addHelper(list, topic, correlationId, fields, options): - return _internals.blpapi_SubscriptionList_addHelper(list, topic, correlationId, fields, options) -blpapi_SubscriptionList_addHelper = _internals.blpapi_SubscriptionList_addHelper - -def blpapi_Name_hasName(nameString): - return _internals.blpapi_Name_hasName(nameString) -blpapi_Name_hasName = _internals.blpapi_Name_hasName - -def blpapi_TopicList_createFromResolutionList(arg1): - return _internals.blpapi_TopicList_createFromResolutionList(arg1) -blpapi_TopicList_createFromResolutionList = _internals.blpapi_TopicList_createFromResolutionList -class intArray(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, intArray, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, intArray, name) - __repr__ = _swig_repr - - def __init__(self, nelements): - this = _internals.new_intArray(nelements) - try: - self.this.append(this) - except __builtin__.Exception: - self.this = this - __swig_destroy__ = _internals.delete_intArray - __del__ = lambda self: None - - def __getitem__(self, index): - return _internals.intArray___getitem__(self, index) - - def __setitem__(self, index, value): - return _internals.intArray___setitem__(self, index, value) - - def cast(self): - return _internals.intArray_cast(self) - if _newclass: - frompointer = staticmethod(_internals.intArray_frompointer) - else: - frompointer = _internals.intArray_frompointer -intArray_swigregister = _internals.intArray_swigregister -intArray_swigregister(intArray) - -def intArray_frompointer(t): - return _internals.intArray_frompointer(t) -intArray_frompointer = _internals.intArray_frompointer - - -def new_topicPtrArray(nelements): - return _internals.new_topicPtrArray(nelements) -new_topicPtrArray = _internals.new_topicPtrArray - -def delete_topicPtrArray(ary): - return _internals.delete_topicPtrArray(ary) -delete_topicPtrArray = _internals.delete_topicPtrArray - -def topicPtrArray_getitem(ary, index): - return _internals.topicPtrArray_getitem(ary, index) -topicPtrArray_getitem = _internals.topicPtrArray_getitem - -def topicPtrArray_setitem(ary, index, value): - return _internals.topicPtrArray_setitem(ary, index, value) -topicPtrArray_setitem = _internals.topicPtrArray_setitem - -def CorrelationId_t_equals(cid1, cid2): - return _internals.CorrelationId_t_equals(cid1, cid2) -CorrelationId_t_equals = _internals.CorrelationId_t_equals -class CorrelationId(_object): - """ - A key used to identify individual subscriptions or requests. - - CorrelationId([value[, classId=0]]) constructs a CorrelationId object. - If 'value' is integer (either int or long) then created CorrelationId will have - type() == CorrelationId.INT_TYPE. Otherwise it will have - type() == CorrelationId.OBJECT_TYPE. If no arguments are specified - then it will have type() == CorrelationId.UNSET_TYPE. - - Two CorrelationIds are considered equal if they have the same - type() and: - - holds the same (not just equal!) objects in case of - type() == CorrelationId.OBJECT_TYPE - - holds equal integers in case of - type() == CorrelationId.INT_TYPE or - type() == CorrelationId.AUTOGEN_TYPE - - True otherwise - (i.e. in case of type() == CorrelationId.UNSET_TYPE) - - It is possible that an user constructed CorrelationId and a - CorrelationId generated by the API could return the same - result for value(). However, they will not compare equal because - they have different type(). - - CorrelationId objects are passed to many of the Session object - methods which initiate an asynchronous operations and are - obtained from Message objects which are delivered as a result - of those asynchronous operations. - - When subscribing or requesting information an application has - the choice of providing a CorrelationId they construct - themselves or allowing the session to construct one for - them. If the application supplies a CorrelationId it must not - re-use the value contained in it in another CorrelationId - whilst the original request or subscription is still active. - - Class attributes: - Possible return values for type() method: - UNSET_TYPE The CorrelationId is unset. That is, it was created by - the default CorrelationId constructor. - INT_TYPE The CorrelationId was created from an integer (or long) - supplied by the user. - OBJECT_TYPE The CorrelationId was created from an object supplied by - the user. - AUTOGEN_TYPE The CorrelationId was created internally by API. - - MAX_CLASS_ID The maximum value allowed for classId. - """ - - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, CorrelationId, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, CorrelationId, name) - __repr__ = _swig_repr - - UNSET_TYPE = _internals.CORRELATION_TYPE_UNSET - - INT_TYPE = _internals.CORRELATION_TYPE_INT - - OBJECT_TYPE = _internals.CORRELATION_TYPE_POINTER - - AUTOGEN_TYPE = _internals.CORRELATION_TYPE_AUTOGEN - - MAX_CLASS_ID = _internals.CORRELATION_MAX_CLASS_ID - - __TYPE_NAMES = { - _internals.CORRELATION_TYPE_UNSET: "UNSET", - _internals.CORRELATION_TYPE_INT: "INTEGER", - _internals.CORRELATION_TYPE_POINTER: "OBJECT", - _internals.CORRELATION_TYPE_AUTOGEN: "AUTOGEN" - } - - def __str__(self): - """x.__str__() <==> str(x)""" - valueType = self.type() - valueTypeName = CorrelationId.__TYPE_NAMES[valueType] - - if valueType == CorrelationId.UNSET_TYPE: - return valueTypeName - else: - return "({0}: {1!r}, ClassId: {2})".format( - valueTypeName, self.value(), self.classId()) - - def __hash__(self): - return hash((self.type(), self.classId(), self.__toInteger())) - - def __eq__(self, other): - """x.__eq__(y) <==> x==y""" - try: - return CorrelationId_t_equals(self, other) - except Exception: - return NotImplemented - - def __ne__(self, other): - """x.__ne__(y) <==> x!=y""" - equal = self.__eq__(other) - return NotImplemented if equal is NotImplemented else not equal - - def value(self): - """Return the value of this CorrelationId object. The return value - depends on this CorrelationId's value type and could be: - - integer (type() == CorrelationId.INT_TYPE - or type() == CorrelationId.AUTOGEN_TYPE) - - object (type() == CorrelationId.OBJECT_TYPE) - - None (type() == CorrelationId.UNSET_TYPE) - """ - valueType = self.type() - if valueType == CorrelationId.INT_TYPE \ - or valueType == CorrelationId.AUTOGEN_TYPE: - return self.__asInteger() - elif valueType == CorrelationId.OBJECT_TYPE: - return self.__asObject() - else: - return None - - def _handle(self): - return self - - - def __init__(self, *args): - """ - A key used to identify individual subscriptions or requests. - - CorrelationId([value[, classId=0]]) constructs a CorrelationId object. - If 'value' is integer (either int or long) then created CorrelationId will have - type() == CorrelationId.INT_TYPE. Otherwise it will have - type() == CorrelationId.OBJECT_TYPE. If no arguments are specified - then it will have type() == CorrelationId.UNSET_TYPE. - - Two CorrelationIds are considered equal if they have the same - type() and: - - holds the same (not just equal!) objects in case of - type() == CorrelationId.OBJECT_TYPE - - holds equal integers in case of - type() == CorrelationId.INT_TYPE or - type() == CorrelationId.AUTOGEN_TYPE - - True otherwise - (i.e. in case of type() == CorrelationId.UNSET_TYPE) - - It is possible that an user constructed CorrelationId and a - CorrelationId generated by the API could return the same - result for value(). However, they will not compare equal because - they have different type(). - - CorrelationId objects are passed to many of the Session object - methods which initiate an asynchronous operations and are - obtained from Message objects which are delivered as a result - of those asynchronous operations. - - When subscribing or requesting information an application has - the choice of providing a CorrelationId they construct - themselves or allowing the session to construct one for - them. If the application supplies a CorrelationId it must not - re-use the value contained in it in another CorrelationId - whilst the original request or subscription is still active. - - Class attributes: - Possible return values for type() method: - UNSET_TYPE The CorrelationId is unset. That is, it was created by - the default CorrelationId constructor. - INT_TYPE The CorrelationId was created from an integer (or long) - supplied by the user. - OBJECT_TYPE The CorrelationId was created from an object supplied by - the user. - AUTOGEN_TYPE The CorrelationId was created internally by API. - - MAX_CLASS_ID The maximum value allowed for classId. - """ - this = _internals.new_CorrelationId(*args) - try: - self.this.append(this) - except __builtin__.Exception: - self.this = this - __swig_destroy__ = _internals.delete_CorrelationId - __del__ = lambda self: None - - def type(self): - """Return the type of this CorrelationId object (see xxx_TYPE class attributes)""" - return _internals.CorrelationId_type(self) - - - def classId(self): - """Return the user defined classification of this CorrelationId object""" - return _internals.CorrelationId_classId(self) - - - def __asObject(self): - return _internals.CorrelationId___asObject(self) - - def __asInteger(self): - return _internals.CorrelationId___asInteger(self) - - def __toInteger(self): - return _internals.CorrelationId___toInteger(self) -CorrelationId_swigregister = _internals.CorrelationId_swigregister -CorrelationId_swigregister(CorrelationId) - - -def blpapi_Element_setElementFloat(element, nameString, name, value): - return _internals.blpapi_Element_setElementFloat(element, nameString, name, value) -blpapi_Element_setElementFloat = _internals.blpapi_Element_setElementFloat - -def blpapi_Element_setValueFloat(element, value, index): - return _internals.blpapi_Element_setValueFloat(element, value, index) -blpapi_Element_setValueFloat = _internals.blpapi_Element_setValueFloat - -def blpapi_Element_printHelper(element, level, spacesPerLevel): - return _internals.blpapi_Element_printHelper(element, level, spacesPerLevel) -blpapi_Element_printHelper = _internals.blpapi_Element_printHelper - -def blpapi_Element_name(element): - return _internals.blpapi_Element_name(element) -blpapi_Element_name = _internals.blpapi_Element_name - -def blpapi_Element_nameString(element): - return _internals.blpapi_Element_nameString(element) -blpapi_Element_nameString = _internals.blpapi_Element_nameString - -def blpapi_Element_definition(element): - return _internals.blpapi_Element_definition(element) -blpapi_Element_definition = _internals.blpapi_Element_definition - -def blpapi_Element_datatype(element): - return _internals.blpapi_Element_datatype(element) -blpapi_Element_datatype = _internals.blpapi_Element_datatype - -def blpapi_Element_isComplexType(element): - return _internals.blpapi_Element_isComplexType(element) -blpapi_Element_isComplexType = _internals.blpapi_Element_isComplexType - -def blpapi_Element_isArray(element): - return _internals.blpapi_Element_isArray(element) -blpapi_Element_isArray = _internals.blpapi_Element_isArray - -def blpapi_Element_isReadOnly(element): - return _internals.blpapi_Element_isReadOnly(element) -blpapi_Element_isReadOnly = _internals.blpapi_Element_isReadOnly - -def blpapi_Element_numValues(element): - return _internals.blpapi_Element_numValues(element) -blpapi_Element_numValues = _internals.blpapi_Element_numValues - -def blpapi_Element_numElements(element): - return _internals.blpapi_Element_numElements(element) -blpapi_Element_numElements = _internals.blpapi_Element_numElements - -def blpapi_Element_isNullValue(element, position): - return _internals.blpapi_Element_isNullValue(element, position) -blpapi_Element_isNullValue = _internals.blpapi_Element_isNullValue - -def blpapi_Element_isNull(element): - return _internals.blpapi_Element_isNull(element) -blpapi_Element_isNull = _internals.blpapi_Element_isNull - -def blpapi_Element_getElementAt(element, position): - return _internals.blpapi_Element_getElementAt(element, position) -blpapi_Element_getElementAt = _internals.blpapi_Element_getElementAt - -def blpapi_Element_getElement(element, nameString, name): - return _internals.blpapi_Element_getElement(element, nameString, name) -blpapi_Element_getElement = _internals.blpapi_Element_getElement - -def blpapi_Element_hasElementEx(element, nameString, name, excludeNullElements, reserved): - return _internals.blpapi_Element_hasElementEx(element, nameString, name, excludeNullElements, reserved) -blpapi_Element_hasElementEx = _internals.blpapi_Element_hasElementEx - -def blpapi_Element_getValueAsBool(element, index): - return _internals.blpapi_Element_getValueAsBool(element, index) -blpapi_Element_getValueAsBool = _internals.blpapi_Element_getValueAsBool - -def blpapi_Element_getValueAsChar(element, buffer, index): - return _internals.blpapi_Element_getValueAsChar(element, buffer, index) -blpapi_Element_getValueAsChar = _internals.blpapi_Element_getValueAsChar - -def blpapi_Element_getValueAsInt32(element, buffer, index): - return _internals.blpapi_Element_getValueAsInt32(element, buffer, index) -blpapi_Element_getValueAsInt32 = _internals.blpapi_Element_getValueAsInt32 - -def blpapi_Element_getValueAsInt64(element, index): - return _internals.blpapi_Element_getValueAsInt64(element, index) -blpapi_Element_getValueAsInt64 = _internals.blpapi_Element_getValueAsInt64 - -def blpapi_Element_getValueAsFloat64(element, index): - return _internals.blpapi_Element_getValueAsFloat64(element, index) -blpapi_Element_getValueAsFloat64 = _internals.blpapi_Element_getValueAsFloat64 - -def blpapi_Element_getValueAsString(element, index): - return _internals.blpapi_Element_getValueAsString(element, index) -blpapi_Element_getValueAsString = _internals.blpapi_Element_getValueAsString - -def blpapi_Element_getValueAsDatetime(element, index): - return _internals.blpapi_Element_getValueAsDatetime(element, index) -blpapi_Element_getValueAsDatetime = _internals.blpapi_Element_getValueAsDatetime - -def blpapi_Element_getValueAsHighPrecisionDatetime(element, buffer, index): - return _internals.blpapi_Element_getValueAsHighPrecisionDatetime(element, buffer, index) -blpapi_Element_getValueAsHighPrecisionDatetime = _internals.blpapi_Element_getValueAsHighPrecisionDatetime - -def blpapi_Element_getValueAsElement(element, index): - return _internals.blpapi_Element_getValueAsElement(element, index) -blpapi_Element_getValueAsElement = _internals.blpapi_Element_getValueAsElement - -def blpapi_Element_getValueAsName(element, index): - return _internals.blpapi_Element_getValueAsName(element, index) -blpapi_Element_getValueAsName = _internals.blpapi_Element_getValueAsName - -def blpapi_Element_getChoice(element): - return _internals.blpapi_Element_getChoice(element) -blpapi_Element_getChoice = _internals.blpapi_Element_getChoice - -def blpapi_Element_setValueBool(element, value, index): - return _internals.blpapi_Element_setValueBool(element, value, index) -blpapi_Element_setValueBool = _internals.blpapi_Element_setValueBool - -def blpapi_Element_setValueInt32(element, value, index): - return _internals.blpapi_Element_setValueInt32(element, value, index) -blpapi_Element_setValueInt32 = _internals.blpapi_Element_setValueInt32 - -def blpapi_Element_setValueInt64(element, value, index): - return _internals.blpapi_Element_setValueInt64(element, value, index) -blpapi_Element_setValueInt64 = _internals.blpapi_Element_setValueInt64 - -def blpapi_Element_setValueString(element, value, index): - return _internals.blpapi_Element_setValueString(element, value, index) -blpapi_Element_setValueString = _internals.blpapi_Element_setValueString - -def blpapi_Element_setValueDatetime(element, value, index): - return _internals.blpapi_Element_setValueDatetime(element, value, index) -blpapi_Element_setValueDatetime = _internals.blpapi_Element_setValueDatetime - -def blpapi_Element_setValueHighPrecisionDatetime(element, value, index): - return _internals.blpapi_Element_setValueHighPrecisionDatetime(element, value, index) -blpapi_Element_setValueHighPrecisionDatetime = _internals.blpapi_Element_setValueHighPrecisionDatetime - -def blpapi_Element_setValueFromName(element, value, index): - return _internals.blpapi_Element_setValueFromName(element, value, index) -blpapi_Element_setValueFromName = _internals.blpapi_Element_setValueFromName - -def blpapi_Element_setElementBool(element, nameString, name, value): - return _internals.blpapi_Element_setElementBool(element, nameString, name, value) -blpapi_Element_setElementBool = _internals.blpapi_Element_setElementBool - -def blpapi_Element_setElementInt32(element, nameString, name, value): - return _internals.blpapi_Element_setElementInt32(element, nameString, name, value) -blpapi_Element_setElementInt32 = _internals.blpapi_Element_setElementInt32 - -def blpapi_Element_setElementInt64(element, nameString, name, value): - return _internals.blpapi_Element_setElementInt64(element, nameString, name, value) -blpapi_Element_setElementInt64 = _internals.blpapi_Element_setElementInt64 - -def blpapi_Element_setElementString(element, nameString, name, value): - return _internals.blpapi_Element_setElementString(element, nameString, name, value) -blpapi_Element_setElementString = _internals.blpapi_Element_setElementString - -def blpapi_Element_setElementDatetime(element, nameString, name, value): - return _internals.blpapi_Element_setElementDatetime(element, nameString, name, value) -blpapi_Element_setElementDatetime = _internals.blpapi_Element_setElementDatetime - -def blpapi_Element_setElementHighPrecisionDatetime(element, nameString, name, value): - return _internals.blpapi_Element_setElementHighPrecisionDatetime(element, nameString, name, value) -blpapi_Element_setElementHighPrecisionDatetime = _internals.blpapi_Element_setElementHighPrecisionDatetime - -def blpapi_Element_setElementFromName(element, elementName, name, buffer): - return _internals.blpapi_Element_setElementFromName(element, elementName, name, buffer) -blpapi_Element_setElementFromName = _internals.blpapi_Element_setElementFromName - -def blpapi_Element_appendElement(element): - return _internals.blpapi_Element_appendElement(element) -blpapi_Element_appendElement = _internals.blpapi_Element_appendElement - -def blpapi_Element_setChoice(element, nameCstr, name, index): - return _internals.blpapi_Element_setChoice(element, nameCstr, name, index) -blpapi_Element_setChoice = _internals.blpapi_Element_setChoice - -def blpapi_EventFormatter_setValueFloat(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueFloat(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueFloat = _internals.blpapi_EventFormatter_setValueFloat - -def blpapi_EventFormatter_appendValueFloat(formatter, value): - return _internals.blpapi_EventFormatter_appendValueFloat(formatter, value) -blpapi_EventFormatter_appendValueFloat = _internals.blpapi_EventFormatter_appendValueFloat - -def blpapi_EventFormatter_create(event): - return _internals.blpapi_EventFormatter_create(event) -blpapi_EventFormatter_create = _internals.blpapi_EventFormatter_create - -def blpapi_EventFormatter_destroy(victim): - return _internals.blpapi_EventFormatter_destroy(victim) -blpapi_EventFormatter_destroy = _internals.blpapi_EventFormatter_destroy - -def blpapi_EventFormatter_appendMessage(formatter, typeString, typeName, topic): - return _internals.blpapi_EventFormatter_appendMessage(formatter, typeString, typeName, topic) -blpapi_EventFormatter_appendMessage = _internals.blpapi_EventFormatter_appendMessage - -def blpapi_EventFormatter_appendMessageSeq(formatter, typeString, typeName, topic, sequenceNumber, arg6): - return _internals.blpapi_EventFormatter_appendMessageSeq(formatter, typeString, typeName, topic, sequenceNumber, arg6) -blpapi_EventFormatter_appendMessageSeq = _internals.blpapi_EventFormatter_appendMessageSeq - -def blpapi_EventFormatter_appendResponse(formatter, typeString, typeName): - return _internals.blpapi_EventFormatter_appendResponse(formatter, typeString, typeName) -blpapi_EventFormatter_appendResponse = _internals.blpapi_EventFormatter_appendResponse - -def blpapi_EventFormatter_appendRecapMessage(formatter, topic, cid): - return _internals.blpapi_EventFormatter_appendRecapMessage(formatter, topic, cid) -blpapi_EventFormatter_appendRecapMessage = _internals.blpapi_EventFormatter_appendRecapMessage - -def blpapi_EventFormatter_appendRecapMessageSeq(formatter, topic, cid, sequenceNumber, arg5): - return _internals.blpapi_EventFormatter_appendRecapMessageSeq(formatter, topic, cid, sequenceNumber, arg5) -blpapi_EventFormatter_appendRecapMessageSeq = _internals.blpapi_EventFormatter_appendRecapMessageSeq - -def blpapi_EventFormatter_setValueBool(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueBool(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueBool = _internals.blpapi_EventFormatter_setValueBool - -def blpapi_EventFormatter_setValueChar(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueChar(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueChar = _internals.blpapi_EventFormatter_setValueChar - -def blpapi_EventFormatter_setValueInt32(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueInt32(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueInt32 = _internals.blpapi_EventFormatter_setValueInt32 - -def blpapi_EventFormatter_setValueInt64(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueInt64(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueInt64 = _internals.blpapi_EventFormatter_setValueInt64 - -def blpapi_EventFormatter_setValueDatetime(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueDatetime(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueDatetime = _internals.blpapi_EventFormatter_setValueDatetime - -def blpapi_EventFormatter_setValueString(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueString(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueString = _internals.blpapi_EventFormatter_setValueString - -def blpapi_EventFormatter_setValueFromName(formatter, typeString, typeName, value): - return _internals.blpapi_EventFormatter_setValueFromName(formatter, typeString, typeName, value) -blpapi_EventFormatter_setValueFromName = _internals.blpapi_EventFormatter_setValueFromName - -def blpapi_EventFormatter_setValueNull(formatter, typeString, typeName): - return _internals.blpapi_EventFormatter_setValueNull(formatter, typeString, typeName) -blpapi_EventFormatter_setValueNull = _internals.blpapi_EventFormatter_setValueNull - -def blpapi_EventFormatter_pushElement(formatter, typeString, typeName): - return _internals.blpapi_EventFormatter_pushElement(formatter, typeString, typeName) -blpapi_EventFormatter_pushElement = _internals.blpapi_EventFormatter_pushElement - -def blpapi_EventFormatter_popElement(formatter): - return _internals.blpapi_EventFormatter_popElement(formatter) -blpapi_EventFormatter_popElement = _internals.blpapi_EventFormatter_popElement - -def blpapi_EventFormatter_appendValueBool(formatter, value): - return _internals.blpapi_EventFormatter_appendValueBool(formatter, value) -blpapi_EventFormatter_appendValueBool = _internals.blpapi_EventFormatter_appendValueBool - -def blpapi_EventFormatter_appendValueChar(formatter, value): - return _internals.blpapi_EventFormatter_appendValueChar(formatter, value) -blpapi_EventFormatter_appendValueChar = _internals.blpapi_EventFormatter_appendValueChar - -def blpapi_EventFormatter_appendValueInt32(formatter, value): - return _internals.blpapi_EventFormatter_appendValueInt32(formatter, value) -blpapi_EventFormatter_appendValueInt32 = _internals.blpapi_EventFormatter_appendValueInt32 - -def blpapi_EventFormatter_appendValueInt64(formatter, value): - return _internals.blpapi_EventFormatter_appendValueInt64(formatter, value) -blpapi_EventFormatter_appendValueInt64 = _internals.blpapi_EventFormatter_appendValueInt64 - -def blpapi_EventFormatter_appendValueDatetime(formatter, value): - return _internals.blpapi_EventFormatter_appendValueDatetime(formatter, value) -blpapi_EventFormatter_appendValueDatetime = _internals.blpapi_EventFormatter_appendValueDatetime - -def blpapi_EventFormatter_appendValueString(formatter, value): - return _internals.blpapi_EventFormatter_appendValueString(formatter, value) -blpapi_EventFormatter_appendValueString = _internals.blpapi_EventFormatter_appendValueString - -def blpapi_EventFormatter_appendValueFromName(formatter, value): - return _internals.blpapi_EventFormatter_appendValueFromName(formatter, value) -blpapi_EventFormatter_appendValueFromName = _internals.blpapi_EventFormatter_appendValueFromName - -def blpapi_EventFormatter_appendElement(formatter): - return _internals.blpapi_EventFormatter_appendElement(formatter) -blpapi_EventFormatter_appendElement = _internals.blpapi_EventFormatter_appendElement - -def Session_createHelper(parameters, eventHandlerFunc, dispatcher): - return _internals.Session_createHelper(parameters, eventHandlerFunc, dispatcher) -Session_createHelper = _internals.Session_createHelper - -def Session_destroyHelper(sessionHandle, eventHandlerFunc): - return _internals.Session_destroyHelper(sessionHandle, eventHandlerFunc) -Session_destroyHelper = _internals.Session_destroyHelper - -def blpapi_EventDispatcher_create(numDispatcherThreads): - return _internals.blpapi_EventDispatcher_create(numDispatcherThreads) -blpapi_EventDispatcher_create = _internals.blpapi_EventDispatcher_create - -def blpapi_EventDispatcher_destroy(handle): - return _internals.blpapi_EventDispatcher_destroy(handle) -blpapi_EventDispatcher_destroy = _internals.blpapi_EventDispatcher_destroy - -def blpapi_EventDispatcher_start(handle): - return _internals.blpapi_EventDispatcher_start(handle) -blpapi_EventDispatcher_start = _internals.blpapi_EventDispatcher_start - -def blpapi_EventDispatcher_stop(handle, async): - return _internals.blpapi_EventDispatcher_stop(handle, async) -blpapi_EventDispatcher_stop = _internals.blpapi_EventDispatcher_stop - -def ProviderSession_createHelper(parameters, eventHandlerFunc, dispatcher): - return _internals.ProviderSession_createHelper(parameters, eventHandlerFunc, dispatcher) -ProviderSession_createHelper = _internals.ProviderSession_createHelper - -def ProviderSession_destroyHelper(sessionHandle, eventHandlerFunc): - return _internals.ProviderSession_destroyHelper(sessionHandle, eventHandlerFunc) -ProviderSession_destroyHelper = _internals.ProviderSession_destroyHelper -UNKNOWN_CLASS = _internals.UNKNOWN_CLASS -INVALIDSTATE_CLASS = _internals.INVALIDSTATE_CLASS -INVALIDARG_CLASS = _internals.INVALIDARG_CLASS -IOERROR_CLASS = _internals.IOERROR_CLASS -CNVERROR_CLASS = _internals.CNVERROR_CLASS -BOUNDSERROR_CLASS = _internals.BOUNDSERROR_CLASS -NOTFOUND_CLASS = _internals.NOTFOUND_CLASS -FLDNOTFOUND_CLASS = _internals.FLDNOTFOUND_CLASS -UNSUPPORTED_CLASS = _internals.UNSUPPORTED_CLASS -ERROR_UNKNOWN = _internals.ERROR_UNKNOWN -ERROR_ILLEGAL_ARG = _internals.ERROR_ILLEGAL_ARG -ERROR_ILLEGAL_ACCESS = _internals.ERROR_ILLEGAL_ACCESS -ERROR_INVALID_SESSION = _internals.ERROR_INVALID_SESSION -ERROR_DUPLICATE_CORRELATIONID = _internals.ERROR_DUPLICATE_CORRELATIONID -ERROR_INTERNAL_ERROR = _internals.ERROR_INTERNAL_ERROR -ERROR_RESOLVE_FAILED = _internals.ERROR_RESOLVE_FAILED -ERROR_CONNECT_FAILED = _internals.ERROR_CONNECT_FAILED -ERROR_ILLEGAL_STATE = _internals.ERROR_ILLEGAL_STATE -ERROR_CODEC_FAILURE = _internals.ERROR_CODEC_FAILURE -ERROR_INDEX_OUT_OF_RANGE = _internals.ERROR_INDEX_OUT_OF_RANGE -ERROR_INVALID_CONVERSION = _internals.ERROR_INVALID_CONVERSION -ERROR_ITEM_NOT_FOUND = _internals.ERROR_ITEM_NOT_FOUND -ERROR_IO_ERROR = _internals.ERROR_IO_ERROR -ERROR_CORRELATION_NOT_FOUND = _internals.ERROR_CORRELATION_NOT_FOUND -ERROR_SERVICE_NOT_FOUND = _internals.ERROR_SERVICE_NOT_FOUND -ERROR_LOGON_LOOKUP_FAILED = _internals.ERROR_LOGON_LOOKUP_FAILED -ERROR_DS_LOOKUP_FAILED = _internals.ERROR_DS_LOOKUP_FAILED -ERROR_UNSUPPORTED_OPERATION = _internals.ERROR_UNSUPPORTED_OPERATION -ERROR_DS_PROPERTY_NOT_FOUND = _internals.ERROR_DS_PROPERTY_NOT_FOUND - -def blpapi_getLastErrorDescription(resultCode): - return _internals.blpapi_getLastErrorDescription(resultCode) -blpapi_getLastErrorDescription = _internals.blpapi_getLastErrorDescription - -def blpapi_SessionOptions_create(): - return _internals.blpapi_SessionOptions_create() -blpapi_SessionOptions_create = _internals.blpapi_SessionOptions_create - -def blpapi_SessionOptions_destroy(parameters): - return _internals.blpapi_SessionOptions_destroy(parameters) -blpapi_SessionOptions_destroy = _internals.blpapi_SessionOptions_destroy - -def blpapi_SessionOptions_setServerHost(parameters, serverHost): - return _internals.blpapi_SessionOptions_setServerHost(parameters, serverHost) -blpapi_SessionOptions_setServerHost = _internals.blpapi_SessionOptions_setServerHost - -def blpapi_SessionOptions_setServerPort(parameters, serverPort): - return _internals.blpapi_SessionOptions_setServerPort(parameters, serverPort) -blpapi_SessionOptions_setServerPort = _internals.blpapi_SessionOptions_setServerPort - -def blpapi_SessionOptions_setServerAddress(parameters, serverHost, serverPort, index): - return _internals.blpapi_SessionOptions_setServerAddress(parameters, serverHost, serverPort, index) -blpapi_SessionOptions_setServerAddress = _internals.blpapi_SessionOptions_setServerAddress - -def blpapi_SessionOptions_removeServerAddress(parameters, index): - return _internals.blpapi_SessionOptions_removeServerAddress(parameters, index) -blpapi_SessionOptions_removeServerAddress = _internals.blpapi_SessionOptions_removeServerAddress - -def blpapi_SessionOptions_setConnectTimeout(parameters, timeoutInMilliseconds): - return _internals.blpapi_SessionOptions_setConnectTimeout(parameters, timeoutInMilliseconds) -blpapi_SessionOptions_setConnectTimeout = _internals.blpapi_SessionOptions_setConnectTimeout - -def blpapi_SessionOptions_setDefaultServices(parameters, defaultServices): - return _internals.blpapi_SessionOptions_setDefaultServices(parameters, defaultServices) -blpapi_SessionOptions_setDefaultServices = _internals.blpapi_SessionOptions_setDefaultServices - -def blpapi_SessionOptions_setDefaultSubscriptionService(parameters, serviceIdentifier): - return _internals.blpapi_SessionOptions_setDefaultSubscriptionService(parameters, serviceIdentifier) -blpapi_SessionOptions_setDefaultSubscriptionService = _internals.blpapi_SessionOptions_setDefaultSubscriptionService - -def blpapi_SessionOptions_setDefaultTopicPrefix(parameters, prefix): - return _internals.blpapi_SessionOptions_setDefaultTopicPrefix(parameters, prefix) -blpapi_SessionOptions_setDefaultTopicPrefix = _internals.blpapi_SessionOptions_setDefaultTopicPrefix - -def blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg(parameters, allowMultipleCorrelatorsPerMsg): - return _internals.blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg(parameters, allowMultipleCorrelatorsPerMsg) -blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg = _internals.blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg - -def blpapi_SessionOptions_setClientMode(parameters, clientMode): - return _internals.blpapi_SessionOptions_setClientMode(parameters, clientMode) -blpapi_SessionOptions_setClientMode = _internals.blpapi_SessionOptions_setClientMode - -def blpapi_SessionOptions_setMaxPendingRequests(parameters, maxPendingRequests): - return _internals.blpapi_SessionOptions_setMaxPendingRequests(parameters, maxPendingRequests) -blpapi_SessionOptions_setMaxPendingRequests = _internals.blpapi_SessionOptions_setMaxPendingRequests - -def blpapi_SessionOptions_setAutoRestartOnDisconnection(parameters, autoRestart): - return _internals.blpapi_SessionOptions_setAutoRestartOnDisconnection(parameters, autoRestart) -blpapi_SessionOptions_setAutoRestartOnDisconnection = _internals.blpapi_SessionOptions_setAutoRestartOnDisconnection - -def blpapi_SessionOptions_setAuthenticationOptions(parameters, authOptions): - return _internals.blpapi_SessionOptions_setAuthenticationOptions(parameters, authOptions) -blpapi_SessionOptions_setAuthenticationOptions = _internals.blpapi_SessionOptions_setAuthenticationOptions - -def blpapi_SessionOptions_setNumStartAttempts(parameters, numStartAttempts): - return _internals.blpapi_SessionOptions_setNumStartAttempts(parameters, numStartAttempts) -blpapi_SessionOptions_setNumStartAttempts = _internals.blpapi_SessionOptions_setNumStartAttempts - -def blpapi_SessionOptions_setMaxEventQueueSize(parameters, maxEventQueueSize): - return _internals.blpapi_SessionOptions_setMaxEventQueueSize(parameters, maxEventQueueSize) -blpapi_SessionOptions_setMaxEventQueueSize = _internals.blpapi_SessionOptions_setMaxEventQueueSize - -def blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark(parameters, hiWaterMark): - return _internals.blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark(parameters, hiWaterMark) -blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark = _internals.blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark - -def blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark(parameters, loWaterMark): - return _internals.blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark(parameters, loWaterMark) -blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark = _internals.blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark - -def blpapi_SessionOptions_setDefaultKeepAliveInactivityTime(parameters, inactivityMsecs): - return _internals.blpapi_SessionOptions_setDefaultKeepAliveInactivityTime(parameters, inactivityMsecs) -blpapi_SessionOptions_setDefaultKeepAliveInactivityTime = _internals.blpapi_SessionOptions_setDefaultKeepAliveInactivityTime - -def blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout(parameters, timeoutMsecs): - return _internals.blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout(parameters, timeoutMsecs) -blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout = _internals.blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout - -def blpapi_SessionOptions_setKeepAliveEnabled(parameters, isEnabled): - return _internals.blpapi_SessionOptions_setKeepAliveEnabled(parameters, isEnabled) -blpapi_SessionOptions_setKeepAliveEnabled = _internals.blpapi_SessionOptions_setKeepAliveEnabled - -def blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes(parameters, shouldRecord): - return _internals.blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes(parameters, shouldRecord) -blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes = _internals.blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes - -def blpapi_SessionOptions_serverHost(parameters): - return _internals.blpapi_SessionOptions_serverHost(parameters) -blpapi_SessionOptions_serverHost = _internals.blpapi_SessionOptions_serverHost - -def blpapi_SessionOptions_serverPort(parameters): - return _internals.blpapi_SessionOptions_serverPort(parameters) -blpapi_SessionOptions_serverPort = _internals.blpapi_SessionOptions_serverPort - -def blpapi_SessionOptions_numServerAddresses(parameters): - return _internals.blpapi_SessionOptions_numServerAddresses(parameters) -blpapi_SessionOptions_numServerAddresses = _internals.blpapi_SessionOptions_numServerAddresses - -def blpapi_SessionOptions_getServerAddress(parameters, index): - return _internals.blpapi_SessionOptions_getServerAddress(parameters, index) -blpapi_SessionOptions_getServerAddress = _internals.blpapi_SessionOptions_getServerAddress - -def blpapi_SessionOptions_connectTimeout(parameters): - return _internals.blpapi_SessionOptions_connectTimeout(parameters) -blpapi_SessionOptions_connectTimeout = _internals.blpapi_SessionOptions_connectTimeout - -def blpapi_SessionOptions_defaultServices(parameters): - return _internals.blpapi_SessionOptions_defaultServices(parameters) -blpapi_SessionOptions_defaultServices = _internals.blpapi_SessionOptions_defaultServices - -def blpapi_SessionOptions_defaultSubscriptionService(parameters): - return _internals.blpapi_SessionOptions_defaultSubscriptionService(parameters) -blpapi_SessionOptions_defaultSubscriptionService = _internals.blpapi_SessionOptions_defaultSubscriptionService - -def blpapi_SessionOptions_defaultTopicPrefix(parameters): - return _internals.blpapi_SessionOptions_defaultTopicPrefix(parameters) -blpapi_SessionOptions_defaultTopicPrefix = _internals.blpapi_SessionOptions_defaultTopicPrefix - -def blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(parameters): - return _internals.blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(parameters) -blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg = _internals.blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg - -def blpapi_SessionOptions_clientMode(parameters): - return _internals.blpapi_SessionOptions_clientMode(parameters) -blpapi_SessionOptions_clientMode = _internals.blpapi_SessionOptions_clientMode - -def blpapi_SessionOptions_maxPendingRequests(parameters): - return _internals.blpapi_SessionOptions_maxPendingRequests(parameters) -blpapi_SessionOptions_maxPendingRequests = _internals.blpapi_SessionOptions_maxPendingRequests - -def blpapi_SessionOptions_autoRestartOnDisconnection(parameters): - return _internals.blpapi_SessionOptions_autoRestartOnDisconnection(parameters) -blpapi_SessionOptions_autoRestartOnDisconnection = _internals.blpapi_SessionOptions_autoRestartOnDisconnection - -def blpapi_SessionOptions_authenticationOptions(parameters): - return _internals.blpapi_SessionOptions_authenticationOptions(parameters) -blpapi_SessionOptions_authenticationOptions = _internals.blpapi_SessionOptions_authenticationOptions - -def blpapi_SessionOptions_numStartAttempts(parameters): - return _internals.blpapi_SessionOptions_numStartAttempts(parameters) -blpapi_SessionOptions_numStartAttempts = _internals.blpapi_SessionOptions_numStartAttempts - -def blpapi_SessionOptions_maxEventQueueSize(parameters): - return _internals.blpapi_SessionOptions_maxEventQueueSize(parameters) -blpapi_SessionOptions_maxEventQueueSize = _internals.blpapi_SessionOptions_maxEventQueueSize - -def blpapi_SessionOptions_slowConsumerWarningHiWaterMark(parameters): - return _internals.blpapi_SessionOptions_slowConsumerWarningHiWaterMark(parameters) -blpapi_SessionOptions_slowConsumerWarningHiWaterMark = _internals.blpapi_SessionOptions_slowConsumerWarningHiWaterMark - -def blpapi_SessionOptions_slowConsumerWarningLoWaterMark(parameters): - return _internals.blpapi_SessionOptions_slowConsumerWarningLoWaterMark(parameters) -blpapi_SessionOptions_slowConsumerWarningLoWaterMark = _internals.blpapi_SessionOptions_slowConsumerWarningLoWaterMark - -def blpapi_SessionOptions_defaultKeepAliveInactivityTime(parameters): - return _internals.blpapi_SessionOptions_defaultKeepAliveInactivityTime(parameters) -blpapi_SessionOptions_defaultKeepAliveInactivityTime = _internals.blpapi_SessionOptions_defaultKeepAliveInactivityTime - -def blpapi_SessionOptions_defaultKeepAliveResponseTimeout(parameters): - return _internals.blpapi_SessionOptions_defaultKeepAliveResponseTimeout(parameters) -blpapi_SessionOptions_defaultKeepAliveResponseTimeout = _internals.blpapi_SessionOptions_defaultKeepAliveResponseTimeout - -def blpapi_SessionOptions_keepAliveEnabled(parameters): - return _internals.blpapi_SessionOptions_keepAliveEnabled(parameters) -blpapi_SessionOptions_keepAliveEnabled = _internals.blpapi_SessionOptions_keepAliveEnabled - -def blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(parameters): - return _internals.blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(parameters) -blpapi_SessionOptions_recordSubscriptionDataReceiveTimes = _internals.blpapi_SessionOptions_recordSubscriptionDataReceiveTimes - -def blpapi_Name_create(nameString): - return _internals.blpapi_Name_create(nameString) -blpapi_Name_create = _internals.blpapi_Name_create - -def blpapi_Name_destroy(name): - return _internals.blpapi_Name_destroy(name) -blpapi_Name_destroy = _internals.blpapi_Name_destroy - -def blpapi_Name_equalsStr(name, string): - return _internals.blpapi_Name_equalsStr(name, string) -blpapi_Name_equalsStr = _internals.blpapi_Name_equalsStr - -def blpapi_Name_string(name): - return _internals.blpapi_Name_string(name) -blpapi_Name_string = _internals.blpapi_Name_string - -def blpapi_Name_length(name): - return _internals.blpapi_Name_length(name) -blpapi_Name_length = _internals.blpapi_Name_length - -def blpapi_Name_findName(nameString): - return _internals.blpapi_Name_findName(nameString) -blpapi_Name_findName = _internals.blpapi_Name_findName - -def blpapi_SubscriptionList_create(): - return _internals.blpapi_SubscriptionList_create() -blpapi_SubscriptionList_create = _internals.blpapi_SubscriptionList_create - -def blpapi_SubscriptionList_destroy(list): - return _internals.blpapi_SubscriptionList_destroy(list) -blpapi_SubscriptionList_destroy = _internals.blpapi_SubscriptionList_destroy - -def blpapi_SubscriptionList_addResolved(list, subscriptionString, correlationId): - return _internals.blpapi_SubscriptionList_addResolved(list, subscriptionString, correlationId) -blpapi_SubscriptionList_addResolved = _internals.blpapi_SubscriptionList_addResolved - -def blpapi_SubscriptionList_clear(list): - return _internals.blpapi_SubscriptionList_clear(list) -blpapi_SubscriptionList_clear = _internals.blpapi_SubscriptionList_clear - -def blpapi_SubscriptionList_append(dest, src): - return _internals.blpapi_SubscriptionList_append(dest, src) -blpapi_SubscriptionList_append = _internals.blpapi_SubscriptionList_append - -def blpapi_SubscriptionList_size(list): - return _internals.blpapi_SubscriptionList_size(list) -blpapi_SubscriptionList_size = _internals.blpapi_SubscriptionList_size - -def blpapi_SubscriptionList_correlationIdAt(list, index): - return _internals.blpapi_SubscriptionList_correlationIdAt(list, index) -blpapi_SubscriptionList_correlationIdAt = _internals.blpapi_SubscriptionList_correlationIdAt - -def blpapi_SubscriptionList_topicStringAt(list, index): - return _internals.blpapi_SubscriptionList_topicStringAt(list, index) -blpapi_SubscriptionList_topicStringAt = _internals.blpapi_SubscriptionList_topicStringAt - -def blpapi_SubscriptionList_isResolvedAt(list, index): - return _internals.blpapi_SubscriptionList_isResolvedAt(list, index) -blpapi_SubscriptionList_isResolvedAt = _internals.blpapi_SubscriptionList_isResolvedAt -class blpapi_Datetime_tag(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, blpapi_Datetime_tag, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, blpapi_Datetime_tag, name) - __repr__ = _swig_repr - __swig_setmethods__["parts"] = _internals.blpapi_Datetime_tag_parts_set - __swig_getmethods__["parts"] = _internals.blpapi_Datetime_tag_parts_get - if _newclass: - parts = _swig_property(_internals.blpapi_Datetime_tag_parts_get, _internals.blpapi_Datetime_tag_parts_set) - __swig_setmethods__["hours"] = _internals.blpapi_Datetime_tag_hours_set - __swig_getmethods__["hours"] = _internals.blpapi_Datetime_tag_hours_get - if _newclass: - hours = _swig_property(_internals.blpapi_Datetime_tag_hours_get, _internals.blpapi_Datetime_tag_hours_set) - __swig_setmethods__["minutes"] = _internals.blpapi_Datetime_tag_minutes_set - __swig_getmethods__["minutes"] = _internals.blpapi_Datetime_tag_minutes_get - if _newclass: - minutes = _swig_property(_internals.blpapi_Datetime_tag_minutes_get, _internals.blpapi_Datetime_tag_minutes_set) - __swig_setmethods__["seconds"] = _internals.blpapi_Datetime_tag_seconds_set - __swig_getmethods__["seconds"] = _internals.blpapi_Datetime_tag_seconds_get - if _newclass: - seconds = _swig_property(_internals.blpapi_Datetime_tag_seconds_get, _internals.blpapi_Datetime_tag_seconds_set) - __swig_setmethods__["milliSeconds"] = _internals.blpapi_Datetime_tag_milliSeconds_set - __swig_getmethods__["milliSeconds"] = _internals.blpapi_Datetime_tag_milliSeconds_get - if _newclass: - milliSeconds = _swig_property(_internals.blpapi_Datetime_tag_milliSeconds_get, _internals.blpapi_Datetime_tag_milliSeconds_set) - __swig_setmethods__["month"] = _internals.blpapi_Datetime_tag_month_set - __swig_getmethods__["month"] = _internals.blpapi_Datetime_tag_month_get - if _newclass: - month = _swig_property(_internals.blpapi_Datetime_tag_month_get, _internals.blpapi_Datetime_tag_month_set) - __swig_setmethods__["day"] = _internals.blpapi_Datetime_tag_day_set - __swig_getmethods__["day"] = _internals.blpapi_Datetime_tag_day_get - if _newclass: - day = _swig_property(_internals.blpapi_Datetime_tag_day_get, _internals.blpapi_Datetime_tag_day_set) - __swig_setmethods__["year"] = _internals.blpapi_Datetime_tag_year_set - __swig_getmethods__["year"] = _internals.blpapi_Datetime_tag_year_get - if _newclass: - year = _swig_property(_internals.blpapi_Datetime_tag_year_get, _internals.blpapi_Datetime_tag_year_set) - __swig_setmethods__["offset"] = _internals.blpapi_Datetime_tag_offset_set - __swig_getmethods__["offset"] = _internals.blpapi_Datetime_tag_offset_get - if _newclass: - offset = _swig_property(_internals.blpapi_Datetime_tag_offset_get, _internals.blpapi_Datetime_tag_offset_set) - - def __init__(self): - this = _internals.new_blpapi_Datetime_tag() - try: - self.this.append(this) - except __builtin__.Exception: - self.this = this - __swig_destroy__ = _internals.delete_blpapi_Datetime_tag - __del__ = lambda self: None -blpapi_Datetime_tag_swigregister = _internals.blpapi_Datetime_tag_swigregister -blpapi_Datetime_tag_swigregister(blpapi_Datetime_tag) - -class blpapi_HighPrecisionDatetime_tag(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, blpapi_HighPrecisionDatetime_tag, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, blpapi_HighPrecisionDatetime_tag, name) - __repr__ = _swig_repr - __swig_setmethods__["datetime"] = _internals.blpapi_HighPrecisionDatetime_tag_datetime_set - __swig_getmethods__["datetime"] = _internals.blpapi_HighPrecisionDatetime_tag_datetime_get - if _newclass: - datetime = _swig_property(_internals.blpapi_HighPrecisionDatetime_tag_datetime_get, _internals.blpapi_HighPrecisionDatetime_tag_datetime_set) - __swig_setmethods__["picoseconds"] = _internals.blpapi_HighPrecisionDatetime_tag_picoseconds_set - __swig_getmethods__["picoseconds"] = _internals.blpapi_HighPrecisionDatetime_tag_picoseconds_get - if _newclass: - picoseconds = _swig_property(_internals.blpapi_HighPrecisionDatetime_tag_picoseconds_get, _internals.blpapi_HighPrecisionDatetime_tag_picoseconds_set) - - def __init__(self): - this = _internals.new_blpapi_HighPrecisionDatetime_tag() - try: - self.this.append(this) - except __builtin__.Exception: - self.this = this - __swig_destroy__ = _internals.delete_blpapi_HighPrecisionDatetime_tag - __del__ = lambda self: None -blpapi_HighPrecisionDatetime_tag_swigregister = _internals.blpapi_HighPrecisionDatetime_tag_swigregister -blpapi_HighPrecisionDatetime_tag_swigregister(blpapi_HighPrecisionDatetime_tag) - - -def blpapi_HighPrecisionDatetime_compare(lhs, rhs): - return _internals.blpapi_HighPrecisionDatetime_compare(lhs, rhs) -blpapi_HighPrecisionDatetime_compare = _internals.blpapi_HighPrecisionDatetime_compare - -def blpapi_HighPrecisionDatetime_print(datetime, streamWriter, stream, level, spacesPerLevel): - return _internals.blpapi_HighPrecisionDatetime_print(datetime, streamWriter, stream, level, spacesPerLevel) -blpapi_HighPrecisionDatetime_print = _internals.blpapi_HighPrecisionDatetime_print - -def blpapi_HighPrecisionDatetime_fromTimePoint(datetime, timePoint, offset): - return _internals.blpapi_HighPrecisionDatetime_fromTimePoint(datetime, timePoint, offset) -blpapi_HighPrecisionDatetime_fromTimePoint = _internals.blpapi_HighPrecisionDatetime_fromTimePoint - -def blpapi_Constant_name(constant): - return _internals.blpapi_Constant_name(constant) -blpapi_Constant_name = _internals.blpapi_Constant_name - -def blpapi_Constant_description(constant): - return _internals.blpapi_Constant_description(constant) -blpapi_Constant_description = _internals.blpapi_Constant_description - -def blpapi_Constant_status(constant): - return _internals.blpapi_Constant_status(constant) -blpapi_Constant_status = _internals.blpapi_Constant_status - -def blpapi_Constant_datatype(constant): - return _internals.blpapi_Constant_datatype(constant) -blpapi_Constant_datatype = _internals.blpapi_Constant_datatype - -def blpapi_Constant_getValueAsInt64(constant): - return _internals.blpapi_Constant_getValueAsInt64(constant) -blpapi_Constant_getValueAsInt64 = _internals.blpapi_Constant_getValueAsInt64 - -def blpapi_Constant_getValueAsFloat64(constant): - return _internals.blpapi_Constant_getValueAsFloat64(constant) -blpapi_Constant_getValueAsFloat64 = _internals.blpapi_Constant_getValueAsFloat64 - -def blpapi_Constant_getValueAsDatetime(constant): - return _internals.blpapi_Constant_getValueAsDatetime(constant) -blpapi_Constant_getValueAsDatetime = _internals.blpapi_Constant_getValueAsDatetime - -def blpapi_Constant_getValueAsString(constant): - return _internals.blpapi_Constant_getValueAsString(constant) -blpapi_Constant_getValueAsString = _internals.blpapi_Constant_getValueAsString - -def blpapi_ConstantList_name(list): - return _internals.blpapi_ConstantList_name(list) -blpapi_ConstantList_name = _internals.blpapi_ConstantList_name - -def blpapi_ConstantList_description(list): - return _internals.blpapi_ConstantList_description(list) -blpapi_ConstantList_description = _internals.blpapi_ConstantList_description - -def blpapi_ConstantList_numConstants(list): - return _internals.blpapi_ConstantList_numConstants(list) -blpapi_ConstantList_numConstants = _internals.blpapi_ConstantList_numConstants - -def blpapi_ConstantList_datatype(constant): - return _internals.blpapi_ConstantList_datatype(constant) -blpapi_ConstantList_datatype = _internals.blpapi_ConstantList_datatype - -def blpapi_ConstantList_status(list): - return _internals.blpapi_ConstantList_status(list) -blpapi_ConstantList_status = _internals.blpapi_ConstantList_status - -def blpapi_ConstantList_getConstant(constant, nameString, name): - return _internals.blpapi_ConstantList_getConstant(constant, nameString, name) -blpapi_ConstantList_getConstant = _internals.blpapi_ConstantList_getConstant - -def blpapi_ConstantList_getConstantAt(constant, index): - return _internals.blpapi_ConstantList_getConstantAt(constant, index) -blpapi_ConstantList_getConstantAt = _internals.blpapi_ConstantList_getConstantAt - -def blpapi_SchemaElementDefinition_name(field): - return _internals.blpapi_SchemaElementDefinition_name(field) -blpapi_SchemaElementDefinition_name = _internals.blpapi_SchemaElementDefinition_name - -def blpapi_SchemaElementDefinition_description(field): - return _internals.blpapi_SchemaElementDefinition_description(field) -blpapi_SchemaElementDefinition_description = _internals.blpapi_SchemaElementDefinition_description - -def blpapi_SchemaElementDefinition_status(field): - return _internals.blpapi_SchemaElementDefinition_status(field) -blpapi_SchemaElementDefinition_status = _internals.blpapi_SchemaElementDefinition_status - -def blpapi_SchemaElementDefinition_type(field): - return _internals.blpapi_SchemaElementDefinition_type(field) -blpapi_SchemaElementDefinition_type = _internals.blpapi_SchemaElementDefinition_type - -def blpapi_SchemaElementDefinition_numAlternateNames(field): - return _internals.blpapi_SchemaElementDefinition_numAlternateNames(field) -blpapi_SchemaElementDefinition_numAlternateNames = _internals.blpapi_SchemaElementDefinition_numAlternateNames - -def blpapi_SchemaElementDefinition_getAlternateName(field, index): - return _internals.blpapi_SchemaElementDefinition_getAlternateName(field, index) -blpapi_SchemaElementDefinition_getAlternateName = _internals.blpapi_SchemaElementDefinition_getAlternateName - -def blpapi_SchemaElementDefinition_minValues(field): - return _internals.blpapi_SchemaElementDefinition_minValues(field) -blpapi_SchemaElementDefinition_minValues = _internals.blpapi_SchemaElementDefinition_minValues - -def blpapi_SchemaElementDefinition_maxValues(field): - return _internals.blpapi_SchemaElementDefinition_maxValues(field) -blpapi_SchemaElementDefinition_maxValues = _internals.blpapi_SchemaElementDefinition_maxValues - -def blpapi_SchemaTypeDefinition_name(type): - return _internals.blpapi_SchemaTypeDefinition_name(type) -blpapi_SchemaTypeDefinition_name = _internals.blpapi_SchemaTypeDefinition_name - -def blpapi_SchemaTypeDefinition_description(type): - return _internals.blpapi_SchemaTypeDefinition_description(type) -blpapi_SchemaTypeDefinition_description = _internals.blpapi_SchemaTypeDefinition_description - -def blpapi_SchemaTypeDefinition_status(type): - return _internals.blpapi_SchemaTypeDefinition_status(type) -blpapi_SchemaTypeDefinition_status = _internals.blpapi_SchemaTypeDefinition_status - -def blpapi_SchemaTypeDefinition_datatype(type): - return _internals.blpapi_SchemaTypeDefinition_datatype(type) -blpapi_SchemaTypeDefinition_datatype = _internals.blpapi_SchemaTypeDefinition_datatype - -def blpapi_SchemaTypeDefinition_isComplexType(type): - return _internals.blpapi_SchemaTypeDefinition_isComplexType(type) -blpapi_SchemaTypeDefinition_isComplexType = _internals.blpapi_SchemaTypeDefinition_isComplexType - -def blpapi_SchemaTypeDefinition_isSimpleType(type): - return _internals.blpapi_SchemaTypeDefinition_isSimpleType(type) -blpapi_SchemaTypeDefinition_isSimpleType = _internals.blpapi_SchemaTypeDefinition_isSimpleType - -def blpapi_SchemaTypeDefinition_isEnumerationType(type): - return _internals.blpapi_SchemaTypeDefinition_isEnumerationType(type) -blpapi_SchemaTypeDefinition_isEnumerationType = _internals.blpapi_SchemaTypeDefinition_isEnumerationType - -def blpapi_SchemaTypeDefinition_numElementDefinitions(type): - return _internals.blpapi_SchemaTypeDefinition_numElementDefinitions(type) -blpapi_SchemaTypeDefinition_numElementDefinitions = _internals.blpapi_SchemaTypeDefinition_numElementDefinitions - -def blpapi_SchemaTypeDefinition_getElementDefinition(type, nameString, name): - return _internals.blpapi_SchemaTypeDefinition_getElementDefinition(type, nameString, name) -blpapi_SchemaTypeDefinition_getElementDefinition = _internals.blpapi_SchemaTypeDefinition_getElementDefinition - -def blpapi_SchemaTypeDefinition_getElementDefinitionAt(type, index): - return _internals.blpapi_SchemaTypeDefinition_getElementDefinitionAt(type, index) -blpapi_SchemaTypeDefinition_getElementDefinitionAt = _internals.blpapi_SchemaTypeDefinition_getElementDefinitionAt - -def blpapi_SchemaTypeDefinition_enumeration(element): - return _internals.blpapi_SchemaTypeDefinition_enumeration(element) -blpapi_SchemaTypeDefinition_enumeration = _internals.blpapi_SchemaTypeDefinition_enumeration - -def blpapi_Request_destroy(request): - return _internals.blpapi_Request_destroy(request) -blpapi_Request_destroy = _internals.blpapi_Request_destroy - -def blpapi_Request_elements(request): - return _internals.blpapi_Request_elements(request) -blpapi_Request_elements = _internals.blpapi_Request_elements - -def blpapi_Request_setPreferredRoute(request, correlationId): - return _internals.blpapi_Request_setPreferredRoute(request, correlationId) -blpapi_Request_setPreferredRoute = _internals.blpapi_Request_setPreferredRoute - -def blpapi_Operation_name(service): - return _internals.blpapi_Operation_name(service) -blpapi_Operation_name = _internals.blpapi_Operation_name - -def blpapi_Operation_description(service): - return _internals.blpapi_Operation_description(service) -blpapi_Operation_description = _internals.blpapi_Operation_description - -def blpapi_Operation_requestDefinition(service): - return _internals.blpapi_Operation_requestDefinition(service) -blpapi_Operation_requestDefinition = _internals.blpapi_Operation_requestDefinition - -def blpapi_Operation_numResponseDefinitions(service): - return _internals.blpapi_Operation_numResponseDefinitions(service) -blpapi_Operation_numResponseDefinitions = _internals.blpapi_Operation_numResponseDefinitions - -def blpapi_Operation_responseDefinition(service, index): - return _internals.blpapi_Operation_responseDefinition(service, index) -blpapi_Operation_responseDefinition = _internals.blpapi_Operation_responseDefinition - -def blpapi_Service_name(service): - return _internals.blpapi_Service_name(service) -blpapi_Service_name = _internals.blpapi_Service_name - -def blpapi_Service_description(service): - return _internals.blpapi_Service_description(service) -blpapi_Service_description = _internals.blpapi_Service_description - -def blpapi_Service_numOperations(service): - return _internals.blpapi_Service_numOperations(service) -blpapi_Service_numOperations = _internals.blpapi_Service_numOperations - -def blpapi_Service_numEventDefinitions(service): - return _internals.blpapi_Service_numEventDefinitions(service) -blpapi_Service_numEventDefinitions = _internals.blpapi_Service_numEventDefinitions - -def blpapi_Service_addRef(service): - return _internals.blpapi_Service_addRef(service) -blpapi_Service_addRef = _internals.blpapi_Service_addRef - -def blpapi_Service_release(service): - return _internals.blpapi_Service_release(service) -blpapi_Service_release = _internals.blpapi_Service_release - -def blpapi_Service_authorizationServiceName(service): - return _internals.blpapi_Service_authorizationServiceName(service) -blpapi_Service_authorizationServiceName = _internals.blpapi_Service_authorizationServiceName - -def blpapi_Service_getOperation(service, nameString, name): - return _internals.blpapi_Service_getOperation(service, nameString, name) -blpapi_Service_getOperation = _internals.blpapi_Service_getOperation - -def blpapi_Service_getOperationAt(service, index): - return _internals.blpapi_Service_getOperationAt(service, index) -blpapi_Service_getOperationAt = _internals.blpapi_Service_getOperationAt - -def blpapi_Service_getEventDefinition(service, nameString, name): - return _internals.blpapi_Service_getEventDefinition(service, nameString, name) -blpapi_Service_getEventDefinition = _internals.blpapi_Service_getEventDefinition - -def blpapi_Service_getEventDefinitionAt(service, index): - return _internals.blpapi_Service_getEventDefinitionAt(service, index) -blpapi_Service_getEventDefinitionAt = _internals.blpapi_Service_getEventDefinitionAt - -def blpapi_Service_createRequest(service, operation): - return _internals.blpapi_Service_createRequest(service, operation) -blpapi_Service_createRequest = _internals.blpapi_Service_createRequest - -def blpapi_Service_createAuthorizationRequest(service, operation): - return _internals.blpapi_Service_createAuthorizationRequest(service, operation) -blpapi_Service_createAuthorizationRequest = _internals.blpapi_Service_createAuthorizationRequest - -def blpapi_Service_createPublishEvent(service): - return _internals.blpapi_Service_createPublishEvent(service) -blpapi_Service_createPublishEvent = _internals.blpapi_Service_createPublishEvent - -def blpapi_Service_createAdminEvent(service): - return _internals.blpapi_Service_createAdminEvent(service) -blpapi_Service_createAdminEvent = _internals.blpapi_Service_createAdminEvent - -def blpapi_Service_createResponseEvent(service, correlationId): - return _internals.blpapi_Service_createResponseEvent(service, correlationId) -blpapi_Service_createResponseEvent = _internals.blpapi_Service_createResponseEvent - -def blpapi_Message_messageType(message): - return _internals.blpapi_Message_messageType(message) -blpapi_Message_messageType = _internals.blpapi_Message_messageType - -def blpapi_Message_topicName(message): - return _internals.blpapi_Message_topicName(message) -blpapi_Message_topicName = _internals.blpapi_Message_topicName - -def blpapi_Message_service(message): - return _internals.blpapi_Message_service(message) -blpapi_Message_service = _internals.blpapi_Message_service - -def blpapi_Message_numCorrelationIds(message): - return _internals.blpapi_Message_numCorrelationIds(message) -blpapi_Message_numCorrelationIds = _internals.blpapi_Message_numCorrelationIds - -def blpapi_Message_correlationId(message, index): - return _internals.blpapi_Message_correlationId(message, index) -blpapi_Message_correlationId = _internals.blpapi_Message_correlationId - -def blpapi_Message_elements(message): - return _internals.blpapi_Message_elements(message) -blpapi_Message_elements = _internals.blpapi_Message_elements - -def blpapi_Message_fragmentType(message): - return _internals.blpapi_Message_fragmentType(message) -blpapi_Message_fragmentType = _internals.blpapi_Message_fragmentType - -def blpapi_Message_addRef(message): - return _internals.blpapi_Message_addRef(message) -blpapi_Message_addRef = _internals.blpapi_Message_addRef - -def blpapi_Message_release(message): - return _internals.blpapi_Message_release(message) -blpapi_Message_release = _internals.blpapi_Message_release - -def blpapi_Message_timeReceived(message, timeReceived): - return _internals.blpapi_Message_timeReceived(message, timeReceived) -blpapi_Message_timeReceived = _internals.blpapi_Message_timeReceived - -def blpapi_Event_eventType(event): - return _internals.blpapi_Event_eventType(event) -blpapi_Event_eventType = _internals.blpapi_Event_eventType - -def blpapi_Event_release(event): - return _internals.blpapi_Event_release(event) -blpapi_Event_release = _internals.blpapi_Event_release - -def blpapi_EventQueue_create(): - return _internals.blpapi_EventQueue_create() -blpapi_EventQueue_create = _internals.blpapi_EventQueue_create - -def blpapi_EventQueue_destroy(eventQueue): - return _internals.blpapi_EventQueue_destroy(eventQueue) -blpapi_EventQueue_destroy = _internals.blpapi_EventQueue_destroy - -def blpapi_EventQueue_nextEvent(eventQueue, timeout): - return _internals.blpapi_EventQueue_nextEvent(eventQueue, timeout) -blpapi_EventQueue_nextEvent = _internals.blpapi_EventQueue_nextEvent - -def blpapi_EventQueue_purge(eventQueue): - return _internals.blpapi_EventQueue_purge(eventQueue) -blpapi_EventQueue_purge = _internals.blpapi_EventQueue_purge - -def blpapi_EventQueue_tryNextEvent(eventQueue): - return _internals.blpapi_EventQueue_tryNextEvent(eventQueue) -blpapi_EventQueue_tryNextEvent = _internals.blpapi_EventQueue_tryNextEvent - -def blpapi_MessageIterator_create(event): - return _internals.blpapi_MessageIterator_create(event) -blpapi_MessageIterator_create = _internals.blpapi_MessageIterator_create - -def blpapi_MessageIterator_destroy(iterator): - return _internals.blpapi_MessageIterator_destroy(iterator) -blpapi_MessageIterator_destroy = _internals.blpapi_MessageIterator_destroy - -def blpapi_MessageIterator_next(iterator): - return _internals.blpapi_MessageIterator_next(iterator) -blpapi_MessageIterator_next = _internals.blpapi_MessageIterator_next - -def blpapi_Identity_release(handle): - return _internals.blpapi_Identity_release(handle) -blpapi_Identity_release = _internals.blpapi_Identity_release - -def blpapi_Identity_addRef(handle): - return _internals.blpapi_Identity_addRef(handle) -blpapi_Identity_addRef = _internals.blpapi_Identity_addRef - -def blpapi_Identity_hasEntitlements(handle, service, eidElement, entitlementIds, numEntitlements, failedEntitlements, failedEntitlementsCount): - return _internals.blpapi_Identity_hasEntitlements(handle, service, eidElement, entitlementIds, numEntitlements, failedEntitlements, failedEntitlementsCount) -blpapi_Identity_hasEntitlements = _internals.blpapi_Identity_hasEntitlements - -def blpapi_Identity_isAuthorized(handle, service): - return _internals.blpapi_Identity_isAuthorized(handle, service) -blpapi_Identity_isAuthorized = _internals.blpapi_Identity_isAuthorized - -def blpapi_Identity_getSeatType(handle): - return _internals.blpapi_Identity_getSeatType(handle) -blpapi_Identity_getSeatType = _internals.blpapi_Identity_getSeatType - -def blpapi_AbstractSession_cancel(session, correlationIds, numCorrelationIds, requestLabel, requestLabelLen): - return _internals.blpapi_AbstractSession_cancel(session, correlationIds, numCorrelationIds, requestLabel, requestLabelLen) -blpapi_AbstractSession_cancel = _internals.blpapi_AbstractSession_cancel - -def blpapi_AbstractSession_sendAuthorizationRequest(session, request, identity, correlationId, eventQueue, requestLabel, requestLabelLen): - return _internals.blpapi_AbstractSession_sendAuthorizationRequest(session, request, identity, correlationId, eventQueue, requestLabel, requestLabelLen) -blpapi_AbstractSession_sendAuthorizationRequest = _internals.blpapi_AbstractSession_sendAuthorizationRequest - -def blpapi_AbstractSession_openService(session, serviceIdentifier): - return _internals.blpapi_AbstractSession_openService(session, serviceIdentifier) -blpapi_AbstractSession_openService = _internals.blpapi_AbstractSession_openService - -def blpapi_AbstractSession_openServiceAsync(session, serviceIdentifier, correlationId): - return _internals.blpapi_AbstractSession_openServiceAsync(session, serviceIdentifier, correlationId) -blpapi_AbstractSession_openServiceAsync = _internals.blpapi_AbstractSession_openServiceAsync - -def blpapi_AbstractSession_generateToken(session, correlationId, eventQueue): - return _internals.blpapi_AbstractSession_generateToken(session, correlationId, eventQueue) -blpapi_AbstractSession_generateToken = _internals.blpapi_AbstractSession_generateToken - -def blpapi_AbstractSession_getService(session, serviceIdentifier): - return _internals.blpapi_AbstractSession_getService(session, serviceIdentifier) -blpapi_AbstractSession_getService = _internals.blpapi_AbstractSession_getService - -def blpapi_AbstractSession_createIdentity(session): - return _internals.blpapi_AbstractSession_createIdentity(session) -blpapi_AbstractSession_createIdentity = _internals.blpapi_AbstractSession_createIdentity - -def blpapi_Session_start(session): - return _internals.blpapi_Session_start(session) -blpapi_Session_start = _internals.blpapi_Session_start - -def blpapi_Session_startAsync(session): - return _internals.blpapi_Session_startAsync(session) -blpapi_Session_startAsync = _internals.blpapi_Session_startAsync - -def blpapi_Session_stop(session): - return _internals.blpapi_Session_stop(session) -blpapi_Session_stop = _internals.blpapi_Session_stop - -def blpapi_Session_stopAsync(session): - return _internals.blpapi_Session_stopAsync(session) -blpapi_Session_stopAsync = _internals.blpapi_Session_stopAsync - -def blpapi_Session_nextEvent(session, timeoutInMilliseconds): - return _internals.blpapi_Session_nextEvent(session, timeoutInMilliseconds) -blpapi_Session_nextEvent = _internals.blpapi_Session_nextEvent - -def blpapi_Session_tryNextEvent(session): - return _internals.blpapi_Session_tryNextEvent(session) -blpapi_Session_tryNextEvent = _internals.blpapi_Session_tryNextEvent - -def blpapi_Session_subscribe(session, subscriptionList, handle, requestLabel, requestLabelLen): - return _internals.blpapi_Session_subscribe(session, subscriptionList, handle, requestLabel, requestLabelLen) -blpapi_Session_subscribe = _internals.blpapi_Session_subscribe - -def blpapi_Session_resubscribe(session, resubscriptionList, requestLabel, requestLabelLen): - return _internals.blpapi_Session_resubscribe(session, resubscriptionList, requestLabel, requestLabelLen) -blpapi_Session_resubscribe = _internals.blpapi_Session_resubscribe - -def blpapi_Session_resubscribeWithId(session, resubscriptionList, resubscriptionId, requestLabel, requestLabelLen): - return _internals.blpapi_Session_resubscribeWithId(session, resubscriptionList, resubscriptionId, requestLabel, requestLabelLen) -blpapi_Session_resubscribeWithId = _internals.blpapi_Session_resubscribeWithId - -def blpapi_Session_unsubscribe(session, unsubscriptionList, requestLabel, requestLabelLen): - return _internals.blpapi_Session_unsubscribe(session, unsubscriptionList, requestLabel, requestLabelLen) -blpapi_Session_unsubscribe = _internals.blpapi_Session_unsubscribe - -def blpapi_Session_setStatusCorrelationId(session, service, identity, correlationId): - return _internals.blpapi_Session_setStatusCorrelationId(session, service, identity, correlationId) -blpapi_Session_setStatusCorrelationId = _internals.blpapi_Session_setStatusCorrelationId - -def blpapi_Session_sendRequest(session, request, correlationId, identity, eventQueue, requestLabel, requestLabelLen): - return _internals.blpapi_Session_sendRequest(session, request, correlationId, identity, eventQueue, requestLabel, requestLabelLen) -blpapi_Session_sendRequest = _internals.blpapi_Session_sendRequest - -def blpapi_Session_getAbstractSession(session): - return _internals.blpapi_Session_getAbstractSession(session) -blpapi_Session_getAbstractSession = _internals.blpapi_Session_getAbstractSession - -def blpapi_ResolutionList_extractAttributeFromResolutionSuccess(message, attribute): - return _internals.blpapi_ResolutionList_extractAttributeFromResolutionSuccess(message, attribute) -blpapi_ResolutionList_extractAttributeFromResolutionSuccess = _internals.blpapi_ResolutionList_extractAttributeFromResolutionSuccess - -def blpapi_ResolutionList_create(arg1): - return _internals.blpapi_ResolutionList_create(arg1) -blpapi_ResolutionList_create = _internals.blpapi_ResolutionList_create - -def blpapi_ResolutionList_destroy(list): - return _internals.blpapi_ResolutionList_destroy(list) -blpapi_ResolutionList_destroy = _internals.blpapi_ResolutionList_destroy - -def blpapi_ResolutionList_add(list, topic, correlationId): - return _internals.blpapi_ResolutionList_add(list, topic, correlationId) -blpapi_ResolutionList_add = _internals.blpapi_ResolutionList_add - -def blpapi_ResolutionList_addFromMessage(list, topic, correlationId): - return _internals.blpapi_ResolutionList_addFromMessage(list, topic, correlationId) -blpapi_ResolutionList_addFromMessage = _internals.blpapi_ResolutionList_addFromMessage - -def blpapi_ResolutionList_addAttribute(list, name): - return _internals.blpapi_ResolutionList_addAttribute(list, name) -blpapi_ResolutionList_addAttribute = _internals.blpapi_ResolutionList_addAttribute - -def blpapi_ResolutionList_correlationIdAt(list, index): - return _internals.blpapi_ResolutionList_correlationIdAt(list, index) -blpapi_ResolutionList_correlationIdAt = _internals.blpapi_ResolutionList_correlationIdAt - -def blpapi_ResolutionList_topicString(list, id): - return _internals.blpapi_ResolutionList_topicString(list, id) -blpapi_ResolutionList_topicString = _internals.blpapi_ResolutionList_topicString - -def blpapi_ResolutionList_topicStringAt(list, index): - return _internals.blpapi_ResolutionList_topicStringAt(list, index) -blpapi_ResolutionList_topicStringAt = _internals.blpapi_ResolutionList_topicStringAt - -def blpapi_ResolutionList_status(list, id): - return _internals.blpapi_ResolutionList_status(list, id) -blpapi_ResolutionList_status = _internals.blpapi_ResolutionList_status - -def blpapi_ResolutionList_statusAt(list, index): - return _internals.blpapi_ResolutionList_statusAt(list, index) -blpapi_ResolutionList_statusAt = _internals.blpapi_ResolutionList_statusAt - -def blpapi_ResolutionList_attribute(list, attribute, id): - return _internals.blpapi_ResolutionList_attribute(list, attribute, id) -blpapi_ResolutionList_attribute = _internals.blpapi_ResolutionList_attribute - -def blpapi_ResolutionList_attributeAt(list, attribute, index): - return _internals.blpapi_ResolutionList_attributeAt(list, attribute, index) -blpapi_ResolutionList_attributeAt = _internals.blpapi_ResolutionList_attributeAt - -def blpapi_ResolutionList_message(list, id): - return _internals.blpapi_ResolutionList_message(list, id) -blpapi_ResolutionList_message = _internals.blpapi_ResolutionList_message - -def blpapi_ResolutionList_messageAt(list, index): - return _internals.blpapi_ResolutionList_messageAt(list, index) -blpapi_ResolutionList_messageAt = _internals.blpapi_ResolutionList_messageAt - -def blpapi_ResolutionList_size(list): - return _internals.blpapi_ResolutionList_size(list) -blpapi_ResolutionList_size = _internals.blpapi_ResolutionList_size - -def blpapi_Topic_create(arg1): - return _internals.blpapi_Topic_create(arg1) -blpapi_Topic_create = _internals.blpapi_Topic_create - -def blpapi_Topic_destroy(victim): - return _internals.blpapi_Topic_destroy(victim) -blpapi_Topic_destroy = _internals.blpapi_Topic_destroy - -def blpapi_Topic_compare(lhs, rhs): - return _internals.blpapi_Topic_compare(lhs, rhs) -blpapi_Topic_compare = _internals.blpapi_Topic_compare - -def blpapi_Topic_service(topic): - return _internals.blpapi_Topic_service(topic) -blpapi_Topic_service = _internals.blpapi_Topic_service - -def blpapi_Topic_isActive(topic): - return _internals.blpapi_Topic_isActive(topic) -blpapi_Topic_isActive = _internals.blpapi_Topic_isActive - -def blpapi_TopicList_create(arg1): - return _internals.blpapi_TopicList_create(arg1) -blpapi_TopicList_create = _internals.blpapi_TopicList_create - -def blpapi_TopicList_destroy(list): - return _internals.blpapi_TopicList_destroy(list) -blpapi_TopicList_destroy = _internals.blpapi_TopicList_destroy - -def blpapi_TopicList_add(list, topic, correlationId): - return _internals.blpapi_TopicList_add(list, topic, correlationId) -blpapi_TopicList_add = _internals.blpapi_TopicList_add - -def blpapi_TopicList_addFromMessage(list, topic, correlationId): - return _internals.blpapi_TopicList_addFromMessage(list, topic, correlationId) -blpapi_TopicList_addFromMessage = _internals.blpapi_TopicList_addFromMessage - -def blpapi_TopicList_correlationIdAt(list, index): - return _internals.blpapi_TopicList_correlationIdAt(list, index) -blpapi_TopicList_correlationIdAt = _internals.blpapi_TopicList_correlationIdAt - -def blpapi_TopicList_topicString(list, id): - return _internals.blpapi_TopicList_topicString(list, id) -blpapi_TopicList_topicString = _internals.blpapi_TopicList_topicString - -def blpapi_TopicList_topicStringAt(list, index): - return _internals.blpapi_TopicList_topicStringAt(list, index) -blpapi_TopicList_topicStringAt = _internals.blpapi_TopicList_topicStringAt - -def blpapi_TopicList_status(list, id): - return _internals.blpapi_TopicList_status(list, id) -blpapi_TopicList_status = _internals.blpapi_TopicList_status - -def blpapi_TopicList_statusAt(list, index): - return _internals.blpapi_TopicList_statusAt(list, index) -blpapi_TopicList_statusAt = _internals.blpapi_TopicList_statusAt - -def blpapi_TopicList_message(list, id): - return _internals.blpapi_TopicList_message(list, id) -blpapi_TopicList_message = _internals.blpapi_TopicList_message - -def blpapi_TopicList_messageAt(list, index): - return _internals.blpapi_TopicList_messageAt(list, index) -blpapi_TopicList_messageAt = _internals.blpapi_TopicList_messageAt - -def blpapi_TopicList_size(list): - return _internals.blpapi_TopicList_size(list) -blpapi_TopicList_size = _internals.blpapi_TopicList_size - -def blpapi_ProviderSession_create(parameters, handler, dispatcher, userData): - return _internals.blpapi_ProviderSession_create(parameters, handler, dispatcher, userData) -blpapi_ProviderSession_create = _internals.blpapi_ProviderSession_create - -def blpapi_ProviderSession_destroy(session): - return _internals.blpapi_ProviderSession_destroy(session) -blpapi_ProviderSession_destroy = _internals.blpapi_ProviderSession_destroy - -def blpapi_ProviderSession_start(session): - return _internals.blpapi_ProviderSession_start(session) -blpapi_ProviderSession_start = _internals.blpapi_ProviderSession_start - -def blpapi_ProviderSession_startAsync(session): - return _internals.blpapi_ProviderSession_startAsync(session) -blpapi_ProviderSession_startAsync = _internals.blpapi_ProviderSession_startAsync - -def blpapi_ProviderSession_stop(session): - return _internals.blpapi_ProviderSession_stop(session) -blpapi_ProviderSession_stop = _internals.blpapi_ProviderSession_stop - -def blpapi_ProviderSession_stopAsync(session): - return _internals.blpapi_ProviderSession_stopAsync(session) -blpapi_ProviderSession_stopAsync = _internals.blpapi_ProviderSession_stopAsync - -def blpapi_ProviderSession_nextEvent(session, timeoutInMilliseconds): - return _internals.blpapi_ProviderSession_nextEvent(session, timeoutInMilliseconds) -blpapi_ProviderSession_nextEvent = _internals.blpapi_ProviderSession_nextEvent - -def blpapi_ProviderSession_tryNextEvent(session): - return _internals.blpapi_ProviderSession_tryNextEvent(session) -blpapi_ProviderSession_tryNextEvent = _internals.blpapi_ProviderSession_tryNextEvent - -def blpapi_ProviderSession_registerService(session, serviceName, identity, registrationOptions): - return _internals.blpapi_ProviderSession_registerService(session, serviceName, identity, registrationOptions) -blpapi_ProviderSession_registerService = _internals.blpapi_ProviderSession_registerService - -def blpapi_ProviderSession_activateSubServiceCodeRange(session, serviceName, begin, end, priority): - return _internals.blpapi_ProviderSession_activateSubServiceCodeRange(session, serviceName, begin, end, priority) -blpapi_ProviderSession_activateSubServiceCodeRange = _internals.blpapi_ProviderSession_activateSubServiceCodeRange - -def blpapi_ProviderSession_deactivateSubServiceCodeRange(session, serviceName, begin, end): - return _internals.blpapi_ProviderSession_deactivateSubServiceCodeRange(session, serviceName, begin, end) -blpapi_ProviderSession_deactivateSubServiceCodeRange = _internals.blpapi_ProviderSession_deactivateSubServiceCodeRange - -def blpapi_ProviderSession_registerServiceAsync(session, serviceName, identity, correlationId, registrationOptions): - return _internals.blpapi_ProviderSession_registerServiceAsync(session, serviceName, identity, correlationId, registrationOptions) -blpapi_ProviderSession_registerServiceAsync = _internals.blpapi_ProviderSession_registerServiceAsync - -def blpapi_ProviderSession_deregisterService(session, serviceName): - return _internals.blpapi_ProviderSession_deregisterService(session, serviceName) -blpapi_ProviderSession_deregisterService = _internals.blpapi_ProviderSession_deregisterService - -def blpapi_ProviderSession_resolve(session, resolutionList, resolveMode, identity): - return _internals.blpapi_ProviderSession_resolve(session, resolutionList, resolveMode, identity) -blpapi_ProviderSession_resolve = _internals.blpapi_ProviderSession_resolve - -def blpapi_ProviderSession_resolveAsync(session, resolutionList, resolveMode, identity): - return _internals.blpapi_ProviderSession_resolveAsync(session, resolutionList, resolveMode, identity) -blpapi_ProviderSession_resolveAsync = _internals.blpapi_ProviderSession_resolveAsync - -def blpapi_ProviderSession_createTopics(session, topicList, resolveMode, identity): - return _internals.blpapi_ProviderSession_createTopics(session, topicList, resolveMode, identity) -blpapi_ProviderSession_createTopics = _internals.blpapi_ProviderSession_createTopics - -def blpapi_ProviderSession_createTopicsAsync(session, topicList, resolveMode, identity): - return _internals.blpapi_ProviderSession_createTopicsAsync(session, topicList, resolveMode, identity) -blpapi_ProviderSession_createTopicsAsync = _internals.blpapi_ProviderSession_createTopicsAsync - -def blpapi_ProviderSession_getTopic(session, message): - return _internals.blpapi_ProviderSession_getTopic(session, message) -blpapi_ProviderSession_getTopic = _internals.blpapi_ProviderSession_getTopic - -def blpapi_ProviderSession_createTopic(session, message): - return _internals.blpapi_ProviderSession_createTopic(session, message) -blpapi_ProviderSession_createTopic = _internals.blpapi_ProviderSession_createTopic - -def blpapi_ProviderSession_createServiceStatusTopic(session, service): - return _internals.blpapi_ProviderSession_createServiceStatusTopic(session, service) -blpapi_ProviderSession_createServiceStatusTopic = _internals.blpapi_ProviderSession_createServiceStatusTopic - -def blpapi_ProviderSession_deleteTopics(session, topics, numTopics): - return _internals.blpapi_ProviderSession_deleteTopics(session, topics, numTopics) -blpapi_ProviderSession_deleteTopics = _internals.blpapi_ProviderSession_deleteTopics - -def blpapi_ProviderSession_publish(session, event): - return _internals.blpapi_ProviderSession_publish(session, event) -blpapi_ProviderSession_publish = _internals.blpapi_ProviderSession_publish - -def blpapi_ProviderSession_sendResponse(session, event, isPartialResponse): - return _internals.blpapi_ProviderSession_sendResponse(session, event, isPartialResponse) -blpapi_ProviderSession_sendResponse = _internals.blpapi_ProviderSession_sendResponse - -def blpapi_ProviderSession_getAbstractSession(session): - return _internals.blpapi_ProviderSession_getAbstractSession(session) -blpapi_ProviderSession_getAbstractSession = _internals.blpapi_ProviderSession_getAbstractSession - -def blpapi_ServiceRegistrationOptions_create(): - return _internals.blpapi_ServiceRegistrationOptions_create() -blpapi_ServiceRegistrationOptions_create = _internals.blpapi_ServiceRegistrationOptions_create - -def blpapi_ServiceRegistrationOptions_duplicate(parameters): - return _internals.blpapi_ServiceRegistrationOptions_duplicate(parameters) -blpapi_ServiceRegistrationOptions_duplicate = _internals.blpapi_ServiceRegistrationOptions_duplicate - -def blpapi_ServiceRegistrationOptions_destroy(parameters): - return _internals.blpapi_ServiceRegistrationOptions_destroy(parameters) -blpapi_ServiceRegistrationOptions_destroy = _internals.blpapi_ServiceRegistrationOptions_destroy - -def blpapi_ServiceRegistrationOptions_copy(lhs, rhs): - return _internals.blpapi_ServiceRegistrationOptions_copy(lhs, rhs) -blpapi_ServiceRegistrationOptions_copy = _internals.blpapi_ServiceRegistrationOptions_copy - -def blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange(parameters, start, end, priority): - return _internals.blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange(parameters, start, end, priority) -blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange = _internals.blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange - -def blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges(parameters): - return _internals.blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges(parameters) -blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges = _internals.blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges - -def blpapi_ServiceRegistrationOptions_setGroupId(parameters, groupId): - return _internals.blpapi_ServiceRegistrationOptions_setGroupId(parameters, groupId) -blpapi_ServiceRegistrationOptions_setGroupId = _internals.blpapi_ServiceRegistrationOptions_setGroupId - -def blpapi_ServiceRegistrationOptions_setServicePriority(parameters, priority): - return _internals.blpapi_ServiceRegistrationOptions_setServicePriority(parameters, priority) -blpapi_ServiceRegistrationOptions_setServicePriority = _internals.blpapi_ServiceRegistrationOptions_setServicePriority - -def blpapi_ServiceRegistrationOptions_setPartsToRegister(parameters, parts): - return _internals.blpapi_ServiceRegistrationOptions_setPartsToRegister(parameters, parts) -blpapi_ServiceRegistrationOptions_setPartsToRegister = _internals.blpapi_ServiceRegistrationOptions_setPartsToRegister - -def blpapi_ServiceRegistrationOptions_getGroupId(parameters): - return _internals.blpapi_ServiceRegistrationOptions_getGroupId(parameters) -blpapi_ServiceRegistrationOptions_getGroupId = _internals.blpapi_ServiceRegistrationOptions_getGroupId - -def blpapi_ServiceRegistrationOptions_getServicePriority(parameters): - return _internals.blpapi_ServiceRegistrationOptions_getServicePriority(parameters) -blpapi_ServiceRegistrationOptions_getServicePriority = _internals.blpapi_ServiceRegistrationOptions_getServicePriority - -def blpapi_ServiceRegistrationOptions_getPartsToRegister(parameters): - return _internals.blpapi_ServiceRegistrationOptions_getPartsToRegister(parameters) -blpapi_ServiceRegistrationOptions_getPartsToRegister = _internals.blpapi_ServiceRegistrationOptions_getPartsToRegister -# This file is compatible with both classic and new-style classes. - - diff --git a/blpapi/internals_wrap.cxx b/blpapi/internals_wrap.cxx deleted file mode 100644 index cf149af..0000000 --- a/blpapi/internals_wrap.cxx +++ /dev/null @@ -1,25220 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.12 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - - -#ifndef SWIGPYTHON -#define SWIGPYTHON -#endif - -#define SWIG_PYTHON_THREADS -#define SWIG_PYTHON_DIRECTOR_NO_VTABLE - - -#ifdef __cplusplus -/* SwigValueWrapper is described in swig.swg */ -template class SwigValueWrapper { - struct SwigMovePointer { - T *ptr; - SwigMovePointer(T *p) : ptr(p) { } - ~SwigMovePointer() { delete ptr; } - SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } - } pointer; - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); - SwigValueWrapper(const SwigValueWrapper& rhs); -public: - SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } - operator T&() const { return *pointer.ptr; } - T *operator&() { return pointer.ptr; } -}; - -template T SwigValueInit() { - return T(); -} -#endif - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - - -#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) -/* Use debug wrappers with the Python release dll */ -# undef _DEBUG -# include -# define _DEBUG -#else -# include -#endif - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast(r) (r) -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCmp(const char *nb, const char *tb) { - int equiv = 1; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (equiv != 0 && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te); - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; -} - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - size_t l = 0; - size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - const unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - char d = *(c++); - unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = (unsigned char)((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = (unsigned char)((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (unsigned char)(d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (unsigned char)(d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -/* Compatibility macros for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) -#define PyString_Check(name) PyBytes_Check(name) -#define PyString_FromString(x) PyUnicode_FromString(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) -#define PyString_AsString(str) PyBytes_AsString(str) -#define PyString_Size(str) PyBytes_Size(str) -#define PyString_InternFromString(key) PyUnicode_InternFromString(key) -#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) -#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Warning: This function will allocate a new string in Python 3, - * so please call SWIG_Python_str_DelForPy3(x) to free the space. - */ -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; - str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); - return newstr; -#else - return PyString_AsString(str); -#endif -} - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) -#else -# define SWIG_Python_str_DelForPy3(x) -#endif - - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -typedef inquiry lenfunc; -typedef intargfunc ssizeargfunc; -typedef intintargfunc ssizessizeargfunc; -typedef intobjargproc ssizeobjargproc; -typedef intintobjargproc ssizessizeobjargproc; -typedef getreadbufferproc readbufferproc; -typedef getwritebufferproc writebufferproc; -typedef getsegcountproc segcountproc; -typedef getcharbufferproc charbufferproc; -static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) -{ - long result = 0; - PyObject *i = PyNumber_Int(x); - if (i) { - result = PyInt_AsLong(i); - Py_DECREF(i); - } - return result; -} -#endif - -#if PY_VERSION_HEX < 0x02050000 -#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) -#endif - -#if PY_VERSION_HEX < 0x02040000 -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((op), arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; - PyBufferProcs as_buffer; - PyObject *name, *slots; -} PyHeapTypeObject; -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef destructor freefunc; -#endif - -#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ - (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ - (PY_MAJOR_VERSION > 3)) -# define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) -#endif - -#if PY_VERSION_HEX < 0x03020000 -#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) -#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) -#define Py_hash_t long -#endif - -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif - -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX >= 0x03000000 -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) -{ - return PyInstanceMethod_New(func); -} -#else -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) -{ - return NULL; -} -#endif - -#ifdef __cplusplus -} -#endif - - -/* ----------------------------------------------------------------------------- - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) - -#ifdef SWIGPYTHON_BUILTIN -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) -#else -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) -#endif - -#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) - -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -#if defined(SWIGPYTHON_BUILTIN) - -SWIGINTERN void -SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { - PyObject *s = PyString_InternFromString(key); - PyList_Append(seq, s); - Py_DECREF(s); -} - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else - PyDict_SetItemString(d, name, obj); -#endif - Py_DECREF(obj); - if (public_interface) - SwigPyBuiltin_AddPublicSymbol(public_interface, name); -} - -#else - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else - PyDict_SetItemString(d, name, obj); -#endif - Py_DECREF(obj); -} - -#endif - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN Py_ssize_t -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - if (min <= 1 && max >= 1) { - Py_ssize_t i; - objs[0] = args; - for (i = 1; i < max; ++i) { - objs[i] = 0; - } - return 2; - } - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - Py_ssize_t i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) -#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) - -#ifdef __cplusplus -extern "C" { -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; - PyTypeObject *pytype; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - data->pytype = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData *data) { - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -#ifdef SWIGPYTHON_BUILTIN - PyObject *dict; -#endif -} SwigPyObject; - - -#ifdef SWIGPYTHON_BUILTIN - -SWIGRUNTIME PyObject * -SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - - if (!sobj->dict) - sobj->dict = PyDict_New(); - - Py_INCREF(sobj->dict); - return sobj->dict; -} - -#endif - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); - if (v->next) { -# ifdef METH_NOARGS - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -# else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -# endif -# if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -# else - PyString_ConcatAndDel(&repr,nrep); -# endif - } - return repr; -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); - return res; -} - - -SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); - -#ifdef SWIGPYTHON_BUILTIN -static swig_type_info *SwigPyObject_stype = 0; -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - SwigPyClientData *cd; - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - assert(cd); - assert(cd->pytype); - return cd->pytype; -} -#else -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); - return type; -} -#endif - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { -#ifdef SWIGPYTHON_BUILTIN - PyTypeObject *target_tp = SwigPyObject_type(); - if (PyType_IsSubtype(op->ob_type, target_tp)) - return 1; - return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); -#else - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); -#endif -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - - /* PyObject_CallFunction() has the potential to silently drop - the active active exception. In cases of unnamed temporary - variable or where we just finished iterating over a generator - StopIteration will be active right now, and this needs to - remain true upon return from SwigPyObject_dealloc. So save - and restore. */ - - PyObject *val = NULL, *type = NULL, *tb = NULL; - PyErr_Fetch(&val, &type, &tb); - - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - if (!res) - PyErr_WriteUnraisable(destroy); - - PyErr_Restore(val, type, tb); - - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!SwigPyObject_Check(next)) { - PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#elif (PY_VERSION_HEX < 0x02050000) - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#else - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -SwigPyObject_TypeOnce(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ -#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - 0, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 - 0, /* tp_prev */ -#endif - 0 /* tp_next */ -#endif - }; - swigpyobject_type = tmp; - type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpyobject_type.ob_type = &PyType_Type; -#else - if (PyType_Ready(&swigpyobject_type) < 0) - return NULL; -#endif - } - return &swigpyobject_type; -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { - return ((op)->ob_type == SwigPyPacked_TypeOnce()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_TypeOnce(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 - 0, /* tp_prev */ -#endif - 0 /* tp_next */ -#endif - }; - swigpypacked_type = tmp; - type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpypacked_type.ob_type = &PyType_Type; -#else - if (PyType_Ready(&swigpypacked_type) < 0) - return NULL; -#endif - } - return &swigpypacked_type; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -static PyObject *swig_this = NULL; - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - if (swig_this == NULL) - swig_this = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - PyObject *obj; - - if (SwigPyObject_Check(pyobj)) - return (SwigPyObject *) pyobj; - -#ifdef SWIGPYTHON_BUILTIN - (void)obj; -# ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - pyobj = PyWeakref_GET_OBJECT(pyobj); - if (pyobj && SwigPyObject_Check(pyobj)) - return (SwigPyObject*) pyobj; - } -# endif - return NULL; -#else - - obj = 0; - -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; -#endif -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - int res; - SwigPyObject *sobj; - int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; - - if (!obj) - return SWIG_ERROR; - if (obj == Py_None && !implicit_conv) { - if (ptr) - *ptr = 0; - return SWIG_OK; - } - - res = SWIG_ERROR; - - sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - res = SWIG_OK; - } else { - if (implicit_conv) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; - } - } - return res; -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) - return SWIG_ERROR; - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, without calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; - } -#else - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } -#endif - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst = 0; - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { - SwigPyClientData *clientdata; - PyObject * robj; - int own; - - if (!ptr) - return SWIG_Py_Void(); - - clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - if (clientdata && clientdata->pytype) { - SwigPyObject *newobj; - if (flags & SWIG_BUILTIN_TP_INIT) { - newobj = (SwigPyObject*) self; - if (newobj->ptr) { - PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); - while (newobj->next) - newobj = (SwigPyObject *) newobj->next; - newobj->next = next_self; - newobj = (SwigPyObject *)next_self; -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif - } - } else { - newobj = PyObject_New(SwigPyObject, clientdata->pytype); -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif - } - if (newobj) { - newobj->ptr = ptr; - newobj->ty = type; - newobj->own = own; - newobj->next = 0; - return (PyObject*) newobj; - } - return SWIG_Py_Void(); - } - - assert(!(flags & SWIG_BUILTIN_TP_INIT)); - - robj = SwigPyObject_New(ptr, type, own); - if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - Py_DECREF(robj); - robj = inst; - } - return robj; -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else -# ifdef SWIGPY_USE_CAPSULE - type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); -# else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); -# endif - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -#ifdef SWIGPY_USE_CAPSULE -SWIG_Python_DestroyModule(PyObject *obj) -#else -SWIG_Python_DestroyModule(void *vptr) -#endif -{ -#ifdef SWIGPY_USE_CAPSULE - swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); -#else - swig_module_info *swig_module = (swig_module_info *) vptr; -#endif - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); - swig_this = NULL; -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); -#else - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); -#endif -#ifdef SWIGPY_USE_CAPSULE - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -#else - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -#endif -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { -#ifdef SWIGPY_USE_CAPSULE - descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); -#else - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); -#endif - } else { - swig_module_info *swig_module = SWIG_GetModule(0); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { -#ifdef SWIGPY_USE_CAPSULE - obj = PyCapsule_New((void*) descriptor, NULL, NULL); -#else - obj = PyCObject_FromVoidPtr(descriptor, NULL); -#endif - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); - } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - } - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : ""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - SWIG_Python_str_DelForPy3(cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); -#if SWIG_POINTER_EXCEPTION - if (flags) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } -#endif - } - return result; -} - -#ifdef SWIGPYTHON_BUILTIN -SWIGRUNTIME int -SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { - PyTypeObject *tp = obj->ob_type; - PyObject *descr; - PyObject *encoded_name; - descrsetfunc f; - int res = -1; - -# ifdef Py_USING_UNICODE - if (PyString_Check(name)) { - name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); - if (!name) - return -1; - } else if (!PyUnicode_Check(name)) -# else - if (!PyString_Check(name)) -# endif - { - PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); - return -1; - } else { - Py_INCREF(name); - } - - if (!tp->tp_dict) { - if (PyType_Ready(tp) < 0) - goto done; - } - - descr = _PyType_Lookup(tp, name); - f = NULL; - if (descr != NULL) - f = descr->ob_type->tp_descr_set; - if (!f) { - if (PyString_Check(name)) { - encoded_name = name; - Py_INCREF(name); - } else { - encoded_name = PyUnicode_AsUTF8String(name); - } - PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); - Py_DECREF(encoded_name); - } else { - res = f(descr, obj, value); - } - - done: - Py_DECREF(name); - return res; -} -#endif - - -#ifdef __cplusplus -} -#endif - - - -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) - -#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else - - - - #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) - - -/* -------- TYPES TABLE (BEGIN) -------- */ - -#define SWIGTYPE_p_BloombergLP__blpapi__AbstractSession swig_types[0] -#define SWIGTYPE_p_BloombergLP__blpapi__ProviderSession swig_types[1] -#define SWIGTYPE_p_BloombergLP__blpapi__Session swig_types[2] -#define SWIGTYPE_p_blpapi_AbstractSession swig_types[3] -#define SWIGTYPE_p_blpapi_Constant swig_types[4] -#define SWIGTYPE_p_blpapi_ConstantList swig_types[5] -#define SWIGTYPE_p_blpapi_CorrelationId_t_ swig_types[6] -#define SWIGTYPE_p_blpapi_Datetime_tag swig_types[7] -#define SWIGTYPE_p_blpapi_Element swig_types[8] -#define SWIGTYPE_p_blpapi_Event swig_types[9] -#define SWIGTYPE_p_blpapi_EventDispatcher swig_types[10] -#define SWIGTYPE_p_blpapi_EventFormatter swig_types[11] -#define SWIGTYPE_p_blpapi_EventQueue swig_types[12] -#define SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag swig_types[13] -#define SWIGTYPE_p_blpapi_Identity swig_types[14] -#define SWIGTYPE_p_blpapi_Logging_Func_t swig_types[15] -#define SWIGTYPE_p_blpapi_Logging_Severity_t swig_types[16] -#define SWIGTYPE_p_blpapi_ManagedPtr_t_ swig_types[17] -#define SWIGTYPE_p_blpapi_Message swig_types[18] -#define SWIGTYPE_p_blpapi_MessageIterator swig_types[19] -#define SWIGTYPE_p_blpapi_Name swig_types[20] -#define SWIGTYPE_p_blpapi_Operation swig_types[21] -#define SWIGTYPE_p_blpapi_ProviderSession swig_types[22] -#define SWIGTYPE_p_blpapi_Request swig_types[23] -#define SWIGTYPE_p_blpapi_ResolutionList swig_types[24] -#define SWIGTYPE_p_blpapi_Service swig_types[25] -#define SWIGTYPE_p_blpapi_ServiceRegistrationOptions swig_types[26] -#define SWIGTYPE_p_blpapi_Session swig_types[27] -#define SWIGTYPE_p_blpapi_SessionOptions swig_types[28] -#define SWIGTYPE_p_blpapi_StreamWriter_t swig_types[29] -#define SWIGTYPE_p_blpapi_SubscriptionItrerator swig_types[30] -#define SWIGTYPE_p_blpapi_SubscriptionList swig_types[31] -#define SWIGTYPE_p_blpapi_TimePoint_t swig_types[32] -#define SWIGTYPE_p_blpapi_Topic swig_types[33] -#define SWIGTYPE_p_blpapi_TopicList swig_types[34] -#define SWIGTYPE_p_char swig_types[35] -#define SWIGTYPE_p_double swig_types[36] -#define SWIGTYPE_p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void swig_types[37] -#define SWIGTYPE_p_float swig_types[38] -#define SWIGTYPE_p_int swig_types[39] -#define SWIGTYPE_p_intArray swig_types[40] -#define SWIGTYPE_p_long_long swig_types[41] -#define SWIGTYPE_p_p_blpapi_Element swig_types[42] -#define SWIGTYPE_p_p_blpapi_Event swig_types[43] -#define SWIGTYPE_p_p_blpapi_Message swig_types[44] -#define SWIGTYPE_p_p_blpapi_Name swig_types[45] -#define SWIGTYPE_p_p_blpapi_Operation swig_types[46] -#define SWIGTYPE_p_p_blpapi_Request swig_types[47] -#define SWIGTYPE_p_p_blpapi_Service swig_types[48] -#define SWIGTYPE_p_p_blpapi_Topic swig_types[49] -#define SWIGTYPE_p_p_char swig_types[50] -#define SWIGTYPE_p_p_p_void swig_types[51] -#define SWIGTYPE_p_p_void swig_types[52] -#define SWIGTYPE_p_short swig_types[53] -#define SWIGTYPE_p_unsigned_char swig_types[54] -#define SWIGTYPE_p_unsigned_int swig_types[55] -#define SWIGTYPE_p_unsigned_long_long swig_types[56] -#define SWIGTYPE_p_unsigned_short swig_types[57] -static swig_type_info *swig_types[59]; -static swig_module_info swig_module = {swig_types, 58, 0, 0, 0, 0}; -#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) -#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) - -/* -------- TYPES TABLE (END) -------- */ - -#if (PY_VERSION_HEX <= 0x02000000) -# if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires swig to be run with the '-classic' option" -# endif -#endif - -/*----------------------------------------------- - @(target):= _internals.so - ------------------------------------------------*/ -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_init PyInit__internals - -#else -# define SWIG_init init_internals - -#endif -#define SWIG_name "_internals" - -#define SWIGVERSION 0x030012 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) - - -#include - - -namespace swig { - class SwigPtr_PyObject { - protected: - PyObject *_obj; - - public: - SwigPtr_PyObject() :_obj(0) - { - } - - SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XINCREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) - { - if (initial_ref) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XINCREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - } - - SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XINCREF(item._obj); - Py_XDECREF(_obj); - _obj = item._obj; - SWIG_PYTHON_THREAD_END_BLOCK; - return *this; - } - - ~SwigPtr_PyObject() - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XDECREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - operator PyObject *() const - { - return _obj; - } - - PyObject *operator->() const - { - return _obj; - } - }; -} - - -namespace swig { - struct SwigVar_PyObject : SwigPtr_PyObject { - SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } - - SwigVar_PyObject & operator = (PyObject* obj) - { - Py_XDECREF(_obj); - _obj = obj; - return *this; - } - }; -} - - -SWIGINTERNINLINE PyObject* - SWIG_From_int (int value) -{ - return PyInt_FromLong((long) value); -} - - -#define SWIG_FILE_WITH_INIT -#include "blpapi_types.h" - - -#include - - -SWIGINTERNINLINE PyObject* - SWIG_From_unsigned_SS_int (unsigned int value) -{ - return PyInt_FromSize_t((size_t) value); -} - - - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERNINLINE PyObject* -SWIG_From_unsigned_SS_long (unsigned long value) -{ - return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value)); -} - - -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - -#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) -# define SWIG_LONG_LONG_AVAILABLE -#endif - - -#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERNINLINE PyObject* -SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) -{ - return (value > LONG_MAX) ? - PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(static_cast< long >(value)); -} -#endif - - -SWIGINTERNINLINE PyObject * -SWIG_From_size_t (size_t value) -{ -#ifdef SWIG_LONG_LONG_AVAILABLE - if (sizeof(size_t) <= sizeof(unsigned long)) { -#endif - return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value)); -#ifdef SWIG_LONG_LONG_AVAILABLE - } else { - /* assume sizeof(size_t) <= sizeof(unsigned long long) */ - return SWIG_From_unsigned_SS_long_SS_long (static_cast< unsigned long long >(value)); - } -#endif -} - - -#include "blpapi_constant.h" -#include "blpapi_datetime.h" -#include "blpapi_diagnosticsutil.h" -#include "blpapi_element.h" -#include "blpapi_error.h" -#include "blpapi_event.h" -#include "blpapi_eventdispatcher.h" -#include "blpapi_highresolutionclock.h" -#include "blpapi_identity.h" -#include "blpapi_logging.h" -#include "blpapi_message.h" -#include "blpapi_name.h" -#include "blpapi_request.h" -#include "blpapi_schema.h" -#include "blpapi_service.h" -#include "blpapi_session.h" -#include "blpapi_sessionoptions.h" -#include "blpapi_streamproxy.h" -#include "blpapi_subscriptionlist.h" -#include "blpapi_timepoint.h" - -// publishing support -#include "blpapi_eventformatter.h" -#include "blpapi_providersession.h" -#include "blpapi_resolutionlist.h" -#include "blpapi_topic.h" -#include "blpapi_topiclist.h" - -#ifndef MAX_GROUP_ID_SIZE -// MAX_GROUP_ID_SIZE is not defined in BLPAPI, but docs say its value is 64 -#define MAX_GROUP_ID_SIZE 64 -#endif - -#include // for std::ostringstream -#include // for std::runtime_error -#include // for tm and mktime - - -std::string blpapi_Service_printHelper( - blpapi_Service_t *service, - int level, - int spacesPerLevel) -{ - std::ostringstream stream; - - blpapi_Service_print( - service, - BloombergLP::blpapi::OstreamWriter, - &stream, - level, - spacesPerLevel); - - return stream.str(); -} - -std::string blpapi_SchemaElementDefinition_printHelper( - blpapi_SchemaElementDefinition_t *item, - int level, - int spacesPerLevel) -{ - std::ostringstream stream; - - blpapi_SchemaElementDefinition_print( - item, - BloombergLP::blpapi::OstreamWriter, - &stream, - level, - spacesPerLevel); - - return stream.str(); -} - -std::string blpapi_SchemaTypeDefinition_printHelper( - blpapi_SchemaTypeDefinition_t *item, - int level, - int spacesPerLevel) -{ - std::ostringstream stream; - - blpapi_SchemaTypeDefinition_print( - item, - BloombergLP::blpapi::OstreamWriter, - &stream, - level, - spacesPerLevel); - - return stream.str(); -} - -bool blpapi_SchemaTypeDefinition_hasElementDefinition( - const blpapi_SchemaTypeDefinition_t *type, - const char *nameString, - const blpapi_Name_t *name) -{ - return 0 != blpapi_SchemaTypeDefinition_getElementDefinition( - type, nameString, name); -} - -bool blpapi_ConstantList_hasConstant( - const blpapi_ConstantList_t *list, - const char *nameString, - const blpapi_Name_t *name) -{ - return 0 != blpapi_ConstantList_getConstant(list, nameString, name); -} - -bool blpapi_Service_hasEventDefinition( - blpapi_Service_t *service, - const char* nameString, - const blpapi_Name_t *name) -{ - blpapi_SchemaElementDefinition_t *eventDefinition; - - return 0 == blpapi_Service_getEventDefinition( - service, &eventDefinition, nameString, name); -} - -bool blpapi_Service_hasOperation( - blpapi_Service_t *service, - const char* nameString, - const blpapi_Name_t *name) -{ - blpapi_Operation_t *operation; - - return 0 == blpapi_Service_getOperation( - service, &operation, nameString, name); -} - -int blpapi_SubscriptionList_addHelper( - blpapi_SubscriptionList_t *list, - const char *topic, - const blpapi_CorrelationId_t *correlationId, - const char *fields, - const char *options) -{ - return blpapi_SubscriptionList_add( - list, - topic, - correlationId, - &fields, - &options, - fields ? 1 : 0, - options ? 1: 0); -} - -bool blpapi_Name_hasName(const char *nameString) -{ - return blpapi_Name_findName(nameString) ? true : false; -} - -blpapi_TopicList_t* blpapi_TopicList_createFromResolutionList( - blpapi_ResolutionList_t* from) -{ - return blpapi_TopicList_create(reinterpret_cast(from)); -} - -std::string blpapi_DiagnosticsUtil_memoryInfo_wrapper() -{ - // Get the length of the buffer first - int len = blpapi_DiagnosticsUtil_memoryInfo(0, 0); - if (len < 0) { - throw std::runtime_error("blpapi_DiagnosticsUtil_memoryInfo error"); - } - - // Allocate buffer and call the function - std::string buffer; - buffer.resize(len+1); - blpapi_DiagnosticsUtil_memoryInfo(&buffer[0], len+1); - return buffer; -} - -typedef void (*blpapi_Logging_Func_t)(blpapi_UInt64_t threadId, - int severity, - blpapi_Datetime_t timestamp, - const char *category, - const char *message); - -// Shared global object guarded by GIL -PyObject* loggerCallback = 0; - -static time_t blpapi_Datetime_to_unix(blpapi_Datetime_t const& original) { - time_t rawtime = time(NULL); - struct tm *ts = localtime(&rawtime); - if (original.parts & BLPAPI_DATETIME_DATE_PART) { - ts->tm_year = original.year - 1900; // tm_year should contain number of years since 1900 - ts->tm_mon = original.month - 1; // tm_mon is zero based - ts->tm_mday = original.day; - if (original.parts & BLPAPI_DATETIME_TIME_PART) { - ts->tm_hour = original.hours; - ts->tm_min = original.minutes; - ts->tm_sec = original.seconds; - } - } - time_t result = mktime(ts); - return result; -} - -void loggerCallbackWrapper(blpapi_UInt64_t threadId, - int severity, - blpapi_Datetime_t original, - const char *category, - const char *message) -{ - time_t ts = blpapi_Datetime_to_unix(original); - - PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject* result = PyObject_CallFunction(loggerCallback, "KiIss", - threadId, severity, ts, - category, message); - PyGILState_Release(gilstate); - Py_XDECREF(result); -} - -void setLoggerCallbackWrapper(PyObject *cb, int severity) -{ - if (!PyCallable_Check(cb)) { - throw std::invalid_argument("parameter must be a function"); - } - Py_XINCREF(cb); - Py_XDECREF(loggerCallback); - loggerCallback = cb; - // Set actual callback - int err = blpapi_Logging_registerCallback(&loggerCallbackWrapper, (blpapi_Logging_Severity_t)severity); - if (err != 0) { - throw std::runtime_error("unable to register callback"); - } -} - -/** Convert `blpapi_TimePoint_t` value to `blpapi_Datetime_t`. Function - * always returns UTC time. - */ -blpapi_Datetime_t fromTimePoint(blpapi_TimePoint_t original) -{ - blpapi_HighPrecisionDatetime_t highPrecisionDatetime; - blpapi_HighPrecisionDatetime_fromTimePoint( - &highPrecisionDatetime, - &original, - 0); - - blpapi_Datetime_t datetime = highPrecisionDatetime.datetime; - - return datetime; -} - -/** Get the timestmap associated with message or throw an exception. - */ -blpapi_Datetime_t blpapi_Message_timeReceived_wrapper( - const blpapi_Message_t *message) -{ - blpapi_TimePoint_t value; - int retval = blpapi_Message_timeReceived(message, &value); - if (retval != 0) { - throw std::invalid_argument("Message has no timestamp"); - } - return fromTimePoint(value); -} - -/** Call blpapi_HighResolutionClock_now and convert result to blpapi_Datetime_t. - */ -blpapi_Datetime_t blpapi_HighResolutionClock_now_wrapper() -{ - blpapi_TimePoint_t timepoint; - int res = blpapi_HighResolutionClock_now(&timepoint); - if (res != 0) { - throw std::runtime_error("High resolution clock error"); - } - return fromTimePoint(timepoint); -} - - -SWIGINTERN int -SWIG_AsVal_double (PyObject *obj, double *val) -{ - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; -#if PY_VERSION_HEX < 0x03000000 - } else if (PyInt_Check(obj)) { - if (val) *val = (double) PyInt_AsLong(obj); - return SWIG_OK; -#endif - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } - } -#endif - return res; -} - - -#include - - -#include - - -SWIGINTERNINLINE int -SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ - if ((errno == EDOM) || (errno == ERANGE)) { - errno = 0; - } else { - double summ, reps, diff; - if (rd < x) { - diff = x - rd; - } else if (rd > x) { - diff = rd - x; - } else { - return 1; - } - summ = rd + x; - reps = diff/summ; - if (reps < 8*DBL_EPSILON) { - *d = rd; - return 1; - } - } - } - return 0; -} - - -SWIGINTERN int -SWIG_AsVal_long (PyObject *obj, long* val) -{ -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else -#endif - if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - long v = PyInt_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< int >(v); - } - } - return res; -} - - -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { -#if PY_VERSION_HEX >= 0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - return PyBytes_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); -#else -#if PY_VERSION_HEX >= 0x03010000 - return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape"); -#else - return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); -#endif -#endif -#else - return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); -#endif - } - } else { - return SWIG_Py_Void(); - } -} - - -SWIGINTERNINLINE PyObject * -SWIG_From_std_string (const std::string& s) -{ - return SWIG_FromCharPtrAndSize(s.data(), s.size()); -} - - -SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -{ -#if PY_VERSION_HEX>=0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_Check(obj)) -#else - if (PyUnicode_Check(obj)) -#endif -#else - if (PyString_Check(obj)) -#endif - { - char *cstr; Py_ssize_t len; -#if PY_VERSION_HEX>=0x03000000 -#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (!alloc && cptr) { - /* We can't allow converting without allocation, since the internal - representation of string in Python 3 is UCS-2/UCS-4 but we require - a UTF-8 representation. - TODO(bhy) More detailed explanation */ - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if(alloc) *alloc = SWIG_NEWOBJ; -#endif - PyBytes_AsStringAndSize(obj, &cstr, &len); -#else - PyString_AsStringAndSize(obj, &cstr, &len); -#endif - if (cptr) { - if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. - - The default behavior is just to return the pointer value, - so, be careful. - */ -#if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) -#else - if (*alloc == SWIG_NEWOBJ) -#endif - { - *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); - *alloc = SWIG_NEWOBJ; - } else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } - } else { -#if PY_VERSION_HEX>=0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - *cptr = PyBytes_AsString(obj); -#else - assert(0); /* Should never reach here with Unicode strings in Python 3 */ -#endif -#else - *cptr = SWIG_Python_str_AsChar(obj); -#endif - } - } - if (psize) *psize = len + 1; -#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - Py_XDECREF(obj); -#endif - return SWIG_OK; - } else { -#if defined(SWIG_PYTHON_2_UNICODE) -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) -#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" -#endif -#if PY_VERSION_HEX<0x03000000 - if (PyUnicode_Check(obj)) { - char *cstr; Py_ssize_t len; - if (!alloc && cptr) { - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { - if (cptr) { - if (alloc) *alloc = SWIG_NEWOBJ; - *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); - } - if (psize) *psize = len + 1; - - Py_XDECREF(obj); - return SWIG_OK; - } else { - Py_XDECREF(obj); - } - } -#endif -#endif - - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} - - - - - -SWIGINTERNINLINE PyObject* - SWIG_From_bool (bool value) -{ - return PyBool_FromLong(value ? 1 : 0); -} - - -typedef int intArray; - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) -{ -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else -#endif - if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) -{ - int res = SWIG_TypeError; - if (PyLong_Check(obj)) { - unsigned long long v = PyLong_AsUnsignedLongLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - res = SWIG_OverflowError; - } - } else { - unsigned long v; - res = SWIG_AsVal_unsigned_SS_long (obj,&v); - if (SWIG_IsOK(res)) { - if (val) *val = v; - return res; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - const double mant_max = 1LL << DBL_MANT_DIG; - double d; - res = SWIG_AsVal_double (obj,&d); - if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) - return SWIG_OverflowError; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { - if (val) *val = (unsigned long long)(d); - return SWIG_AddCast(res); - } - res = SWIG_TypeError; - } -#endif - return res; -} -#endif - - -SWIGINTERNINLINE int -SWIG_AsVal_size_t (PyObject * obj, size_t *val) -{ - int res = SWIG_TypeError; -#ifdef SWIG_LONG_LONG_AVAILABLE - if (sizeof(size_t) <= sizeof(unsigned long)) { -#endif - unsigned long v; - res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v); -#ifdef SWIG_LONG_LONG_AVAILABLE - } else if (sizeof(size_t) <= sizeof(unsigned long long)) { - unsigned long long v; - res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v); - } -#endif - return res; -} - -SWIGINTERN intArray *new_intArray(size_t nelements){ - return (new int[nelements]()); - } -SWIGINTERN void delete_intArray(intArray *self){ - delete[] self; - } -SWIGINTERN int intArray___getitem__(intArray *self,size_t index){ - return self[index]; - } -SWIGINTERN void intArray___setitem__(intArray *self,size_t index,int value){ - self[index] = value; - } -SWIGINTERN int *intArray_cast(intArray *self){ - return self; - } -SWIGINTERN intArray *intArray_frompointer(int *t){ - return static_cast< intArray * >(t); - } - - static blpapi_Topic_t* *new_topicPtrArray(size_t nelements) { - return (new blpapi_Topic_t*[nelements]()); - } - - static void delete_topicPtrArray(blpapi_Topic_t* *ary) { - delete[] ary; - } - - static blpapi_Topic_t* topicPtrArray_getitem(blpapi_Topic_t* *ary, size_t index) { - return ary[index]; - } - static void topicPtrArray_setitem(blpapi_Topic_t* *ary, size_t index, blpapi_Topic_t* value) { - ary[index] = value; - } - - - -#include "blpapi_correlationid.h" - -int pyObjectManagerFunc( - blpapi_ManagedPtr_t *managedPtr, - const blpapi_ManagedPtr_t *srcPtr, - int operation) -{ - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (operation == BLPAPI_MANAGEDPTR_COPY) { - managedPtr->pointer = srcPtr->pointer; - managedPtr->manager = srcPtr->manager; - Py_INCREF(reinterpret_cast(managedPtr->pointer)); - } - else if (operation == BLPAPI_MANAGEDPTR_DESTROY) { - Py_DECREF(reinterpret_cast(managedPtr->pointer)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - - return 0; -} - -blpapi_CorrelationId_t *CorrelationId_t_createEmpty() -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_CorrelationId_t *cid = new blpapi_CorrelationId_t; - std::memset(cid, 0, sizeof(blpapi_CorrelationId_t)); - SWIG_PYTHON_THREAD_END_ALLOW; - - return cid; -} - -blpapi_CorrelationId_t *CorrelationId_t_createFromInteger(long long value, unsigned short classId) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_CorrelationId_t *cid = new blpapi_CorrelationId_t; - std::memset(cid, 0, sizeof(blpapi_CorrelationId_t)); - - cid->size = sizeof(blpapi_CorrelationId_t); - cid->valueType = BLPAPI_CORRELATION_TYPE_INT; - cid->classId = classId; - cid->value.intValue = value; - SWIG_PYTHON_THREAD_END_ALLOW; - - return cid; -} - -blpapi_CorrelationId_t *CorrelationId_t_createFromObject(PyObject *value, unsigned short classId) -{ - if (!value) { - value = Py_None; - } - - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_CorrelationId_t *cid = new blpapi_CorrelationId_t; - std::memset(cid, 0, sizeof(blpapi_CorrelationId_t)); - - cid->size = sizeof(blpapi_CorrelationId_t); - cid->valueType = BLPAPI_CORRELATION_TYPE_POINTER; - cid->classId = classId; - - cid->value.ptrValue.manager = &pyObjectManagerFunc; - cid->value.ptrValue.pointer = value; - SWIG_PYTHON_THREAD_END_ALLOW; - - Py_INCREF(value); - - return cid; -} - -blpapi_CorrelationId_t *CorrelationId_t_clone(const blpapi_CorrelationId_t& original) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_CorrelationId_t *cid = new blpapi_CorrelationId_t(original); - SWIG_PYTHON_THREAD_END_ALLOW; - - if (BLPAPI_CORRELATION_TYPE_POINTER == cid->valueType) { - blpapi_ManagedPtr_ManagerFunction_t& manager = - cid->value.ptrValue.manager; - if (manager) { - manager(&cid->value.ptrValue, &original.value.ptrValue, - BLPAPI_MANAGEDPTR_COPY); - } - } - - return cid; -} - -void CorrelationId_t_cleanup(blpapi_CorrelationId_t& cid) -{ - if (BLPAPI_CORRELATION_TYPE_POINTER == cid.valueType) { - blpapi_ManagedPtr_ManagerFunction_t &manager = - cid.value.ptrValue.manager; - if (manager) { - manager(&cid.value.ptrValue, 0, BLPAPI_MANAGEDPTR_DESTROY); - } - } -} - -void CorrelationId_t_delete(blpapi_CorrelationId_t *cid) -{ - if (!cid) { - return; - } - - CorrelationId_t_cleanup(*cid); - - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - delete cid; - SWIG_PYTHON_THREAD_END_ALLOW; -} - -bool CorrelationId_t_equals( - const blpapi_CorrelationId_t& cid1, - const blpapi_CorrelationId_t& cid2) -{ - if (cid1.valueType != cid2.valueType) { - return false; - } - - if (cid1.classId != cid2.classId) { - return false; - } - - if (cid1.valueType == BLPAPI_CORRELATION_TYPE_POINTER) { - return cid1.value.ptrValue.pointer == cid2.value.ptrValue.pointer; - } else { - return cid1.value.intValue == cid2.value.intValue; - } -} - -long long CorrelationId_t_toInteger(const blpapi_CorrelationId_t& cid) -{ - if (cid.valueType == BLPAPI_CORRELATION_TYPE_POINTER) - return reinterpret_cast(cid.value.ptrValue.pointer); - return cid.value.intValue; -} - -PyObject *CorrelationId_t_getObject(const blpapi_CorrelationId_t& cid) { - PyObject *res; - - if (BLPAPI_CORRELATION_TYPE_POINTER == cid.valueType - && &pyObjectManagerFunc == cid.value.ptrValue.manager) - { - res = reinterpret_cast(cid.value.ptrValue.pointer); - } - else { - res = Py_None; - } - - Py_INCREF(res); - return res; -} - - -SWIGINTERN blpapi_CorrelationId_t_ *new_blpapi_CorrelationId_t___SWIG_0(){ - return CorrelationId_t_createEmpty(); - } - -#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERN int -SWIG_AsVal_long_SS_long (PyObject *obj, long long *val) -{ - int res = SWIG_TypeError; - if (PyLong_Check(obj)) { - long long v = PyLong_AsLongLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - res = SWIG_OverflowError; - } - } else { - long v; - res = SWIG_AsVal_long (obj,&v); - if (SWIG_IsOK(res)) { - if (val) *val = v; - return res; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - const double mant_max = 1LL << DBL_MANT_DIG; - const double mant_min = -mant_max; - double d; - res = SWIG_AsVal_double (obj,&d); - if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max)) - return SWIG_OverflowError; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { - if (val) *val = (long long)(d); - return SWIG_AddCast(res); - } - res = SWIG_TypeError; - } -#endif - return res; -} -#endif - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > USHRT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< unsigned short >(v); - } - } - return res; -} - -SWIGINTERN blpapi_CorrelationId_t_ *new_blpapi_CorrelationId_t___SWIG_1(long long value,unsigned short classId=0){ - return CorrelationId_t_createFromInteger(value, classId); - } -SWIGINTERN blpapi_CorrelationId_t_ *new_blpapi_CorrelationId_t___SWIG_3(PyObject *value,unsigned short classId=0){ - return CorrelationId_t_createFromObject(value, classId); - } -SWIGINTERN void delete_blpapi_CorrelationId_t_(blpapi_CorrelationId_t_ *self){ - CorrelationId_t_delete((self)); - } -SWIGINTERN unsigned short blpapi_CorrelationId_t__type(blpapi_CorrelationId_t_ const *self){ - return self->valueType; - } - -SWIGINTERNINLINE PyObject * -SWIG_From_unsigned_SS_short (unsigned short value) -{ - return SWIG_From_unsigned_SS_long (value); -} - -SWIGINTERN unsigned short blpapi_CorrelationId_t__classId(blpapi_CorrelationId_t_ const *self){ - return self->classId; - } -SWIGINTERN PyObject *blpapi_CorrelationId_t____asObject(blpapi_CorrelationId_t_ const *self){ - return CorrelationId_t_getObject(*self); - } -SWIGINTERN long long blpapi_CorrelationId_t____asInteger(blpapi_CorrelationId_t_ const *self){ - return self->value.intValue; - } - -#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERNINLINE PyObject* -SWIG_From_long_SS_long (long long value) -{ - return ((value < LONG_MIN) || (value > LONG_MAX)) ? - PyLong_FromLongLong(value) : PyInt_FromLong(static_cast< long >(value)); -} -#endif - -SWIGINTERN long long blpapi_CorrelationId_t____toInteger(blpapi_CorrelationId_t_ const *self){ - return CorrelationId_t_toInteger(*self); - } - - -#include "blpapi_element.h" -#include // for std::ostringstream - -int blpapi_Element_setElementFloat( - blpapi_Element_t *element, - const char* nameString, - const blpapi_Name_t* name, - blpapi_Float64_t value) -{ - // The C interface will not silently discard precision to store a 64-bit - // float in a field whose schema type is 32-bit, however all Python floats - // are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. - - blpapi_Element_t *fldt; - int ret = blpapi_Element_getElement(element, &fldt, nameString, name); - if (ret == 0) { - // Able to get field, consider its datatype - if (blpapi_Element_datatype(fldt) == BLPAPI_DATATYPE_FLOAT32) { - ret = blpapi_Element_setElementFloat32(element, - nameString, name, value); - } else { - ret = blpapi_Element_setElementFloat64(element, - nameString, name, value); - } - return ret; - } - - // Unable to get field. Try to set element anyway - ret = blpapi_Element_setElementFloat64(element, - nameString, name, value); - - if (ret) { - ret = blpapi_Element_setElementFloat32(element, - nameString, name, value); - } - - return ret; -} - -int blpapi_Element_setValueFloat( - blpapi_Element_t *element, - blpapi_Float64_t value, - size_t index) -{ - // The C interface will not silently discard precision to store a 64-bit - // float in a field whose schema type is 32-bit, however all Python floats - // are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. - - int ret; - - // Consider field datatype - if (blpapi_Element_datatype(element) == BLPAPI_DATATYPE_FLOAT32) { - ret = blpapi_Element_setValueFloat32(element, value, index); - } else { - ret = blpapi_Element_setValueFloat64(element, value, index); - } - - return ret; -} - -std::string blpapi_Element_printHelper( - blpapi_Element_t *element, - int level, - int spacesPerLevel) -{ - std::ostringstream stream; - - blpapi_Element_print( - element, - BloombergLP::blpapi::OstreamWriter, - &stream, - level, - spacesPerLevel); - - return stream.str(); -} - - - -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) -{ - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); -} - - - #define SWIG_From_double PyFloat_FromDouble - - - -#include "blpapi_eventformatter.h" - -int blpapi_EventFormatter_setValueFloat( - blpapi_EventFormatter_t* formatter, - char const* typeString, - const blpapi_Name_t* typeName, - blpapi_Float64_t value) -{ - // The C interface will not silently discard precision to store a 64-bit - // float in a field whose schema type is 32-bit, however all Python floats - // are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. - - int ret = blpapi_EventFormatter_setValueFloat64(formatter, typeString, - typeName, value); - if (ret) { - ret = blpapi_EventFormatter_setValueFloat32(formatter, typeString, - typeName, value); - } - - return ret; -} - -int blpapi_EventFormatter_appendValueFloat( - blpapi_EventFormatter_t* formatter, - blpapi_Float64_t value) -{ - // The C interface will not silently discard precision to store a 64-bit - // float in a field whose schema type is 32-bit, however all Python floats - // are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. - - int ret = blpapi_EventFormatter_appendValueFloat64(formatter, value); - - if (ret) { - ret = blpapi_EventFormatter_appendValueFloat32(formatter, value); - } - - return ret; -} - - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< unsigned int >(v); - } - } - return res; -} - - -SWIGINTERN int -SWIG_AsCharArray(PyObject * obj, char *val, size_t size) -{ - char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; - int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); - if (SWIG_IsOK(res)) { - /* special case of single char conversion when we don't need space for NUL */ - if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize; - if (csize <= size) { - if (val) { - if (csize) memcpy(val, cptr, csize*sizeof(char)); - if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char)); - } - if (alloc == SWIG_NEWOBJ) { - delete[] cptr; - res = SWIG_DelNewMask(res); - } - return res; - } - if (alloc == SWIG_NEWOBJ) delete[] cptr; - } - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_char (PyObject * obj, char *val) -{ - int res = SWIG_AsCharArray(obj, val, 1); - if (!SWIG_IsOK(res)) { - long v; - res = SWIG_AddCast(SWIG_AsVal_long (obj, &v)); - if (SWIG_IsOK(res)) { - if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { - if (val) *val = static_cast< char >(v); - } else { - res = SWIG_OverflowError; - } - } - } - return res; -} - - -#include "blpapi_session.h" - -void dispatchEventProxy(blpapi_Event_t *event, blpapi_Session_t *, void *userData) -{ - PyObject *eventDispatcherFunc = reinterpret_cast(userData); - - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - - PyObject *arglist = PyTuple_New(1); - PyTuple_SET_ITEM(arglist, 0, - SWIG_NewPointerObj(SWIG_as_voidptr(event), SWIGTYPE_p_blpapi_Event, 0)); - - PyObject *result = PyEval_CallObject(eventDispatcherFunc, arglist); - - Py_DECREF(arglist); - Py_XDECREF(result); - - SWIG_PYTHON_THREAD_END_BLOCK; -} - -blpapi_Session_t *Session_createHelper(blpapi_SessionOptions_t *parameters, - PyObject *eventHandlerFunc, - blpapi_EventDispatcher_t *dispatcher) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - const bool hasHandler = - eventHandlerFunc != 0 && eventHandlerFunc != Py_None; - - blpapi_Session_t *const res = blpapi_Session_create( - parameters, - hasHandler ? &dispatchEventProxy : 0, - dispatcher, - hasHandler ? eventHandlerFunc : 0); - - if (!res) { - return 0; - } - SWIG_PYTHON_THREAD_END_ALLOW; - - Py_XINCREF(eventHandlerFunc); - - return res; -} - -void Session_destroyHelper(blpapi_Session_t *sessionHandle, PyObject *eventHandlerFunc) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Session_destroy(sessionHandle); - SWIG_PYTHON_THREAD_END_ALLOW; - - Py_XDECREF(eventHandlerFunc); -} - - - -#include "blpapi_providersession.h" - -void dispatchProviderEventProxy(blpapi_Event_t *event, blpapi_ProviderSession_t *, void *userData) -{ - PyObject *eventDispatcherFunc = reinterpret_cast(userData); - - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - - PyObject *arglist = PyTuple_New(1); - PyTuple_SET_ITEM(arglist, 0, - SWIG_NewPointerObj(SWIG_as_voidptr(event), SWIGTYPE_p_blpapi_Event, 0)); - - PyObject *result = PyEval_CallObject(eventDispatcherFunc, arglist); - - Py_DECREF(arglist); - Py_XDECREF(result); - - SWIG_PYTHON_THREAD_END_BLOCK; -} - -blpapi_ProviderSession_t *ProviderSession_createHelper(blpapi_SessionOptions_t *parameters, - PyObject *eventHandlerFunc, - blpapi_EventDispatcher_t *dispatcher) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - const bool hasHandler = - eventHandlerFunc != 0 && eventHandlerFunc != Py_None; - - blpapi_ProviderSession_t *const res = blpapi_ProviderSession_create( - parameters, - hasHandler ? &dispatchProviderEventProxy : 0, - dispatcher, - hasHandler ? eventHandlerFunc : 0); - - if (!res) { - return 0; - } - SWIG_PYTHON_THREAD_END_ALLOW; - - Py_XINCREF(eventHandlerFunc); - - return res; -} - -void ProviderSession_destroyHelper(blpapi_ProviderSession_t *sessionHandle, - PyObject *eventHandlerFunc) -{ - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ProviderSession_destroy(sessionHandle); - SWIG_PYTHON_THREAD_END_ALLOW; - - Py_XDECREF(eventHandlerFunc); -} - - - -/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ -#ifndef SWIG_isfinite -/* isfinite() is a macro for C99 */ -# if defined(isfinite) -# define SWIG_isfinite(X) (isfinite(X)) -# elif defined __cplusplus && __cplusplus >= 201103L -/* Use a template so that this works whether isfinite() is std::isfinite() or - * in the global namespace. The reality seems to vary between compiler - * versions. - * - * Make sure namespace std exists to avoid compiler warnings. - * - * extern "C++" is required as this fragment can end up inside an extern "C" { } block - */ -namespace std { } -extern "C++" template -inline int SWIG_isfinite_func(T x) { - using namespace std; - return isfinite(x); -} -# define SWIG_isfinite(X) (SWIG_isfinite_func(X)) -# elif defined(_MSC_VER) -# define SWIG_isfinite(X) (_finite(X)) -# elif defined(__sun) && defined(__SVR4) -# include -# define SWIG_isfinite(X) (finite(X)) -# endif -#endif - - -/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ -#ifdef SWIG_isfinite -# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) -#else -# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) -#endif - - -SWIGINTERN int -SWIG_AsVal_float (PyObject * obj, float *val) -{ - double v; - int res = SWIG_AsVal_double (obj, &v); - if (SWIG_IsOK(res)) { - if (SWIG_Float_Overflow_Check(v)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< float >(v); - } - } - return res; -} - - -SWIGINTERNINLINE PyObject * -SWIG_From_float (float value) -{ - return SWIG_From_double (value); -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > UCHAR_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< unsigned char >(v); - } - } - return res; -} - - -SWIGINTERNINLINE PyObject * -SWIG_From_unsigned_SS_char (unsigned char value) -{ - return SWIG_From_unsigned_SS_long (value); -} - - -SWIGINTERN int -SWIG_AsVal_short (PyObject * obj, short *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < SHRT_MIN || v > SHRT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< short >(v); - } - } - return res; -} - - -SWIGINTERNINLINE PyObject * -SWIG_From_short (short value) -{ - return SWIG_From_long (value); -} - -#ifdef __cplusplus -extern "C" { -#endif -SWIGINTERN PyObject *_wrap_setLoggerCallbackWrapper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:setLoggerCallbackWrapper",&obj0,&obj1)) SWIG_fail; - arg1 = obj0; - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "setLoggerCallbackWrapper" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - setLoggerCallbackWrapper(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Logging_registerCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Logging_Func_t arg1 ; - blpapi_Logging_Severity_t arg2 ; - void *argp1 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Logging_registerCallback",&obj0,&obj1)) SWIG_fail; - { - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_blpapi_Logging_Func_t, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Logging_registerCallback" "', argument " "1"" of type '" "blpapi_Logging_Func_t""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "blpapi_Logging_registerCallback" "', argument " "1"" of type '" "blpapi_Logging_Func_t""'"); - } else { - blpapi_Logging_Func_t * temp = reinterpret_cast< blpapi_Logging_Func_t * >(argp1); - arg1 = *temp; - if (SWIG_IsNewObj(res1)) delete temp; - } - } - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Logging_registerCallback" "', argument " "2"" of type '" "blpapi_Logging_Severity_t""'"); - } - arg2 = static_cast< blpapi_Logging_Severity_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Logging_registerCallback(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Logging_logTestMessage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Logging_Severity_t arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Logging_logTestMessage",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "blpapi_Logging_logTestMessage" "', argument " "1"" of type '" "blpapi_Logging_Severity_t""'"); - } - arg1 = static_cast< blpapi_Logging_Severity_t >(val1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Logging_logTestMessage(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_DiagnosticsUtil_memoryInfo_wrapper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_DiagnosticsUtil_memoryInfo_wrapper")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_DiagnosticsUtil_memoryInfo_wrapper(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_timeReceived_wrapper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Datetime_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_timeReceived_wrapper",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_timeReceived_wrapper" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Message_timeReceived_wrapper((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj((new blpapi_Datetime_t(static_cast< const blpapi_Datetime_t& >(result))), SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighResolutionClock_now_wrapper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_t result; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_HighResolutionClock_now_wrapper")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_HighResolutionClock_now_wrapper(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj((new blpapi_Datetime_t(static_cast< const blpapi_Datetime_t& >(result))), SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_OWN | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_printHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Service_printHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_printHelper" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Service_printHelper" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Service_printHelper" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Service_printHelper(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_printHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_SchemaElementDefinition_printHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_printHelper" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SchemaElementDefinition_printHelper" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SchemaElementDefinition_printHelper" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaElementDefinition_printHelper(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_printHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_SchemaTypeDefinition_printHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_printHelper" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SchemaTypeDefinition_printHelper" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SchemaTypeDefinition_printHelper" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaTypeDefinition_printHelper(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_hasElementDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_SchemaTypeDefinition_hasElementDefinition",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_hasElementDefinition" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SchemaTypeDefinition_hasElementDefinition" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_SchemaTypeDefinition_hasElementDefinition" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)blpapi_SchemaTypeDefinition_hasElementDefinition((void *const *)arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_hasConstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ConstantList_hasConstant",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_hasConstant" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ConstantList_hasConstant" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ConstantList_hasConstant" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)blpapi_ConstantList_hasConstant((blpapi_ConstantList const *)arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_hasEventDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Service_hasEventDefinition",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_hasEventDefinition" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Service_hasEventDefinition" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_hasEventDefinition" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)blpapi_Service_hasEventDefinition(arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_hasOperation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Service_hasOperation",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_hasOperation" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Service_hasOperation" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_hasOperation" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)blpapi_Service_hasOperation(arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_addHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - char *arg4 = (char *) 0 ; - char *arg5 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int res5 ; - char *buf5 = 0 ; - int alloc5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_SubscriptionList_addHelper",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_addHelper" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SubscriptionList_addHelper" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_SubscriptionList_addHelper" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_SubscriptionList_addHelper" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "blpapi_SubscriptionList_addHelper" "', argument " "5"" of type '" "char const *""'"); - } - arg5 = reinterpret_cast< char * >(buf5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_addHelper(arg1,(char const *)arg2,(blpapi_CorrelationId_t_ const *)arg3,(char const *)arg4,(char const *)arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_hasName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject * obj0 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_hasName",&obj0)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_hasName" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = reinterpret_cast< char * >(buf1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)blpapi_Name_hasName((char const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_createFromResolutionList(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_TopicList_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_TopicList_createFromResolutionList",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_createFromResolutionList" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_TopicList_t *)blpapi_TopicList_createFromResolutionList(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_intArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - size_t arg1 ; - size_t val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - intArray *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_intArray",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_size_t(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_intArray" "', argument " "1"" of type '" "size_t""'"); - } - arg1 = static_cast< size_t >(val1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (intArray *)new_intArray(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_intArray, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_intArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - intArray *arg1 = (intArray *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_intArray",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_intArray, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_intArray" "', argument " "1"" of type '" "intArray *""'"); - } - arg1 = reinterpret_cast< intArray * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - delete_intArray(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_intArray___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - intArray *arg1 = (intArray *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:intArray___getitem__",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_intArray, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "intArray___getitem__" "', argument " "1"" of type '" "intArray *""'"); - } - arg1 = reinterpret_cast< intArray * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "intArray___getitem__" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)intArray___getitem__(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_intArray___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - intArray *arg1 = (intArray *) 0 ; - size_t arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:intArray___setitem__",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_intArray, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "intArray___setitem__" "', argument " "1"" of type '" "intArray *""'"); - } - arg1 = reinterpret_cast< intArray * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "intArray___setitem__" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "intArray___setitem__" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - intArray___setitem__(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_intArray_cast(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - intArray *arg1 = (intArray *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:intArray_cast",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_intArray, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "intArray_cast" "', argument " "1"" of type '" "intArray *""'"); - } - arg1 = reinterpret_cast< intArray * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int *)intArray_cast(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_intArray_frompointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int *arg1 = (int *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - intArray *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:intArray_frompointer",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "intArray_frompointer" "', argument " "1"" of type '" "int *""'"); - } - arg1 = reinterpret_cast< int * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (intArray *)intArray_frompointer(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_intArray, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *intArray_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_intArray, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_new_topicPtrArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - size_t arg1 ; - size_t val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Topic_t **result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_topicPtrArray",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_size_t(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_topicPtrArray" "', argument " "1"" of type '" "size_t""'"); - } - arg1 = static_cast< size_t >(val1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Topic_t **)new_topicPtrArray(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_blpapi_Topic, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_topicPtrArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t **arg1 = (blpapi_Topic_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_topicPtrArray",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_topicPtrArray" "', argument " "1"" of type '" "blpapi_Topic_t **""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t ** >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - delete_topicPtrArray(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_topicPtrArray_getitem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t **arg1 = (blpapi_Topic_t **) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_Topic_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:topicPtrArray_getitem",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "topicPtrArray_getitem" "', argument " "1"" of type '" "blpapi_Topic_t **""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t ** >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "topicPtrArray_getitem" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Topic_t *)topicPtrArray_getitem(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_topicPtrArray_setitem(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t **arg1 = (blpapi_Topic_t **) 0 ; - size_t arg2 ; - blpapi_Topic_t *arg3 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:topicPtrArray_setitem",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "topicPtrArray_setitem" "', argument " "1"" of type '" "blpapi_Topic_t **""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t ** >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "topicPtrArray_setitem" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "topicPtrArray_setitem" "', argument " "3"" of type '" "blpapi_Topic_t *""'"); - } - arg3 = reinterpret_cast< blpapi_Topic_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - topicPtrArray_setitem(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId_t_equals(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t *arg1 = 0 ; - blpapi_CorrelationId_t *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - bool result; - - if (!PyArg_ParseTuple(args,(char *)"OO:CorrelationId_t_equals",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId_t_equals" "', argument " "1"" of type '" "blpapi_CorrelationId_t const &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CorrelationId_t_equals" "', argument " "1"" of type '" "blpapi_CorrelationId_t const &""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CorrelationId_t_equals" "', argument " "2"" of type '" "blpapi_CorrelationId_t const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CorrelationId_t_equals" "', argument " "2"" of type '" "blpapi_CorrelationId_t const &""'"); - } - arg2 = reinterpret_cast< blpapi_CorrelationId_t * >(argp2); - - try { - result = (bool)CorrelationId_t_equals((blpapi_CorrelationId_t_ const &)*arg1,(blpapi_CorrelationId_t_ const &)*arg2); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_bool(static_cast< bool >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":new_CorrelationId")) SWIG_fail; - - try { - result = (blpapi_CorrelationId_t_ *)new_blpapi_CorrelationId_t___SWIG_0(); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - long long arg1 ; - unsigned short arg2 ; - long long val1 ; - int ecode1 = 0 ; - unsigned short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_CorrelationId_t_ *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:new_CorrelationId",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_CorrelationId" "', argument " "1"" of type '" "long long""'"); - } - arg1 = static_cast< long long >(val1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_CorrelationId" "', argument " "2"" of type '" "unsigned short""'"); - } - arg2 = static_cast< unsigned short >(val2); - - try { - result = (blpapi_CorrelationId_t_ *)new_blpapi_CorrelationId_t___SWIG_1(arg1,arg2); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - long long arg1 ; - long long val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_CorrelationId_t_ *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_CorrelationId",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_long_SS_long(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_CorrelationId" "', argument " "1"" of type '" "long long""'"); - } - arg1 = static_cast< long long >(val1); - - try { - result = (blpapi_CorrelationId_t_ *)new_blpapi_CorrelationId_t___SWIG_1(arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - unsigned short arg2 ; - unsigned short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_CorrelationId_t_ *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:new_CorrelationId",&obj0,&obj1)) SWIG_fail; - { - arg1 = obj0; - } - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_CorrelationId" "', argument " "2"" of type '" "unsigned short""'"); - } - arg2 = static_cast< unsigned short >(val2); - - try { - result = (blpapi_CorrelationId_t_ *)new_blpapi_CorrelationId_t___SWIG_3(arg1,arg2); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject * obj0 = 0 ; - blpapi_CorrelationId_t_ *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:new_CorrelationId",&obj0)) SWIG_fail; - { - arg1 = obj0; - } - - try { - result = (blpapi_CorrelationId_t_ *)new_blpapi_CorrelationId_t___SWIG_3(arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_CorrelationId(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[3] = { - 0 - }; - Py_ssize_t ii; - - if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? PyObject_Length(args) : 0; - for (ii = 0; (ii < 2) && (ii < argc); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } - if (argc == 0) { - return _wrap_new_CorrelationId__SWIG_0(self, args); - } - if (argc == 1) { - int _v; - { - int res = SWIG_AsVal_long_SS_long(argv[0], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_new_CorrelationId__SWIG_2(self, args); - } - } - if (argc == 1) { - int _v; - _v = (argv[0] != 0); - if (_v) { - return _wrap_new_CorrelationId__SWIG_4(self, args); - } - } - if (argc == 2) { - int _v; - { - int res = SWIG_AsVal_long_SS_long(argv[0], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - { - int res = SWIG_AsVal_unsigned_SS_short(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_new_CorrelationId__SWIG_1(self, args); - } - } - } - if (argc == 2) { - int _v; - _v = (argv[0] != 0); - if (_v) { - { - int res = SWIG_AsVal_unsigned_SS_short(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_new_CorrelationId__SWIG_3(self, args); - } - } - } - -fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_CorrelationId'.\n" - " Possible C/C++ prototypes are:\n" - " blpapi_CorrelationId_t_::blpapi_CorrelationId_t_()\n" - " blpapi_CorrelationId_t_::blpapi_CorrelationId_t_(long long,unsigned short)\n" - " blpapi_CorrelationId_t_::blpapi_CorrelationId_t_(long long)\n" - " blpapi_CorrelationId_t_::blpapi_CorrelationId_t_(PyObject *,unsigned short)\n" - " blpapi_CorrelationId_t_::blpapi_CorrelationId_t_(PyObject *)\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_delete_CorrelationId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_CorrelationId",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_CorrelationId" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - delete_blpapi_CorrelationId_t_(arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId_type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - unsigned short result; - - if (!PyArg_ParseTuple(args,(char *)"O:CorrelationId_type",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId_type" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ const *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - result = (unsigned short)blpapi_CorrelationId_t__type((blpapi_CorrelationId_t_ const *)arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId_classId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - unsigned short result; - - if (!PyArg_ParseTuple(args,(char *)"O:CorrelationId_classId",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId_classId" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ const *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - result = (unsigned short)blpapi_CorrelationId_t__classId((blpapi_CorrelationId_t_ const *)arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId___asObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:CorrelationId___asObject",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId___asObject" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ const *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - result = (PyObject *)blpapi_CorrelationId_t____asObject((blpapi_CorrelationId_t_ const *)arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - { - resultobj = result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId___asInteger(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - long long result; - - if (!PyArg_ParseTuple(args,(char *)"O:CorrelationId___asInteger",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId___asInteger" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ const *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - result = (long long)blpapi_CorrelationId_t____asInteger((blpapi_CorrelationId_t_ const *)arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_CorrelationId___toInteger(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_CorrelationId_t_ *arg1 = (blpapi_CorrelationId_t_ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - long long result; - - if (!PyArg_ParseTuple(args,(char *)"O:CorrelationId___toInteger",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CorrelationId___toInteger" "', argument " "1"" of type '" "blpapi_CorrelationId_t_ const *""'"); - } - arg1 = reinterpret_cast< blpapi_CorrelationId_t_ * >(argp1); - - try { - result = (long long)blpapi_CorrelationId_t____toInteger((blpapi_CorrelationId_t_ const *)arg1); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *CorrelationId_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementFloat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Float64_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - double val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementFloat",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementFloat" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementFloat" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementFloat" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_double(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Element_setElementFloat" "', argument " "4"" of type '" "blpapi_Float64_t""'"); - } - arg4 = static_cast< blpapi_Float64_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementFloat(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueFloat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Float64_t arg2 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueFloat",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueFloat" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_double(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_setValueFloat" "', argument " "2"" of type '" "blpapi_Float64_t""'"); - } - arg2 = static_cast< blpapi_Float64_t >(val2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueFloat" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueFloat(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_printHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - std::string result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_printHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_printHelper" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_printHelper" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_printHelper" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Element_printHelper(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_name" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_Element_name((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_nameString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_nameString",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_nameString" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Element_nameString((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_definition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_SchemaElementDefinition_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_definition",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_definition" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SchemaElementDefinition_t *)blpapi_Element_definition((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_datatype(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_datatype",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_datatype" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_datatype((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_isComplexType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_isComplexType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_isComplexType" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_isComplexType((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_isArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_isArray",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_isArray" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_isArray((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_isReadOnly(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_isReadOnly",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_isReadOnly" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_isReadOnly((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_numValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_numValues",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_numValues" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Element_numValues((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_numElements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_numElements",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_numElements" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Element_numElements((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_isNullValue(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_isNullValue",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_isNullValue" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_isNullValue" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_isNullValue((blpapi_Element const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_isNull(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_isNull",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_isNull" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_isNull((blpapi_Element const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getElementAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getElementAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getElementAt" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getElementAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getElementAt((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - char *arg3 = (char *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_getElement",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getElement" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_getElement" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_getElement" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getElement((blpapi_Element const *)arg1,arg2,(char const *)arg3,(blpapi_Name const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_hasElementEx(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - int arg4 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_Element_hasElementEx",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_hasElementEx" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_hasElementEx" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_hasElementEx" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Element_hasElementEx" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_Element_hasElementEx" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_hasElementEx((blpapi_Element const *)arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsBool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Bool_t *arg2 = (blpapi_Bool_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Bool_t temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsBool",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsBool" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsBool" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsBool((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsChar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Char_t *arg2 = (blpapi_Char_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_getValueAsChar",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsChar" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_getValueAsChar" "', argument " "2"" of type '" "blpapi_Char_t *""'"); - } - arg2 = reinterpret_cast< blpapi_Char_t * >(buf2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsChar" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsChar((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Int32_t *arg2 = (blpapi_Int32_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_getValueAsInt32",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsInt32" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_getValueAsInt32" "', argument " "2"" of type '" "blpapi_Int32_t *""'"); - } - arg2 = reinterpret_cast< blpapi_Int32_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsInt32" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsInt32((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Int64_t *arg2 = (blpapi_Int64_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Int64_t temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsInt64",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsInt64" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsInt64" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsInt64((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_long_long, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Float64_t *arg2 = (blpapi_Float64_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Float64_t temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsFloat64",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsFloat64" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsFloat64" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsFloat64((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_double, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char **arg2 = (char **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsString",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsString" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsString" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsString((blpapi_Element const *)arg1,(char const **)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Datetime_t *arg2 = (blpapi_Datetime_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = new blpapi_Datetime_t; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsDatetime",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsDatetime" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsDatetime" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsDatetime((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((arg2), SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_OWN)); - arg2 = 0; - if(arg2) delete arg2; - return resultobj; -fail: - if(arg2) delete arg2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsHighPrecisionDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_HighPrecisionDatetime_t *arg2 = (blpapi_HighPrecisionDatetime_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_getValueAsHighPrecisionDatetime",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsHighPrecisionDatetime" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_getValueAsHighPrecisionDatetime" "', argument " "2"" of type '" "blpapi_HighPrecisionDatetime_t *""'"); - } - arg2 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsHighPrecisionDatetime" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsHighPrecisionDatetime((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsElement",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsElement" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsElement" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsElement((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getValueAsName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Name_t **arg2 = (blpapi_Name_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Name_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Element_getValueAsName",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getValueAsName" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_getValueAsName" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getValueAsName((blpapi_Element const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Name, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_getChoice(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_getChoice",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_getChoice" "', argument " "1"" of type '" "blpapi_Element_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_getChoice((blpapi_Element const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueBool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Bool_t arg2 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueBool",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueBool" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_setValueBool" "', argument " "2"" of type '" "blpapi_Bool_t""'"); - } - arg2 = static_cast< blpapi_Bool_t >(val2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueBool" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueBool(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Int32_t arg2 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueInt32",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueInt32" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_setValueInt32" "', argument " "2"" of type '" "blpapi_Int32_t""'"); - } - arg2 = static_cast< blpapi_Int32_t >(val2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueInt32" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueInt32(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Int64_t arg2 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - long long val2 ; - int ecode2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueInt64",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueInt64" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Element_setValueInt64" "', argument " "2"" of type '" "blpapi_Int64_t""'"); - } - arg2 = static_cast< blpapi_Int64_t >(val2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueInt64" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueInt64(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueString",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueString" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setValueString" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueString" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueString(arg1,(char const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Datetime_t *arg2 = (blpapi_Datetime_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueDatetime",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueDatetime" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setValueDatetime" "', argument " "2"" of type '" "blpapi_Datetime_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Datetime_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueDatetime" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueDatetime(arg1,(blpapi_Datetime_tag const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueHighPrecisionDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_HighPrecisionDatetime_t *arg2 = (blpapi_HighPrecisionDatetime_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueHighPrecisionDatetime",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueHighPrecisionDatetime" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setValueHighPrecisionDatetime" "', argument " "2"" of type '" "blpapi_HighPrecisionDatetime_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueHighPrecisionDatetime" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueHighPrecisionDatetime(arg1,(blpapi_HighPrecisionDatetime_tag const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setValueFromName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Name_t *arg2 = (blpapi_Name_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Element_setValueFromName",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setValueFromName" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setValueFromName" "', argument " "2"" of type '" "blpapi_Name_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Name_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Element_setValueFromName" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setValueFromName(arg1,(blpapi_Name const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementBool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Bool_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementBool",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementBool" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementBool" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementBool" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Element_setElementBool" "', argument " "4"" of type '" "blpapi_Bool_t""'"); - } - arg4 = static_cast< blpapi_Bool_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementBool(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Int32_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementInt32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementInt32" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementInt32" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementInt32" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Element_setElementInt32" "', argument " "4"" of type '" "blpapi_Int32_t""'"); - } - arg4 = static_cast< blpapi_Int32_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementInt32(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Int64_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - long long val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementInt64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementInt64" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementInt64" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementInt64" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Element_setElementInt64" "', argument " "4"" of type '" "blpapi_Int64_t""'"); - } - arg4 = static_cast< blpapi_Int64_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementInt64(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - char *arg4 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementString",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementString" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementString" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementString" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_setElementString" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementString(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(char const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Datetime_t *arg4 = (blpapi_Datetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementDatetime",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementDatetime" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementDatetime" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementDatetime" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_setElementDatetime" "', argument " "4"" of type '" "blpapi_Datetime_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Datetime_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementDatetime(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(blpapi_Datetime_tag const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementHighPrecisionDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_HighPrecisionDatetime_t *arg4 = (blpapi_HighPrecisionDatetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementHighPrecisionDatetime",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementHighPrecisionDatetime" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementHighPrecisionDatetime" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementHighPrecisionDatetime" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_setElementHighPrecisionDatetime" "', argument " "4"" of type '" "blpapi_HighPrecisionDatetime_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementHighPrecisionDatetime(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(blpapi_HighPrecisionDatetime_tag const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setElementFromName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setElementFromName",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setElementFromName" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Element_setElementFromName" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setElementFromName" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_setElementFromName" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setElementFromName(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(blpapi_Name const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_appendElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Element_appendElement",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_appendElement" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_appendElement(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Element_setChoice(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Element_t *arg1 = (blpapi_Element_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - char *arg3 = (char *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - size_t arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - size_t val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Element_setChoice",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Element_setChoice" "', argument " "1"" of type '" "blpapi_Element_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Element_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Element_setChoice" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Element_setChoice" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - ecode5 = SWIG_AsVal_size_t(obj3, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_Element_setChoice" "', argument " "5"" of type '" "size_t""'"); - } - arg5 = static_cast< size_t >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Element_setChoice(arg1,arg2,(char const *)arg3,(blpapi_Name const *)arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueFloat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Float64_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - double val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueFloat",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueFloat" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueFloat" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueFloat" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_double(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_setValueFloat" "', argument " "4"" of type '" "blpapi_Float64_t""'"); - } - arg4 = static_cast< blpapi_Float64_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueFloat(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueFloat(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Float64_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueFloat",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueFloat" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - ecode2 = SWIG_AsVal_double(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventFormatter_appendValueFloat" "', argument " "2"" of type '" "blpapi_Float64_t""'"); - } - arg2 = static_cast< blpapi_Float64_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueFloat(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Event_t *arg1 = (blpapi_Event_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_EventFormatter_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventFormatter_create",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_create" "', argument " "1"" of type '" "blpapi_Event_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Event_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_EventFormatter_t *)blpapi_EventFormatter_create(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventFormatter_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_destroy" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_EventFormatter_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendMessage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Topic_t *arg4 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_appendMessage",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendMessage" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendMessage" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_appendMessage" "', argument " "3"" of type '" "blpapi_Name_t *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_EventFormatter_appendMessage" "', argument " "4"" of type '" "blpapi_Topic_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Topic_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendMessage(arg1,(char const *)arg2,arg3,(blpapi_Topic const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendMessageSeq(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Topic_t *arg4 = (blpapi_Topic_t *) 0 ; - unsigned int arg5 ; - unsigned int arg6 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - unsigned int val5 ; - int ecode5 = 0 ; - unsigned int val6 ; - int ecode6 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:blpapi_EventFormatter_appendMessageSeq",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "3"" of type '" "blpapi_Name_t *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "4"" of type '" "blpapi_Topic_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Topic_t * >(argp4); - ecode5 = SWIG_AsVal_unsigned_SS_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "5"" of type '" "unsigned int""'"); - } - arg5 = static_cast< unsigned int >(val5); - ecode6 = SWIG_AsVal_unsigned_SS_int(obj5, &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "blpapi_EventFormatter_appendMessageSeq" "', argument " "6"" of type '" "unsigned int""'"); - } - arg6 = static_cast< unsigned int >(val6); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendMessageSeq(arg1,(char const *)arg2,arg3,(blpapi_Topic const *)arg4,arg5,arg6); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendResponse(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_EventFormatter_appendResponse",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendResponse" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendResponse" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_appendResponse" "', argument " "3"" of type '" "blpapi_Name_t *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendResponse(arg1,(char const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendRecapMessage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Topic_t *arg2 = (blpapi_Topic_t *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_EventFormatter_appendRecapMessage",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendRecapMessage" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendRecapMessage" "', argument " "2"" of type '" "blpapi_Topic_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Topic_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_appendRecapMessage" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendRecapMessage(arg1,(blpapi_Topic const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendRecapMessageSeq(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Topic_t *arg2 = (blpapi_Topic_t *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - unsigned int arg4 ; - unsigned int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - unsigned int val4 ; - int ecode4 = 0 ; - unsigned int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_EventFormatter_appendRecapMessageSeq",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendRecapMessageSeq" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendRecapMessageSeq" "', argument " "2"" of type '" "blpapi_Topic_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Topic_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_appendRecapMessageSeq" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - ecode4 = SWIG_AsVal_unsigned_SS_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_appendRecapMessageSeq" "', argument " "4"" of type '" "unsigned int""'"); - } - arg4 = static_cast< unsigned int >(val4); - ecode5 = SWIG_AsVal_unsigned_SS_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_EventFormatter_appendRecapMessageSeq" "', argument " "5"" of type '" "unsigned int""'"); - } - arg5 = static_cast< unsigned int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendRecapMessageSeq(arg1,(blpapi_Topic const *)arg2,(blpapi_CorrelationId_t_ const *)arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueBool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Bool_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueBool",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueBool" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueBool" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueBool" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_setValueBool" "', argument " "4"" of type '" "blpapi_Bool_t""'"); - } - arg4 = static_cast< blpapi_Bool_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueBool(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueChar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - char arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - char val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueChar",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueChar" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueChar" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueChar" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_char(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_setValueChar" "', argument " "4"" of type '" "char""'"); - } - arg4 = static_cast< char >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueChar(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Int32_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueInt32",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueInt32" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueInt32" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueInt32" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_setValueInt32" "', argument " "4"" of type '" "blpapi_Int32_t""'"); - } - arg4 = static_cast< blpapi_Int32_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueInt32(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Int64_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - long long val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueInt64",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueInt64" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueInt64" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueInt64" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_long_SS_long(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_EventFormatter_setValueInt64" "', argument " "4"" of type '" "blpapi_Int64_t""'"); - } - arg4 = static_cast< blpapi_Int64_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueInt64(arg1,(char const *)arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Datetime_t *arg4 = (blpapi_Datetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueDatetime",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueDatetime" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueDatetime" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueDatetime" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_EventFormatter_setValueDatetime" "', argument " "4"" of type '" "blpapi_Datetime_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Datetime_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueDatetime(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(blpapi_Datetime_tag const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - char *arg4 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueString",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueString" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueString" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueString" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_EventFormatter_setValueString" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueString(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(char const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueFromName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_EventFormatter_setValueFromName",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueFromName" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueFromName" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueFromName" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_EventFormatter_setValueFromName" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueFromName(arg1,(char const *)arg2,(blpapi_Name const *)arg3,(blpapi_Name const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_setValueNull(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_EventFormatter_setValueNull",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_setValueNull" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_setValueNull" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_setValueNull" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_setValueNull(arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_pushElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_EventFormatter_pushElement",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_pushElement" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_pushElement" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_EventFormatter_pushElement" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_pushElement(arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_popElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventFormatter_popElement",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_popElement" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_popElement(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueBool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Bool_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueBool",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueBool" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventFormatter_appendValueBool" "', argument " "2"" of type '" "blpapi_Bool_t""'"); - } - arg2 = static_cast< blpapi_Bool_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueBool(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueChar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueChar",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueChar" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - ecode2 = SWIG_AsVal_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventFormatter_appendValueChar" "', argument " "2"" of type '" "char""'"); - } - arg2 = static_cast< char >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueChar(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueInt32(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Int32_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueInt32",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueInt32" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventFormatter_appendValueInt32" "', argument " "2"" of type '" "blpapi_Int32_t""'"); - } - arg2 = static_cast< blpapi_Int32_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueInt32(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Int64_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long long val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueInt64",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueInt64" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventFormatter_appendValueInt64" "', argument " "2"" of type '" "blpapi_Int64_t""'"); - } - arg2 = static_cast< blpapi_Int64_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueInt64(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Datetime_t *arg2 = (blpapi_Datetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueDatetime",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueDatetime" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendValueDatetime" "', argument " "2"" of type '" "blpapi_Datetime_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Datetime_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueDatetime(arg1,(blpapi_Datetime_tag const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueString",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueString" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendValueString" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueString(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendValueFromName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - blpapi_Name_t *arg2 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventFormatter_appendValueFromName",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendValueFromName" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_EventFormatter_appendValueFromName" "', argument " "2"" of type '" "blpapi_Name_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Name_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendValueFromName(arg1,(blpapi_Name const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventFormatter_appendElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventFormatter_t *arg1 = (blpapi_EventFormatter_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventFormatter_appendElement",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventFormatter, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventFormatter_appendElement" "', argument " "1"" of type '" "blpapi_EventFormatter_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventFormatter_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventFormatter_appendElement(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Session_createHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - blpapi_EventDispatcher_t *arg3 = (blpapi_EventDispatcher_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - blpapi_Session_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:Session_createHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_createHelper" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - { - arg2 = obj1; - } - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Session_createHelper" "', argument " "3"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg3 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp3); - - try { - result = (blpapi_Session_t *)Session_createHelper(arg1,arg2,arg3); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Session, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Session_destroyHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:Session_destroyHelper",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_destroyHelper" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - { - arg2 = obj1; - } - - try { - Session_destroyHelper(arg1,arg2); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventDispatcher_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - size_t arg1 ; - size_t val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_EventDispatcher_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventDispatcher_create",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_size_t(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "blpapi_EventDispatcher_create" "', argument " "1"" of type '" "size_t""'"); - } - arg1 = static_cast< size_t >(val1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_EventDispatcher_t *)blpapi_EventDispatcher_create(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventDispatcher_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventDispatcher_t *arg1 = (blpapi_EventDispatcher_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventDispatcher_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventDispatcher_destroy" "', argument " "1"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_EventDispatcher_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventDispatcher_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventDispatcher_t *arg1 = (blpapi_EventDispatcher_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventDispatcher_start",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventDispatcher_start" "', argument " "1"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventDispatcher_start(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventDispatcher_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventDispatcher_t *arg1 = (blpapi_EventDispatcher_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventDispatcher_stop",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventDispatcher_stop" "', argument " "1"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventDispatcher_stop" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventDispatcher_stop(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ProviderSession_createHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - blpapi_EventDispatcher_t *arg3 = (blpapi_EventDispatcher_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - blpapi_ProviderSession_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:ProviderSession_createHelper",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ProviderSession_createHelper" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - { - arg2 = obj1; - } - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ProviderSession_createHelper" "', argument " "3"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg3 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp3); - - try { - result = (blpapi_ProviderSession_t *)ProviderSession_createHelper(arg1,arg2,arg3); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ProviderSession_destroyHelper(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:ProviderSession_destroyHelper",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ProviderSession_destroyHelper" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - { - arg2 = obj1; - } - - try { - ProviderSession_destroyHelper(arg1,arg2); - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_getLastErrorDescription(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_getLastErrorDescription",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "blpapi_getLastErrorDescription" "', argument " "1"" of type '" "int""'"); - } - arg1 = static_cast< int >(val1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_getLastErrorDescription(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_SessionOptions_create")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SessionOptions_t *)blpapi_SessionOptions_create(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_destroy" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setServerHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setServerHost",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setServerHost" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setServerHost" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setServerHost(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setServerPort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - unsigned short arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setServerPort",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setServerPort" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setServerPort" "', argument " "2"" of type '" "unsigned short""'"); - } - arg2 = static_cast< unsigned short >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setServerPort(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setServerAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - unsigned short arg3 ; - size_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - unsigned short val3 ; - int ecode3 = 0 ; - size_t val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_SessionOptions_setServerAddress",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setServerAddress" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setServerAddress" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SessionOptions_setServerAddress" "', argument " "3"" of type '" "unsigned short""'"); - } - arg3 = static_cast< unsigned short >(val3); - ecode4 = SWIG_AsVal_size_t(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_SessionOptions_setServerAddress" "', argument " "4"" of type '" "size_t""'"); - } - arg4 = static_cast< size_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setServerAddress(arg1,(char const *)arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_removeServerAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_removeServerAddress",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_removeServerAddress" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_removeServerAddress" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_removeServerAddress(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setConnectTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - unsigned int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setConnectTimeout",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setConnectTimeout" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setConnectTimeout" "', argument " "2"" of type '" "unsigned int""'"); - } - arg2 = static_cast< unsigned int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setConnectTimeout(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setDefaultServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setDefaultServices",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setDefaultServices" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setDefaultServices" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setDefaultServices(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setDefaultSubscriptionService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setDefaultSubscriptionService",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setDefaultSubscriptionService" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setDefaultSubscriptionService" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setDefaultSubscriptionService(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setDefaultTopicPrefix(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setDefaultTopicPrefix",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setDefaultTopicPrefix" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setDefaultTopicPrefix" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setDefaultTopicPrefix(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setClientMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setClientMode",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setClientMode" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setClientMode" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setClientMode(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setMaxPendingRequests(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setMaxPendingRequests",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setMaxPendingRequests" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setMaxPendingRequests" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setMaxPendingRequests(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setAutoRestartOnDisconnection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setAutoRestartOnDisconnection",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setAutoRestartOnDisconnection" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setAutoRestartOnDisconnection" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setAutoRestartOnDisconnection(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setAuthenticationOptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setAuthenticationOptions",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setAuthenticationOptions" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SessionOptions_setAuthenticationOptions" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setAuthenticationOptions(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setNumStartAttempts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setNumStartAttempts",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setNumStartAttempts" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setNumStartAttempts" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setNumStartAttempts(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setMaxEventQueueSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setMaxEventQueueSize",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setMaxEventQueueSize" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setMaxEventQueueSize" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setMaxEventQueueSize(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - float arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - float val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_float(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark" "', argument " "2"" of type '" "float""'"); - } - arg2 = static_cast< float >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - float arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - float val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_float(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark" "', argument " "2"" of type '" "float""'"); - } - arg2 = static_cast< float >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setDefaultKeepAliveInactivityTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setDefaultKeepAliveInactivityTime",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setDefaultKeepAliveInactivityTime" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setDefaultKeepAliveInactivityTime" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setDefaultKeepAliveInactivityTime(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setKeepAliveEnabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setKeepAliveEnabled",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setKeepAliveEnabled" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setKeepAliveEnabled" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_setKeepAliveEnabled(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_serverHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_serverHost",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_serverHost" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SessionOptions_serverHost(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_serverPort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - unsigned int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_serverPort",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_serverPort" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (unsigned int)blpapi_SessionOptions_serverPort(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_numServerAddresses(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_numServerAddresses",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_numServerAddresses" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_numServerAddresses(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_getServerAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - char **arg2 = (char **) 0 ; - unsigned short *arg3 = (unsigned short *) 0 ; - size_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *tempServerHost2 = 0 ; - unsigned short tempServerPort2 = 0 ; - size_t val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &tempServerHost2; - arg3 = &tempServerPort2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SessionOptions_getServerAddress",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_getServerAddress" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - ecode4 = SWIG_AsVal_size_t(obj1, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_SessionOptions_getServerAddress" "', argument " "4"" of type '" "size_t""'"); - } - arg4 = static_cast< size_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_getServerAddress(arg1,(char const **)arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int(*arg3)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_connectTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - unsigned int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_connectTimeout",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_connectTimeout" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (unsigned int)blpapi_SessionOptions_connectTimeout(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_defaultServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_defaultServices",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_defaultServices" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SessionOptions_defaultServices(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_defaultSubscriptionService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_defaultSubscriptionService",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_defaultSubscriptionService" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SessionOptions_defaultSubscriptionService(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_defaultTopicPrefix(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_defaultTopicPrefix",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_defaultTopicPrefix" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SessionOptions_defaultTopicPrefix(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_clientMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_clientMode",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_clientMode" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_clientMode(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_maxPendingRequests(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_maxPendingRequests",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_maxPendingRequests" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_maxPendingRequests(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_autoRestartOnDisconnection(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_autoRestartOnDisconnection",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_autoRestartOnDisconnection" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_autoRestartOnDisconnection(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_authenticationOptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_authenticationOptions",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_authenticationOptions" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SessionOptions_authenticationOptions(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_numStartAttempts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_numStartAttempts",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_numStartAttempts" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_numStartAttempts(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_maxEventQueueSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_maxEventQueueSize",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_maxEventQueueSize" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SessionOptions_maxEventQueueSize(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_slowConsumerWarningHiWaterMark(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - float result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_slowConsumerWarningHiWaterMark",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_slowConsumerWarningHiWaterMark" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (float)blpapi_SessionOptions_slowConsumerWarningHiWaterMark(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_float(static_cast< float >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_slowConsumerWarningLoWaterMark(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - float result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_slowConsumerWarningLoWaterMark",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_slowConsumerWarningLoWaterMark" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (float)blpapi_SessionOptions_slowConsumerWarningLoWaterMark(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_float(static_cast< float >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_defaultKeepAliveInactivityTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_defaultKeepAliveInactivityTime",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_defaultKeepAliveInactivityTime" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_defaultKeepAliveInactivityTime(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_defaultKeepAliveResponseTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_defaultKeepAliveResponseTimeout",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_defaultKeepAliveResponseTimeout" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_defaultKeepAliveResponseTimeout(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_keepAliveEnabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_keepAliveEnabled",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_keepAliveEnabled" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_keepAliveEnabled(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SessionOptions_recordSubscriptionDataReceiveTimes",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SessionOptions_recordSubscriptionDataReceiveTimes" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_create",&obj0)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_create" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = reinterpret_cast< char * >(buf1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_Name_create((char const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Name_t *arg1 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_destroy" "', argument " "1"" of type '" "blpapi_Name_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Name_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Name_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_equalsStr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Name_t *arg1 = (blpapi_Name_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Name_equalsStr",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_equalsStr" "', argument " "1"" of type '" "blpapi_Name_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Name_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Name_equalsStr" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Name_equalsStr((blpapi_Name const *)arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_string(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Name_t *arg1 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_string",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_string" "', argument " "1"" of type '" "blpapi_Name_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Name_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Name_string((blpapi_Name const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_length(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Name_t *arg1 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_length",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_length" "', argument " "1"" of type '" "blpapi_Name_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Name_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Name_length((blpapi_Name const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Name_findName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Name_findName",&obj0)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Name_findName" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = reinterpret_cast< char * >(buf1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_Name_findName((char const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) delete[] buf1; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_SubscriptionList_create")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SubscriptionList_t *)blpapi_SubscriptionList_create(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SubscriptionList_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_destroy" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_SubscriptionList_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_addResolved(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_SubscriptionList_addResolved",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_addResolved" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SubscriptionList_addResolved" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_SubscriptionList_addResolved" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_addResolved(arg1,(char const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SubscriptionList_clear",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_clear" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_clear(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - blpapi_SubscriptionList_t *arg2 = (blpapi_SubscriptionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SubscriptionList_append",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_append" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SubscriptionList_append" "', argument " "2"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_append(arg1,(blpapi_SubscriptionList const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SubscriptionList_size",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_size" "', argument " "1"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_size((blpapi_SubscriptionList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_correlationIdAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_CorrelationId_t temp2 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SubscriptionList_correlationIdAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_correlationIdAt" "', argument " "1"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SubscriptionList_correlationIdAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_correlationIdAt((blpapi_SubscriptionList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(CorrelationId_t_clone(*arg2), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_OWN)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_topicStringAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - char **arg2 = (char **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SubscriptionList_topicStringAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_topicStringAt" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SubscriptionList_topicStringAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_topicStringAt(arg1,(char const **)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SubscriptionList_isResolvedAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SubscriptionList_t *arg1 = (blpapi_SubscriptionList_t *) 0 ; - int *arg2 = (int *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SubscriptionList_isResolvedAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SubscriptionList_isResolvedAt" "', argument " "1"" of type '" "blpapi_SubscriptionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_SubscriptionList_isResolvedAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SubscriptionList_isResolvedAt(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_parts_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_parts_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_parts_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_parts_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->parts = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_parts_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_parts_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_parts_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->parts); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_hours_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_hours_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_hours_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_hours_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->hours = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_hours_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_hours_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_hours_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->hours); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_minutes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_minutes_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_minutes_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_minutes_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->minutes = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_minutes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_minutes_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_minutes_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->minutes); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_seconds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_seconds_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_seconds_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_seconds_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->seconds = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_seconds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_seconds_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_seconds_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->seconds); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_milliSeconds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UInt16_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_milliSeconds_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_milliSeconds_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_milliSeconds_set" "', argument " "2"" of type '" "blpapi_UInt16_t""'"); - } - arg2 = static_cast< blpapi_UInt16_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->milliSeconds = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_milliSeconds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UInt16_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_milliSeconds_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_milliSeconds_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UInt16_t) ((arg1)->milliSeconds); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_month_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_month_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_month_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_month_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->month = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_month_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_month_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_month_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->month); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_day_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UChar_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_day_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_day_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_day_set" "', argument " "2"" of type '" "blpapi_UChar_t""'"); - } - arg2 = static_cast< blpapi_UChar_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->day = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_day_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UChar_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_day_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_day_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UChar_t) ((arg1)->day); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_year_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_UInt16_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_year_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_year_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_year_set" "', argument " "2"" of type '" "blpapi_UInt16_t""'"); - } - arg2 = static_cast< blpapi_UInt16_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->year = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_year_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UInt16_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_year_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_year_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UInt16_t) ((arg1)->year); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_offset_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - blpapi_Int16_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - short val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Datetime_tag_offset_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_offset_set" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - ecode2 = SWIG_AsVal_short(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Datetime_tag_offset_set" "', argument " "2"" of type '" "blpapi_Int16_t""'"); - } - arg2 = static_cast< blpapi_Int16_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->offset = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Datetime_tag_offset_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Int16_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Datetime_tag_offset_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Datetime_tag_offset_get" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Int16_t) ((arg1)->offset); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_short(static_cast< short >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_blpapi_Datetime_tag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":new_blpapi_Datetime_tag")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Datetime_tag *)new blpapi_Datetime_tag(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_blpapi_Datetime_tag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Datetime_tag *arg1 = (blpapi_Datetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_blpapi_Datetime_tag",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_blpapi_Datetime_tag" "', argument " "1"" of type '" "blpapi_Datetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_Datetime_tag * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - delete arg1; - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *blpapi_Datetime_tag_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_blpapi_Datetime_tag, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_tag_datetime_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *arg1 = (blpapi_HighPrecisionDatetime_tag *) 0 ; - blpapi_Datetime_t *arg2 = (blpapi_Datetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_HighPrecisionDatetime_tag_datetime_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_tag_datetime_set" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_tag * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_HighPrecisionDatetime_tag_datetime_set" "', argument " "2"" of type '" "blpapi_Datetime_t *""'"); - } - arg2 = reinterpret_cast< blpapi_Datetime_t * >(argp2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->datetime = *arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_tag_datetime_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *arg1 = (blpapi_HighPrecisionDatetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Datetime_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_HighPrecisionDatetime_tag_datetime_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_tag_datetime_get" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Datetime_t *)& ((arg1)->datetime); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Datetime_tag, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_tag_picoseconds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *arg1 = (blpapi_HighPrecisionDatetime_tag *) 0 ; - blpapi_UInt32_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_HighPrecisionDatetime_tag_picoseconds_set",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_tag_picoseconds_set" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_tag * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_HighPrecisionDatetime_tag_picoseconds_set" "', argument " "2"" of type '" "blpapi_UInt32_t""'"); - } - arg2 = static_cast< blpapi_UInt32_t >(val2); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - if (arg1) (arg1)->picoseconds = arg2; - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_tag_picoseconds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *arg1 = (blpapi_HighPrecisionDatetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_UInt32_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_HighPrecisionDatetime_tag_picoseconds_get",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_tag_picoseconds_get" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_tag * >(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_UInt32_t) ((arg1)->picoseconds); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_blpapi_HighPrecisionDatetime_tag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":new_blpapi_HighPrecisionDatetime_tag")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_HighPrecisionDatetime_tag *)new blpapi_HighPrecisionDatetime_tag(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_delete_blpapi_HighPrecisionDatetime_tag(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_tag *arg1 = (blpapi_HighPrecisionDatetime_tag *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:delete_blpapi_HighPrecisionDatetime_tag",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_blpapi_HighPrecisionDatetime_tag" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_tag *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_tag * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - delete arg1; - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *blpapi_HighPrecisionDatetime_tag_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_compare(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_t *arg1 = (blpapi_HighPrecisionDatetime_t *) 0 ; - blpapi_HighPrecisionDatetime_t *arg2 = (blpapi_HighPrecisionDatetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_HighPrecisionDatetime_compare",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_compare" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_HighPrecisionDatetime_compare" "', argument " "2"" of type '" "blpapi_HighPrecisionDatetime_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_HighPrecisionDatetime_compare((blpapi_HighPrecisionDatetime_tag const *)arg1,(blpapi_HighPrecisionDatetime_tag const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_print(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_t *arg1 = (blpapi_HighPrecisionDatetime_t *) 0 ; - blpapi_StreamWriter_t arg2 ; - void *arg3 = (void *) 0 ; - int arg4 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 ; - int res2 = 0 ; - int res3 ; - int val4 ; - int ecode4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_HighPrecisionDatetime_print",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp1); - { - res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_blpapi_StreamWriter_t, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "2"" of type '" "blpapi_StreamWriter_t""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "2"" of type '" "blpapi_StreamWriter_t""'"); - } else { - blpapi_StreamWriter_t * temp = reinterpret_cast< blpapi_StreamWriter_t * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "3"" of type '" "void *""'"); - } - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_HighPrecisionDatetime_print" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_HighPrecisionDatetime_print((blpapi_HighPrecisionDatetime_tag const *)arg1,arg2,arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_HighPrecisionDatetime_fromTimePoint(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_HighPrecisionDatetime_t *arg1 = (blpapi_HighPrecisionDatetime_t *) 0 ; - blpapi_TimePoint_t *arg2 = (blpapi_TimePoint_t *) 0 ; - short arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - short val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_HighPrecisionDatetime_fromTimePoint",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_HighPrecisionDatetime_tag, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_HighPrecisionDatetime_fromTimePoint" "', argument " "1"" of type '" "blpapi_HighPrecisionDatetime_t *""'"); - } - arg1 = reinterpret_cast< blpapi_HighPrecisionDatetime_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_TimePoint_t, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_HighPrecisionDatetime_fromTimePoint" "', argument " "2"" of type '" "blpapi_TimePoint_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_TimePoint_t * >(argp2); - ecode3 = SWIG_AsVal_short(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_HighPrecisionDatetime_fromTimePoint" "', argument " "3"" of type '" "short""'"); - } - arg3 = static_cast< short >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_HighPrecisionDatetime_fromTimePoint(arg1,(blpapi_TimePoint_t const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_name" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_Constant_name((blpapi_Constant const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_description" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Constant_description((blpapi_Constant const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_status",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_status" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_status((blpapi_Constant const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_datatype(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_datatype",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_datatype" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_datatype((blpapi_Constant const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_getValueAsInt64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - blpapi_Int64_t *arg2 = (blpapi_Int64_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Int64_t temp2 ; - int res2 = SWIG_TMPOBJ ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_getValueAsInt64",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_getValueAsInt64" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_getValueAsInt64((blpapi_Constant const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_long_long, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_getValueAsFloat64(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - blpapi_Float64_t *arg2 = (blpapi_Float64_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Float64_t temp2 ; - int res2 = SWIG_TMPOBJ ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_getValueAsFloat64",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_getValueAsFloat64" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_getValueAsFloat64((blpapi_Constant const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_double, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_getValueAsDatetime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - blpapi_Datetime_t *arg2 = (blpapi_Datetime_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = new blpapi_Datetime_t; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_getValueAsDatetime",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_getValueAsDatetime" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_getValueAsDatetime((blpapi_Constant const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((arg2), SWIGTYPE_p_blpapi_Datetime_tag, SWIG_POINTER_OWN)); - arg2 = 0; - if(arg2) delete arg2; - return resultobj; -fail: - if(arg2) delete arg2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Constant_getValueAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Constant_t *arg1 = (blpapi_Constant_t *) 0 ; - char **arg2 = (char **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Constant_getValueAsString",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Constant_getValueAsString" "', argument " "1"" of type '" "blpapi_Constant_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Constant_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Constant_getValueAsString((blpapi_Constant const *)arg1,(char const **)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ConstantList_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_name" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_ConstantList_name((blpapi_ConstantList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ConstantList_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_description" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_ConstantList_description((blpapi_ConstantList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_numConstants(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ConstantList_numConstants",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_numConstants" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ConstantList_numConstants((blpapi_ConstantList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_datatype(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ConstantList_datatype",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_datatype" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ConstantList_datatype((blpapi_ConstantList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ConstantList_status",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_status" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ConstantList_status((blpapi_ConstantList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_getConstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - blpapi_Constant_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ConstantList_getConstant",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_getConstant" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ConstantList_getConstant" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ConstantList_getConstant" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Constant_t *)blpapi_ConstantList_getConstant((blpapi_ConstantList const *)arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ConstantList_getConstantAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ConstantList_t *arg1 = (blpapi_ConstantList_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_Constant_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ConstantList_getConstantAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ConstantList_getConstantAt" "', argument " "1"" of type '" "blpapi_ConstantList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ConstantList_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_ConstantList_getConstantAt" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Constant_t *)blpapi_ConstantList_getConstantAt((blpapi_ConstantList const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Constant, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_name" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_SchemaElementDefinition_name((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_description" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SchemaElementDefinition_description((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_status",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_status" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaElementDefinition_status((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_SchemaTypeDefinition_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_type",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_type" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SchemaTypeDefinition_t *)blpapi_SchemaElementDefinition_type((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_numAlternateNames(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_numAlternateNames",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_numAlternateNames" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaElementDefinition_numAlternateNames((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_getAlternateName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SchemaElementDefinition_getAlternateName",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_getAlternateName" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SchemaElementDefinition_getAlternateName" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_SchemaElementDefinition_getAlternateName((void *const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_minValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_minValues",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_minValues" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaElementDefinition_minValues((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaElementDefinition_maxValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaElementDefinition_t *arg1 = (blpapi_SchemaElementDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaElementDefinition_maxValues",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaElementDefinition_maxValues" "', argument " "1"" of type '" "blpapi_SchemaElementDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaElementDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaElementDefinition_maxValues((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_name" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_SchemaTypeDefinition_name((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_description" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_SchemaTypeDefinition_description((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_status",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_status" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaTypeDefinition_status((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_datatype(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_datatype",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_datatype" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaTypeDefinition_datatype((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_isComplexType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_isComplexType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_isComplexType" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaTypeDefinition_isComplexType((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_isSimpleType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_isSimpleType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_isSimpleType" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaTypeDefinition_isSimpleType((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_isEnumerationType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_isEnumerationType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_isEnumerationType" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_SchemaTypeDefinition_isEnumerationType((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_numElementDefinitions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - size_t result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_numElementDefinitions",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_numElementDefinitions" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_SchemaTypeDefinition_numElementDefinitions((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_size_t(static_cast< size_t >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_getElementDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - blpapi_SchemaElementDefinition_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_SchemaTypeDefinition_getElementDefinition",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_getElementDefinition" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_SchemaTypeDefinition_getElementDefinition" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_SchemaTypeDefinition_getElementDefinition" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SchemaElementDefinition_t *)blpapi_SchemaTypeDefinition_getElementDefinition((void *const *)arg1,(char const *)arg2,(blpapi_Name const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_void, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_getElementDefinitionAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_SchemaElementDefinition_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_SchemaTypeDefinition_getElementDefinitionAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_getElementDefinitionAt" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_SchemaTypeDefinition_getElementDefinitionAt" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_SchemaElementDefinition_t *)blpapi_SchemaTypeDefinition_getElementDefinitionAt((void *const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_SchemaTypeDefinition_enumeration(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SchemaTypeDefinition_t *arg1 = (blpapi_SchemaTypeDefinition_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_ConstantList_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_SchemaTypeDefinition_enumeration",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_p_void, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_SchemaTypeDefinition_enumeration" "', argument " "1"" of type '" "blpapi_SchemaTypeDefinition_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_SchemaTypeDefinition_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_ConstantList_t *)blpapi_SchemaTypeDefinition_enumeration((void *const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ConstantList, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Request_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Request_t *arg1 = (blpapi_Request_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Request_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Request, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Request_destroy" "', argument " "1"" of type '" "blpapi_Request_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Request_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Request_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Request_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Request_t *arg1 = (blpapi_Request_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Element_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Request_elements",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Request, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Request_elements" "', argument " "1"" of type '" "blpapi_Request_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Request_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Element_t *)blpapi_Request_elements(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Element, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Request_setPreferredRoute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Request_t *arg1 = (blpapi_Request_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Request_setPreferredRoute",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Request, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Request_setPreferredRoute" "', argument " "1"" of type '" "blpapi_Request_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Request_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Request_setPreferredRoute" "', argument " "2"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg2 = reinterpret_cast< blpapi_CorrelationId_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Request_setPreferredRoute(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Operation_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Operation_t *arg1 = (blpapi_Operation_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Operation_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Operation, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Operation_name" "', argument " "1"" of type '" "blpapi_Operation_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Operation_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Operation_name(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Operation_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Operation_t *arg1 = (blpapi_Operation_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Operation_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Operation, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Operation_description" "', argument " "1"" of type '" "blpapi_Operation_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Operation_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Operation_description(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Operation_requestDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Operation_t *arg1 = (blpapi_Operation_t *) 0 ; - blpapi_SchemaElementDefinition_t **arg2 = (blpapi_SchemaElementDefinition_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_SchemaElementDefinition_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Operation_requestDefinition",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Operation, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Operation_requestDefinition" "', argument " "1"" of type '" "blpapi_Operation_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Operation_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Operation_requestDefinition(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_p_void, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Operation_numResponseDefinitions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Operation_t *arg1 = (blpapi_Operation_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Operation_numResponseDefinitions",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Operation, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Operation_numResponseDefinitions" "', argument " "1"" of type '" "blpapi_Operation_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Operation_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Operation_numResponseDefinitions(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Operation_responseDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Operation_t *arg1 = (blpapi_Operation_t *) 0 ; - blpapi_SchemaElementDefinition_t **arg2 = (blpapi_SchemaElementDefinition_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_SchemaElementDefinition_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Operation_responseDefinition",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Operation, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Operation_responseDefinition" "', argument " "1"" of type '" "blpapi_Operation_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Operation_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Operation_responseDefinition" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Operation_responseDefinition(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_p_void, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_name",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_name" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Service_name(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_description(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_description",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_description" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Service_description(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_numOperations(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_numOperations",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_numOperations" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_numOperations(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_numEventDefinitions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_numEventDefinitions",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_numEventDefinitions" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_numEventDefinitions(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_addRef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_addRef",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_addRef" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_addRef(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_release",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_release" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Service_release(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_authorizationServiceName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_authorizationServiceName",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_authorizationServiceName" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Service_authorizationServiceName(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_getOperation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Operation_t **arg2 = (blpapi_Operation_t **) 0 ; - char *arg3 = (char *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Operation_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Service_getOperation",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_getOperation" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_getOperation" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Service_getOperation" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_getOperation(arg1,arg2,(char const *)arg3,(blpapi_Name const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Operation, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_getOperationAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Operation_t **arg2 = (blpapi_Operation_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Operation_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Service_getOperationAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_getOperationAt" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Service_getOperationAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_getOperationAt(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Operation, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_getEventDefinition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_SchemaElementDefinition_t **arg2 = (blpapi_SchemaElementDefinition_t **) 0 ; - char *arg3 = (char *) 0 ; - blpapi_Name_t *arg4 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_SchemaElementDefinition_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_Service_getEventDefinition",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_getEventDefinition" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_getEventDefinition" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Service_getEventDefinition" "', argument " "4"" of type '" "blpapi_Name_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Name_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_getEventDefinition(arg1,arg2,(char const *)arg3,(blpapi_Name const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_p_void, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_getEventDefinitionAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_SchemaElementDefinition_t **arg2 = (blpapi_SchemaElementDefinition_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_SchemaElementDefinition_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Service_getEventDefinitionAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_getEventDefinitionAt" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Service_getEventDefinitionAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_getEventDefinitionAt(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_p_void, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_createRequest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Request_t **arg2 = (blpapi_Request_t **) 0 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Request_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Service_createRequest",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_createRequest" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_createRequest" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_createRequest(arg1,arg2,(char const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Request, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_createAuthorizationRequest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Request_t **arg2 = (blpapi_Request_t **) 0 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Request_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Service_createAuthorizationRequest",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_createAuthorizationRequest" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Service_createAuthorizationRequest" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_createAuthorizationRequest(arg1,arg2,(char const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Request, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_createPublishEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_createPublishEvent",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_createPublishEvent" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_createPublishEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_createAdminEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Service_createAdminEvent",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_createAdminEvent" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_createAdminEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Service_createResponseEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Service_t *arg1 = (blpapi_Service_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - blpapi_Event_t **arg3 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - blpapi_Event_t *temp3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg3 = &temp3; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Service_createResponseEvent",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Service_createResponseEvent" "', argument " "1"" of type '" "blpapi_Service_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Service_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Service_createResponseEvent" "', argument " "2"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_CorrelationId_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Service_createResponseEvent(arg1,(blpapi_CorrelationId_t_ const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg3), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_messageType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Name_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_messageType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_messageType" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Name_t *)blpapi_Message_messageType((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Name, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_topicName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - char *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_topicName",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_topicName" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (char *)blpapi_Message_topicName((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_service(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Service_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_service",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_service" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Service_t *)blpapi_Message_service((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Service, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_numCorrelationIds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_numCorrelationIds",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_numCorrelationIds" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Message_numCorrelationIds((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_correlationId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_CorrelationId_t result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Message_correlationId",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_correlationId" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - ecode2 = SWIG_AsVal_size_t(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_Message_correlationId" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = blpapi_Message_correlationId((blpapi_Message const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(CorrelationId_t_clone(result), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_OWN)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Element_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_elements",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_elements" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Element_t *)blpapi_Message_elements((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Element, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_fragmentType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_fragmentType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_fragmentType" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Message_fragmentType((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_addRef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_addRef",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_addRef" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Message_addRef((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Message_release",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_release" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Message_release((blpapi_Message const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Message_timeReceived(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - blpapi_TimePoint_t *arg2 = (blpapi_TimePoint_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Message_timeReceived",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Message_timeReceived" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_TimePoint_t, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Message_timeReceived" "', argument " "2"" of type '" "blpapi_TimePoint_t *""'"); - } - arg2 = reinterpret_cast< blpapi_TimePoint_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Message_timeReceived((blpapi_Message const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Event_eventType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Event_t *arg1 = (blpapi_Event_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Event_eventType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Event_eventType" "', argument " "1"" of type '" "blpapi_Event_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Event_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Event_eventType((blpapi_Event const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Event_release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Event_t *arg1 = (blpapi_Event_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Event_release",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Event_release" "', argument " "1"" of type '" "blpapi_Event_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Event_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Event_release((blpapi_Event const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventQueue_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventQueue_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_EventQueue_create")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_EventQueue_t *)blpapi_EventQueue_create(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventQueue_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventQueue_t *arg1 = (blpapi_EventQueue_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventQueue_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventQueue_destroy" "', argument " "1"" of type '" "blpapi_EventQueue_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventQueue_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventQueue_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventQueue_nextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventQueue_t *arg1 = (blpapi_EventQueue_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_Event_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_EventQueue_nextEvent",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventQueue_nextEvent" "', argument " "1"" of type '" "blpapi_EventQueue_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventQueue_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_EventQueue_nextEvent" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Event_t *)blpapi_EventQueue_nextEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Event, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventQueue_purge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventQueue_t *arg1 = (blpapi_EventQueue_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventQueue_purge",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventQueue_purge" "', argument " "1"" of type '" "blpapi_EventQueue_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventQueue_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventQueue_purge(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_EventQueue_tryNextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_EventQueue_t *arg1 = (blpapi_EventQueue_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_EventQueue_tryNextEvent",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_EventQueue_tryNextEvent" "', argument " "1"" of type '" "blpapi_EventQueue_t *""'"); - } - arg1 = reinterpret_cast< blpapi_EventQueue_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_EventQueue_tryNextEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_MessageIterator_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Event_t *arg1 = (blpapi_Event_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_MessageIterator_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_MessageIterator_create",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_MessageIterator_create" "', argument " "1"" of type '" "blpapi_Event_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Event_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_MessageIterator_t *)blpapi_MessageIterator_create((blpapi_Event const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_MessageIterator, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_MessageIterator_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_MessageIterator_t *arg1 = (blpapi_MessageIterator_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_MessageIterator_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_MessageIterator, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_MessageIterator_destroy" "', argument " "1"" of type '" "blpapi_MessageIterator_t *""'"); - } - arg1 = reinterpret_cast< blpapi_MessageIterator_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_MessageIterator_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_MessageIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_MessageIterator_t *arg1 = (blpapi_MessageIterator_t *) 0 ; - blpapi_Message_t **arg2 = (blpapi_Message_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Message_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_MessageIterator_next",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_MessageIterator, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_MessageIterator_next" "', argument " "1"" of type '" "blpapi_MessageIterator_t *""'"); - } - arg1 = reinterpret_cast< blpapi_MessageIterator_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_MessageIterator_next(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Message, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Identity_release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Identity_t *arg1 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Identity_release",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Identity_release" "', argument " "1"" of type '" "blpapi_Identity_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Identity_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Identity_release(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Identity_addRef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Identity_t *arg1 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Identity_addRef",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Identity_addRef" "', argument " "1"" of type '" "blpapi_Identity_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Identity_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Identity_addRef(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Identity_hasEntitlements(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Identity_t *arg1 = (blpapi_Identity_t *) 0 ; - blpapi_Service_t *arg2 = (blpapi_Service_t *) 0 ; - blpapi_Element_t *arg3 = (blpapi_Element_t *) 0 ; - int *arg4 = (int *) 0 ; - size_t arg5 ; - int *arg6 = (int *) 0 ; - int *arg7 = (int *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - size_t val5 ; - int ecode5 = 0 ; - void *argp6 = 0 ; - int res6 = 0 ; - void *argp7 = 0 ; - int res7 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:blpapi_Identity_hasEntitlements",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "1"" of type '" "blpapi_Identity_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Identity_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "2"" of type '" "blpapi_Service_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Service_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Element, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "3"" of type '" "blpapi_Element_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Element_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "4"" of type '" "int const *""'"); - } - arg4 = reinterpret_cast< int * >(argp4); - ecode5 = SWIG_AsVal_size_t(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "5"" of type '" "size_t""'"); - } - arg5 = static_cast< size_t >(val5); - res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "6"" of type '" "int *""'"); - } - arg6 = reinterpret_cast< int * >(argp6); - res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_int, 0 | 0 ); - if (!SWIG_IsOK(res7)) { - SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "blpapi_Identity_hasEntitlements" "', argument " "7"" of type '" "int *""'"); - } - arg7 = reinterpret_cast< int * >(argp7); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Identity_hasEntitlements((blpapi_Identity const *)arg1,(blpapi_Service const *)arg2,(blpapi_Element const *)arg3,(int const *)arg4,arg5,arg6,arg7); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Identity_isAuthorized(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Identity_t *arg1 = (blpapi_Identity_t *) 0 ; - blpapi_Service_t *arg2 = (blpapi_Service_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Identity_isAuthorized",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Identity_isAuthorized" "', argument " "1"" of type '" "blpapi_Identity_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Identity_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Identity_isAuthorized" "', argument " "2"" of type '" "blpapi_Service_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Service_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Identity_isAuthorized((blpapi_Identity const *)arg1,(blpapi_Service const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Identity_getSeatType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Identity_t *arg1 = (blpapi_Identity_t *) 0 ; - int *arg2 = (int *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Identity_getSeatType",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Identity_getSeatType" "', argument " "1"" of type '" "blpapi_Identity_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Identity_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Identity_getSeatType((blpapi_Identity const *)arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - size_t arg3 ; - char *arg4 = (char *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_AbstractSession_cancel",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_cancel" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_AbstractSession_cancel" "', argument " "2"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_CorrelationId_t * >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_AbstractSession_cancel" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_AbstractSession_cancel" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_AbstractSession_cancel" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_cancel(arg1,(blpapi_CorrelationId_t_ const *)arg2,arg3,(char const *)arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return resultobj; -fail: - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_sendAuthorizationRequest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - blpapi_Request_t *arg2 = (blpapi_Request_t *) 0 ; - blpapi_Identity_t *arg3 = (blpapi_Identity_t *) 0 ; - blpapi_CorrelationId_t *arg4 = (blpapi_CorrelationId_t *) 0 ; - blpapi_EventQueue_t *arg5 = (blpapi_EventQueue_t *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - int res6 ; - char *buf6 = 0 ; - int alloc6 = 0 ; - int val7 ; - int ecode7 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:blpapi_AbstractSession_sendAuthorizationRequest",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Request, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "2"" of type '" "blpapi_Request_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Request_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "3"" of type '" "blpapi_Identity_t *""'"); - } - arg3 = reinterpret_cast< blpapi_Identity_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "4"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg4 = reinterpret_cast< blpapi_CorrelationId_t * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "5"" of type '" "blpapi_EventQueue_t *""'"); - } - arg5 = reinterpret_cast< blpapi_EventQueue_t * >(argp5); - res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "6"" of type '" "char const *""'"); - } - arg6 = reinterpret_cast< char * >(buf6); - ecode7 = SWIG_AsVal_int(obj6, &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "blpapi_AbstractSession_sendAuthorizationRequest" "', argument " "7"" of type '" "int""'"); - } - arg7 = static_cast< int >(val7); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_sendAuthorizationRequest(arg1,(blpapi_Request const *)arg2,arg3,arg4,arg5,(char const *)arg6,arg7); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; - return resultobj; -fail: - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_openService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_AbstractSession_openService",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_openService" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_AbstractSession_openService" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_openService(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_openServiceAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_AbstractSession_openServiceAsync",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_openServiceAsync" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_AbstractSession_openServiceAsync" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_AbstractSession_openServiceAsync" "', argument " "3"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_openServiceAsync(arg1,(char const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_generateToken(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - blpapi_EventQueue_t *arg3 = (blpapi_EventQueue_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_AbstractSession_generateToken",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_generateToken" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_AbstractSession_generateToken" "', argument " "2"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg2 = reinterpret_cast< blpapi_CorrelationId_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_AbstractSession_generateToken" "', argument " "3"" of type '" "blpapi_EventQueue_t *""'"); - } - arg3 = reinterpret_cast< blpapi_EventQueue_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_generateToken(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_getService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - blpapi_Service_t **arg2 = (blpapi_Service_t **) 0 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Service_t *temp2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_AbstractSession_getService",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_getService" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_AbstractSession_getService" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_AbstractSession_getService(arg1,arg2,(char const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Service, 0)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_AbstractSession_createIdentity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_AbstractSession_t *arg1 = (blpapi_AbstractSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Identity_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_AbstractSession_createIdentity",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_AbstractSession_createIdentity" "', argument " "1"" of type '" "blpapi_AbstractSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_AbstractSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Identity_t *)blpapi_AbstractSession_createIdentity(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_start",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_start" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_start(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_startAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_startAsync",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_startAsync" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_startAsync(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_stop",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_stop" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_stop(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_stopAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_stopAsync",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_stopAsync" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_stopAsync(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_nextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - unsigned int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - unsigned int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Session_nextEvent",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_nextEvent" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - ecode3 = SWIG_AsVal_unsigned_SS_int(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Session_nextEvent" "', argument " "3"" of type '" "unsigned int""'"); - } - arg3 = static_cast< unsigned int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_nextEvent(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_tryNextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_tryNextEvent",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_tryNextEvent" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_tryNextEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_subscribe(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_SubscriptionList_t *arg2 = (blpapi_SubscriptionList_t *) 0 ; - blpapi_Identity_t *arg3 = (blpapi_Identity_t *) 0 ; - char *arg4 = (char *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_Session_subscribe",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_subscribe" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_subscribe" "', argument " "2"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Session_subscribe" "', argument " "3"" of type '" "blpapi_Identity_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Identity_t * >(argp3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Session_subscribe" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_Session_subscribe" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_subscribe(arg1,(blpapi_SubscriptionList const *)arg2,(blpapi_Identity const *)arg3,(char const *)arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return resultobj; -fail: - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_resubscribe(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_SubscriptionList_t *arg2 = (blpapi_SubscriptionList_t *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Session_resubscribe",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_resubscribe" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_resubscribe" "', argument " "2"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp2); - res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Session_resubscribe" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Session_resubscribe" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_resubscribe(arg1,(blpapi_SubscriptionList const *)arg2,(char const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_resubscribeWithId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_SubscriptionList_t *arg2 = (blpapi_SubscriptionList_t *) 0 ; - int arg3 ; - char *arg4 = (char *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_Session_resubscribeWithId",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_resubscribeWithId" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_resubscribeWithId" "', argument " "2"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_Session_resubscribeWithId" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Session_resubscribeWithId" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = reinterpret_cast< char * >(buf4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_Session_resubscribeWithId" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_resubscribeWithId(arg1,(blpapi_SubscriptionList const *)arg2,arg3,(char const *)arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return resultobj; -fail: - if (alloc4 == SWIG_NEWOBJ) delete[] buf4; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_unsubscribe(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_SubscriptionList_t *arg2 = (blpapi_SubscriptionList_t *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Session_unsubscribe",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_unsubscribe" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_SubscriptionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_unsubscribe" "', argument " "2"" of type '" "blpapi_SubscriptionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_SubscriptionList_t * >(argp2); - res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Session_unsubscribe" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = reinterpret_cast< char * >(buf3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_Session_unsubscribe" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_unsubscribe(arg1,(blpapi_SubscriptionList const *)arg2,(char const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) delete[] buf3; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_setStatusCorrelationId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_Service_t *arg2 = (blpapi_Service_t *) 0 ; - blpapi_Identity_t *arg3 = (blpapi_Identity_t *) 0 ; - blpapi_CorrelationId_t *arg4 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_Session_setStatusCorrelationId",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_setStatusCorrelationId" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_setStatusCorrelationId" "', argument " "2"" of type '" "blpapi_Service_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Service_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Session_setStatusCorrelationId" "', argument " "3"" of type '" "blpapi_Identity_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Identity_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Session_setStatusCorrelationId" "', argument " "4"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_CorrelationId_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_setStatusCorrelationId(arg1,(blpapi_Service const *)arg2,(blpapi_Identity const *)arg3,(blpapi_CorrelationId_t_ const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_sendRequest(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - blpapi_Request_t *arg2 = (blpapi_Request_t *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - blpapi_Identity_t *arg4 = (blpapi_Identity_t *) 0 ; - blpapi_EventQueue_t *arg5 = (blpapi_EventQueue_t *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - int res6 ; - char *buf6 = 0 ; - int alloc6 = 0 ; - int val7 ; - int ecode7 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:blpapi_Session_sendRequest",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_sendRequest" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Request, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Session_sendRequest" "', argument " "2"" of type '" "blpapi_Request_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Request_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_Session_sendRequest" "', argument " "3"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_Session_sendRequest" "', argument " "4"" of type '" "blpapi_Identity_t *""'"); - } - arg4 = reinterpret_cast< blpapi_Identity_t * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_blpapi_EventQueue, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "blpapi_Session_sendRequest" "', argument " "5"" of type '" "blpapi_EventQueue_t *""'"); - } - arg5 = reinterpret_cast< blpapi_EventQueue_t * >(argp5); - res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "blpapi_Session_sendRequest" "', argument " "6"" of type '" "char const *""'"); - } - arg6 = reinterpret_cast< char * >(buf6); - ecode7 = SWIG_AsVal_int(obj6, &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "blpapi_Session_sendRequest" "', argument " "7"" of type '" "int""'"); - } - arg7 = static_cast< int >(val7); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Session_sendRequest(arg1,(blpapi_Request const *)arg2,arg3,arg4,arg5,(char const *)arg6,arg7); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; - return resultobj; -fail: - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Session_getAbstractSession(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Session_t *arg1 = (blpapi_Session_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_AbstractSession_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Session_getAbstractSession",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Session, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Session_getAbstractSession" "', argument " "1"" of type '" "blpapi_Session_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Session_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_AbstractSession_t *)blpapi_Session_getAbstractSession(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_extractAttributeFromResolutionSuccess(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Message_t *arg1 = (blpapi_Message_t *) 0 ; - blpapi_Name_t *arg2 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - blpapi_Element_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_extractAttributeFromResolutionSuccess",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_extractAttributeFromResolutionSuccess" "', argument " "1"" of type '" "blpapi_Message_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Message_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ResolutionList_extractAttributeFromResolutionSuccess" "', argument " "2"" of type '" "blpapi_Name_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Name_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Element_t *)blpapi_ResolutionList_extractAttributeFromResolutionSuccess((blpapi_Message const *)arg1,(blpapi_Name const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Element, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_ResolutionList_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ResolutionList_create",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_create" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_ResolutionList_t *)blpapi_ResolutionList_create(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ResolutionList_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_destroy" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ResolutionList_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ResolutionList_add",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_add" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ResolutionList_add" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_add" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_add(arg1,(char const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_addFromMessage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Message_t *arg2 = (blpapi_Message_t *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ResolutionList_addFromMessage",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_addFromMessage" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ResolutionList_addFromMessage" "', argument " "2"" of type '" "blpapi_Message_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Message_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_addFromMessage" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_addFromMessage(arg1,(blpapi_Message const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_addAttribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Name_t *arg2 = (blpapi_Name_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_addAttribute",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_addAttribute" "', argument " "1"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ResolutionList_addAttribute" "', argument " "2"" of type '" "blpapi_Name_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Name_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_addAttribute(arg1,(blpapi_Name const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_correlationIdAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_CorrelationId_t temp2 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_correlationIdAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_correlationIdAt" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ResolutionList_correlationIdAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_correlationIdAt((blpapi_ResolutionList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(CorrelationId_t_clone(*arg2), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_OWN)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_topicString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - char **arg2 = (char **) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_topicString",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_topicString" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_topicString" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_topicString((blpapi_ResolutionList const *)arg1,(char const **)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_topicStringAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - char **arg2 = (char **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_topicStringAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_topicStringAt" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ResolutionList_topicStringAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_topicStringAt((blpapi_ResolutionList const *)arg1,(char const **)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - int *arg2 = (int *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_status",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_status" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_status" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_status((blpapi_ResolutionList const *)arg1,arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_statusAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - int *arg2 = (int *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_statusAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_statusAt" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ResolutionList_statusAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_statusAt((blpapi_ResolutionList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_attribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - blpapi_CorrelationId_t *arg4 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ResolutionList_attribute",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_attribute" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_attribute" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ResolutionList_attribute" "', argument " "4"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_CorrelationId_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_attribute((blpapi_ResolutionList const *)arg1,arg2,(blpapi_Name const *)arg3,(blpapi_CorrelationId_t_ const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_attributeAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Element_t **arg2 = (blpapi_Element_t **) 0 ; - blpapi_Name_t *arg3 = (blpapi_Name_t *) 0 ; - size_t arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Element_t *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - size_t val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ResolutionList_attributeAt",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_attributeAt" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_Name, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_attributeAt" "', argument " "3"" of type '" "blpapi_Name_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Name_t * >(argp3); - ecode4 = SWIG_AsVal_size_t(obj2, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_ResolutionList_attributeAt" "', argument " "4"" of type '" "size_t""'"); - } - arg4 = static_cast< size_t >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_attributeAt((blpapi_ResolutionList const *)arg1,arg2,(blpapi_Name const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Element, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_message(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Message_t **arg2 = (blpapi_Message_t **) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Message_t *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_message",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_message" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ResolutionList_message" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_message((blpapi_ResolutionList const *)arg1,arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Message, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_messageAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - blpapi_Message_t **arg2 = (blpapi_Message_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Message_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ResolutionList_messageAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_messageAt" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ResolutionList_messageAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_messageAt((blpapi_ResolutionList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Message, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ResolutionList_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ResolutionList_t *arg1 = (blpapi_ResolutionList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ResolutionList_size",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ResolutionList_size" "', argument " "1"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ResolutionList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ResolutionList_size((blpapi_ResolutionList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Topic_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t *arg1 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Topic_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Topic_create",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Topic_create" "', argument " "1"" of type '" "blpapi_Topic_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Topic_t *)blpapi_Topic_create(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Topic_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t *arg1 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Topic_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Topic_destroy" "', argument " "1"" of type '" "blpapi_Topic_t *""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_Topic_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Topic_compare(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t *arg1 = (blpapi_Topic_t *) 0 ; - blpapi_Topic_t *arg2 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_Topic_compare",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Topic_compare" "', argument " "1"" of type '" "blpapi_Topic_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_Topic_compare" "', argument " "2"" of type '" "blpapi_Topic_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Topic_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Topic_compare((blpapi_Topic const *)arg1,(blpapi_Topic const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Topic_service(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t *arg1 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_Service_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Topic_service",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Topic_service" "', argument " "1"" of type '" "blpapi_Topic_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_Service_t *)blpapi_Topic_service((blpapi_Topic const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_Service, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_Topic_isActive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_Topic_t *arg1 = (blpapi_Topic_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_Topic_isActive",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_Topic_isActive" "', argument " "1"" of type '" "blpapi_Topic_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_Topic_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_Topic_isActive((blpapi_Topic const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_TopicList_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_TopicList_create",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_create" "', argument " "1"" of type '" "blpapi_TopicList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_TopicList_t *)blpapi_TopicList_create(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_TopicList_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_destroy" "', argument " "1"" of type '" "blpapi_TopicList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_TopicList_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_TopicList_add",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_add" "', argument " "1"" of type '" "blpapi_TopicList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_TopicList_add" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_TopicList_add" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_add(arg1,(char const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_addFromMessage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - blpapi_Message_t *arg2 = (blpapi_Message_t *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_TopicList_addFromMessage",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_addFromMessage" "', argument " "1"" of type '" "blpapi_TopicList_t *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_TopicList_addFromMessage" "', argument " "2"" of type '" "blpapi_Message_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Message_t * >(argp2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_TopicList_addFromMessage" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_addFromMessage(arg1,(blpapi_Message const *)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_correlationIdAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - blpapi_CorrelationId_t *arg2 = (blpapi_CorrelationId_t *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_CorrelationId_t temp2 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_correlationIdAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_correlationIdAt" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_TopicList_correlationIdAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_correlationIdAt((blpapi_TopicList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj(CorrelationId_t_clone(*arg2), SWIGTYPE_p_blpapi_CorrelationId_t_, SWIG_POINTER_OWN)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_topicString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - char **arg2 = (char **) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_topicString",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_topicString" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_TopicList_topicString" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_topicString((blpapi_TopicList const *)arg1,(char const **)arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_topicStringAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - char **arg2 = (char **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_topicStringAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_topicStringAt" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_TopicList_topicStringAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_topicStringAt((blpapi_TopicList const *)arg1,(char const **)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(*arg2)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_status(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - int *arg2 = (int *) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_status",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_status" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_TopicList_status" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_status((blpapi_TopicList const *)arg1,arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_statusAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - int *arg2 = (int *) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int temp2 ; - int res2 = SWIG_TMPOBJ ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_statusAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_statusAt" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_TopicList_statusAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_statusAt((blpapi_TopicList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (SWIG_IsTmpObj(res2)) { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg2))); - } else { - int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_int, new_flags)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_message(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - blpapi_Message_t **arg2 = (blpapi_Message_t **) 0 ; - blpapi_CorrelationId_t *arg3 = (blpapi_CorrelationId_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Message_t *temp2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_message",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_message" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_TopicList_message" "', argument " "3"" of type '" "blpapi_CorrelationId_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_CorrelationId_t * >(argp3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_message((blpapi_TopicList const *)arg1,arg2,(blpapi_CorrelationId_t_ const *)arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Message, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_messageAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - blpapi_Message_t **arg2 = (blpapi_Message_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Message_t *temp2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_TopicList_messageAt",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_messageAt" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - ecode3 = SWIG_AsVal_size_t(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_TopicList_messageAt" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_messageAt((blpapi_TopicList const *)arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Message, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_TopicList_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_TopicList_t *arg1 = (blpapi_TopicList_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_TopicList_size",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_TopicList_size" "', argument " "1"" of type '" "blpapi_TopicList_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_TopicList_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_TopicList_size((blpapi_TopicList const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_SessionOptions_t *arg1 = (blpapi_SessionOptions_t *) 0 ; - blpapi_ProviderEventHandler_t arg2 = (blpapi_ProviderEventHandler_t) 0 ; - blpapi_EventDispatcher_t *arg3 = (blpapi_EventDispatcher_t *) 0 ; - void *arg4 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - blpapi_ProviderSession_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_create",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_SessionOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_create" "', argument " "1"" of type '" "blpapi_SessionOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_SessionOptions_t * >(argp1); - { - int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "blpapi_ProviderSession_create" "', argument " "2"" of type '" "blpapi_ProviderEventHandler_t""'"); - } - } - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_EventDispatcher, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ProviderSession_create" "', argument " "3"" of type '" "blpapi_EventDispatcher_t *""'"); - } - arg3 = reinterpret_cast< blpapi_EventDispatcher_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3,SWIG_as_voidptrptr(&arg4), 0, 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_create" "', argument " "4"" of type '" "void *""'"); - } - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_ProviderSession_t *)blpapi_ProviderSession_create(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_destroy" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ProviderSession_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_start",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_start" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_start(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_startAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_startAsync",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_startAsync" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_startAsync(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_stop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_stop",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_stop" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_stop(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_stopAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_stopAsync",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_stopAsync" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_stopAsync(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_nextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - unsigned int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - unsigned int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_nextEvent",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_nextEvent" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - ecode3 = SWIG_AsVal_unsigned_SS_int(obj1, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_nextEvent" "', argument " "3"" of type '" "unsigned int""'"); - } - arg3 = static_cast< unsigned int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_nextEvent(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_tryNextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Event_t **arg2 = (blpapi_Event_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - blpapi_Event_t *temp2 = 0 ; - PyObject * obj0 = 0 ; - int result; - - arg2 = &temp2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_tryNextEvent",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_tryNextEvent" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_tryNextEvent(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg2), SWIGTYPE_p_blpapi_Event, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_registerService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Identity_t *arg3 = (blpapi_Identity_t *) 0 ; - blpapi_ServiceRegistrationOptions_t *arg4 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_registerService",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_registerService" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_registerService" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ProviderSession_registerService" "', argument " "3"" of type '" "blpapi_Identity_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Identity_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_registerService" "', argument " "4"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg4 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_registerService(arg1,(char const *)arg2,(blpapi_Identity const *)arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_activateSubServiceCodeRange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - int arg4 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_ProviderSession_activateSubServiceCodeRange",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_activateSubServiceCodeRange" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_activateSubServiceCodeRange" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_activateSubServiceCodeRange" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_ProviderSession_activateSubServiceCodeRange" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "blpapi_ProviderSession_activateSubServiceCodeRange" "', argument " "5"" of type '" "int""'"); - } - arg5 = static_cast< int >(val5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_activateSubServiceCodeRange(arg1,(char const *)arg2,arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_deactivateSubServiceCodeRange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_deactivateSubServiceCodeRange",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_deactivateSubServiceCodeRange" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_deactivateSubServiceCodeRange" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_deactivateSubServiceCodeRange" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_ProviderSession_deactivateSubServiceCodeRange" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_deactivateSubServiceCodeRange(arg1,(char const *)arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_registerServiceAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - char *arg2 = (char *) 0 ; - blpapi_Identity_t *arg3 = (blpapi_Identity_t *) 0 ; - blpapi_CorrelationId_t *arg4 = (blpapi_CorrelationId_t *) 0 ; - blpapi_ServiceRegistrationOptions_t *arg5 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:blpapi_ProviderSession_registerServiceAsync",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_registerServiceAsync" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_registerServiceAsync" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "blpapi_ProviderSession_registerServiceAsync" "', argument " "3"" of type '" "blpapi_Identity_t const *""'"); - } - arg3 = reinterpret_cast< blpapi_Identity_t * >(argp3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_CorrelationId_t_, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_registerServiceAsync" "', argument " "4"" of type '" "blpapi_CorrelationId_t *""'"); - } - arg4 = reinterpret_cast< blpapi_CorrelationId_t * >(argp4); - res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "blpapi_ProviderSession_registerServiceAsync" "', argument " "5"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg5 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp5); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_registerServiceAsync(arg1,(char const *)arg2,(blpapi_Identity const *)arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_deregisterService(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_deregisterService",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_deregisterService" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_deregisterService" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_deregisterService(arg1,(char const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_resolve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_ResolutionList_t *arg2 = (blpapi_ResolutionList_t *) 0 ; - int arg3 ; - blpapi_Identity_t *arg4 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_resolve",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_resolve" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_resolve" "', argument " "2"" of type '" "blpapi_ResolutionList_t *""'"); - } - arg2 = reinterpret_cast< blpapi_ResolutionList_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_resolve" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_resolve" "', argument " "4"" of type '" "blpapi_Identity_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Identity_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_resolve(arg1,arg2,arg3,(blpapi_Identity const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_resolveAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_ResolutionList_t *arg2 = (blpapi_ResolutionList_t *) 0 ; - int arg3 ; - blpapi_Identity_t *arg4 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_resolveAsync",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_resolveAsync" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_ResolutionList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_resolveAsync" "', argument " "2"" of type '" "blpapi_ResolutionList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_ResolutionList_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_resolveAsync" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_resolveAsync" "', argument " "4"" of type '" "blpapi_Identity_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Identity_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_resolveAsync(arg1,(blpapi_ResolutionList const *)arg2,arg3,(blpapi_Identity const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_createTopics(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_TopicList_t *arg2 = (blpapi_TopicList_t *) 0 ; - int arg3 ; - blpapi_Identity_t *arg4 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_createTopics",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_createTopics" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_createTopics" "', argument " "2"" of type '" "blpapi_TopicList_t *""'"); - } - arg2 = reinterpret_cast< blpapi_TopicList_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_createTopics" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_createTopics" "', argument " "4"" of type '" "blpapi_Identity_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Identity_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_createTopics(arg1,arg2,arg3,(blpapi_Identity const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_createTopicsAsync(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_TopicList_t *arg2 = (blpapi_TopicList_t *) 0 ; - int arg3 ; - blpapi_Identity_t *arg4 = (blpapi_Identity_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ProviderSession_createTopicsAsync",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_createTopicsAsync" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_TopicList, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_createTopicsAsync" "', argument " "2"" of type '" "blpapi_TopicList_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_TopicList_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_createTopicsAsync" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_blpapi_Identity, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "blpapi_ProviderSession_createTopicsAsync" "', argument " "4"" of type '" "blpapi_Identity_t const *""'"); - } - arg4 = reinterpret_cast< blpapi_Identity_t * >(argp4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_createTopicsAsync(arg1,(blpapi_TopicList const *)arg2,arg3,(blpapi_Identity const *)arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_getTopic(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Message_t *arg2 = (blpapi_Message_t *) 0 ; - blpapi_Topic_t **arg3 = (blpapi_Topic_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - blpapi_Topic_t *temp3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg3 = &temp3; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_getTopic",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_getTopic" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_getTopic" "', argument " "2"" of type '" "blpapi_Message_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Message_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_getTopic(arg1,(blpapi_Message const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg3), SWIGTYPE_p_blpapi_Topic, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_createTopic(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Message_t *arg2 = (blpapi_Message_t *) 0 ; - blpapi_Topic_t **arg3 = (blpapi_Topic_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - blpapi_Topic_t *temp3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg3 = &temp3; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_createTopic",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_createTopic" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Message, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_createTopic" "', argument " "2"" of type '" "blpapi_Message_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Message_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_createTopic(arg1,(blpapi_Message const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg3), SWIGTYPE_p_blpapi_Topic, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_createServiceStatusTopic(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Service_t *arg2 = (blpapi_Service_t *) 0 ; - blpapi_Topic_t **arg3 = (blpapi_Topic_t **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - blpapi_Topic_t *temp3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - arg3 = &temp3; - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_createServiceStatusTopic",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_createServiceStatusTopic" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Service, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_createServiceStatusTopic" "', argument " "2"" of type '" "blpapi_Service_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_Service_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_createServiceStatusTopic(arg1,(blpapi_Service const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((*arg3), SWIGTYPE_p_blpapi_Topic, 0)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_deleteTopics(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Topic_t **arg2 = (blpapi_Topic_t **) 0 ; - size_t arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - size_t val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ProviderSession_deleteTopics",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_deleteTopics" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_p_blpapi_Topic, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_deleteTopics" "', argument " "2"" of type '" "blpapi_Topic_t const **""'"); - } - arg2 = reinterpret_cast< blpapi_Topic_t ** >(argp2); - ecode3 = SWIG_AsVal_size_t(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_deleteTopics" "', argument " "3"" of type '" "size_t""'"); - } - arg3 = static_cast< size_t >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_deleteTopics(arg1,(blpapi_Topic const **)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_publish(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Event_t *arg2 = (blpapi_Event_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ProviderSession_publish",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_publish" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_publish" "', argument " "2"" of type '" "blpapi_Event_t *""'"); - } - arg2 = reinterpret_cast< blpapi_Event_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_publish(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_sendResponse(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - blpapi_Event_t *arg2 = (blpapi_Event_t *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:blpapi_ProviderSession_sendResponse",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_sendResponse" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_Event, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ProviderSession_sendResponse" "', argument " "2"" of type '" "blpapi_Event_t *""'"); - } - arg2 = reinterpret_cast< blpapi_Event_t * >(argp2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ProviderSession_sendResponse" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ProviderSession_sendResponse(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ProviderSession_getAbstractSession(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ProviderSession_t *arg1 = (blpapi_ProviderSession_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_AbstractSession_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ProviderSession_getAbstractSession",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ProviderSession, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ProviderSession_getAbstractSession" "', argument " "1"" of type '" "blpapi_ProviderSession_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ProviderSession_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_AbstractSession_t *)blpapi_ProviderSession_getAbstractSession(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_AbstractSession, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)":blpapi_ServiceRegistrationOptions_create")) SWIG_fail; - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_ServiceRegistrationOptions_t *)blpapi_ServiceRegistrationOptions_create(); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_duplicate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - blpapi_ServiceRegistrationOptions_t *result = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_duplicate",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_duplicate" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t const *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (blpapi_ServiceRegistrationOptions_t *)blpapi_ServiceRegistrationOptions_duplicate((blpapi_ServiceRegistrationOptions const *)arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_destroy",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_destroy" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ServiceRegistrationOptions_destroy(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - blpapi_ServiceRegistrationOptions_t *arg2 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ServiceRegistrationOptions_copy",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_copy" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "blpapi_ServiceRegistrationOptions_copy" "', argument " "2"" of type '" "blpapi_ServiceRegistrationOptions_t const *""'"); - } - arg2 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ServiceRegistrationOptions_copy(arg1,(blpapi_ServiceRegistrationOptions const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - int arg2 ; - int arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange" "', argument " "4"" of type '" "int""'"); - } - arg4 = static_cast< int >(val4); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_setGroupId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - unsigned int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ServiceRegistrationOptions_setGroupId",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_setGroupId" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - { - arg2 = PyString_AsString(obj1); - arg3 = PyString_Size(obj1); - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ServiceRegistrationOptions_setGroupId(arg1,(char const *)arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_setServicePriority(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ServiceRegistrationOptions_setServicePriority",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_setServicePriority" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_ServiceRegistrationOptions_setServicePriority" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ServiceRegistrationOptions_setServicePriority(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_setPartsToRegister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:blpapi_ServiceRegistrationOptions_setPartsToRegister",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_setPartsToRegister" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "blpapi_ServiceRegistrationOptions_setPartsToRegister" "', argument " "2"" of type '" "int""'"); - } - arg2 = static_cast< int >(val2); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - blpapi_ServiceRegistrationOptions_setPartsToRegister(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_getGroupId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - char *arg2 = (char *) 0 ; - int *arg3 = (int *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char temp2[MAX_GROUP_ID_SIZE] ; - int len2 = MAX_GROUP_ID_SIZE ; - PyObject * obj0 = 0 ; - int result; - - arg2 = temp2; - arg3 = &len2; - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_getGroupId",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_getGroupId" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ServiceRegistrationOptions_getGroupId(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - { - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(arg2, *arg3)); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_getServicePriority(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_getServicePriority",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_getServicePriority" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ServiceRegistrationOptions_getServicePriority(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_blpapi_ServiceRegistrationOptions_getPartsToRegister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - blpapi_ServiceRegistrationOptions_t *arg1 = (blpapi_ServiceRegistrationOptions_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"O:blpapi_ServiceRegistrationOptions_getPartsToRegister",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_blpapi_ServiceRegistrationOptions, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "blpapi_ServiceRegistrationOptions_getPartsToRegister" "', argument " "1"" of type '" "blpapi_ServiceRegistrationOptions_t *""'"); - } - arg1 = reinterpret_cast< blpapi_ServiceRegistrationOptions_t * >(argp1); - - try { - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)blpapi_ServiceRegistrationOptions_getPartsToRegister(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - } catch(std::out_of_range const& error) { - SWIG_exception(SWIG_IndexError, error.what()); - } catch(std::bad_alloc const& error) { - SWIG_exception(SWIG_MemoryError, error.what()); - } catch(std::overflow_error const& error) { - SWIG_exception(SWIG_OverflowError, error.what()); - } catch(std::invalid_argument const& error) { - SWIG_exception(SWIG_ValueError, error.what()); - } catch(std::runtime_error const& error) { - SWIG_exception(SWIG_RuntimeError, error.what()); - } catch(std::exception const& error) { - SWIG_exception(SWIG_UnknownError, error.what()); - } - - resultobj = SWIG_From_int(static_cast< int >(result)); - return resultobj; -fail: - return NULL; -} - - -static PyMethodDef SwigMethods[] = { - { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"setLoggerCallbackWrapper", _wrap_setLoggerCallbackWrapper, METH_VARARGS, NULL}, - { (char *)"blpapi_Logging_registerCallback", _wrap_blpapi_Logging_registerCallback, METH_VARARGS, NULL}, - { (char *)"blpapi_Logging_logTestMessage", _wrap_blpapi_Logging_logTestMessage, METH_VARARGS, NULL}, - { (char *)"blpapi_DiagnosticsUtil_memoryInfo_wrapper", _wrap_blpapi_DiagnosticsUtil_memoryInfo_wrapper, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_timeReceived_wrapper", _wrap_blpapi_Message_timeReceived_wrapper, METH_VARARGS, NULL}, - { (char *)"blpapi_HighResolutionClock_now_wrapper", _wrap_blpapi_HighResolutionClock_now_wrapper, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_printHelper", _wrap_blpapi_Service_printHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_printHelper", _wrap_blpapi_SchemaElementDefinition_printHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_printHelper", _wrap_blpapi_SchemaTypeDefinition_printHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_hasElementDefinition", _wrap_blpapi_SchemaTypeDefinition_hasElementDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_hasConstant", _wrap_blpapi_ConstantList_hasConstant, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_hasEventDefinition", _wrap_blpapi_Service_hasEventDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_hasOperation", _wrap_blpapi_Service_hasOperation, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_addHelper", _wrap_blpapi_SubscriptionList_addHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_hasName", _wrap_blpapi_Name_hasName, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_createFromResolutionList", _wrap_blpapi_TopicList_createFromResolutionList, METH_VARARGS, NULL}, - { (char *)"new_intArray", _wrap_new_intArray, METH_VARARGS, NULL}, - { (char *)"delete_intArray", _wrap_delete_intArray, METH_VARARGS, NULL}, - { (char *)"intArray___getitem__", _wrap_intArray___getitem__, METH_VARARGS, NULL}, - { (char *)"intArray___setitem__", _wrap_intArray___setitem__, METH_VARARGS, NULL}, - { (char *)"intArray_cast", _wrap_intArray_cast, METH_VARARGS, NULL}, - { (char *)"intArray_frompointer", _wrap_intArray_frompointer, METH_VARARGS, NULL}, - { (char *)"intArray_swigregister", intArray_swigregister, METH_VARARGS, NULL}, - { (char *)"new_topicPtrArray", _wrap_new_topicPtrArray, METH_VARARGS, NULL}, - { (char *)"delete_topicPtrArray", _wrap_delete_topicPtrArray, METH_VARARGS, NULL}, - { (char *)"topicPtrArray_getitem", _wrap_topicPtrArray_getitem, METH_VARARGS, NULL}, - { (char *)"topicPtrArray_setitem", _wrap_topicPtrArray_setitem, METH_VARARGS, NULL}, - { (char *)"CorrelationId_t_equals", _wrap_CorrelationId_t_equals, METH_VARARGS, NULL}, - { (char *)"new_CorrelationId", _wrap_new_CorrelationId, METH_VARARGS, (char *)"\n" - "A key used to identify individual subscriptions or requests.\n" - "\n" - "CorrelationId([value[, classId=0]]) constructs a CorrelationId object.\n" - "If 'value' is integer (either int or long) then created CorrelationId will have\n" - "type() == CorrelationId.INT_TYPE. Otherwise it will have\n" - "type() == CorrelationId.OBJECT_TYPE. If no arguments are specified\n" - "then it will have type() == CorrelationId.UNSET_TYPE.\n" - "\n" - "Two CorrelationIds are considered equal if they have the same\n" - "type() and:\n" - "- holds the same (not just equal!) objects in case of\n" - " type() == CorrelationId.OBJECT_TYPE\n" - "- holds equal integers in case of\n" - " type() == CorrelationId.INT_TYPE or\n" - " type() == CorrelationId.AUTOGEN_TYPE\n" - "- True otherwise\n" - " (i.e. in case of type() == CorrelationId.UNSET_TYPE)\n" - "\n" - "It is possible that an user constructed CorrelationId and a\n" - "CorrelationId generated by the API could return the same\n" - "result for value(). However, they will not compare equal because\n" - "they have different type().\n" - "\n" - "CorrelationId objects are passed to many of the Session object\n" - "methods which initiate an asynchronous operations and are\n" - "obtained from Message objects which are delivered as a result\n" - "of those asynchronous operations.\n" - "\n" - "When subscribing or requesting information an application has\n" - "the choice of providing a CorrelationId they construct\n" - "themselves or allowing the session to construct one for\n" - "them. If the application supplies a CorrelationId it must not\n" - "re-use the value contained in it in another CorrelationId\n" - "whilst the original request or subscription is still active.\n" - "\n" - "Class attributes:\n" - " Possible return values for type() method:\n" - " UNSET_TYPE The CorrelationId is unset. That is, it was created by\n" - " the default CorrelationId constructor.\n" - " INT_TYPE The CorrelationId was created from an integer (or long)\n" - " supplied by the user.\n" - " OBJECT_TYPE The CorrelationId was created from an object supplied by\n" - " the user.\n" - " AUTOGEN_TYPE The CorrelationId was created internally by API.\n" - "\n" - " MAX_CLASS_ID The maximum value allowed for classId.\n" - ""}, - { (char *)"delete_CorrelationId", _wrap_delete_CorrelationId, METH_VARARGS, NULL}, - { (char *)"CorrelationId_type", _wrap_CorrelationId_type, METH_VARARGS, (char *)"Return the type of this CorrelationId object (see xxx_TYPE class attributes)"}, - { (char *)"CorrelationId_classId", _wrap_CorrelationId_classId, METH_VARARGS, (char *)"Return the user defined classification of this CorrelationId object"}, - { (char *)"CorrelationId___asObject", _wrap_CorrelationId___asObject, METH_VARARGS, NULL}, - { (char *)"CorrelationId___asInteger", _wrap_CorrelationId___asInteger, METH_VARARGS, NULL}, - { (char *)"CorrelationId___toInteger", _wrap_CorrelationId___toInteger, METH_VARARGS, NULL}, - { (char *)"CorrelationId_swigregister", CorrelationId_swigregister, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementFloat", _wrap_blpapi_Element_setElementFloat, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueFloat", _wrap_blpapi_Element_setValueFloat, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_printHelper", _wrap_blpapi_Element_printHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_name", _wrap_blpapi_Element_name, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_nameString", _wrap_blpapi_Element_nameString, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_definition", _wrap_blpapi_Element_definition, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_datatype", _wrap_blpapi_Element_datatype, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_isComplexType", _wrap_blpapi_Element_isComplexType, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_isArray", _wrap_blpapi_Element_isArray, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_isReadOnly", _wrap_blpapi_Element_isReadOnly, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_numValues", _wrap_blpapi_Element_numValues, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_numElements", _wrap_blpapi_Element_numElements, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_isNullValue", _wrap_blpapi_Element_isNullValue, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_isNull", _wrap_blpapi_Element_isNull, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getElementAt", _wrap_blpapi_Element_getElementAt, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getElement", _wrap_blpapi_Element_getElement, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_hasElementEx", _wrap_blpapi_Element_hasElementEx, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsBool", _wrap_blpapi_Element_getValueAsBool, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsChar", _wrap_blpapi_Element_getValueAsChar, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsInt32", _wrap_blpapi_Element_getValueAsInt32, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsInt64", _wrap_blpapi_Element_getValueAsInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsFloat64", _wrap_blpapi_Element_getValueAsFloat64, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsString", _wrap_blpapi_Element_getValueAsString, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsDatetime", _wrap_blpapi_Element_getValueAsDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsHighPrecisionDatetime", _wrap_blpapi_Element_getValueAsHighPrecisionDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsElement", _wrap_blpapi_Element_getValueAsElement, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getValueAsName", _wrap_blpapi_Element_getValueAsName, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_getChoice", _wrap_blpapi_Element_getChoice, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueBool", _wrap_blpapi_Element_setValueBool, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueInt32", _wrap_blpapi_Element_setValueInt32, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueInt64", _wrap_blpapi_Element_setValueInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueString", _wrap_blpapi_Element_setValueString, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueDatetime", _wrap_blpapi_Element_setValueDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueHighPrecisionDatetime", _wrap_blpapi_Element_setValueHighPrecisionDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setValueFromName", _wrap_blpapi_Element_setValueFromName, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementBool", _wrap_blpapi_Element_setElementBool, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementInt32", _wrap_blpapi_Element_setElementInt32, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementInt64", _wrap_blpapi_Element_setElementInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementString", _wrap_blpapi_Element_setElementString, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementDatetime", _wrap_blpapi_Element_setElementDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementHighPrecisionDatetime", _wrap_blpapi_Element_setElementHighPrecisionDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setElementFromName", _wrap_blpapi_Element_setElementFromName, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_appendElement", _wrap_blpapi_Element_appendElement, METH_VARARGS, NULL}, - { (char *)"blpapi_Element_setChoice", _wrap_blpapi_Element_setChoice, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueFloat", _wrap_blpapi_EventFormatter_setValueFloat, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueFloat", _wrap_blpapi_EventFormatter_appendValueFloat, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_create", _wrap_blpapi_EventFormatter_create, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_destroy", _wrap_blpapi_EventFormatter_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendMessage", _wrap_blpapi_EventFormatter_appendMessage, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendMessageSeq", _wrap_blpapi_EventFormatter_appendMessageSeq, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendResponse", _wrap_blpapi_EventFormatter_appendResponse, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendRecapMessage", _wrap_blpapi_EventFormatter_appendRecapMessage, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendRecapMessageSeq", _wrap_blpapi_EventFormatter_appendRecapMessageSeq, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueBool", _wrap_blpapi_EventFormatter_setValueBool, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueChar", _wrap_blpapi_EventFormatter_setValueChar, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueInt32", _wrap_blpapi_EventFormatter_setValueInt32, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueInt64", _wrap_blpapi_EventFormatter_setValueInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueDatetime", _wrap_blpapi_EventFormatter_setValueDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueString", _wrap_blpapi_EventFormatter_setValueString, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueFromName", _wrap_blpapi_EventFormatter_setValueFromName, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_setValueNull", _wrap_blpapi_EventFormatter_setValueNull, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_pushElement", _wrap_blpapi_EventFormatter_pushElement, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_popElement", _wrap_blpapi_EventFormatter_popElement, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueBool", _wrap_blpapi_EventFormatter_appendValueBool, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueChar", _wrap_blpapi_EventFormatter_appendValueChar, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueInt32", _wrap_blpapi_EventFormatter_appendValueInt32, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueInt64", _wrap_blpapi_EventFormatter_appendValueInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueDatetime", _wrap_blpapi_EventFormatter_appendValueDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueString", _wrap_blpapi_EventFormatter_appendValueString, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendValueFromName", _wrap_blpapi_EventFormatter_appendValueFromName, METH_VARARGS, NULL}, - { (char *)"blpapi_EventFormatter_appendElement", _wrap_blpapi_EventFormatter_appendElement, METH_VARARGS, NULL}, - { (char *)"Session_createHelper", _wrap_Session_createHelper, METH_VARARGS, NULL}, - { (char *)"Session_destroyHelper", _wrap_Session_destroyHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_EventDispatcher_create", _wrap_blpapi_EventDispatcher_create, METH_VARARGS, NULL}, - { (char *)"blpapi_EventDispatcher_destroy", _wrap_blpapi_EventDispatcher_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_EventDispatcher_start", _wrap_blpapi_EventDispatcher_start, METH_VARARGS, NULL}, - { (char *)"blpapi_EventDispatcher_stop", _wrap_blpapi_EventDispatcher_stop, METH_VARARGS, NULL}, - { (char *)"ProviderSession_createHelper", _wrap_ProviderSession_createHelper, METH_VARARGS, NULL}, - { (char *)"ProviderSession_destroyHelper", _wrap_ProviderSession_destroyHelper, METH_VARARGS, NULL}, - { (char *)"blpapi_getLastErrorDescription", _wrap_blpapi_getLastErrorDescription, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_create", _wrap_blpapi_SessionOptions_create, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_destroy", _wrap_blpapi_SessionOptions_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setServerHost", _wrap_blpapi_SessionOptions_setServerHost, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setServerPort", _wrap_blpapi_SessionOptions_setServerPort, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setServerAddress", _wrap_blpapi_SessionOptions_setServerAddress, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_removeServerAddress", _wrap_blpapi_SessionOptions_removeServerAddress, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setConnectTimeout", _wrap_blpapi_SessionOptions_setConnectTimeout, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setDefaultServices", _wrap_blpapi_SessionOptions_setDefaultServices, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setDefaultSubscriptionService", _wrap_blpapi_SessionOptions_setDefaultSubscriptionService, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setDefaultTopicPrefix", _wrap_blpapi_SessionOptions_setDefaultTopicPrefix, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg", _wrap_blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setClientMode", _wrap_blpapi_SessionOptions_setClientMode, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setMaxPendingRequests", _wrap_blpapi_SessionOptions_setMaxPendingRequests, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setAutoRestartOnDisconnection", _wrap_blpapi_SessionOptions_setAutoRestartOnDisconnection, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setAuthenticationOptions", _wrap_blpapi_SessionOptions_setAuthenticationOptions, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setNumStartAttempts", _wrap_blpapi_SessionOptions_setNumStartAttempts, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setMaxEventQueueSize", _wrap_blpapi_SessionOptions_setMaxEventQueueSize, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark", _wrap_blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark", _wrap_blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setDefaultKeepAliveInactivityTime", _wrap_blpapi_SessionOptions_setDefaultKeepAliveInactivityTime, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout", _wrap_blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setKeepAliveEnabled", _wrap_blpapi_SessionOptions_setKeepAliveEnabled, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes", _wrap_blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_serverHost", _wrap_blpapi_SessionOptions_serverHost, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_serverPort", _wrap_blpapi_SessionOptions_serverPort, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_numServerAddresses", _wrap_blpapi_SessionOptions_numServerAddresses, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_getServerAddress", _wrap_blpapi_SessionOptions_getServerAddress, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_connectTimeout", _wrap_blpapi_SessionOptions_connectTimeout, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_defaultServices", _wrap_blpapi_SessionOptions_defaultServices, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_defaultSubscriptionService", _wrap_blpapi_SessionOptions_defaultSubscriptionService, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_defaultTopicPrefix", _wrap_blpapi_SessionOptions_defaultTopicPrefix, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg", _wrap_blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_clientMode", _wrap_blpapi_SessionOptions_clientMode, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_maxPendingRequests", _wrap_blpapi_SessionOptions_maxPendingRequests, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_autoRestartOnDisconnection", _wrap_blpapi_SessionOptions_autoRestartOnDisconnection, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_authenticationOptions", _wrap_blpapi_SessionOptions_authenticationOptions, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_numStartAttempts", _wrap_blpapi_SessionOptions_numStartAttempts, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_maxEventQueueSize", _wrap_blpapi_SessionOptions_maxEventQueueSize, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_slowConsumerWarningHiWaterMark", _wrap_blpapi_SessionOptions_slowConsumerWarningHiWaterMark, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_slowConsumerWarningLoWaterMark", _wrap_blpapi_SessionOptions_slowConsumerWarningLoWaterMark, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_defaultKeepAliveInactivityTime", _wrap_blpapi_SessionOptions_defaultKeepAliveInactivityTime, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_defaultKeepAliveResponseTimeout", _wrap_blpapi_SessionOptions_defaultKeepAliveResponseTimeout, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_keepAliveEnabled", _wrap_blpapi_SessionOptions_keepAliveEnabled, METH_VARARGS, NULL}, - { (char *)"blpapi_SessionOptions_recordSubscriptionDataReceiveTimes", _wrap_blpapi_SessionOptions_recordSubscriptionDataReceiveTimes, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_create", _wrap_blpapi_Name_create, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_destroy", _wrap_blpapi_Name_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_equalsStr", _wrap_blpapi_Name_equalsStr, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_string", _wrap_blpapi_Name_string, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_length", _wrap_blpapi_Name_length, METH_VARARGS, NULL}, - { (char *)"blpapi_Name_findName", _wrap_blpapi_Name_findName, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_create", _wrap_blpapi_SubscriptionList_create, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_destroy", _wrap_blpapi_SubscriptionList_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_addResolved", _wrap_blpapi_SubscriptionList_addResolved, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_clear", _wrap_blpapi_SubscriptionList_clear, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_append", _wrap_blpapi_SubscriptionList_append, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_size", _wrap_blpapi_SubscriptionList_size, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_correlationIdAt", _wrap_blpapi_SubscriptionList_correlationIdAt, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_topicStringAt", _wrap_blpapi_SubscriptionList_topicStringAt, METH_VARARGS, NULL}, - { (char *)"blpapi_SubscriptionList_isResolvedAt", _wrap_blpapi_SubscriptionList_isResolvedAt, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_parts_set", _wrap_blpapi_Datetime_tag_parts_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_parts_get", _wrap_blpapi_Datetime_tag_parts_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_hours_set", _wrap_blpapi_Datetime_tag_hours_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_hours_get", _wrap_blpapi_Datetime_tag_hours_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_minutes_set", _wrap_blpapi_Datetime_tag_minutes_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_minutes_get", _wrap_blpapi_Datetime_tag_minutes_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_seconds_set", _wrap_blpapi_Datetime_tag_seconds_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_seconds_get", _wrap_blpapi_Datetime_tag_seconds_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_milliSeconds_set", _wrap_blpapi_Datetime_tag_milliSeconds_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_milliSeconds_get", _wrap_blpapi_Datetime_tag_milliSeconds_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_month_set", _wrap_blpapi_Datetime_tag_month_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_month_get", _wrap_blpapi_Datetime_tag_month_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_day_set", _wrap_blpapi_Datetime_tag_day_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_day_get", _wrap_blpapi_Datetime_tag_day_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_year_set", _wrap_blpapi_Datetime_tag_year_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_year_get", _wrap_blpapi_Datetime_tag_year_get, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_offset_set", _wrap_blpapi_Datetime_tag_offset_set, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_offset_get", _wrap_blpapi_Datetime_tag_offset_get, METH_VARARGS, NULL}, - { (char *)"new_blpapi_Datetime_tag", _wrap_new_blpapi_Datetime_tag, METH_VARARGS, NULL}, - { (char *)"delete_blpapi_Datetime_tag", _wrap_delete_blpapi_Datetime_tag, METH_VARARGS, NULL}, - { (char *)"blpapi_Datetime_tag_swigregister", blpapi_Datetime_tag_swigregister, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_tag_datetime_set", _wrap_blpapi_HighPrecisionDatetime_tag_datetime_set, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_tag_datetime_get", _wrap_blpapi_HighPrecisionDatetime_tag_datetime_get, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_tag_picoseconds_set", _wrap_blpapi_HighPrecisionDatetime_tag_picoseconds_set, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_tag_picoseconds_get", _wrap_blpapi_HighPrecisionDatetime_tag_picoseconds_get, METH_VARARGS, NULL}, - { (char *)"new_blpapi_HighPrecisionDatetime_tag", _wrap_new_blpapi_HighPrecisionDatetime_tag, METH_VARARGS, NULL}, - { (char *)"delete_blpapi_HighPrecisionDatetime_tag", _wrap_delete_blpapi_HighPrecisionDatetime_tag, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_tag_swigregister", blpapi_HighPrecisionDatetime_tag_swigregister, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_compare", _wrap_blpapi_HighPrecisionDatetime_compare, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_print", _wrap_blpapi_HighPrecisionDatetime_print, METH_VARARGS, NULL}, - { (char *)"blpapi_HighPrecisionDatetime_fromTimePoint", _wrap_blpapi_HighPrecisionDatetime_fromTimePoint, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_name", _wrap_blpapi_Constant_name, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_description", _wrap_blpapi_Constant_description, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_status", _wrap_blpapi_Constant_status, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_datatype", _wrap_blpapi_Constant_datatype, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_getValueAsInt64", _wrap_blpapi_Constant_getValueAsInt64, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_getValueAsFloat64", _wrap_blpapi_Constant_getValueAsFloat64, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_getValueAsDatetime", _wrap_blpapi_Constant_getValueAsDatetime, METH_VARARGS, NULL}, - { (char *)"blpapi_Constant_getValueAsString", _wrap_blpapi_Constant_getValueAsString, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_name", _wrap_blpapi_ConstantList_name, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_description", _wrap_blpapi_ConstantList_description, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_numConstants", _wrap_blpapi_ConstantList_numConstants, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_datatype", _wrap_blpapi_ConstantList_datatype, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_status", _wrap_blpapi_ConstantList_status, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_getConstant", _wrap_blpapi_ConstantList_getConstant, METH_VARARGS, NULL}, - { (char *)"blpapi_ConstantList_getConstantAt", _wrap_blpapi_ConstantList_getConstantAt, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_name", _wrap_blpapi_SchemaElementDefinition_name, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_description", _wrap_blpapi_SchemaElementDefinition_description, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_status", _wrap_blpapi_SchemaElementDefinition_status, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_type", _wrap_blpapi_SchemaElementDefinition_type, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_numAlternateNames", _wrap_blpapi_SchemaElementDefinition_numAlternateNames, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_getAlternateName", _wrap_blpapi_SchemaElementDefinition_getAlternateName, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_minValues", _wrap_blpapi_SchemaElementDefinition_minValues, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaElementDefinition_maxValues", _wrap_blpapi_SchemaElementDefinition_maxValues, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_name", _wrap_blpapi_SchemaTypeDefinition_name, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_description", _wrap_blpapi_SchemaTypeDefinition_description, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_status", _wrap_blpapi_SchemaTypeDefinition_status, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_datatype", _wrap_blpapi_SchemaTypeDefinition_datatype, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_isComplexType", _wrap_blpapi_SchemaTypeDefinition_isComplexType, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_isSimpleType", _wrap_blpapi_SchemaTypeDefinition_isSimpleType, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_isEnumerationType", _wrap_blpapi_SchemaTypeDefinition_isEnumerationType, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_numElementDefinitions", _wrap_blpapi_SchemaTypeDefinition_numElementDefinitions, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_getElementDefinition", _wrap_blpapi_SchemaTypeDefinition_getElementDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_getElementDefinitionAt", _wrap_blpapi_SchemaTypeDefinition_getElementDefinitionAt, METH_VARARGS, NULL}, - { (char *)"blpapi_SchemaTypeDefinition_enumeration", _wrap_blpapi_SchemaTypeDefinition_enumeration, METH_VARARGS, NULL}, - { (char *)"blpapi_Request_destroy", _wrap_blpapi_Request_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_Request_elements", _wrap_blpapi_Request_elements, METH_VARARGS, NULL}, - { (char *)"blpapi_Request_setPreferredRoute", _wrap_blpapi_Request_setPreferredRoute, METH_VARARGS, NULL}, - { (char *)"blpapi_Operation_name", _wrap_blpapi_Operation_name, METH_VARARGS, NULL}, - { (char *)"blpapi_Operation_description", _wrap_blpapi_Operation_description, METH_VARARGS, NULL}, - { (char *)"blpapi_Operation_requestDefinition", _wrap_blpapi_Operation_requestDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_Operation_numResponseDefinitions", _wrap_blpapi_Operation_numResponseDefinitions, METH_VARARGS, NULL}, - { (char *)"blpapi_Operation_responseDefinition", _wrap_blpapi_Operation_responseDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_name", _wrap_blpapi_Service_name, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_description", _wrap_blpapi_Service_description, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_numOperations", _wrap_blpapi_Service_numOperations, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_numEventDefinitions", _wrap_blpapi_Service_numEventDefinitions, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_addRef", _wrap_blpapi_Service_addRef, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_release", _wrap_blpapi_Service_release, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_authorizationServiceName", _wrap_blpapi_Service_authorizationServiceName, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_getOperation", _wrap_blpapi_Service_getOperation, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_getOperationAt", _wrap_blpapi_Service_getOperationAt, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_getEventDefinition", _wrap_blpapi_Service_getEventDefinition, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_getEventDefinitionAt", _wrap_blpapi_Service_getEventDefinitionAt, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_createRequest", _wrap_blpapi_Service_createRequest, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_createAuthorizationRequest", _wrap_blpapi_Service_createAuthorizationRequest, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_createPublishEvent", _wrap_blpapi_Service_createPublishEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_createAdminEvent", _wrap_blpapi_Service_createAdminEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_Service_createResponseEvent", _wrap_blpapi_Service_createResponseEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_messageType", _wrap_blpapi_Message_messageType, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_topicName", _wrap_blpapi_Message_topicName, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_service", _wrap_blpapi_Message_service, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_numCorrelationIds", _wrap_blpapi_Message_numCorrelationIds, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_correlationId", _wrap_blpapi_Message_correlationId, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_elements", _wrap_blpapi_Message_elements, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_fragmentType", _wrap_blpapi_Message_fragmentType, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_addRef", _wrap_blpapi_Message_addRef, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_release", _wrap_blpapi_Message_release, METH_VARARGS, NULL}, - { (char *)"blpapi_Message_timeReceived", _wrap_blpapi_Message_timeReceived, METH_VARARGS, NULL}, - { (char *)"blpapi_Event_eventType", _wrap_blpapi_Event_eventType, METH_VARARGS, NULL}, - { (char *)"blpapi_Event_release", _wrap_blpapi_Event_release, METH_VARARGS, NULL}, - { (char *)"blpapi_EventQueue_create", _wrap_blpapi_EventQueue_create, METH_VARARGS, NULL}, - { (char *)"blpapi_EventQueue_destroy", _wrap_blpapi_EventQueue_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_EventQueue_nextEvent", _wrap_blpapi_EventQueue_nextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_EventQueue_purge", _wrap_blpapi_EventQueue_purge, METH_VARARGS, NULL}, - { (char *)"blpapi_EventQueue_tryNextEvent", _wrap_blpapi_EventQueue_tryNextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_MessageIterator_create", _wrap_blpapi_MessageIterator_create, METH_VARARGS, NULL}, - { (char *)"blpapi_MessageIterator_destroy", _wrap_blpapi_MessageIterator_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_MessageIterator_next", _wrap_blpapi_MessageIterator_next, METH_VARARGS, NULL}, - { (char *)"blpapi_Identity_release", _wrap_blpapi_Identity_release, METH_VARARGS, NULL}, - { (char *)"blpapi_Identity_addRef", _wrap_blpapi_Identity_addRef, METH_VARARGS, NULL}, - { (char *)"blpapi_Identity_hasEntitlements", _wrap_blpapi_Identity_hasEntitlements, METH_VARARGS, NULL}, - { (char *)"blpapi_Identity_isAuthorized", _wrap_blpapi_Identity_isAuthorized, METH_VARARGS, NULL}, - { (char *)"blpapi_Identity_getSeatType", _wrap_blpapi_Identity_getSeatType, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_cancel", _wrap_blpapi_AbstractSession_cancel, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_sendAuthorizationRequest", _wrap_blpapi_AbstractSession_sendAuthorizationRequest, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_openService", _wrap_blpapi_AbstractSession_openService, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_openServiceAsync", _wrap_blpapi_AbstractSession_openServiceAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_generateToken", _wrap_blpapi_AbstractSession_generateToken, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_getService", _wrap_blpapi_AbstractSession_getService, METH_VARARGS, NULL}, - { (char *)"blpapi_AbstractSession_createIdentity", _wrap_blpapi_AbstractSession_createIdentity, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_start", _wrap_blpapi_Session_start, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_startAsync", _wrap_blpapi_Session_startAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_stop", _wrap_blpapi_Session_stop, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_stopAsync", _wrap_blpapi_Session_stopAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_nextEvent", _wrap_blpapi_Session_nextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_tryNextEvent", _wrap_blpapi_Session_tryNextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_subscribe", _wrap_blpapi_Session_subscribe, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_resubscribe", _wrap_blpapi_Session_resubscribe, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_resubscribeWithId", _wrap_blpapi_Session_resubscribeWithId, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_unsubscribe", _wrap_blpapi_Session_unsubscribe, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_setStatusCorrelationId", _wrap_blpapi_Session_setStatusCorrelationId, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_sendRequest", _wrap_blpapi_Session_sendRequest, METH_VARARGS, NULL}, - { (char *)"blpapi_Session_getAbstractSession", _wrap_blpapi_Session_getAbstractSession, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_extractAttributeFromResolutionSuccess", _wrap_blpapi_ResolutionList_extractAttributeFromResolutionSuccess, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_create", _wrap_blpapi_ResolutionList_create, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_destroy", _wrap_blpapi_ResolutionList_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_add", _wrap_blpapi_ResolutionList_add, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_addFromMessage", _wrap_blpapi_ResolutionList_addFromMessage, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_addAttribute", _wrap_blpapi_ResolutionList_addAttribute, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_correlationIdAt", _wrap_blpapi_ResolutionList_correlationIdAt, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_topicString", _wrap_blpapi_ResolutionList_topicString, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_topicStringAt", _wrap_blpapi_ResolutionList_topicStringAt, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_status", _wrap_blpapi_ResolutionList_status, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_statusAt", _wrap_blpapi_ResolutionList_statusAt, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_attribute", _wrap_blpapi_ResolutionList_attribute, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_attributeAt", _wrap_blpapi_ResolutionList_attributeAt, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_message", _wrap_blpapi_ResolutionList_message, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_messageAt", _wrap_blpapi_ResolutionList_messageAt, METH_VARARGS, NULL}, - { (char *)"blpapi_ResolutionList_size", _wrap_blpapi_ResolutionList_size, METH_VARARGS, NULL}, - { (char *)"blpapi_Topic_create", _wrap_blpapi_Topic_create, METH_VARARGS, NULL}, - { (char *)"blpapi_Topic_destroy", _wrap_blpapi_Topic_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_Topic_compare", _wrap_blpapi_Topic_compare, METH_VARARGS, NULL}, - { (char *)"blpapi_Topic_service", _wrap_blpapi_Topic_service, METH_VARARGS, NULL}, - { (char *)"blpapi_Topic_isActive", _wrap_blpapi_Topic_isActive, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_create", _wrap_blpapi_TopicList_create, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_destroy", _wrap_blpapi_TopicList_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_add", _wrap_blpapi_TopicList_add, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_addFromMessage", _wrap_blpapi_TopicList_addFromMessage, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_correlationIdAt", _wrap_blpapi_TopicList_correlationIdAt, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_topicString", _wrap_blpapi_TopicList_topicString, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_topicStringAt", _wrap_blpapi_TopicList_topicStringAt, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_status", _wrap_blpapi_TopicList_status, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_statusAt", _wrap_blpapi_TopicList_statusAt, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_message", _wrap_blpapi_TopicList_message, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_messageAt", _wrap_blpapi_TopicList_messageAt, METH_VARARGS, NULL}, - { (char *)"blpapi_TopicList_size", _wrap_blpapi_TopicList_size, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_create", _wrap_blpapi_ProviderSession_create, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_destroy", _wrap_blpapi_ProviderSession_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_start", _wrap_blpapi_ProviderSession_start, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_startAsync", _wrap_blpapi_ProviderSession_startAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_stop", _wrap_blpapi_ProviderSession_stop, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_stopAsync", _wrap_blpapi_ProviderSession_stopAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_nextEvent", _wrap_blpapi_ProviderSession_nextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_tryNextEvent", _wrap_blpapi_ProviderSession_tryNextEvent, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_registerService", _wrap_blpapi_ProviderSession_registerService, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_activateSubServiceCodeRange", _wrap_blpapi_ProviderSession_activateSubServiceCodeRange, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_deactivateSubServiceCodeRange", _wrap_blpapi_ProviderSession_deactivateSubServiceCodeRange, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_registerServiceAsync", _wrap_blpapi_ProviderSession_registerServiceAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_deregisterService", _wrap_blpapi_ProviderSession_deregisterService, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_resolve", _wrap_blpapi_ProviderSession_resolve, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_resolveAsync", _wrap_blpapi_ProviderSession_resolveAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_createTopics", _wrap_blpapi_ProviderSession_createTopics, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_createTopicsAsync", _wrap_blpapi_ProviderSession_createTopicsAsync, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_getTopic", _wrap_blpapi_ProviderSession_getTopic, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_createTopic", _wrap_blpapi_ProviderSession_createTopic, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_createServiceStatusTopic", _wrap_blpapi_ProviderSession_createServiceStatusTopic, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_deleteTopics", _wrap_blpapi_ProviderSession_deleteTopics, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_publish", _wrap_blpapi_ProviderSession_publish, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_sendResponse", _wrap_blpapi_ProviderSession_sendResponse, METH_VARARGS, NULL}, - { (char *)"blpapi_ProviderSession_getAbstractSession", _wrap_blpapi_ProviderSession_getAbstractSession, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_create", _wrap_blpapi_ServiceRegistrationOptions_create, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_duplicate", _wrap_blpapi_ServiceRegistrationOptions_duplicate, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_destroy", _wrap_blpapi_ServiceRegistrationOptions_destroy, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_copy", _wrap_blpapi_ServiceRegistrationOptions_copy, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange", _wrap_blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges", _wrap_blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_setGroupId", _wrap_blpapi_ServiceRegistrationOptions_setGroupId, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_setServicePriority", _wrap_blpapi_ServiceRegistrationOptions_setServicePriority, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_setPartsToRegister", _wrap_blpapi_ServiceRegistrationOptions_setPartsToRegister, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_getGroupId", _wrap_blpapi_ServiceRegistrationOptions_getGroupId, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_getServicePriority", _wrap_blpapi_ServiceRegistrationOptions_getServicePriority, METH_VARARGS, NULL}, - { (char *)"blpapi_ServiceRegistrationOptions_getPartsToRegister", _wrap_blpapi_ServiceRegistrationOptions_getPartsToRegister, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ - -static void *_p_BloombergLP__blpapi__SessionTo_p_BloombergLP__blpapi__AbstractSession(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((BloombergLP::blpapi::AbstractSession *) ((BloombergLP::blpapi::Session *) x)); -} -static void *_p_BloombergLP__blpapi__ProviderSessionTo_p_BloombergLP__blpapi__AbstractSession(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((BloombergLP::blpapi::AbstractSession *) ((BloombergLP::blpapi::ProviderSession *) x)); -} -static void *_p_intArrayTo_p_int(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((int *) ((intArray *) x)); -} -static swig_type_info _swigt__p_BloombergLP__blpapi__AbstractSession = {"_p_BloombergLP__blpapi__AbstractSession", "BloombergLP::blpapi::AbstractSession *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_BloombergLP__blpapi__Session = {"_p_BloombergLP__blpapi__Session", 0, 0, 0, 0, 0}; -static swig_type_info _swigt__p_BloombergLP__blpapi__ProviderSession = {"_p_BloombergLP__blpapi__ProviderSession", 0, 0, 0, 0, 0}; -static swig_type_info _swigt__p_blpapi_AbstractSession = {"_p_blpapi_AbstractSession", "blpapi_AbstractSession *|blpapi_AbstractSession_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Constant = {"_p_blpapi_Constant", "blpapi_Constant *|blpapi_Constant_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_ConstantList = {"_p_blpapi_ConstantList", "blpapi_ConstantList *|blpapi_ConstantList_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_CorrelationId_t_ = {"_p_blpapi_CorrelationId_t_", "blpapi_CorrelationId_t_ *|blpapi_CorrelationId_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Datetime_tag = {"_p_blpapi_Datetime_tag", "blpapi_Datetime_t *|blpapi_Datetime_tag *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Element = {"_p_blpapi_Element", "blpapi_Element_t *|blpapi_Element *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Event = {"_p_blpapi_Event", "blpapi_Event *|blpapi_Event_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_EventDispatcher = {"_p_blpapi_EventDispatcher", "blpapi_EventDispatcher *|blpapi_EventDispatcher_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_EventFormatter = {"_p_blpapi_EventFormatter", "blpapi_EventFormatter *|blpapi_EventFormatter_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_EventQueue = {"_p_blpapi_EventQueue", "blpapi_EventQueue *|blpapi_EventQueue_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_HighPrecisionDatetime_tag = {"_p_blpapi_HighPrecisionDatetime_tag", "blpapi_HighPrecisionDatetime_t *|blpapi_HighPrecisionDatetime_tag *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Identity = {"_p_blpapi_Identity", "blpapi_Identity *|blpapi_UserHandle_t *|blpapi_UserHandle *|blpapi_Identity_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Logging_Func_t = {"_p_blpapi_Logging_Func_t", "blpapi_Logging_Func_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Logging_Severity_t = {"_p_blpapi_Logging_Severity_t", "enum blpapi_Logging_Severity_t *|blpapi_Logging_Severity_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_ManagedPtr_t_ = {"_p_blpapi_ManagedPtr_t_", "blpapi_ManagedPtr_t *|blpapi_ManagedPtr_t_ *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Message = {"_p_blpapi_Message", "blpapi_Message *|blpapi_Message_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_MessageIterator = {"_p_blpapi_MessageIterator", "blpapi_MessageIterator *|blpapi_MessageIterator_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Name = {"_p_blpapi_Name", "blpapi_Name *|blpapi_Name_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Operation = {"_p_blpapi_Operation", "blpapi_Operation_t *|blpapi_Operation *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_ProviderSession = {"_p_blpapi_ProviderSession", "blpapi_ProviderSession *|blpapi_ProviderSession_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Request = {"_p_blpapi_Request", "blpapi_Request *|blpapi_Request_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_ResolutionList = {"_p_blpapi_ResolutionList", "blpapi_ResolutionList *|blpapi_ResolutionList_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Service = {"_p_blpapi_Service", "blpapi_Service_t *|blpapi_Service *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_ServiceRegistrationOptions = {"_p_blpapi_ServiceRegistrationOptions", "blpapi_ServiceRegistrationOptions *|blpapi_ServiceRegistrationOptions_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Session = {"_p_blpapi_Session", "blpapi_Session *|blpapi_Session_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_SessionOptions = {"_p_blpapi_SessionOptions", "blpapi_SessionOptions *|blpapi_SessionOptions_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_StreamWriter_t = {"_p_blpapi_StreamWriter_t", "blpapi_StreamWriter_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_SubscriptionItrerator = {"_p_blpapi_SubscriptionItrerator", "blpapi_SubscriptionItrerator *|blpapi_SubscriptionIterator_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_SubscriptionList = {"_p_blpapi_SubscriptionList", "blpapi_SubscriptionList *|blpapi_SubscriptionList_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_TimePoint_t = {"_p_blpapi_TimePoint_t", "blpapi_TimePoint_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_Topic = {"_p_blpapi_Topic", "blpapi_Topic *|blpapi_Topic_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_blpapi_TopicList = {"_p_blpapi_TopicList", "blpapi_TopicList *|blpapi_TopicList_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_char = {"_p_char", "char *|blpapi_Char_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_double = {"_p_double", "blpapi_Float64_t *|double *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void = {"_p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void", "void (*)(blpapi_Event *,blpapi_ProviderSession *,void *)|blpapi_ProviderEventHandler_t", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_float = {"_p_float", "blpapi_Float32_t *|float *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_int = {"_p_int", "blpapi_Bool_t *|int *|blpapi_Int32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_intArray = {"_p_intArray", "intArray *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_long_long = {"_p_long_long", "blpapi_Int64_t *|long long *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Element = {"_p_p_blpapi_Element", "blpapi_Element **|blpapi_Element_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Event = {"_p_p_blpapi_Event", "blpapi_Event **|blpapi_Event_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Message = {"_p_p_blpapi_Message", "blpapi_Message_t **|blpapi_Message **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Name = {"_p_p_blpapi_Name", "blpapi_Name **|blpapi_Name_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Operation = {"_p_p_blpapi_Operation", "blpapi_Operation **|blpapi_Operation_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Request = {"_p_p_blpapi_Request", "blpapi_Request_t **|blpapi_Request **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Service = {"_p_p_blpapi_Service", "blpapi_Service_t **|blpapi_Service **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_blpapi_Topic = {"_p_p_blpapi_Topic", "blpapi_Topic **|blpapi_Topic_t **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_p_void = {"_p_p_p_void", "blpapi_SchemaElementDefinition_t **|void ***", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_void = {"_p_p_void", "blpapi_SchemaElementDefinition_t *|blpapi_SchemaTypeDefinition_t *|void **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_short = {"_p_short", "short *|blpapi_Int16_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|blpapi_UChar_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "blpapi_UInt32_t *|unsigned int *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "blpapi_UInt64_t *|unsigned long long *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|blpapi_UInt16_t *", 0, 0, (void*)0, 0}; - -static swig_type_info *swig_type_initial[] = { - &_swigt__p_BloombergLP__blpapi__AbstractSession, - &_swigt__p_BloombergLP__blpapi__ProviderSession, - &_swigt__p_BloombergLP__blpapi__Session, - &_swigt__p_blpapi_AbstractSession, - &_swigt__p_blpapi_Constant, - &_swigt__p_blpapi_ConstantList, - &_swigt__p_blpapi_CorrelationId_t_, - &_swigt__p_blpapi_Datetime_tag, - &_swigt__p_blpapi_Element, - &_swigt__p_blpapi_Event, - &_swigt__p_blpapi_EventDispatcher, - &_swigt__p_blpapi_EventFormatter, - &_swigt__p_blpapi_EventQueue, - &_swigt__p_blpapi_HighPrecisionDatetime_tag, - &_swigt__p_blpapi_Identity, - &_swigt__p_blpapi_Logging_Func_t, - &_swigt__p_blpapi_Logging_Severity_t, - &_swigt__p_blpapi_ManagedPtr_t_, - &_swigt__p_blpapi_Message, - &_swigt__p_blpapi_MessageIterator, - &_swigt__p_blpapi_Name, - &_swigt__p_blpapi_Operation, - &_swigt__p_blpapi_ProviderSession, - &_swigt__p_blpapi_Request, - &_swigt__p_blpapi_ResolutionList, - &_swigt__p_blpapi_Service, - &_swigt__p_blpapi_ServiceRegistrationOptions, - &_swigt__p_blpapi_Session, - &_swigt__p_blpapi_SessionOptions, - &_swigt__p_blpapi_StreamWriter_t, - &_swigt__p_blpapi_SubscriptionItrerator, - &_swigt__p_blpapi_SubscriptionList, - &_swigt__p_blpapi_TimePoint_t, - &_swigt__p_blpapi_Topic, - &_swigt__p_blpapi_TopicList, - &_swigt__p_char, - &_swigt__p_double, - &_swigt__p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void, - &_swigt__p_float, - &_swigt__p_int, - &_swigt__p_intArray, - &_swigt__p_long_long, - &_swigt__p_p_blpapi_Element, - &_swigt__p_p_blpapi_Event, - &_swigt__p_p_blpapi_Message, - &_swigt__p_p_blpapi_Name, - &_swigt__p_p_blpapi_Operation, - &_swigt__p_p_blpapi_Request, - &_swigt__p_p_blpapi_Service, - &_swigt__p_p_blpapi_Topic, - &_swigt__p_p_char, - &_swigt__p_p_p_void, - &_swigt__p_p_void, - &_swigt__p_short, - &_swigt__p_unsigned_char, - &_swigt__p_unsigned_int, - &_swigt__p_unsigned_long_long, - &_swigt__p_unsigned_short, -}; - -static swig_cast_info _swigc__p_BloombergLP__blpapi__Session[] = {{&_swigt__p_BloombergLP__blpapi__Session, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_BloombergLP__blpapi__ProviderSession[] = {{&_swigt__p_BloombergLP__blpapi__ProviderSession, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_BloombergLP__blpapi__AbstractSession[] = { {&_swigt__p_BloombergLP__blpapi__AbstractSession, 0, 0, 0}, {&_swigt__p_BloombergLP__blpapi__Session, _p_BloombergLP__blpapi__SessionTo_p_BloombergLP__blpapi__AbstractSession, 0, 0}, {&_swigt__p_BloombergLP__blpapi__ProviderSession, _p_BloombergLP__blpapi__ProviderSessionTo_p_BloombergLP__blpapi__AbstractSession, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_AbstractSession[] = { {&_swigt__p_blpapi_AbstractSession, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Constant[] = { {&_swigt__p_blpapi_Constant, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_ConstantList[] = { {&_swigt__p_blpapi_ConstantList, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_CorrelationId_t_[] = { {&_swigt__p_blpapi_CorrelationId_t_, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Datetime_tag[] = { {&_swigt__p_blpapi_Datetime_tag, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Element[] = { {&_swigt__p_blpapi_Element, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Event[] = { {&_swigt__p_blpapi_Event, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_EventDispatcher[] = { {&_swigt__p_blpapi_EventDispatcher, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_EventFormatter[] = { {&_swigt__p_blpapi_EventFormatter, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_EventQueue[] = { {&_swigt__p_blpapi_EventQueue, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_HighPrecisionDatetime_tag[] = { {&_swigt__p_blpapi_HighPrecisionDatetime_tag, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Identity[] = { {&_swigt__p_blpapi_Identity, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Logging_Func_t[] = { {&_swigt__p_blpapi_Logging_Func_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Logging_Severity_t[] = { {&_swigt__p_blpapi_Logging_Severity_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_ManagedPtr_t_[] = { {&_swigt__p_blpapi_ManagedPtr_t_, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Message[] = { {&_swigt__p_blpapi_Message, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_MessageIterator[] = { {&_swigt__p_blpapi_MessageIterator, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Name[] = { {&_swigt__p_blpapi_Name, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Operation[] = { {&_swigt__p_blpapi_Operation, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_ProviderSession[] = { {&_swigt__p_blpapi_ProviderSession, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Request[] = { {&_swigt__p_blpapi_Request, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_ResolutionList[] = { {&_swigt__p_blpapi_ResolutionList, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Service[] = { {&_swigt__p_blpapi_Service, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_ServiceRegistrationOptions[] = { {&_swigt__p_blpapi_ServiceRegistrationOptions, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Session[] = { {&_swigt__p_blpapi_Session, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_SessionOptions[] = { {&_swigt__p_blpapi_SessionOptions, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_StreamWriter_t[] = { {&_swigt__p_blpapi_StreamWriter_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_SubscriptionItrerator[] = { {&_swigt__p_blpapi_SubscriptionItrerator, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_SubscriptionList[] = { {&_swigt__p_blpapi_SubscriptionList, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_TimePoint_t[] = { {&_swigt__p_blpapi_TimePoint_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_Topic[] = { {&_swigt__p_blpapi_Topic, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_blpapi_TopicList[] = { {&_swigt__p_blpapi_TopicList, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void[] = { {&_swigt__p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_int[] = { {&_swigt__p_intArray, _p_intArrayTo_p_int, 0, 0}, {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_intArray[] = { {&_swigt__p_intArray, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Element[] = { {&_swigt__p_p_blpapi_Element, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Event[] = { {&_swigt__p_p_blpapi_Event, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Message[] = { {&_swigt__p_p_blpapi_Message, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Name[] = { {&_swigt__p_p_blpapi_Name, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Operation[] = { {&_swigt__p_p_blpapi_Operation, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Request[] = { {&_swigt__p_p_blpapi_Request, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Service[] = { {&_swigt__p_p_blpapi_Service, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_blpapi_Topic[] = { {&_swigt__p_p_blpapi_Topic, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_p_void[] = { {&_swigt__p_p_p_void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; - -static swig_cast_info *swig_cast_initial[] = { - _swigc__p_BloombergLP__blpapi__AbstractSession, - _swigc__p_BloombergLP__blpapi__ProviderSession, - _swigc__p_BloombergLP__blpapi__Session, - _swigc__p_blpapi_AbstractSession, - _swigc__p_blpapi_Constant, - _swigc__p_blpapi_ConstantList, - _swigc__p_blpapi_CorrelationId_t_, - _swigc__p_blpapi_Datetime_tag, - _swigc__p_blpapi_Element, - _swigc__p_blpapi_Event, - _swigc__p_blpapi_EventDispatcher, - _swigc__p_blpapi_EventFormatter, - _swigc__p_blpapi_EventQueue, - _swigc__p_blpapi_HighPrecisionDatetime_tag, - _swigc__p_blpapi_Identity, - _swigc__p_blpapi_Logging_Func_t, - _swigc__p_blpapi_Logging_Severity_t, - _swigc__p_blpapi_ManagedPtr_t_, - _swigc__p_blpapi_Message, - _swigc__p_blpapi_MessageIterator, - _swigc__p_blpapi_Name, - _swigc__p_blpapi_Operation, - _swigc__p_blpapi_ProviderSession, - _swigc__p_blpapi_Request, - _swigc__p_blpapi_ResolutionList, - _swigc__p_blpapi_Service, - _swigc__p_blpapi_ServiceRegistrationOptions, - _swigc__p_blpapi_Session, - _swigc__p_blpapi_SessionOptions, - _swigc__p_blpapi_StreamWriter_t, - _swigc__p_blpapi_SubscriptionItrerator, - _swigc__p_blpapi_SubscriptionList, - _swigc__p_blpapi_TimePoint_t, - _swigc__p_blpapi_Topic, - _swigc__p_blpapi_TopicList, - _swigc__p_char, - _swigc__p_double, - _swigc__p_f_p_blpapi_Event_p_blpapi_ProviderSession_p_void__void, - _swigc__p_float, - _swigc__p_int, - _swigc__p_intArray, - _swigc__p_long_long, - _swigc__p_p_blpapi_Element, - _swigc__p_p_blpapi_Event, - _swigc__p_p_blpapi_Message, - _swigc__p_p_blpapi_Name, - _swigc__p_p_blpapi_Operation, - _swigc__p_p_blpapi_Request, - _swigc__p_p_blpapi_Service, - _swigc__p_p_blpapi_Topic, - _swigc__p_p_char, - _swigc__p_p_p_void, - _swigc__p_p_void, - _swigc__p_short, - _swigc__p_unsigned_char, - _swigc__p_unsigned_int, - _swigc__p_unsigned_long_long, - _swigc__p_unsigned_short, -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ - -static swig_const_info swig_const_table[] = { -{0, 0, 0, 0.0, 0, 0}}; - -#ifdef __cplusplus -} -#endif -/* ----------------------------------------------------------------------------- - * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to - * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of - * swig_module, and does all the lookup, filling in the swig_module.types - * array with the correct data and linking the correct swig_cast_info - * structures together. - * - * The generated swig_type_info structures are assigned statically to an initial - * array. We just loop through that array, and handle each type individually. - * First we lookup if this type has been already loaded, and if so, use the - * loaded structure instead of the generated one. Then we have to fill in the - * cast linked list. The cast data is initially stored in something like a - * two-dimensional array. Each row corresponds to a type (there are the same - * number of rows as there are in the swig_type_initial array). Each entry in - * a column is one of the swig_cast_info structures for that type. - * The cast_initial array is actually an array of arrays, because each row has - * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it - * adding the casts to the list. The one last trick we need to do is making - * sure the type pointer in the swig_cast_info struct is correct. - * - * First off, we lookup the cast->type name to see if it is already loaded. - * There are three cases to handle: - * 1) If the cast->type has already been loaded AND the type we are adding - * casting info to has not been loaded (it is in this module), THEN we - * replace the cast->type pointer with the type pointer that has already - * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the - * cast->type) are loaded, THEN the cast info has already been loaded by - * the previous module so we just ignore it. - * 3) Finally, if cast->type has not already been loaded, then we add that - * swig_cast_info to the linked list (because the cast->type) pointer will - * be correct. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* c-mode */ -#endif -#endif - -#if 0 -#define SWIGRUNTIME_DEBUG -#endif - - -SWIGRUNTIME void -SWIG_InitializeModule(void *clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int init; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - iter=module_head; - do { - if (iter==&swig_module) { - /* Our module is already in the list, so there's nothing more to do. */ - return; - } - iter=iter->next; - } while (iter!= module_head); - - /* otherwise we must add our module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } - - /* When multiple interpreters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); -#endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); -#endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); -#endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); -#endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); -#endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); -#ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); -#endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); -#endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); -#ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); -#endif - if (!ocast) ret = 0; - } - } - - if (!ret) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); -#endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; - } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; - } - swig_module.types[i] = 0; - -#ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n",j); - } - printf("**** SWIG_InitializeModule: Cast List ******\n"); -#endif -} - -/* This function will propagate the clientdata field of type to -* any new swig_type_info structures that have been added into the list -* of equivalent types. It is like calling -* SWIG_TypeClientData(type, clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } - } - } -} - -#ifdef __cplusplus -#if 0 -{ - /* c-mode */ -#endif -} -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - /* Python-specific SWIG API */ -#define SWIG_newvarlink() SWIG_Python_newvarlink() -#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) -#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - - /* ----------------------------------------------------------------------------- - * global variable support code. - * ----------------------------------------------------------------------------- */ - - typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; - } swig_globalvar; - - typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; - } swig_varlinkobject; - - SWIGINTERN PyObject * - swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); -#else - return PyString_FromString(""); -#endif - } - - SWIGINTERN PyObject * - swig_varlink_str(swig_varlinkobject *v) { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - tail = PyUnicode_FromString(var->name); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - } - } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; -#else - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - PyString_ConcatAndDel(&str,PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str,PyString_FromString(")")); -#endif - return str; - } - - SWIGINTERN int - swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; - PyObject *str = swig_varlink_str(v); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(str); - return 0; - } - - SWIGINTERN void - swig_varlink_dealloc(swig_varlinkobject *v) { - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } - } - - SWIGINTERN PyObject * - swig_varlink_getattr(swig_varlinkobject *v, char *n) { - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; - } - if (res == NULL && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; - } - - SWIGINTERN int - swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; - } - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { - static char varlink__doc__[] = "Swig var link object"; - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"swigvarlink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) swig_varlink_dealloc, /* tp_dealloc */ - (printfunc) swig_varlink_print, /* tp_print */ - (getattrfunc) swig_varlink_getattr, /* tp_getattr */ - (setattrfunc) swig_varlink_setattr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc) swig_varlink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) swig_varlink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - varlink__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 - 0, /* tp_prev */ -#endif - 0 /* tp_next */ -#endif - }; - varlink_type = tmp; - type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - varlink_type.ob_type = &PyType_Type; -#else - if (PyType_Ready(&varlink_type) < 0) - return NULL; -#endif - } - return &varlink_type; - } - - /* Create a variable linking object for use later */ - SWIGINTERN PyObject * - SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject*) result); - } - - SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name)+1; - gv->name = (char *)malloc(size); - if (gv->name) { - strncpy(gv->name,name,size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } - } - v->vars = gv; - } - - SWIGINTERN PyObject * - SWIG_globals(void) { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; - } - - /* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - - /* Install Constants */ - SWIGINTERN void - SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { - PyObject *obj = 0; - size_t i; - for (i = 0; constants[i].type; ++i) { - switch(constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - Py_DECREF(obj); - } - } - } - - /* -----------------------------------------------------------------------------*/ - /* Fix SwigMethods to carry the callback ptrs when needed */ - /* -----------------------------------------------------------------------------*/ - - SWIGINTERN void - SWIG_Python_FixMethods(PyMethodDef *methods, - swig_const_info *const_table, - swig_type_info **types, - swig_type_info **types_initial) { - size_t i; - for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; - if (!c) continue; - c = strstr(c, "swig_ptr: "); - if (c) { - int j; - swig_const_info *ci = 0; - const char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - strncpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - strncpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } - } - } - } - } - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" -#endif - -SWIGEXPORT -#if PY_VERSION_HEX >= 0x03000000 -PyObject* -#else -void -#endif -SWIG_init(void) { - PyObject *m, *d, *md; -#if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { -# if PY_VERSION_HEX >= 0x03020000 - PyModuleDef_HEAD_INIT, -# else - { - PyObject_HEAD_INIT(NULL) - NULL, /* m_init */ - 0, /* m_index */ - NULL, /* m_copy */ - }, -# endif - (char *) SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - -#if defined(SWIGPYTHON_BUILTIN) - static SwigPyClientData SwigPyObject_clientdata = { - 0, 0, 0, 0, 0, 0, 0 - }; - static PyGetSetDef this_getset_def = { - (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL - }; - static SwigPyGetSet thisown_getset_closure = { - (PyCFunction) SwigPyObject_own, - (PyCFunction) SwigPyObject_own - }; - static PyGetSetDef thisown_getset_def = { - (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure - }; - PyTypeObject *builtin_pytype; - int builtin_base_count; - swig_type_info *builtin_basetype; - PyObject *tuple; - PyGetSetDescrObject *static_getset; - PyTypeObject *metatype; - PyTypeObject *swigpyobject; - SwigPyClientData *cd; - PyObject *public_interface, *public_symbol; - PyObject *this_descr; - PyObject *thisown_descr; - PyObject *self = 0; - int i; - - (void)builtin_pytype; - (void)builtin_base_count; - (void)builtin_basetype; - (void)tuple; - (void)static_getset; - (void)self; - - /* Metaclass is used to implement static member variables */ - metatype = SwigPyObjectType(); - assert(metatype); -#endif - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - -#if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); -#else - m = Py_InitModule((char *) SWIG_name, SwigMethods); -#endif - - md = d = PyModule_GetDict(m); - (void)md; - - SWIG_InitializeModule(0); - -#ifdef SWIGPYTHON_BUILTIN - swigpyobject = SwigPyObject_TypeOnce(); - - SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - if (!cd) { - SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; - SwigPyObject_clientdata.pytype = swigpyobject; - } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { - PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); -# if PY_VERSION_HEX >= 0x03000000 - return NULL; -# else - return; -# endif - } - - /* All objects have a 'this' attribute */ - this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); - (void)this_descr; - - /* All objects have a 'thisown' attribute */ - thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); - (void)thisown_descr; - - public_interface = PyList_New(0); - public_symbol = 0; - (void)public_symbol; - - PyDict_SetItemString(md, "__all__", public_interface); - Py_DECREF(public_interface); - for (i = 0; SwigMethods[i].ml_name != NULL; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); - for (i = 0; swig_const_table[i].name != 0; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); -#endif - - SWIG_InstallConstants(d,swig_const_table); - - SWIG_Python_SetConstant(d, "TOPICLIST_NOT_CREATED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::TopicList::NOT_CREATED))); - SWIG_Python_SetConstant(d, "TOPICLIST_CREATED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::TopicList::CREATED))); - SWIG_Python_SetConstant(d, "TOPICLIST_FAILURE",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::TopicList::FAILURE))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_UNRESOLVED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::UNRESOLVED))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_RESOLVED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::RESOLVED))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::RESOLUTION_FAILURE_BAD_SERVICE))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::RESOLUTION_FAILURE_BAD_TOPIC))); - SWIG_Python_SetConstant(d, "RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::ResolutionList::RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED))); - SWIG_Python_SetConstant(d, "MESSAGE_FRAGMENT_NONE",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::Message::FRAGMENT_NONE))); - SWIG_Python_SetConstant(d, "MESSAGE_FRAGMENT_START",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::Message::FRAGMENT_START))); - SWIG_Python_SetConstant(d, "MESSAGE_FRAGMENT_INTERMEDIATE",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::Message::FRAGMENT_INTERMEDIATE))); - SWIG_Python_SetConstant(d, "MESSAGE_FRAGMENT_END",SWIG_From_int(static_cast< int >(BloombergLP::blpapi::Message::FRAGMENT_END))); - SWIG_Python_SetConstant(d, "ELEMENTDEFINITION_UNBOUNDED",SWIG_From_unsigned_SS_int(static_cast< unsigned int >(BLPAPI_ELEMENTDEFINITION_UNBOUNDED))); - SWIG_Python_SetConstant(d, "ELEMENT_INDEX_END",SWIG_From_size_t(static_cast< size_t >(BLPAPI_ELEMENT_INDEX_END))); - SWIG_Python_SetConstant(d, "SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM",SWIG_From_int(static_cast< int >(INT_MAX/2))); - SWIG_Python_SetConstant(d, "SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH",SWIG_From_int(static_cast< int >(INT_MAX))); - SWIG_Python_SetConstant(d, "CORRELATION_TYPE_UNSET",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "CORRELATION_TYPE_INT",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "CORRELATION_TYPE_POINTER",SWIG_From_int(static_cast< int >(2))); - SWIG_Python_SetConstant(d, "CORRELATION_TYPE_AUTOGEN",SWIG_From_int(static_cast< int >(3))); - SWIG_Python_SetConstant(d, "CORRELATION_MAX_CLASS_ID",SWIG_From_int(static_cast< int >(((1 << 16) -1)))); - SWIG_Python_SetConstant(d, "MANAGEDPTR_COPY",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "MANAGEDPTR_DESTROY",SWIG_From_int(static_cast< int >((-1)))); - SWIG_Python_SetConstant(d, "DATETIME_YEAR_PART",SWIG_From_int(static_cast< int >(0x1))); - SWIG_Python_SetConstant(d, "DATETIME_MONTH_PART",SWIG_From_int(static_cast< int >(0x2))); - SWIG_Python_SetConstant(d, "DATETIME_DAY_PART",SWIG_From_int(static_cast< int >(0x4))); - SWIG_Python_SetConstant(d, "DATETIME_OFFSET_PART",SWIG_From_int(static_cast< int >(0x8))); - SWIG_Python_SetConstant(d, "DATETIME_HOURS_PART",SWIG_From_int(static_cast< int >(0x10))); - SWIG_Python_SetConstant(d, "DATETIME_MINUTES_PART",SWIG_From_int(static_cast< int >(0x20))); - SWIG_Python_SetConstant(d, "DATETIME_SECONDS_PART",SWIG_From_int(static_cast< int >(0x40))); - SWIG_Python_SetConstant(d, "DATETIME_MILLISECONDS_PART",SWIG_From_int(static_cast< int >(0x80))); - SWIG_Python_SetConstant(d, "DATETIME_FRACSECONDS_PART",SWIG_From_int(static_cast< int >(0x80))); - SWIG_Python_SetConstant(d, "DATETIME_DATE_PART",SWIG_From_int(static_cast< int >((0x1|0x2|0x4)))); - SWIG_Python_SetConstant(d, "DATETIME_TIME_PART",SWIG_From_int(static_cast< int >((0x10|0x20|0x40)))); - SWIG_Python_SetConstant(d, "DATETIME_TIMEMILLI_PART",SWIG_From_int(static_cast< int >(((0x10|0x20|0x40)|0x80)))); - SWIG_Python_SetConstant(d, "DATETIME_TIMEFRACSECONDS_PART",SWIG_From_int(static_cast< int >(((0x10|0x20|0x40)|0x80)))); - SWIG_Python_SetConstant(d, "EVENTTYPE_ADMIN",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "EVENTTYPE_SESSION_STATUS",SWIG_From_int(static_cast< int >(2))); - SWIG_Python_SetConstant(d, "EVENTTYPE_SUBSCRIPTION_STATUS",SWIG_From_int(static_cast< int >(3))); - SWIG_Python_SetConstant(d, "EVENTTYPE_REQUEST_STATUS",SWIG_From_int(static_cast< int >(4))); - SWIG_Python_SetConstant(d, "EVENTTYPE_RESPONSE",SWIG_From_int(static_cast< int >(5))); - SWIG_Python_SetConstant(d, "EVENTTYPE_PARTIAL_RESPONSE",SWIG_From_int(static_cast< int >(6))); - SWIG_Python_SetConstant(d, "EVENTTYPE_SUBSCRIPTION_DATA",SWIG_From_int(static_cast< int >(8))); - SWIG_Python_SetConstant(d, "EVENTTYPE_SERVICE_STATUS",SWIG_From_int(static_cast< int >(9))); - SWIG_Python_SetConstant(d, "EVENTTYPE_TIMEOUT",SWIG_From_int(static_cast< int >(10))); - SWIG_Python_SetConstant(d, "EVENTTYPE_AUTHORIZATION_STATUS",SWIG_From_int(static_cast< int >(11))); - SWIG_Python_SetConstant(d, "EVENTTYPE_RESOLUTION_STATUS",SWIG_From_int(static_cast< int >(12))); - SWIG_Python_SetConstant(d, "EVENTTYPE_TOPIC_STATUS",SWIG_From_int(static_cast< int >(13))); - SWIG_Python_SetConstant(d, "EVENTTYPE_TOKEN_STATUS",SWIG_From_int(static_cast< int >(14))); - SWIG_Python_SetConstant(d, "EVENTTYPE_REQUEST",SWIG_From_int(static_cast< int >(15))); - SWIG_Python_SetConstant(d, "STATUS_ACTIVE",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "STATUS_DEPRECATED",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "STATUS_INACTIVE",SWIG_From_int(static_cast< int >(2))); - SWIG_Python_SetConstant(d, "STATUS_PENDING_DEPRECATION",SWIG_From_int(static_cast< int >(3))); - SWIG_Python_SetConstant(d, "SUBSCRIPTIONSTATUS_UNSUBSCRIBED",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "SUBSCRIPTIONSTATUS_SUBSCRIBING",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "SUBSCRIPTIONSTATUS_SUBSCRIBED",SWIG_From_int(static_cast< int >(2))); - SWIG_Python_SetConstant(d, "SUBSCRIPTIONSTATUS_CANCELLED",SWIG_From_int(static_cast< int >(3))); - SWIG_Python_SetConstant(d, "SUBSCRIPTIONSTATUS_PENDING_CANCELLATION",SWIG_From_int(static_cast< int >(4))); - SWIG_Python_SetConstant(d, "CLIENTMODE_AUTO",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "CLIENTMODE_DAPI",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "CLIENTMODE_SAPI",SWIG_From_int(static_cast< int >(2))); - SWIG_Python_SetConstant(d, "CLIENTMODE_COMPAT_33X",SWIG_From_int(static_cast< int >(16))); - SWIG_Python_SetConstant(d, "RESOLVEMODE_DONT_REGISTER_SERVICES",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "RESOLVEMODE_AUTO_REGISTER_SERVICES",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "SEATTYPE_INVALID_SEAT",SWIG_From_int(static_cast< int >(-1))); - SWIG_Python_SetConstant(d, "SEATTYPE_BPS",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "SEATTYPE_NONBPS",SWIG_From_int(static_cast< int >(1))); - SWIG_Python_SetConstant(d, "SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW",SWIG_From_int(static_cast< int >(0))); - SWIG_Python_SetConstant(d, "REGISTRATIONPARTS_DEFAULT",SWIG_From_int(static_cast< int >(0x1))); - SWIG_Python_SetConstant(d, "REGISTRATIONPARTS_PUBLISHING",SWIG_From_int(static_cast< int >(0x2))); - SWIG_Python_SetConstant(d, "REGISTRATIONPARTS_OPERATIONS",SWIG_From_int(static_cast< int >(0x4))); - SWIG_Python_SetConstant(d, "REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION",SWIG_From_int(static_cast< int >(0x8))); - SWIG_Python_SetConstant(d, "REGISTRATIONPARTS_PUBLISHER_RESOLUTION",SWIG_From_int(static_cast< int >(0x10))); - SWIG_Python_SetConstant(d, "DATATYPE_BOOL",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_BOOL))); - SWIG_Python_SetConstant(d, "DATATYPE_CHAR",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_CHAR))); - SWIG_Python_SetConstant(d, "DATATYPE_BYTE",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_BYTE))); - SWIG_Python_SetConstant(d, "DATATYPE_INT32",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_INT32))); - SWIG_Python_SetConstant(d, "DATATYPE_INT64",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_INT64))); - SWIG_Python_SetConstant(d, "DATATYPE_FLOAT32",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_FLOAT32))); - SWIG_Python_SetConstant(d, "DATATYPE_FLOAT64",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_FLOAT64))); - SWIG_Python_SetConstant(d, "DATATYPE_STRING",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_STRING))); - SWIG_Python_SetConstant(d, "DATATYPE_BYTEARRAY",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_BYTEARRAY))); - SWIG_Python_SetConstant(d, "DATATYPE_DATE",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_DATE))); - SWIG_Python_SetConstant(d, "DATATYPE_TIME",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_TIME))); - SWIG_Python_SetConstant(d, "DATATYPE_DECIMAL",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_DECIMAL))); - SWIG_Python_SetConstant(d, "DATATYPE_DATETIME",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_DATETIME))); - SWIG_Python_SetConstant(d, "DATATYPE_ENUMERATION",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_ENUMERATION))); - SWIG_Python_SetConstant(d, "DATATYPE_SEQUENCE",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_SEQUENCE))); - SWIG_Python_SetConstant(d, "DATATYPE_CHOICE",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_CHOICE))); - SWIG_Python_SetConstant(d, "DATATYPE_CORRELATION_ID",SWIG_From_int(static_cast< int >(BLPAPI_DATATYPE_CORRELATION_ID))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_OFF",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_OFF))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_FATAL",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_FATAL))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_ERROR",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_ERROR))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_WARN",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_WARN))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_INFO",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_INFO))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_DEBUG",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_DEBUG))); - SWIG_Python_SetConstant(d, "blpapi_Logging_SEVERITY_TRACE",SWIG_From_int(static_cast< int >(blpapi_Logging_SEVERITY_TRACE))); - SWIG_Python_SetConstant(d, "UNKNOWN_CLASS",SWIG_From_int(static_cast< int >(0x00000))); - SWIG_Python_SetConstant(d, "INVALIDSTATE_CLASS",SWIG_From_int(static_cast< int >(0x10000))); - SWIG_Python_SetConstant(d, "INVALIDARG_CLASS",SWIG_From_int(static_cast< int >(0x20000))); - SWIG_Python_SetConstant(d, "IOERROR_CLASS",SWIG_From_int(static_cast< int >(0x30000))); - SWIG_Python_SetConstant(d, "CNVERROR_CLASS",SWIG_From_int(static_cast< int >(0x40000))); - SWIG_Python_SetConstant(d, "BOUNDSERROR_CLASS",SWIG_From_int(static_cast< int >(0x50000))); - SWIG_Python_SetConstant(d, "NOTFOUND_CLASS",SWIG_From_int(static_cast< int >(0x60000))); - SWIG_Python_SetConstant(d, "FLDNOTFOUND_CLASS",SWIG_From_int(static_cast< int >(0x70000))); - SWIG_Python_SetConstant(d, "UNSUPPORTED_CLASS",SWIG_From_int(static_cast< int >(0x80000))); - SWIG_Python_SetConstant(d, "ERROR_UNKNOWN",SWIG_From_int(static_cast< int >((0x00000|1)))); - SWIG_Python_SetConstant(d, "ERROR_ILLEGAL_ARG",SWIG_From_int(static_cast< int >((0x20000|2)))); - SWIG_Python_SetConstant(d, "ERROR_ILLEGAL_ACCESS",SWIG_From_int(static_cast< int >((0x00000|3)))); - SWIG_Python_SetConstant(d, "ERROR_INVALID_SESSION",SWIG_From_int(static_cast< int >((0x20000|4)))); - SWIG_Python_SetConstant(d, "ERROR_DUPLICATE_CORRELATIONID",SWIG_From_int(static_cast< int >((0x20000|5)))); - SWIG_Python_SetConstant(d, "ERROR_INTERNAL_ERROR",SWIG_From_int(static_cast< int >((0x00000|6)))); - SWIG_Python_SetConstant(d, "ERROR_RESOLVE_FAILED",SWIG_From_int(static_cast< int >((0x30000|7)))); - SWIG_Python_SetConstant(d, "ERROR_CONNECT_FAILED",SWIG_From_int(static_cast< int >((0x30000|8)))); - SWIG_Python_SetConstant(d, "ERROR_ILLEGAL_STATE",SWIG_From_int(static_cast< int >((0x10000|9)))); - SWIG_Python_SetConstant(d, "ERROR_CODEC_FAILURE",SWIG_From_int(static_cast< int >((0x00000|10)))); - SWIG_Python_SetConstant(d, "ERROR_INDEX_OUT_OF_RANGE",SWIG_From_int(static_cast< int >((0x50000|11)))); - SWIG_Python_SetConstant(d, "ERROR_INVALID_CONVERSION",SWIG_From_int(static_cast< int >((0x40000|12)))); - SWIG_Python_SetConstant(d, "ERROR_ITEM_NOT_FOUND",SWIG_From_int(static_cast< int >((0x60000|13)))); - SWIG_Python_SetConstant(d, "ERROR_IO_ERROR",SWIG_From_int(static_cast< int >((0x30000|14)))); - SWIG_Python_SetConstant(d, "ERROR_CORRELATION_NOT_FOUND",SWIG_From_int(static_cast< int >((0x60000|15)))); - SWIG_Python_SetConstant(d, "ERROR_SERVICE_NOT_FOUND",SWIG_From_int(static_cast< int >((0x60000|16)))); - SWIG_Python_SetConstant(d, "ERROR_LOGON_LOOKUP_FAILED",SWIG_From_int(static_cast< int >((0x00000|17)))); - SWIG_Python_SetConstant(d, "ERROR_DS_LOOKUP_FAILED",SWIG_From_int(static_cast< int >((0x00000|18)))); - SWIG_Python_SetConstant(d, "ERROR_UNSUPPORTED_OPERATION",SWIG_From_int(static_cast< int >((0x80000|19)))); - SWIG_Python_SetConstant(d, "ERROR_DS_PROPERTY_NOT_FOUND",SWIG_From_int(static_cast< int >((0x60000|20)))); - - /* Initialize threading */ - SWIG_PYTHON_INITIALIZE_THREADS; -#if PY_VERSION_HEX >= 0x03000000 - return m; -#else - return; -#endif -} - diff --git a/blpapi/logging.py b/blpapi/logging.py deleted file mode 100644 index b7bddac..0000000 --- a/blpapi/logging.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding: utf-8 - -#@PURPOSE: Provide a C call to register a call back for logging -# -#@DESCRIPTION: This component provides a function that is used to -# register a callback for logging - -from __future__ import absolute_import -from datetime import datetime -from blpapi import internals -from . import utils -from .compat import with_metaclass - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class Logger: - """This utility class provides a namespace for functions to test the - logging configuration.""" - - # Different logging levels - SEVERITY_OFF = internals.blpapi_Logging_SEVERITY_OFF - SEVERITY_FATAL = internals.blpapi_Logging_SEVERITY_FATAL - SEVERITY_ERROR = internals.blpapi_Logging_SEVERITY_ERROR - SEVERITY_WARN = internals.blpapi_Logging_SEVERITY_WARN - SEVERITY_INFO = internals.blpapi_Logging_SEVERITY_INFO - SEVERITY_DEBUG = internals.blpapi_Logging_SEVERITY_DEBUG - SEVERITY_TRACE = internals.blpapi_Logging_SEVERITY_TRACE - - @staticmethod - def registerCallback(callback, thresholdSeverity=internals.blpapi_Logging_SEVERITY_INFO): - """Register the specified 'callback' that will be called for all log - messages with severity greater than or equal to the specified - 'thresholdSeverity'. The callback needs to be registered before the - start of all sessions. If this function is called multiple times, only - the last registered callback will take effect. An exception of type - 'RuntimeError' will be thrown if 'callback' cannot be registered.""" - cb = callback - def callbackWrapper(threadId, severity, ts, category, message): - dt = datetime.fromtimestamp(ts) - callback(threadId, severity, dt, category, message) - - internals.setLoggerCallbackWrapper(callbackWrapper, thresholdSeverity) - - @staticmethod - def logTestMessage(severity): - """Log a test message at the specified 'severity'. Note that this function - is intended for testing of the logging configuration only.""" - internals.blpapi_Logging_logTestMessage(severity) diff --git a/blpapi/message.py b/blpapi/message.py deleted file mode 100644 index 348969d..0000000 --- a/blpapi/message.py +++ /dev/null @@ -1,225 +0,0 @@ -# message.py - -"""Defines a message containing elements. - -This file defines a class 'Message' which represents an individual message -inside an event and containing elements. - -""" - - -from __future__ import absolute_import -from .element import Element -from .name import Name -from . import internals -import datetime -import weakref -from blpapi.datetime import _DatetimeUtil, UTC - -# Handling a circular dependancy between modules: -# service->event->message->service -import sys -service = sys.modules.get('blpapi.service') -if service is None: - from . import service - - -class Message(object): - """A handle to a single message. - - Message objects are obtained by iterating an Event. Each Message is - associated with a Service and with one or more CorrelationId values. The - Message contents are represented as an Element and all Elements accessors - could be used to access the data. - - Class attributes: - The possible types of fragment types: - FRAGMENT_NONE Unfragmented message - FRAGMENT_START Start of a fragmented message - FRAGMENT_INTERMEDIATE Intermediate fragment - FRAGMENT_END Final part of a fragmented message - """ - - __handle = None - - FRAGMENT_NONE = internals.MESSAGE_FRAGMENT_NONE - """Unfragmented message""" - FRAGMENT_START = internals.MESSAGE_FRAGMENT_START - """Start of a fragmented message""" - FRAGMENT_INTERMEDIATE = internals.MESSAGE_FRAGMENT_INTERMEDIATE - """Intermediate fragment""" - FRAGMENT_END = internals.MESSAGE_FRAGMENT_END - """Final part of a fragmented message""" - - def __init__(self, handle, event=None, sessions=None): - internals.blpapi_Message_addRef(handle) - self.__handle = handle - if event is None: - if sessions is None: - self.__sessions = set() - else: - self.__sessions = sessions - else: - self.__sessions = event._sessions() - - self.__element = None - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle is not None: - internals.blpapi_Message_release(self.__handle) - self.__handle = None - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string representation of this Message. Call of str(message) - is equivalent to message.toString() called with default parameters. - - """ - - return self.toString() - - def messageType(self): - """Return the type of this message as a Name.""" - return Name._createInternally( - internals.blpapi_Message_messageType(self.__handle)) - - def fragmentType(self): - """Return the frament type - - The fragment type is one of MESSAGE_FRAGMENT_NONE, - MESSAGE_FRAGMENT_START, MESSAGE_FRAGMENT_INTERMEDIATE or - MESSAGE_FRAGMENT_END.""" - return internals.blpapi_Message_fragmentType(self.__handle) - - def topicName(self): - """Return a string containing the topic string of this message. - - If there iss no topic associated with this message then an empty string - is returned. - - """ - - return internals.blpapi_Message_topicName(self.__handle) - - def service(self): - """Return the Service that this Message is associated with.""" - serviceHandle = internals.blpapi_Message_service(self.__handle) - return None if serviceHandle is None \ - else service.Service(serviceHandle, self.__sessions) - - def correlationIds(self): - """Return the list of CorrelationIds associated with this message. - - Note: A Message will have exactly one CorrelationId unless - 'allowMultipleCorrelatorsPerMsg' option was enabled for the Session - this Message belongs to. When 'allowMultipleCorrelatorsPerMsg' is - disabled (the default) and more than one active subscription would - result in the same Message the Message is delivered multiple times - (without making physical copies). Each Message is accompanied by a - single CorrelationId. When 'allowMultipleCorrelatorsPerMsg' is enabled - and more than one active subscription would result in the same Message - the Message is delivered once with a list of corresponding - CorrelationId values. - - """ - - res = [] - for i in range( - internals.blpapi_Message_numCorrelationIds(self.__handle)): - res.append( - internals.blpapi_Message_correlationId(self.__handle, i)) - return res - - def hasElement(self, name, excludeNullElements=False): - """Equivalent to asElement().hasElement(name, excludeNullElements).""" - return self.asElement().hasElement(name, excludeNullElements) - - def numElements(self): - """Equivalent to asElement().numElements().""" - return self.asElement().numElements() - - def getElement(self, name): - """Equivalent to asElement().getElement(name).""" - return self.asElement().getElement(name) - - def getElementAsBool(self, name): - """Equivalent to asElement().getElementAsBool(name).""" - return self.asElement().getElementAsBool(name) - - def getElementAsString(self, name): - """Equivalent to asElement().getElementAsString(name).""" - return self.asElement().getElementAsString(name) - - def getElementAsInteger(self, name): - """Equivalent to asElement().getElementAsInteger(name).""" - return self.asElement().getElementAsInteger(name) - - def getElementAsFloat(self, name): - """Equivalent to asElement().getElementAsFloat(name).""" - return self.asElement().getElementAsFloat(name) - - def getElementAsDatetime(self, name): - """Equivalent to asElement().getElementAsDatetime(name).""" - return self.asElement().getElementAsDatetime(name) - - def asElement(self): - """Return the content of this Message as an Element.""" - el = None - if self.__element: - el = self.__element() - if el is None: - el = Element(internals.blpapi_Message_elements(self.__handle), - self) - self.__element = weakref.ref(el) - return el - - def toString(self, level=0, spacesPerLevel=4): - """Format this Element to the string.""" - return self.asElement().toString(level, spacesPerLevel) - - def timeReceived(self, tzinfo=UTC): - """Return the time when the message was received by the SDK. This - method will throw 'ValueError' if this information was not recorded for - this message; see 'SessionOptions.recordSubscriptionDataReceiveTimes' - for information on configuring this recording. The resulting datetime - will be represented using the specified 'tzinfo' value, and will be - measured using a high-resolution clock internal to the SDK; see - 'highresclock' for more information on this clock.""" - original = internals.blpapi_Message_timeReceived_wrapper(self.__handle) - native = _DatetimeUtil.convertToNative(original) - return native.astimezone(tzinfo) - - def _handle(self): - return self.__handle - - def _sessions(self): - """Return session(s) this Message related to. For internal use.""" - return self.__sessions - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/name.py b/blpapi/name.py deleted file mode 100644 index 381cb80..0000000 --- a/blpapi/name.py +++ /dev/null @@ -1,162 +0,0 @@ -# name.py - -"""Provide a representation of a string for efficient comparison. - -This file defines a class 'Name' which represents a string in a -form for efficient string comparison. - -""" - - - -from . import internals -import sys -from .compat import conv2str, tolong, isstr - - -class Name(object): - """Name represents a string in a form which is efficient for comparison. - - Name(nameString) constructs a Name object. - - Name objects are used to identify and access the classes which define the - schema - SchemaTypeDefinition, SchemaElementDefinition, SchemaConstant, - SchemaConstantList. They are also used to access the values in Element - objects and Message objects. - - The Name class is an efficient substitute for a string when used as a key, - providing constant time comparison and ordering operations. Two Name - objects constructed from equal strings will always compare equally. - - Where possible, Name objects should be initialized once and then reused. - Creating a Name object involves a search in a container requiring multiple - string comparison operations. - - Note: Each Name instance refers to an entry in a global static table. Name - instances for identical strings will refer to the same data. There is no - provision for removing entries from the static table so Name objects should - only be used when the set of input strings is bounded. - - For example, creating a Name for every possible field name and type in a - data model is reasonable (in fact, the API will do this whenever it - receives schema information). However converting sequence numbers on - incoming messages to strings and creating a Name from each one of those - strings will cause the static table to grow in an unbounded manner. - - """ - - __handle = None - - @staticmethod - def findName(nameString): - """Return an existing Name object representing 'nameString'. - - If no such object exists, None is returned. - """ - nameHandle = internals.blpapi_Name_findName(nameString) - return None if nameHandle is None \ - else Name._createInternally(nameHandle) - - @staticmethod - def hasName(nameString): - """Return True if a Name object representing 'nameString' exists. - """ - return internals.blpapi_Name_hasName(nameString) - - @staticmethod - def _createInternally(handle): - return Name(None, handle) - - def __init__(self, nameString, internalHandle=None): - if internalHandle is not None: - self.__handle = internalHandle - else: - self.__handle = internals.blpapi_Name_create(nameString) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_Name_destroy(self.__handle) - self.__handle = None - - def __len__(self): - """Return the length of the string that this Name represents. - """ - - return internals.blpapi_Name_length(self.__handle) - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string that this Name represents. - - """ - - return internals.blpapi_Name_string(self.__handle) - - def __eq__(self, other): - """x.__eq__(y) <==> x==y""" - try: - s = conv2str(other) - if s is not None: - p = internals.blpapi_Name_equalsStr(self.__handle, s) - return 0 != p - else: - return self.__handle == other.__handle - except Exception: - return NotImplemented - - def __ne__(self, other): - """x.__ne__(y) <==> x!=y""" - equal = self.__eq__(other) - return NotImplemented if equal is NotImplemented else not equal - - def __hash__(self): - """x.__hash__() <==> hash(x)""" - return tolong(self.__handle) - - def _handle(self): - return self.__handle - - -def getNamePair(name): - """Create a tuple that contains nameString and blpapi_Name_t *. - - Return (None, name._handle()) if 'name' is a Name instance or (name, None) - if name is a string. In other cases raise TypeError exception. - - """ - - if isinstance(name, Name): - return (None, name._handle()) - elif isstr(name): - return (conv2str(name), None) - else: - raise TypeError( - "name should be an instance of a string or blpapi.Name") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/providersession.py b/blpapi/providersession.py deleted file mode 100644 index 1f858c3..0000000 --- a/blpapi/providersession.py +++ /dev/null @@ -1,728 +0,0 @@ -# providersession.py - -"""Provide a session that can be used for providing services. - -ProviderSession inherits from AbstractSession. In addition to AbstractSession -functionality, ProviderSession provides functions that are needed to support -publishing like 'registerService', 'createTopics' and 'publish'. - -Topic Life Cycle ----------------- -A provider wishing to publish subscription data must explicitly open each topic -on which they publish using 'ProviderSession.createTopics' (or -'ProviderSession.createTopicsAsync'). Creating a topic prepares the -distribution and caching infrastructure for new data associated with the -topic's resolved identifier. (Note that several different topics could resolve -to the same ID.) Independent of a topic's creation status is its subscription -status, i.e. whether there are subscribers ready to receive the data published. -A topic that is both created and subscribed is *activated*. - -There are two models for managing topic creation: broadcast and interactive. -Broadcast publishers proactively call 'ProviderSession.createTopic*' for each -topic on which they intend to publish, while interactive publishers wait to -receive a 'TopicSubscribed' message (within an 'Event' of type -'Event.TOPIC_STATUS') before calling 'ProviderSession.createTopic*' in -response. Topics are resolved before they are created---it is possible that -multiple different topic strings will map to the same underlying topic. See -below for the behavior of the SDK when the same topic is created multiple -times. - -After 'ProviderSession.createTopic*' is called, the publisher will receive a -'TopicCreated' message (within an 'Event.TOPIC_STATUS' event), and when there -is at least one subscriber to the topic the publisher will then receive a -'TopicActivated' message (also within an 'Event.TOPIC_STATUS' event). As -subscribers come and go, additional 'TopicSubscribed', 'TopicActivated', -'TopicUnsubscribed', and 'TopicDeactivated' messages may be received by the -publisher. A 'Topic' object can be retrieved from each of these messages using -the 'ProviderSession.getTopic' method, and this object can be used for -subsequent calls to 'EventFormatter.appendMessage' and -'ProviderSession.deleteTopic'. In the case that the same resolved topic is -created multiple times by a publisher using different names, it is unspecified -which of those names will be returned by 'Message.topicName' for these (or -other) messages. - -If a publisher no longer intends to publish data on a topic, it can call -'ProviderSession.deleteTopic*' to free the internal caching and distribution -resources associated with the topic. When a resolved topic has been deleted the -same number of times that it has been created, a 'TopicDeleted' message will be -delivered, preceded by 'TopicUnsubscribed' and 'TopicDeactivated' messages if -the topic was still subscribed (and activated). No further messages can be -published on a deleted topic. - -Deregistering a service deletes all topics associated with that service. - -Note that 'TopicActivated' and 'TopicDeactivated' messages are entirely -redundant with 'TopicCreated', 'TopicSubscribed', 'TopicDeleted', and -'TopicUnsubscribed' messages, and are provided only for the convenience of -publishers that do not maintain per-topic state. -""" - -from __future__ import print_function -from __future__ import absolute_import -import weakref -import sys -import traceback -import os -import functools -from .abstractsession import AbstractSession -from .event import Event -from . import exception -from .exception import _ExceptionUtil -from .identity import Identity -from . import internals -from .internals import CorrelationId -from .sessionoptions import SessionOptions -from .topic import Topic -from . import utils -from .compat import with_metaclass, conv2str, isstr - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class ServiceRegistrationOptions(object): - """Contains the options which can be specified when registering a service. - - To use non-default options to registerService, create a - ServiceRegistrationOptions instance and set the required options and then - supply it when using the registerService interface. - """ - - PRIORITY_LOW = internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW - PRIORITY_MEDIUM = \ - internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM - PRIORITY_HIGH = internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH - - # Constants for specifying which part(s) of a service should be registered: - - PART_PUBLISHING = internals.REGISTRATIONPARTS_PUBLISHING - # register to receive subscribe and unsubscribe messages - - PART_OPERATIONS = internals.REGISTRATIONPARTS_OPERATIONS - # register to receive the request types corresponding to each - # "operation" defined in the service metadata - - PART_SUBSCRIBER_RESOLUTION \ - = internals.REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION - # register to receive resolution requests (with message type - # 'PermissionRequest') from subscribers - - PART_PUBLISHER_RESOLUTION \ - = internals.REGISTRATIONPARTS_PUBLISHER_RESOLUTION - # register to receive resolution requests (with message type - # 'PermissionRequest') from publishers (via - # 'ProviderSession.createTopics') - - PART_DEFAULT = internals.REGISTRATIONPARTS_DEFAULT - # register the parts of the service implied by options - # specified in the service metadata - - def __init__(self): - """Create ServiceRegistrationOptions with default options.""" - self.__handle = internals.blpapi_ServiceRegistrationOptions_create() - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this ServiceRegistrationOptions.""" - if self.__handle: - internals.blpapi_ServiceRegistrationOptions_destroy(self.__handle) - self.__handle = None - - def setGroupId(self, groupId): - """Set the Group ID for the service to be registered. - - Set the Group ID for the service to be registered to the specified - 'groupId' string. If 'groupId' length is greater than - MAX_GROUP_ID_SIZE (=64) only the first MAX_GROUP_ID_SIZE chars are - considered as Group Id. - """ - internals.blpapi_ServiceRegistrationOptions_setGroupId( - self.__handle, groupId.encode('utf-8')) - # NOTE: we should convert groupId to bytes here because - # otherwise we'll get an error in SWIG wrapper. - - def setServicePriority(self, priority): - """Set the priority with which a service will be registered. - - Set the priority with which a service will be registered to the - non-negative value specified in priority. This call returns with a - non-zero value indicating error when a negative priority is specified. - Any non-negative priority value, other than the one pre-defined in - ServiceRegistrationPriority can be used. Default value is - PRIORITY_HIGH. - """ - return internals.blpapi_ServiceRegistrationOptions_setServicePriority( - self.__handle, - priority) - - def getGroupId(self): - """Return the value of the service Group Id in this instance.""" - errorCode, groupId = \ - internals.blpapi_ServiceRegistrationOptions_getGroupId( - self.__handle) - return groupId - - def getServicePriority(self): - """Return the value of the service priority in this instance.""" - priority = \ - internals.blpapi_ServiceRegistrationOptions_getServicePriority( - self.__handle) - return priority - - def addActiveSubServiceCodeRange(self, begin, end, priority): - """Advertise the service to be registered to receive, with the - specified 'priority', subscriptions that the resolver has mapped to a - service code between the specified 'begin' and the specified 'end' - values, inclusive. The behavior of this function is undefined unless '0 - <= begin <= end < (1 << 24)', and 'priority' is non-negative.""" - err = internals.blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange( - self.__handle, begin, end, priority) - _ExceptionUtil.raiseOnError(err) - - def removeAllActiveSubServiceCodeRanges(self): - """Remove all previously added sub-service code ranges.""" - internals.blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges( - self.__handle) - - def setPartsToRegister(self, parts): - """Set the parts of the service to be registered to the specified - 'parts', which must be a bitwise-or of the options provided in - 'RegistrationParts', above. This option defaults to - 'RegistrationParts.PARTS_DEFAULT'.""" - internals.blpapi_ServiceRegistrationOptions_setPartsToRegister( - self.__handle, parts) - - def getPartsToRegister(self): - """Return the parts of the service to be registered. See - 'RegistrationParts', above for additional details.""" - return internals.blpapi_ServiceRegistrationOptions_getPartsToRegister( - self.__handle) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class ProviderSession(AbstractSession): - """This class provides a session that can be used for providing services. - - It inherits from AbstractSession. In addition to the AbstractSession - functionality a ProviderSession provides the following functions to - applications. - - A provider can register to provide services using - 'ProviderSession.registerService*'. Before registering to provide a - service the provider must have established its identity. Then the provider - can create topics and publish events on topics. It also can get requests - from the event queue and send back responses. - - After users have registered a service they will start receiving - subscription requests ('TopicSubscribed' message in 'TOPIC_STATUS') for - topics which belong to the service. If the resolver has specified - 'subServiceCode' for topics in 'PermissionResponse', then only providers - who have activated the 'subServiceCode' will get the subscription request. - Where multiple providers have registered the same service and sub-service - code (if any), the provider that registered the highest priority for the - sub-service code will receive subscription requests; if multiple providers - have registered the same sub-service code with the same priority (or the - resolver did not set a sub-service code for the subscription), the - subscription request will be routed to one of the providers with the - highest service priority. - """ - - AUTO_REGISTER_SERVICES = \ - internals.RESOLVEMODE_AUTO_REGISTER_SERVICES - - DONT_REGISTER_SERVICES = \ - internals.RESOLVEMODE_DONT_REGISTER_SERVICES - - __handle = None - __handlerProxy = None - - @staticmethod - def __dispatchEvent(sessionRef, eventHandle): - try: - session = sessionRef() - if session is not None: - event = Event(eventHandle, session) - session.__handler(event, session) - except: - print("Exception in event handler:", file=sys.stderr) - traceback.print_exc(file=sys.stderr) - os._exit(1) - - def __init__(self, options=None, eventHandler=None, eventDispatcher=None): - """Constructor. - - Construct a Session using the optionally specified 'options', the - optionally specified 'eventHandler' and the optionally specified - 'eventDispatcher'. - - See the SessionOptions documentation for details on what can be - specified in the 'options'. - - If 'eventHandler' is not None then this Session will operate in - asynchronous mode, otherwise the Session will operate in synchronous - mode. - - If supplied, 'eventHandler' is a callable object that takes two - arguments: received event and related session. - - If 'eventDispatcher' is None then the Session will create a default - EventDispatcher for this Session which will use a single thread for - dispatching events. For more control over event dispatching a specific - instance of EventDispatcher can be supplied. This can be used to share - a single EventDispatcher amongst multiple Session objects. - - If an 'eventDispatcher' is supplied which uses more than one thread the - Session will ensure that events which should be ordered are passed to - callbacks in a correct order. For example, partial response to - a request or updates to a single subscription. - - If 'eventHandler' is None and the 'eventDispatcher' is not None an - exception is raised. - - Each EventDispatcher uses its own thread or pool of threads so if you - want to ensure that a session which receives very large messages and - takes a long time to process them does not delay a session that - receives small messages and processes each one very quickly then give - each one a separate EventDispatcher. - """ - AbstractSession.__init__(self) - if (eventHandler is None) and (eventDispatcher is not None): - raise exception.InvalidArgumentException( - "eventDispatcher is specified but eventHandler is None", 0) - if options is None: - options = SessionOptions() - if eventHandler is not None: - self.__handler = eventHandler - self.__handlerProxy = functools.partial( - ProviderSession.__dispatchEvent, weakref.ref(self)) - self.__handle = internals.ProviderSession_createHelper( - options._handle(), - self.__handlerProxy, - None if eventDispatcher is None else eventDispatcher._handle()) - AbstractSession.__init__( - self, - internals.blpapi_ProviderSession_getAbstractSession(self.__handle)) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destructor.""" - if self.__handle: - internals.ProviderSession_destroyHelper( - self.__handle, - self.__handlerProxy) - self.__handle = None - - def start(self): - """Start this session in synchronous mode. - - Attempt to start this Session and blocks until the Session has started - or failed to start. If the Session is started successfully iTrue is - returned, otherwise False is returned. Before start() returns a - SESSION_STATUS Event is generated. If this is an asynchronous Session - then the SESSION_STATUS may be processed by the registered EventHandler - before start() has returned. A Session may only be started once. - """ - return internals.blpapi_ProviderSession_start(self.__handle) == 0 - - def startAsync(self): - """Start this session in asynchronous mode. - - Attempt to begin the process to start this Session and return True if - successful, otherwise return False. The application must monitor events - for a SESSION_STATUS Event which will be generated once the Session has - started or if it fails to start. If this is an asynchronous Session - then the SESSION_STATUS Event may be processed by the registered - EventHandler before startAsync() has returned. A Session may only be - started once. - """ - return internals.blpapi_ProviderSession_startAsync(self.__handle) == 0 - - def stop(self): - """Stop operation of this session and wait until it stops. - - Stop operation of this session and block until all callbacks to - EventHandler objects relating to this Session which are currently in - progress have completed (including the callback to handle - the SESSION_STATUS Event this call generates). Once this returns no - further callbacks to EventHandlers will occur. If stop() is called from - within an EventHandler callback it is silently converted to - a stopAsync() in order to prevent deadlock. Once a Session has been - stopped it can only be destroyed. - """ - return internals.blpapi_ProviderSession_stop(self.__handle) == 0 - - def stopAsync(self): - """Begin the process to stop this Session and return immediately. - - The application must monitor events for a - SESSION_STATUS Event which will be generated once the - Session has been stopped. After this SESSION_STATUS Event - no further callbacks to EventHandlers will occur(). Once a - Session has been stopped it can only be destroyed. - """ - return internals.blpapi_ProviderSession_stop(self.__handle) == 0 - - def nextEvent(self, timeout=0): - """Return the next available Event for this session. - - If there is no event available this will block for up to the specified - 'timeoutMillis' milliseconds for an Event to arrive. A value of 0 for - 'timeoutMillis' (the default) indicates nextEvent() should not timeout - and will not return until the next Event is available. - - If nextEvent() returns due to a timeout it will return an event of type - 'EventType.TIMEOUT'. - - If this is invoked on a Session which was created in asynchronous mode - an InvalidStateException is raised. - """ - retCode, event = internals.blpapi_ProviderSession_nextEvent( - self.__handle, - timeout) - - _ExceptionUtil.raiseOnError(retCode) - - return Event(event, self) - - def tryNextEvent(self): - """Return the next Event for this session if it is available. - - If there are Events available for the session, return the next Event - If there is no event available for the session, return None. This - method never blocks. - """ - retCode, event = internals.blpapi_ProviderSession_tryNextEvent( - self.__handle) - if retCode: - return None - else: - return Event(event, self) - - def registerService(self, uri, identity=None, options=None): - """Attempt to register the service and block until it is done. - - Attempt to register the service identified by the specified 'uri' and - block until the service is either registered successfully or has failed - to be registered. The optionally specified 'identity' is used to verify - permissions to provide the service being registered. The optionally - specified 'options' is used to specify the group ID and service - priority of the service being registered. Return 'True' if the service - is registered successfully and 'False' if the service cannot be - registered successfully. - - The 'uri' must begin with a full qualified service name. That is it - must begin with "///[/]". Any portion of the - 'uri' after the service name is ignored. - - Before registerService() returns a SERVICE_STATUS Event is generated. - If this is an asynchronous ProviderSession then this Event may be - processed by the registered Event before registerService() has - returned. - """ - if options is None: - options = ServiceRegistrationOptions() - if internals.blpapi_ProviderSession_registerService( - self.__handle, uri, - None if identity is None else identity._handle(), - options._handle()) == 0: - return True - return False - - def registerServiceAsync(self, uri, identity=None, correlationId=None, - options=None): - """Begin the process of registering the service immediately. - - Begin the process of registering the service identified by the - specified 'uri' and return immediately. The optionally specified - 'identity' is used to verify permissions to provide the service being - registered. The optionally specified 'correlationId' is used to track - Events generated as a result of this call. The actual correlationId - that will identify Events generated as a result of this call is - returned. The optionally specified 'options' is used to specify the - group ID and service priority of the service being registered. - - The 'uri' must begin with a full qualified service name. That is it - must begin with "///[/]". Any portion of the - - The application must monitor events for a SERVICE_STATUS Event which - will be generated once the service has been successfully registered or - registration has failed. - """ - if correlationId is None: - correlationId = CorrelationId() - if options is None: - options = ServiceRegistrationOptions() - - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_registerServiceAsync( - self.__handle, - uri, - None if identity is None else identity._handle(), - correlationId._handle(), - options._handle() - )) - - return correlationId - - def resolve(self, resolutionList, resolveMode=DONT_REGISTER_SERVICES, - identity=None): - """Resolve the topics in the specified 'resolutionList'. - - Resolve the topics in the specified 'resolutionList', which must be an - object of type 'ResolutionList', and update the 'resolutionList' with - the results of the resolution process. If the specified 'resolveMode' - is DONT_REGISTER_SERVICES (the default) then all the services - referenced in the topics in the 'resolutionList' must already have been - registered using registerService(). If 'resolveMode' is - AUTO_REGISTER_SERVICES then the specified 'identity' should be supplied - and ProviderSession will automatically attempt to register any services - reference in the topics in the 'resolutionList' that have not already - been registered. Once resolve() returns each entry in the - 'resolutionList' will have been updated with a new status. - - Before resolve() returns one or more RESOLUTION_STATUS events and, if - 'resolveMode' is AUTO_REGISTER_SERVICES, zero or more SERVICE_STATUS - events are generated. If this is an asynchronous ProviderSession then - these Events may be processed by the registered EventHandler before - resolve() has returned. - """ - resolutionList._addSession(self) - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_resolve( - self.__handle, - resolutionList._handle(), - resolveMode, - None if identity is None else identity._handle())) - - def resolveAsync(self, resolutionList, resolveMode=DONT_REGISTER_SERVICES, - identity=None): - """Begin the resolution of the topics in the specified list. - - Begin the resolution of the topics in the specified 'resolutionList', - which must be an object of type 'ResolutionList'. If the specified - 'resolveMode' is DONT_REGISTER_SERVICES (the default) then all the - services referenced in the topics in the 'resolutionList' must already - have been registered using registerService(). If 'resolveMode' is - AUTO_REGISTER_SERVICES then the specified 'identity' should be supplied - and ProviderSession will automatically attempt to register any services - reference in the topics in the 'resolutionList' that have not already - been registered. - - One or more RESOLUTION_STATUS events will be delivered with the results - of the resolution. These events may be generated before or after - resolveAsync() returns. If AUTO_REGISTER_SERVICES is specified - SERVICE_STATUS events may also be generated before or after - resolveAsync() returns. - """ - resolutionList._addSession(self) - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_resolveAsync( - self.__handle, - resolutionList._handle(), - resolveMode, - None if identity is None else identity._handle())) - - def getTopic(self, message): - """Find a previously created Topic object based on the 'message'. - - Find a previously created Topic object based on the specified - 'message'. The 'message' must be one of the following - types: TopicCreated, TopicActivated, TopicDeactivated, - TopicSubscribed, TopicUnsubscribed, TopicRecap. - If the 'message' is not valid then invoking isValid() on the - returned Topic will return False. - """ - errorCode, topic = internals.blpapi_ProviderSession_getTopic( - self.__handle, - message._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return Topic(topic, sessions=(self,)) - - def createServiceStatusTopic(self, service): - """Create a Service Status Topic. - - Create a Service Status Topic which is to be used to provide - service status. On success invoking isValid() on the returned Topic - will return False. - """ - errorCode, topic = \ - internals.blpapi_ProviderSession_createServiceStatusTopic( - self.__handle, - service._handle() - ) - _ExceptionUtil.raiseOnError(errorCode) - return Topic(topic) - - def publish(self, event): - """Publish the specified 'event'.""" - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_publish( - self.__handle, - event._handle())) - - def sendResponse(self, event, isPartialResponse=False): - """Send the response event for previously received request.""" - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_sendResponse( - self.__handle, - event._handle(), - isPartialResponse)) - - def createTopics(self, topicList, - resolveMode=DONT_REGISTER_SERVICES, - identity=None): - """Create the topics in the specified 'topicList'. - - Create the topics in the specified 'topicList', which must be an object - of type 'TopicList', and update 'topicList' with the results of the - creation process. If service needs to be registered, 'identity' should - be supplied. Once a call to this function returns, each entry in the - 'topicList' will have been updated with a new topic creation status. - - Before createTopics() returns one or more RESOLUTION_STATUS events, - zero or more SERVICE_STATUS events and one or more TOPIC_STATUS events - are generated. If this is an asynchronous ProviderSession then these - Events may be processed by the registered EventHandler before - createTopics() has returned. - """ - topicList._addSession(self) - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_createTopics( - self.__handle, - topicList._handle(), - resolveMode, - None if identity is None else identity._handle())) - - def createTopicsAsync(self, topicList, - resolveMode=DONT_REGISTER_SERVICES, - identity=None): - """Create the topics in the specified 'topicList'. - - Create the topics in the specified 'topicList', which must be an object - of type 'TopicList', and update the 'topicList' with the results of the - creation process. If service needs to be registered, 'providerIdentity' - should be supplied. - - One or more RESOLUTION_STATUS events, zero or more SERVICE_STATUS - events and one or more TOPIC_STATUS events are generated. If this is - an asynchronous ProviderSession then these Events may be processed by - the registered EventHandler before createTopics() has returned. - """ - topicList._addSession(self) - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_createTopicsAsync( - self.__handle, - topicList._handle(), - resolveMode, - None if identity is None else identity._handle())) - - def activateSubServiceCodeRange(self, serviceName, begin, end, priority): - """Register to receive, with the specified 'priority', subscriptions - for the specified 'service' that the resolver has mapped to a service - code between the specified 'begin' and the specified 'end' values, - inclusive. The behavior of this function is undefined unless 'service' - has already been successfully registered, '0 <= begin <= end < (1 << - 24)', and 'priority' is non-negative.""" - err = internals.blpapi_ProviderSession_activateSubServiceCodeRange( - self.__handle, serviceName, begin, end, priority) - _ExceptionUtil.raiseOnError(err) - - def deactivateSubServiceCodeRange(self, serviceName, begin, end): - """De-register to receive subscriptions for the specified 'service' - that the resolver has mapped to a service code between the specified - 'begin' and the specified 'end' values, inclusive. The behavior of this - function is undefined unless 'service' has already been successfully - registered and '0 <= begin <= end < (1 << 24)'.""" - err = internals.blpapi_ProviderSession_deactivateSubServiceCodeRange( - self.__handle, serviceName, begin, end) - _ExceptionUtil.raiseOnError(err) - - def deregisterService(self, serviceName): - """Deregister the service, including all registered parts, identified - by the specified 'serviceName'. The identity in the service - registration is reused to verify permissions for deregistration. If the - service is not registered nor in pending registration, return false; - return true otherwise. If the service is in pending registration, - cancel the pending registration. If the service is registered, send a - deregistration request; generate TOPIC_STATUS events containing a - TopicUnsubscribed message for each subscribed topic, a TopicDeactivated - message for each active topic and a TopicDeleted for each created - topic; generate REQUEST_STATUS events containing a RequestFailure - message for each pending incoming request; and generate a - SERVICE_STATUS Event containing a ServiceDeregistered message. All - published events on topics created on this service will be ignored - after this method returns.""" - res = internals.blpapi_ProviderSession_deregisterService( - self.__handle, serviceName) - return res == 0 - - def deleteTopic(self, topic): - """Remove one reference from the specified 'topic'. If this function - has been called the same number of times that 'topic' was created - by 'createTopics', then 'topic' is deleted: a 'TopicDeleted' - message is delivered, preceded by 'TopicUnsubscribed' and - 'TopicDeactivated' if 'topic' was subscribed. (See "Topic - Life Cycle", above, for additional details.) The behavior of this - function is undefined if 'topic' has already been deleted the same - number of times that it has been created. Further, the behavior is - undefined if a provider attempts to publish a message on a deleted - topic.""" - self.deleteTopics((topic,)) - - def deleteTopics(self, topics): - """Delete each topic in the specified 'topics' container. - - See 'deleteTopic(topic)' above for additional details.""" - if not topics: - return - topicsCArraySize = len(topics) - topicsCArray = internals.new_topicPtrArray(topicsCArraySize) - try: - for i, topic in enumerate(topics): - internals.topicPtrArray_setitem(topicsCArray, - i, - topic._handle()) - _ExceptionUtil.raiseOnError( - internals.blpapi_ProviderSession_deleteTopics( - self.__handle, - topicsCArray, - topicsCArraySize)) - finally: - internals.delete_topicPtrArray(topicsCArray) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/request.py b/blpapi/request.py deleted file mode 100644 index 100f318..0000000 --- a/blpapi/request.py +++ /dev/null @@ -1,112 +0,0 @@ -# request.py - -"""Defines a request which can be sent for a service. - -This file defines a class 'Request' which represents a request sent through the -Session. - -""" - - - -from .element import Element -from . import internals -import weakref - - -class Request(object): - """A single request to a single service. - - Request objects are created using Service.createRequest() or - Service.createAuthorizationRequest(). They are used with - Session.sendRequest() or Session.sendAuthorizationRequest(). - - The Request object contains the parameters for a single request to a single - service. Once a Request has been created its fields can be populated - directly using the functions provided by Element or using the Element - interface on the Element returned by asElement(). - - The schema for the Request can be queried using the Element interface. - - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - self.__element = None - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_Request_destroy(self.__handle) - self.__handle = None - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string representation of this Request. Call of str(request) is - equivalent to request.toString() called with default parameters. - - """ - - return self.toString() - - def set(self, name, value): - """Equivalent to asElement().setElement(name, value).""" - self.asElement().setElement(name, value) - - def append(self, name, value): - """Equivalent to getElement(name).appendValue(value).""" - return self.getElement(name).appendValue(value) - - def asElement(self): - """Return the content of this Request as an Element.""" - el = None - if self.__element: - el = self.__element() - if el is None: - el = Element(internals.blpapi_Request_elements(self.__handle), - self) - self.__element = weakref.ref(el) - return el - - def getElement(self, name): - """Equivalent to asElement().getElement(name).""" - return self.asElement().getElement(name) - - def toString(self, level=0, spacesPerLevel=4): - """Format this Element to the string.""" - return self.asElement().toString(level, spacesPerLevel) - - def _handle(self): - return self.__handle - - def _sessions(self): - """Return session(s) this Request related to. For internal use.""" - return self.__sessions - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/resolutionlist.py b/blpapi/resolutionlist.py deleted file mode 100644 index ef6d5ad..0000000 --- a/blpapi/resolutionlist.py +++ /dev/null @@ -1,303 +0,0 @@ -# resolutionlist.py - -"""Provide a representation of a list of topics. - -This component implements a list of topics that require resolution. -""" - - - -from .element import Element -from .exception import _ExceptionUtil -from .message import Message -from .name import Name -from . import internals -from . import utils -from .internals import CorrelationId -from .compat import with_metaclass - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class ResolutionList(object): - """Contains a list of topics that require resolution. - - Created from topic strings or from SUBSCRIPTION_STARTED messages. This is - passed to a 'resolve()' call or 'resolveAsync()' call on a 'ProviderSession'. It - is updated and returned by the 'resolve()' call. - """ - - UNRESOLVED = internals.RESOLUTIONLIST_UNRESOLVED - RESOLVED = internals.RESOLUTIONLIST_RESOLVED - RESOLUTION_FAILURE_BAD_SERVICE = \ - internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE - RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED = \ - internals. \ - RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED - RESOLUTION_FAILURE_BAD_TOPIC = \ - internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC - RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED = \ - internals.RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED - - @staticmethod - def extractAttributeFromResolutionSuccess(message, attribute): - """Return the value of the value in the specified 'message'. - - Return the value of the value in the specified 'message' which - represents the specified 'attribute'. The 'message' must be a message - of type "RESOLUTION_SUCCESS". The 'attribute' should be an attribute - that was requested using 'addAttribute()' on the ResolutionList passed to - the 'resolve()' or 'resolveAsync()' that caused this RESOLUTION_SUCCESS - message. If the 'attribute' is not present an empty Element is - returned. - """ - i = internals # to fit next line in 79 chars - res = i.blpapi_ResolutionList_extractAttributeFromResolutionSuccess( - message._handle(), attribute._handle()) - return Element(res, message) - - def __init__(self): - """Create an empty ResolutionList. - - Create an empty ResolutionList. - """ - self.__handle = internals.blpapi_ResolutionList_create(None) - self.__sessions = set() - - def __del__(self): - """Destroy this ResolutionList.""" - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy resolutionlist""" - if self.__handle: - internals.blpapi_ResolutionList_destroy(self.__handle) - self.__handle = None - - def add(self, topicOrMessage, correlationId=None): - """Add the specified topic or topic from message to this list. - - If 'topicOrMessage' is of string type, add the specified - 'topicOrMessage' to this list, optionally specifying a 'correlationId'. - Return 0 on success or negative number on failure. After a successful - call to add() the status for this entry is UNRESOLVED_TOPIC. - - If 'topicOrMessage' is of Message type, add the topic contained in the - specified 'topicOrMessage' to this list, optionally specifying a - 'correlationId'. Return 0 on success or a negative number on failure. - After a successful call to add() the status for this entry is - UNRESOLVED_TOPIC. - """ - if correlationId is None: - correlationId = CorrelationId() - if not isinstance(correlationId, CorrelationId): - raise TypeError( - "correlationId should be an instance of 'CorrelationId'") - if isinstance(topicOrMessage, Message): - return internals.blpapi_ResolutionList_addFromMessage( - self.__handle, - topicOrMessage._handle(), - correlationId._handle()) - else: - return internals.blpapi_ResolutionList_add( - self.__handle, - topicOrMessage, - correlationId._handle()) - - def addAttribute(self, attribute): - """Add the specified 'attribute' to the list of attributes. - - Add the specified 'attribute' to the list of attributes requested - during resolution for each topic in this ResolutionList. Return 0 on - success or a negative number on failure. - """ - attribute = Name(attribute) - return internals.blpapi_ResolutionList_addAttribute( - self.__handle, attribute._handle()) - - def correlationIdAt(self, index): - """Return the CorrelationId at the specified 'index'. - - Return the CorrelationId of the specified 'index'th entry - in this ResolutionList. An exception is raised if 'index'>=size(). - """ - errorCode, cid = internals.blpapi_ResolutionList_correlationIdAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return cid - - def topicString(self, correlationId): - """Return the topic of the entry identified by 'correlationId'. - - Return the topic of the entry identified by 'correlationId'. If the - 'correlationId' does not identify an entry in this ResolutionList then - an exception is raised. - """ - errorCode, topic = internals.blpapi_ResolutionList_topicString( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return topic - - def topicStringAt(self, index): - """Return the full topic string at the specified 'index'. - - Return the full topic string of the specified 'index'th entry in this - ResolutionList. An exception is raised if 'index'>=size(). - """ - errorCode, topic = internals.blpapi_ResolutionList_topicStringAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return topic - - def status(self, correlationId): - """Return the status of the entry in this ResolutionList. - - Return the status of the entry in this ResolutionList identified by the - specified 'correlationId'. This may be UNRESOLVED, RESOLVED, - RESOLUTION_FAILURE_BAD_SERVICE, - RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED, - RESOLUTION_FAILURE_BAD_TOPIC, - RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED. If the 'correlationId' - does not identify an entry in this ResolutionList then an exception is - raised. - """ - errorCode, status = internals.blpapi_ResolutionList_status( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return status - - def statusAt(self, index): - """Return the status of the specified 'index'th entry in this list. - - Return the status of the specified 'index'th entry in this - ResolutionList. This may be UNRESOLVED, RESOLVED, - RESOLUTION_FAILURE_BAD_SERVICE, - RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED, - RESOLUTION_FAILURE_BAD_TOPIC, - RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED. If 'index' > size() an - exception is raised. - """ - errorCode, status = internals.blpapi_ResolutionList_statusAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return status - - def attribute(self, attribute, correlationId): - """Return the value for the specified 'attribute' of this list entry. - - Return the value for the specified 'attribute' of the entry in this - ResolutionList identified by the specified 'correlationId'. The Element - returned may be empty if the resolution service cannot provide the - attribute. If 'correlationId' does not identify an entry in this - ResolutionList or if the status of the entry identified by - 'correlationId' is not RESOLVED an exception is raised. - """ - attribute = Name(attribute) - errorCode, element = internals.blpapi_ResolutionList_attribute( - self.__handle, - attribute._handle(), - correlationId._handle()) - - _ExceptionUtil.raiseOnError(errorCode) - - return Element(element, self) - - def attributeAt(self, attribute, index): - """Return the value for the specified 'attribute' of 'index'th entry. - - Return the value for the specified 'attribute' of the specified - 'index'th entry in this ResolutionList. The Element returned may be - empty if the resolution service cannot provide the attribute. If - 'index' >= size() or if the status of the 'index'th entry is not - RESOLVED an exception is raised. - """ - attribute = Name(attribute) - errorCode, element = internals.blpapi_ResolutionList_attributeAt( - self.__handle, - attribute._handle(), - index) - - _ExceptionUtil.raiseOnError(errorCode) - - return Element(element, self) - - def message(self, correlationId): - """Return the message identified by 'correlationId'. - - Return the value of the message received during resolution of the topic - identified by the specified 'correlationId'. If 'correlationId' does - not identify an entry in this ResolutionList or if the status of the - entry identify by 'correlationId' is not RESOLVED an exception is - raised. - - The message returned can be used when creating an instance of Topic. - """ - errorCode, message = internals.blpapi_ResolutionList_message( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return Message(message, sessions=self.__sessions) - - def messageAt(self, index): - """Return the message received during resolution of entry at 'index'. - - Return the value of the message received during resolution of the - specified 'index'th entry in this ResolutionList. If 'index >= size()' - or if the status of the 'index'th entry is not RESOLVED an exception is - raised. - - The message returned can be used when creating an instance of Topic. - """ - errorCode, message = internals.blpapi_ResolutionList_messageAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return Message(message, sessions=self.__sessions) - - def size(self): - """Return the number of entries in this ResolutionList.""" - return internals.blpapi_ResolutionList_size(self.__handle) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - def _sessions(self): - """Return session(s) that this 'ResolutionList' is related to. - - For internal use.""" - return self.__sessions - - def _addSession(self, session): - """Add a new session to this 'ResolutionList'. - - For internal use.""" - self.__sessions.add(session) - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/schema.py b/blpapi/schema.py deleted file mode 100644 index 6d06bbb..0000000 --- a/blpapi/schema.py +++ /dev/null @@ -1,437 +0,0 @@ -# schema.py - -"""Provide a representation of a schema describing structured messages. - -This file defines these classes: - - 'SchemaStatus' - the version status of a schema - 'SchemaTypeDefinition' - definitions of schema types - 'SchemaElementDefinition' - definitions of message elements - -This component provides types for representing schemata which describe -structured messages. Such schemata consist of two distinct kinds of -definitions: "type" definitions (represented by 'SchemaTypeDefinition' objects) -declare types that can be used within other definitions (of both kinds); an -"element" definition defines a specific field by associating a field identifier -with a particular type, as well as the number of values of that type that are -permitted to be associated with that identifier. - -""" - - - -from .exception import NotFoundException, IndexOutOfRangeException -from .name import Name, getNamePair -from .constant import ConstantList -from . import utils -from . import internals -from .compat import with_metaclass - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class SchemaStatus(object): - """The possible deprecation statuses of a schema element or type. - - Class attributes: - - ACTIVE This item is current and may appear in Messages - DEPRECATED This item is current and may appear in Messages but will - be removed in due course - INACTIVE This item is not current and will not appear in Messages - PENDING_DEPRECATION This item is expected to be deprecated in the - future; clients are advised to migrate away from use of - this item. - - """ - - ACTIVE = internals.STATUS_ACTIVE - """This item is current and may appear in Messages""" - DEPRECATED = internals.STATUS_DEPRECATED - """This item is current and may appear in Messages but will be removed""" - INACTIVE = internals.STATUS_INACTIVE - """This item is not current and will not appear in Messages""" - PENDING_DEPRECATION = internals.STATUS_PENDING_DEPRECATION - """This item is expected to be deprecated in the future""" - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class SchemaElementDefinition(object): - """The definition of an individual field within a schema type. - - This class implements the definition of an individual field within a schema - type. An element is defined by an identifer/name, a type, and the number of - values of that type that may be associated with the identifier/name. In - addition, this class offers access to metadata providing a description and - deprecation status for the field. - - 'SchemaElementDefinition' objects are returned by 'Service' and 'Operation' - objects to define the content of requests, replies and events. The - 'SchemaTypeDefinition' returned by - 'SchemaElementDefinition.typeDefinition()' may itself provide access to - 'SchemaElementDefinition' objects when the schema contains nested elements. - (See the 'SchemaTypeDefinition' documentation for more information on - complex types.) - - An optional element has 'minValues() == 0'. - - A mandatory element has 'minValues() >= 1'. - - An element that must constain a single value has - 'minValues() == maxValues() == 1'. - - An element containing an array has 'maxValues() > 1'. - - An element with no upper limit on the number of values has - 'maxValues() == UNBOUNDED'. - - 'SchemaElementDefinition' objects are read-only. - - Application clients need never create 'SchemaElementDefinition' objects - directly; applications will typically work with objects returned by other - 'blpapi' components. - - Class attributes: - - UNBOUNDED - Indicates an array has an unbounded number of values. - """ - - UNBOUNDED = internals.ELEMENTDEFINITION_UNBOUNDED - """Indicates an array has an unbounded number of values.""" - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string representation of this item. It is equivalent to - toString() with default parameters. - - """ - - return self.toString() - - def name(self): - """Return the name of this element. - - Return the name identifying this element within its containing - structure/type. - - """ - - return Name._createInternally( - internals.blpapi_SchemaElementDefinition_name(self.__handle)) - - def description(self): - """Return a human readable description of this element.""" - return internals.blpapi_SchemaElementDefinition_description( - self.__handle) - - def status(self): - """Return the deprecation status of this element. - - The possible return values are enumerated in 'SchemaStatus' class. - - """ - - return internals.blpapi_SchemaElementDefinition_status(self.__handle) - - def typeDefinition(self): - """Return the type of values contained in this element.""" - return SchemaTypeDefinition( - internals.blpapi_SchemaElementDefinition_type(self.__handle), - self.__sessions) - - def minValues(self): - """Return the minimum number of occurences of this element. - - This value is always greater than or equal to zero. - - """ - - return internals.blpapi_SchemaElementDefinition_minValues( - self.__handle) - - def maxValues(self): - """Return the maximum number of occurences of this element. - - This value is always greater than or equal to one. - - Return value is equal to 'SchemaElementDefinition.UNBOUNDED' if this - item is an unbounded array. - - """ - - return internals.blpapi_SchemaElementDefinition_maxValues( - self.__handle) - - def alternateNames(self): - """Return the list of alternate names for this element. - - The result is a list of Name objects. - - """ - - res = [] - numAlternateNames = \ - internals.blpapi_SchemaElementDefinition_numAlternateNames( - self.__handle) - for i in range(numAlternateNames): - res.append(Name._createInternally( - internals.blpapi_SchemaElementDefinition_getAlternateName( - self.__handle, - i))) - return res - - def toString(self, level=0, spacesPerLevel=4): - """Format this 'SchemaElementDefinition' to the string. - - Format this 'SchemaElementDefinition' to the string at the (absolute - value of) optionally specified indentation 'level'. If 'level' is - specified, optionally specify 'spacesPerLevel', the number of spaces - per indentation level for this and all of its nested objects. If - 'level' is negative, suppress indentation of the first line. If - 'spacesPerLevel' is negative, format the entire output on one line, - suppressing all but the initial indentation (as governed by 'level'). - - """ - - return internals.blpapi_SchemaElementDefinition_printHelper( - self.__handle, - level, - spacesPerLevel) - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - - -class SchemaTypeDefinition(object): - - """Representation of a "type" that can be used within a schema. - - This class implements a representation of a "type" that can be used within - a schema, including both simple atomic types (integers, dates, strings, - etc.) as well as "complex" types defined a sequences of or choice among a - collection (named) elements, each of which is in turn described by another - type. In addition to accessors for the type's structure, this class also - offers access to metadata providing a description and deprecation status - for the type. - - Each 'SchemaElementDefinition' object is associated with a single - 'SchemaTypeDefinition'; one 'SchemaTypeDefinition' may be used by zero, - one, or many 'SchemaElementDefinition' objects. - - 'SchemaTypeDefinition' objects are read-only. - - Application clients need never create fresh 'SchemaTypeDefinition' objects - directly; applications will typically work with objects returned by other - 'blpapi' components. - - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def __str__(self): - """x.__str__() <==> str(x) - - Return a string representation of this 'SchemaTypeDefinition'. It is - equivalent to call of toString() with default parameters. - - """ - - return self.toString() - - def datatype(self): - """Return the data type of this 'SchemaTypeDefinition'. - - The possible return values are enumerated in 'DataType' class. - - """ - - return internals.blpapi_SchemaTypeDefinition_datatype(self.__handle) - - def name(self): - """Return the name of this 'SchemaTypeDefinition'.""" - return Name._createInternally( - internals.blpapi_SchemaTypeDefinition_name(self.__handle)) - - def description(self): - """Return a human readable description of this 'SchemaTypeDefinition'. - """ - return internals.blpapi_SchemaTypeDefinition_description(self.__handle) - - def status(self): - """Return the deprecation status of this 'SchemaTypeDefinition'. - - The possible return values are enumerated in 'SchemaStatus' class. - - """ - - return internals.blpapi_SchemaTypeDefinition_status(self.__handle) - - def numElementDefinitions(self): - """Return the number of 'SchemaElementDefinition' objects. - - Return the number of 'SchemaElementDefinition' objects contained by - this 'SchemaTypeDefinition'. If this 'SchemaTypeDefinition' is neither - a choice nor a sequence this will return 0. - - """ - - return internals.blpapi_SchemaTypeDefinition_numElementDefinitions( - self.__handle) - - def isComplexType(self): - """Return True if this is a sequence or choice type. - - Return True if this 'SchemaTypeDefinition' represents a sequence or - choice type. - - """ - - return bool(internals.blpapi_SchemaTypeDefinition_isComplexType( - self.__handle)) - - def isSimpleType(self): - """Return True if this is neither a sequence nor a choice type. - - Return True if this 'SchemaTypeDefinition' represents neither a - sequence nor a choice type. - - """ - - return bool(internals.blpapi_SchemaTypeDefinition_isSimpleType( - self.__handle)) - - def isEnumerationType(self): - """Return True if this is an enmeration type. - - Return True if this 'SchemaTypeDefinition' represents an enmeration - type. - - """ - - return bool(internals.blpapi_SchemaTypeDefinition_isEnumerationType( - self.__handle)) - - def hasElementDefinition(self, name): - """True if this object contains an item with the specified 'name'. - - Return True if this 'SchemaTypeDefinition' contains an item with the - specified 'name'; otherwise return False. - - Exception is raised if 'name' is neither a Name nor a string. - - """ - - name = getNamePair(name) - return internals.blpapi_SchemaTypeDefinition_hasElementDefinition( - self.__handle, - name[0], - name[1]) - - def getElementDefinition(self, nameOrIndex): - """Return the definition of a specified element. - - Return a 'SchemaElementDefinition' object describing the element - identified by the specified 'nameOrIndex', which must be either a - string or an integer. If 'nameOrIndex' is a string and - 'hasElement(nameOrIndex) != True', then a 'NotFoundException' is - raised; if 'nameOrIndex' is an integer and 'nameOrIndex >= - numElementDefinitions()' then an 'IndexOutOfRangeException' is raised. - - """ - - if not isinstance(nameOrIndex, int): - name = nameOrIndex - names = getNamePair(name) - res = internals.blpapi_SchemaTypeDefinition_getElementDefinition( - self.__handle, - names[0], - names[1]) - if res is None: - errMessage =\ - "Name '{0!s}' not a sub-element of element '{1!s}'.".\ - format(name, self.name()) - raise NotFoundException(errMessage, 0) - return SchemaElementDefinition(res, self.__sessions) - position = nameOrIndex - res = internals.blpapi_SchemaTypeDefinition_getElementDefinitionAt( - self.__handle, - position) - if res is None: - errMessage = "Index '{0}' out of bounds.".format(position) - raise IndexOutOfRangeException(errMessage, 0) - return SchemaElementDefinition(res, self.__sessions) - - def elementDefinitions(self): - """Return an iterator over 'SchemaElementDefinitions'. - - Return an iterator over 'SchemaElementDefinitions' defined by this - 'SchemaTypeDefinition'. - - """ - - return utils.Iterator(self, - SchemaTypeDefinition.numElementDefinitions, - SchemaTypeDefinition.getElementDefinition) - - def enumeration(self): - """Return all possible values of the enumeration defined by this type. - - Return a 'ConstantList' containing all possible values of the - enumeration defined by this type. - - Return None in case this 'SchemaTypeDefinition' is not a enumeration. - - """ - - res = internals.blpapi_SchemaTypeDefinition_enumeration(self.__handle) - return None if res is None else ConstantList(res, self.__sessions) - - def toString(self, level=0, spacesPerLevel=4): - """Format this 'SchemaTypeDefinition' to the string. - - Format this 'SchemaTypeDefinition' to the string at the (absolute value - of) optionally specified indentation 'level'. If 'level' is specified, - optionally specify 'spacesPerLevel', the number of spaces per - indentation level for this and all of its nested objects. If 'level' is - negative, suppress indentation of the first line. If 'spacesPerLevel' - is negative, format the entire output on one line, suppressing all but - the initial indentation (as governed by 'level'). - - """ - - return internals.blpapi_SchemaTypeDefinition_printHelper( - self.__handle, - level, - spacesPerLevel) - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/service.py b/blpapi/service.py deleted file mode 100644 index 80f1bcc..0000000 --- a/blpapi/service.py +++ /dev/null @@ -1,371 +0,0 @@ -# service.py - -"""A service which provides access to API data (provide or consume). - -All API data is associated with a 'Service'. A service object is obtained -from a Session and contains zero or more 'Operations'. A service can be a -provider service (can generate API data) or a consumer service. - -""" - - - - -from .event import Event -from .name import getNamePair -from .request import Request -from .schema import SchemaElementDefinition -from .exception import _ExceptionUtil -from . import utils -from . import internals - - -class Operation(object): - """Defines an operation which can be performed by a Service. - - Operation objects are obtained from a Service object. They provide - read-only access to the schema of the Operations Request and the schema of - the possible response. - - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - - def name(self): - """Return the name of this Operation.""" - return internals.blpapi_Operation_name(self.__handle) - - def description(self): - """Return a human readable description of this Operation.""" - return internals.blpapi_Operation_description(self.__handle) - - def requestDefinition(self): - """Return a SchemaElementDefinition for this Operation. - - Return a SchemaElementDefinition which defines the schema for this - Operation. - - """ - - errCode, definition = internals.blpapi_Operation_requestDefinition( - self.__handle) - return None if 0 != errCode else\ - SchemaElementDefinition(definition, self.__sessions) - - def numResponseDefinitions(self): - """Return the number of the response types for this Operation. - - Return the number of the response types that can be returned by this - Operation. - - """ - - return internals.blpapi_Operation_numResponseDefinitions(self.__handle) - - def getResponseDefinitionAt(self, position): - """Return a SchemaElementDefinition for the response to this Operation. - - Return a SchemaElementDefinition which defines the schema for the - response that this Operation delivers. - - If 'position' >= numResponseDefinitions() an exception is raised. - - """ - - errCode, definition = internals.blpapi_Operation_responseDefinition( - self.__handle, - position) - _ExceptionUtil.raiseOnError(errCode) - return SchemaElementDefinition(definition, self.__sessions) - - def responseDefinitions(self): - """Return an iterator over response for this Operation. - - Return an iterator over response types that can be returned by this - Operation. - - Response type is defined by SchemaElementDefinition object. - - """ - - return utils.Iterator(self, - Operation.numResponseDefinitions, - Operation.getResponseDefinitionAt) - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - - -class Service(object): - """Defines a service which provides access to API data. - - A Service object is obtained from a Session and contains the Operations - (each of which contains its own schema) and the schema for Events which - this Service may produce. A Service object is also used to create Request - objects used with a Session to issue requests. - - Provider services are created to generate API data and must be registered - before use. - - The Service object is a handle to the underlying data which is owned by the - Session. Once a Service has been succesfully opened in a Session it remains - accessible until the Session is terminated. - - """ - - def __init__(self, handle, sessions): - self.__handle = handle - self.__sessions = sessions - internals.blpapi_Service_addRef(self.__handle) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.blpapi_Service_release(self.__handle) - self.__handle = None - - def __str__(self): - """Convert the service schema to a string.""" - return self.toString() - - def toString(self, level=0, spacesPerLevel=4): - """Convert this Service schema to a string. - - Convert this Service schema to a string at (absolute value specified - for) the optionally specified indentation 'level'. If 'level' is - specified, optionally specify 'spacesPerLevel', the number of spaces - per indentation level for this and all of its nested objects. If - 'level' is negative, suppress indentation of the first line. If - 'spacesPerLevel' is negative, format the entire output on one line, - suppressing all but the initial indentation (as governed by 'level'). - - """ - - return internals.blpapi_Service_printHelper(self.__handle, - level, - spacesPerLevel) - - def createPublishEvent(self): - """Create an Event suitable for publishing to this Service. - - Use an EventFormatter to add Messages to the Event and set fields. - - """ - - errCode, event = internals.blpapi_Service_createPublishEvent( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return Event(event, self.__sessions) - - def createAdminEvent(self): - """Create an Admin Event suitable for publishing to this Service. - - Use an EventFormatter to add Messages to the Event and set fields. - - """ - - errCode, event = internals.blpapi_Service_createAdminEvent( - self.__handle) - _ExceptionUtil.raiseOnError(errCode) - return Event(event, self.__sessions) - - def createResponseEvent(self, correlationId): - """Create a response Event to answer the request. - - Use an EventFormatter to add a Message to the Event and set fields. - - """ - - errCode, event = internals.blpapi_Service_createResponseEvent( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errCode) - return Event(event, self.__sessions) - - def name(self): - """Return the name of this service.""" - return internals.blpapi_Service_name(self.__handle) - - def description(self): - """Return a human-readable description of this service.""" - return internals.blpapi_Service_description(self.__handle) - - def hasOperation(self, name): - """Return True if the specified 'name' is a valid Operation. - - Return True if the specified 'name' identifies a valid Operation in - this Service. - - """ - - names = getNamePair(name) - return internals.blpapi_Service_hasOperation(self.__handle, - names[0], - names[1]) - - def getOperation(self, nameOrIndex): - """Return a specified operation. - - Return an 'Operation' object identified by the specified - 'nameOrIndex', which must be either a string, a Name, or an integer. - If 'nameOrIndex' is a string or a Name and 'hasOperation(nameOrIndex) - != True', or if 'nameOrIndex' is an integer and 'nameOrIndex >= - numOperations()', then an exception is raised. - - """ - - if not isinstance(nameOrIndex, int): - names = getNamePair(nameOrIndex) - errCode, operation = internals.blpapi_Service_getOperation( - self.__handle, names[0], names[1]) - _ExceptionUtil.raiseOnError(errCode) - return Operation(operation, self.__sessions) - errCode, operation = internals.blpapi_Service_getOperationAt( - self.__handle, - nameOrIndex) - _ExceptionUtil.raiseOnError(errCode) - return Operation(operation, self.__sessions) - - def numOperations(self): - """Return the number of Operations defined by this Service.""" - return internals.blpapi_Service_numOperations(self.__handle) - - def operations(self): - """Return an iterator over Operations defined by this Service""" - return utils.Iterator(self, - Service.numOperations, - Service.getOperation) - - def hasEventDefinition(self, name): - """Return True if the specified 'name' identifies a valid event. - - Return True if the specified 'name' identifies a valid event in this - Service, False otherwise. - - Exception is raised if 'name' is neither a Name nor a string. - - """ - - names = getNamePair(name) - return internals.blpapi_Service_hasEventDefinition(self.__handle, - names[0], - names[1]) - - def getEventDefinition(self, nameOrIndex): - """Return the definition of a specified event. - - Return a 'SchemaElementDefinition' object describing the element - identified by the specified 'nameOrIndex', which must be either a - string or an integer. If 'nameOrIndex' is a string and - 'hasEventDefinition(nameOrIndex) != True', then a 'NotFoundException' - is raised; if 'nameOrIndex' is an integer and 'nameOrIndex >= - numEventDefinitions()' then an 'IndexOutOfRangeException' is raised. - - """ - - if not isinstance(nameOrIndex, int): - names = getNamePair(nameOrIndex) - errCode, definition = internals.blpapi_Service_getEventDefinition( - self.__handle, - names[0], - names[1]) - _ExceptionUtil.raiseOnError(errCode) - return SchemaElementDefinition(definition, self.__sessions) - errCode, definition = internals.blpapi_Service_getEventDefinitionAt( - self.__handle, - nameOrIndex) - _ExceptionUtil.raiseOnError(errCode) - return SchemaElementDefinition(definition, self.__sessions) - - def numEventDefinitions(self): - """Return the number of unsolicited events defined by this Service.""" - return internals.blpapi_Service_numEventDefinitions(self.__handle) - - def eventDefinitions(self): - """Return an iterator over unsolicited events defined by this Service. - """ - - return utils.Iterator(self, - Service.numEventDefinitions, - Service.getEventDefinition) - - def authorizationServiceName(self): - """Return the authorization service name. - - Return the name of the Service which must be used in order to authorize - access to restricted operations on this Service. If no authorization is - required to access operations on this service an empty string is - returned. Authorization services never require authorization to use. - """ - return internals.blpapi_Service_authorizationServiceName(self.__handle) - - def createRequest(self, operation): - """Return a empty Request object for the specified 'operation'. - - If 'operation' does not identify a valid operation in the Service then - an exception is raised. - - An application must populate the Request before issuing it using - Session.sendRequest(). - - """ - - errCode, request = internals.blpapi_Service_createRequest( - self.__handle, - operation) - _ExceptionUtil.raiseOnError(errCode) - return Request(request, self.__sessions) - - def createAuthorizationRequest(self, authorizationOperation=None): - """Return an empty Request object for 'authorizationOperation'. - - If the 'authorizationOperation' does not identify a valid operation for - this Service then an exception is raised. - - An application must populate the Request before issuing it using - Session.sendAuthorizationRequest(). - - """ - - errCode, request = internals.blpapi_Service_createAuthorizationRequest( - self.__handle, - authorizationOperation) - _ExceptionUtil.raiseOnError(errCode) - return Request(request, self.__sessions) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - def _sessions(self): - """Return session(s) this object is related to. For internal use.""" - return self.__sessions - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/session.py b/blpapi/session.py deleted file mode 100644 index bf90715..0000000 --- a/blpapi/session.py +++ /dev/null @@ -1,412 +0,0 @@ -# session.py - -"""Provide consumer session to get Bloomberg Service. - -This component implements a consumer session for getting services. -""" - -from __future__ import print_function -from __future__ import absolute_import -import weakref -import sys -import traceback -import os -import functools -from .abstractsession import AbstractSession -from .event import Event -from . import exception -from .exception import _ExceptionUtil -from . import internals -from .internals import CorrelationId -from .sessionoptions import SessionOptions - - -class Session(AbstractSession): - """Consumer session for making requests for Bloomberg services. - - This class provides a consumer session for making requests for Bloomberg - services. - - Sessions manage access to services either by requests and responses or - subscriptions. A Session can dispatch events and replies in either - a synchronous or asynchronous mode. The mode of a Session is determined - when it is constructed and cannot be changed subsequently. - - A Session is asynchronous if an eventHandler argument is supplied when it - is constructed. The nextEvent() method may not be called. All incoming - events are delivered to the event handler supplied on construction. - - A Session is synchronous if an eventHandler argument is not supplied when - it is constructed. The nextEvent() method must be called to read incoming - events. - - Several methods in Session take a CorrelationId parameter. The application - may choose to supply its own CorrelationId values or allow the Session to - create values. If the application supplys its own CorrelationId values it - must manage their lifetime such that the same value is not reused for more - than one operation at a time. The lifetime of a CorrelationId begins when - it is supplied in a method invoked on a Session and ends either when it is - explicitly cancelled using cancel() or unsubscribe(), when a RESPONSE Event - (not a PARTIAL_RESPONSE) containing it is received or when a - SUBSCRIPTION_STATUS Event which indicates that the subscription it refers - to has been terminated is received. - - When using an asynchronous Session the application must be aware that - because the callbacks are generated from another thread they may be - processed before the call which generates them has returned. For example, - the SESSION_STATUS Event generated by a startAsync() may be processed - before startAsync() has returned (even though startAsync() itself will not - block). - - This becomes more significant when Session generated CorrelationIds are in - use. For example, if a call to subscribe() which returns a Session - generated CorrelationId has not completed before the first Events which - contain that CorrelationId arrive the application may not be able to - interpret those events correctly. For this reason, it is preferable to use - user generated CorrelationIds when using asynchronous Sessions. This issue - does not arise when using a synchronous Session as long as the calls to - subscribe() etc are made on the same thread as the calls to nextEvent(). - - The possible statuses a subscription may be in. - - UNSUBSCRIBED No longer active, terminated by API. - SUBSCRIBING Initiated but no updates received. - SUBSCRIBED Updates are flowing. - CANCELLED No longer active, terminated by Application. - PENDING_CANCELLATION Pending cancellation. - """ - - UNSUBSCRIBED = internals.SUBSCRIPTIONSTATUS_UNSUBSCRIBED - """No longer active, terminated by API.""" - SUBSCRIBING = internals.SUBSCRIPTIONSTATUS_SUBSCRIBING - """Initiated but no updates received.""" - SUBSCRIBED = internals.SUBSCRIPTIONSTATUS_SUBSCRIBED - """Updates are flowing.""" - CANCELLED = internals.SUBSCRIPTIONSTATUS_CANCELLED - """No longer active, terminated by Application.""" - PENDING_CANCELLATION = \ - internals.SUBSCRIPTIONSTATUS_PENDING_CANCELLATION - """No longer active, terminated by Application.""" - - __handle = None - __handlerProxy = None - - @staticmethod - def __dispatchEvent(sessionRef, eventHandle): - try: - session = sessionRef() - if session is not None: - event = Event(eventHandle, session) - session.__handler(event, session) - except: - print("Exception in event handler:", file=sys.stderr) - traceback.print_exc(file=sys.stderr) - os._exit(1) - - def __init__(self, options=None, eventHandler=None, eventDispatcher=None): - """Constructor. - - Session([options, [eventHandler, [eventDispatcher]]]) constructs a - Session object using the optionally specified 'options', the - optionally specified 'eventHandler' and the optionally specified - 'eventDispatcher'. - - See the SessionOptions documentation for details on what can be - specified in the 'options'. - - 'eventHandler' can be None or a callable object that takes two - arguments: received event and related session. - - Note that in case of unhandled exception in 'eventHandler', the - exception traceback will be printed to sys.stderr and application - will be terminated with nonzero exit code. - - If 'eventHandler' is not None then this Session will operate in - asynchronous mode, otherwise the Session will operate in synchronous - mode. - - If 'eventDispatcher' is None then the Session will create a default - EventDispatcher for this Session which will use a single thread for - dispatching events. For more control over event dispatching a specific - instance of EventDispatcher can be supplied. This can be used to share - a single EventDispatcher amongst multiple Session objects. - - If an 'eventDispatcher' is supplied which uses more than one thread the - Session will ensure that events which should be ordered are passed to - callbacks in a correct order. For example, partial response to - a request or updates to a single subscription. - - If 'eventHandler' is None and and the 'eventDispatcher' is not None - an exception is raised. - - Each 'eventDispatcher' uses it's own thread or pool of threads so if - you want to ensure that a session which receives very large messages - and takes a long time to process them does not delay a session that - receives small messages and processes each one very quickly then give - each one a separate 'eventDispatcher'. - """ - if (eventHandler is None) and (eventDispatcher is not None): - raise exception.InvalidArgumentException( - "eventDispatcher is specified but eventHandler is None", 0) - if options is None: - options = SessionOptions() - if eventHandler is not None: - self.__handler = eventHandler - self.__handlerProxy = functools.partial(Session.__dispatchEvent, - weakref.ref(self)) - self.__handle = internals.Session_createHelper( - options._handle(), - self.__handlerProxy, - None if eventDispatcher is None else eventDispatcher._handle()) - AbstractSession.__init__( - self, - internals.blpapi_Session_getAbstractSession(self.__handle)) - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - if self.__handle: - internals.Session_destroyHelper(self.__handle, self.__handlerProxy) - self.__handle = None - - def start(self): - """Start this session in synchronous mode. - - Attempt to start this Session and blocks until the Session has started - or failed to start. If the Session is started successfully iTrue is - returned, otherwise False is returned. Before start() returns a - SESSION_STATUS Event is generated. If this is an asynchronous Session - then the SESSION_STATUS may be processed by the registered EventHandler - before start() has returned. A Session may only be started once. - """ - return internals.blpapi_Session_start(self.__handle) == 0 - - def startAsync(self): - """Start this session in asynchronous mode. - - Attempt to begin the process to start this Session and return True if - successful, otherwise return False. The application must monitor events - for a SESSION_STATUS Event which will be generated once the Session has - started or if it fails to start. If this is an asynchronous Session - then the SESSION_STATUS Event may be processed by the registered - EventHandler before startAsync() has returned. A Session may only be - started once. - """ - return internals.blpapi_Session_startAsync(self.__handle) == 0 - - def stop(self): - """Stop operation of this session and wait until it stops. - - Stop operation of this session and block until all callbacks to - EventHandler objects relating to this Session which are currently in - progress have completed (including the callback to handle - the SESSION_STATUS Event this call generates). Once this returns no - further callbacks to EventHandlers will occur. If stop() is called from - within an EventHandler callback it is silently converted to - a stopAsync() in order to prevent deadlock. Once a Session has been - stopped it can only be destroyed. - """ - return internals.blpapi_Session_stop(self.__handle) == 0 - - def stopAsync(self): - """Begin the process to stop this Session and return immediately. - - The application must monitor events for a - SESSION_STATUS Event which will be generated once the - Session has been stopped. After this SESSION_STATUS Event - no further callbacks to EventHandlers will occur(). Once a - Session has been stopped it can only be destroyed. - """ - return internals.blpapi_Session_stop(self.__handle) == 0 - - def nextEvent(self, timeout=0): - """Return the next available Event for this session. - - If there is no event available this will block for up to the specified - 'timeoutMillis' milliseconds for an Event to arrive. A value of 0 for - 'timeoutMillis' (the default) indicates nextEvent() should not timeout - and will not return until the next Event is available. - - If nextEvent() returns due to a timeout it will return an event of type - 'EventType.TIMEOUT'. - - If this is invoked on a Session which was created in asynchronous mode - an InvalidStateException is raised. - """ - retCode, event = internals.blpapi_Session_nextEvent(self.__handle, - timeout) - - _ExceptionUtil.raiseOnError(retCode) - - return Event(event, self) - - def tryNextEvent(self): - """Return the next Event for this session if it is available. - - If there are Events available for the session, return the next Event - If there is no event available for the session, return None. This - method never blocks. - """ - retCode, event = internals.blpapi_Session_tryNextEvent(self.__handle) - if retCode: - return None - else: - return Event(event, self) - - def subscribe(self, subscriptionList, identity=None, requestLabel=""): - """Begin subscriptions for each entry in the specified list. - - Begin subscriptions for each entry in the specified 'subscriptionList', - which must be an object of type 'SubscriptionList', optionally using - the specified 'identity' for authorization. If no 'identity' is - specified, the default authorization information is used. If the - optional 'requestLabel' is provided it defines a string which will be - recorded along with any diagnostics for this operation. - - A SUBSCRIPTION_STATUS Event will be generated for each - entry in the 'subscriptionList'. - """ - _ExceptionUtil.raiseOnError(internals.blpapi_Session_subscribe( - self.__handle, - subscriptionList._handle(), - None if identity is None else identity._handle(), - requestLabel, - len(requestLabel))) - - def unsubscribe(self, subscriptionList): - """Cancel subscriptions from the specified 'subscriptionList'. - - Cancel each of the current subscriptions identified by the specified - 'subscriptionList', which must be an object of type 'SubscriptionList'. - If the correlation ID of any entry in the 'subscriptionList' does not - identify a current subscription then that entry is ignored. All entries - which have valid correlation IDs will be cancelled. - - Once this call returns the correlation ids in the 'subscriptionList' - will not be seen in any subsequent Message obtained from - a MessageIterator by calling next(). However, any Message currently - pointed to by a MessageIterator when unsubscribe() is called is not - affected even if it has one of the correlation IDs in the - 'subscriptionList'. Also any Message where a reference has been - retained by the application may still contain a correlation ID from - the 'subscriptionList'. For these reasons, although technically - an application is free to re-use the correlation IDs as soon as this - method returns it is preferable not to aggressively re-use correlation - IDs, particularly with an asynchronous Session. - """ - _ExceptionUtil.raiseOnError(internals.blpapi_Session_unsubscribe( - self.__handle, - subscriptionList._handle(), - None, - 0)) - - def resubscribe(self, subscriptionList, requestLabel="", resubscriptionId=None): - """Modify subscriptions in 'subscriptionList'. - - Modify each subscription in the specified 'subscriptionList', which - must be an object of type 'SubscriptionList', to reflect the modified - options specified for it. If the optional 'requestLabel' is provided it - defines a string which will be recorded along with any diagnostics for - this operation. - - For each entry in the 'subscriptionList' which has a correlation ID - which identifies a current subscription the modified options replace - the current options for the subscription and a SUBSCRIPTION_STATUS - event will be generated in the event stream before the first update - based on the new options. If the correlation ID of an entry in the - 'subscriptionList' does not identify a current subscription then that - entry is ignored. - """ - error = None - if resubscriptionId is None: - error = internals.blpapi_Session_resubscribe( - self.__handle, - subscriptionList._handle(), - requestLabel, - len(requestLabel)) - else: - error = internals.blpapi_Session_resubscribeWithId( - self.__handle, - subscriptionList._handle(), - resubscriptionId, - requestLabel, - len(requestLabel)) - - _ExceptionUtil.raiseOnError(error) - - def setStatusCorrelationId(self, service, correlationId, identity=None): - """Set the CorrelationID on which service status messages. - - Set the CorrelationID on which service status messages will be - received. - Note: No service status messages are received prior to this call - """ - _ExceptionUtil.raiseOnError( - internals.blpapi_Session_setStatusCorrelationId( - self.__handle, - service._handle(), - None if identity is None else identity._handle(), - correlationId._handle())) - - def sendRequest(self, - request, - identity=None, - correlationId=None, - eventQueue=None, - requestLabel=""): - """Send the specified 'request'. - - Send the specified 'request' using the specified 'identity' for - authorization. If the optionally specified 'correlationId' is supplied - use it, otherwise create a CorrelationId. The actual CorrelationId used - is returned. If the optionally specified 'eventQueue' is supplied all - events relating to this Request will arrive on that EventQueue. If - the optional 'requestLabel' is provided it defines a string which will - be recorded along with any diagnostics for this operation. - - A successful request will generate zero or more PARTIAL_RESPONSE - Messages followed by exactly one RESPONSE Message. Once the final - RESPONSE Message has been received the CorrelationId associated with - this request may be re-used. If the request fails at any stage - a REQUEST_STATUS will be generated after which the CorrelationId - associated with the request may be re-used. - """ - if correlationId is None: - correlationId = CorrelationId() - res = internals.blpapi_Session_sendRequest( - self.__handle, - request._handle(), - correlationId._handle(), - None if identity is None else identity._handle(), - None if eventQueue is None else eventQueue._handle(), - requestLabel, - len(requestLabel)) - _ExceptionUtil.raiseOnError(res) - if eventQueue is not None: - eventQueue._registerSession(self) - return correlationId - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/sessionoptions.py b/blpapi/sessionoptions.py deleted file mode 100644 index 44b150e..0000000 --- a/blpapi/sessionoptions.py +++ /dev/null @@ -1,508 +0,0 @@ -# sessionoptions.py - -"""A common interface shared between publish and consumer sessions. - -This file defines a 'SessionOptions' class which is used to specify various -options during session creation. - -Usage ------ - -The following snippet shows how to use the SessionOptions when creating a -'Session'. - - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - session = blpapi.Session(sessionOptions) - if not session.start(): - raise Exception("Can't start session.") - -""" - -from __future__ import absolute_import -from .exception import _ExceptionUtil -from . import internals -from . import utils -from .compat import with_metaclass - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class SessionOptions(object): - """Options which the user can specify when creating a session. - - To use non-default options on a Session, create a SessionOptions instance - and set the required options and then supply it when creating a Session. - - The possible options for how to connect to the API: - - AUTO - Automatic (desktop if available otherwise server) - DAPI - Always connect to the desktop API - SAPI - Always connect to the server API - - """ - - AUTO = internals.CLIENTMODE_AUTO - """Automatic (desktop if available otherwise server)""" - DAPI = internals.CLIENTMODE_DAPI - """Always connect to the desktop API""" - SAPI = internals.CLIENTMODE_SAPI - """Always connect to the server API""" - - def __init__(self): - """Create a SessionOptions with all options set to the defaults""" - self.__handle = internals.blpapi_SessionOptions_create() - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this SessionOptions.""" - if self.__handle: - internals.blpapi_SessionOptions_destroy(self.__handle) - self.__handle = None - - def setServerHost(self, serverHost): - """Set the API server host to connect to when using the server API. - - Set the API server host to connect to when using the server API to the - specified 'host'. A hostname or an IPv4 address (that is, a.b.c.d). - The default is "127.0.0.1". - - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setServerHost(self.__handle, - serverHost)) - - def setServerPort(self, serverPort): - """Set the port to connect to when using the server API. - - Set the port to connect to when using the server API to the specified - 'port'. The default is "8194". - - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setServerPort(self.__handle, - serverPort)) - - def setServerAddress(self, serverHost, serverPort, index): - """Set the server address at the specified 'index'. - - Set the server address at the specified 'index' using the specified - 'serverHost' and 'serverPort'. - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setServerAddress(self.__handle, - serverHost, - serverPort, - index)) - - def removeServerAddress(self, index): - """Remove the server address at the specified 'index'.""" - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_removeServerAddress(self.__handle, - index)) - - def setConnectTimeout(self, timeoutMilliSeconds): - """Set the connection timeout in milliseconds. - - Set the connection timeout in milliseconds when connecting to the API. - The default is 5000 milliseconds. Behavior is not defined unless the - specified 'timeoutMilliSeconds' is in range of [1 .. 120000] - milliseconds. - - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setConnectTimeout( - self.__handle, - timeoutMilliSeconds)) - - def setDefaultServices(self, defaultServices): - """Set the default service for the session. - - DEPRECATED - Set the default service for the session. This function is deprecated; - see 'setDefaultSubscriptionService'. - - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setDefaultServices( - self.__handle, - defaultServices)) - - def setDefaultSubscriptionService(self, defaultSubscriptionService): - """Set the default service for subscriptions. - - Set the default service for subscriptions which do not specify a - subscription server to the specified 'defaultSubscriptionService'. The - behavior is undefined unless 'defaultSubscriptionService' matches the - regular expression '^//[-_.a-zA-Z0-9]+/[-_.a-zA-Z0-9]+$'. The default - is "//blp/mktdata". For more information on when this will be used see - 'QUALIFYING SUBSCRIPTION STRINGS' section in 'blpapi_subscriptionlist'. - - """ - - _ExceptionUtil.raiseOnError( - internals.blpapi_SessionOptions_setDefaultSubscriptionService( - self.__handle, - defaultSubscriptionService)) - - def setDefaultTopicPrefix(self, prefix): - """Set the default topic prefix. - - Set the default topic prefix to be used when a subscription does not - specify a prefix to the specified 'prefix'. The default is "/ticker/". - For more information on when this will be used see 'QUALIFYING - SUBSCRIPTION STRINGS' section in 'blpapi_subscriptionlist'. - - """ - - internals.blpapi_SessionOptions_setDefaultTopicPrefix( - self.__handle, - prefix) - - def setAllowMultipleCorrelatorsPerMsg(self, - allowMultipleCorrelatorsPerMsg): - """Associate more than one CorrelationId with a Message. - - Set whether the Session is allowed to associate more than one - CorrelationId with a Message to the specified - 'allowMultipleCorrelatorsPerMsg'. The default is False. This means that - if you have multiple subscriptions which overlap (that is a particular - Message is relevant to all of them) you will be presented with the same - message multiple times when you use the MessageIterator, each time with - a different CorrelationId. If you specify True for this then a Message - may be presented with multiple CorrelationId's. - - """ - - internals.blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg( - self.__handle, - allowMultipleCorrelatorsPerMsg) - - def setClientMode(self, clientMode): - """Set how to connect to the API. The default is AUTO. - - Set how to connect to the API. The default is AUTO which will try to - connect to the desktop API but fall back to the server API if the - desktop is not available. DAPI always connects to the desktop API and - will fail if it is not available. SAPI always connects to the server - API and will fail if it is not available. - - """ - - internals.blpapi_SessionOptions_setClientMode(self.__handle, - clientMode) - - def setMaxPendingRequests(self, maxPendingRequests): - """Set the maximum number of requests which can be pending. - - Set the maximum number of requests which can be pending to - the specified 'maxPendingRequests'. The default is 1024. - - """ - - internals.blpapi_SessionOptions_setMaxPendingRequests( - self.__handle, - maxPendingRequests) - - def setAuthenticationOptions(self, authOptions): - """Set the specified 'authOptions' as authentication option.""" - internals.blpapi_SessionOptions_setAuthenticationOptions( - self.__handle, - authOptions) - - def setNumStartAttempts(self, numStartAttempts): - """Set the maximum number of attempts to start a session. - - Set the maximum number of attempts to start a session by connecting a - server. - """ - internals.blpapi_SessionOptions_setNumStartAttempts(self.__handle, - numStartAttempts) - - def setAutoRestartOnDisconnection(self, autoRestart): - """Set whether automatically restarting connection if disconnected.""" - internals.blpapi_SessionOptions_setAutoRestartOnDisconnection( - self.__handle, - autoRestart) - - def setSlowConsumerWarningHiWaterMark(self, hiWaterMark): - """Set the point at which "slow consumer" events will be generated, - using the specified 'highWaterMark' as a fraction of - 'maxEventQueueSize'; the default value is 0.75. A warning event will - be generated when the number of outstanding undelivered events passes - above 'hiWaterMark * maxEventQueueSize'. The behavior of the function - is undefined unless '0.0 < hiWaterMark <= 1.0'. Further, at the time - that 'Session.start()' is called, it must be the case that - 'slowConsumerWarningLoWaterMark() * maxEventQueueSize()' < - 'slowConsumerWarningHiWaterMark() * maxEventQueueSize()'.""" - err = internals.blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark( - self.__handle, hiWaterMark) - _ExceptionUtil.raiseOnError(err) - - def setSlowConsumerWarningLoWaterMark(self, loWaterMark): - """Set the point at which "slow consumer cleared" events will be - generated, using the specified 'loWaterMark' as a fraction of - 'maxEventQueueSize'; the default value is 0.5. A warning cleared event - will be generated when the number of outstanding undelivered events - drops below 'loWaterMark * maxEventQueueSize'. The behavior of the - function is undefined unless '0.0 <= loWaterMark < 1.0'. Further, at - the time that 'Session.start()' is called, it must be the case that - 'slowConsumerWarningLoWaterMark() * maxEventQueueSize()' < - 'slowConsumerWarningHiWaterMark() * maxEventQueueSize()'.""" - err = internals.blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark( - self.__handle, loWaterMark) - _ExceptionUtil.raiseOnError(err) - - def setMaxEventQueueSize(self, eventQueueSize): - """Set the maximum number of outstanding undelivered events per session - to the specified 'eventQueueSize'. All subsequent events delivered - over the network will be dropped by the session if the number of - outstanding undelivered events is 'eventQueueSize', the specified - threshold. The default value is 10000.""" - internals.blpapi_SessionOptions_setMaxEventQueueSize(self.__handle, - eventQueueSize) - - def setKeepAliveEnabled(self, isEnabled): - """If the specified 'isEnabled' is False, then disable all keep-alive - mechanisms, both from the client to the server and from the server to - the client; otherwise enable keep-alive pings both from the client to - the server (as configured by 'setDefaultKeepAliveInactivityTime' and - 'setDefaultKeepAliveResponseTimeout' if the connection supports - ping-based keep-alives), and from the server to the client as specified - by the server configuration.""" - keepAliveValue = 1 if isEnabled else 0 - err = internals.blpapi_SessionOptions_setKeepAliveEnabled( - self.__handle, keepAliveValue) - _ExceptionUtil.raiseOnError(err) - - def setDefaultKeepAliveInactivityTime(self, inactivityMsecs): - """ Set to the specified 'inactivityMsecs' the amount of time that no - traffic can be received on a connection before the ping-based - keep-alive mechanism is triggered; if no traffic is received for this - duration then a keep-alive ping is sent to the remote end to solicit a - response. If 'inactivityMsecs == 0', then no keep-alive pings will be - sent. The behavior of this function is undefined unless - 'inactivityMsecs' is a non-negative value. The default value is 20,000 - milliseconds. Note that not all back-end connections provide - ping-based keep-alives; this option is ignored by such connections.""" - err = internals.blpapi_SessionOptions_setDefaultKeepAliveInactivityTime( - self.__handle, inactivityMsecs) - _ExceptionUtil.raiseOnError(err) - - def setDefaultKeepAliveResponseTimeout(self, timeoutMsecs): - """ When a keep-alive ping is sent, wait for the specified - 'timeoutMsecs' to receive traffic (of any kind) before terminating the - connection due to inactivity. If 'timeoutMsecs == 0', then connections - are never terminated due to the absence of traffic after a keep-alive - ping. The behavior of this function is undefined unless 'timeoutMsecs' - is a non-negative value. The default value is 5,000 milliseconds. - Note that not all back-end connections provide support for ping-based - keep-alives; this option is ignored by such connections.""" - err = internals.blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout( - self.__handle, timeoutMsecs) - _ExceptionUtil.raiseOnError(err) - - def setRecordSubscriptionDataReceiveTimes(self, shouldRecord): - """Set whether the receipt time (accessed via - 'blpapi.Message.timeReceived') should be recorded for subscription data - messages. By default, the receipt time for these messages is not - recorded.""" - internals.blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes( - self.__handle, shouldRecord) - - def serverHost(self): - """Return the server host option in this SessionOptions instance.""" - - return internals.blpapi_SessionOptions_serverHost(self.__handle) - - def serverPort(self): - """Return the server port that this session connects to.""" - - return internals.blpapi_SessionOptions_serverPort(self.__handle) - - def numServerAddresses(self): - """Return the number of server addresses.""" - - return internals.blpapi_SessionOptions_numServerAddresses( - self.__handle) - - def getServerAddress(self, index): - """Return tuple of the server name and port indexed by 'index'.""" - - errorCode, host, port = \ - internals.blpapi_SessionOptions_getServerAddress(self.__handle, - index) - - _ExceptionUtil.raiseOnError(errorCode) - - return host, port - - def serverAddresses(self): - """Return an iterator over server addresses for this SessionOptions. - """ - - return utils.Iterator(self, - SessionOptions.numServerAddresses, - SessionOptions.getServerAddress) - - def connectTimeout(self): - """Return the value of the connection timeout option. - - Return the value of the connection timeout option in this - SessionOptions instance in milliseconds. - - """ - - return internals.blpapi_SessionOptions_connectTimeout(self.__handle) - - def defaultServices(self): - """Return all default services in one string.""" - return internals.blpapi_SessionOptions_defaultServices(self.__handle) - - def defaultSubscriptionService(self): - """Return the default subscription service. - - Return the value of the default subscription service option in this - SessionOptions instance. - - """ - - return internals.blpapi_SessionOptions_defaultSubscriptionService( - self.__handle) - - def defaultTopicPrefix(self): - """Return the default topic prefix. - - Return the value of the default topic prefix option in this - SessionOptions instance. - - """ - - return internals.blpapi_SessionOptions_defaultTopicPrefix( - self.__handle) - - def allowMultipleCorrelatorsPerMsg(self): - """Return the value of the allow multiple correlators per message. - - Return the value of the allow multiple correlators per message option - in this SessionOptions instance. - - """ - - return internals.blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg( - self.__handle) != 0 - - def clientMode(self): - """Return the value of the client mode option. - - Return the value of the client mode option in this SessionOptions - instance. - - """ - - return internals.blpapi_SessionOptions_clientMode(self.__handle) - - def maxPendingRequests(self): - """Return the value of the maximum pending request option. - - Return the value of the maximum pending request option in this - SessionOptions instance. - - """ - - return internals.blpapi_SessionOptions_maxPendingRequests( - self.__handle) - - def autoRestartOnDisconnection(self): - """Return whether automatically restart connection if disconnected.""" - return internals.blpapi_SessionOptions_autoRestartOnDisconnection( - self.__handle) != 0 - - def authenticationOptions(self): - """Return authentication options in a string.""" - return internals.blpapi_SessionOptions_authenticationOptions( - self.__handle) - - def numStartAttempts(self): - """Return the maximum number of attempts to start a session. Return - the maximum number of attempts to start a session by connecting a - server. """ - return internals.blpapi_SessionOptions_numStartAttempts(self.__handle) - - def recordSubscriptionDataReceiveTimes(self): - """Return whether the receipt time (accessed via - 'blpapi.Message.timeReceived') should be recorded for subscription data - messages.""" - return internals.blpapi_SessionOptions_recordSubscriptionDataReceiveTimes( - self.__handle) - - def slowConsumerWarningHiWaterMark(self): - """Return the fraction of maxEventQueueSize at which "slow consumer" - event will be generated.""" - return internals.blpapi_SessionOptions_slowConsumerWarningHiWaterMark( - self.__handle) - - def slowConsumerWarningLoWaterMark(self): - """Return the fraction of maxEventQueueSize at which "slow consumer - cleared" event will be generated.""" - return internals.blpapi_SessionOptions_slowConsumerWarningLoWaterMark( - self.__handle) - - def maxEventQueueSize(self): - """Return the value of maximum outstanding undelivered events that the - session is configured with.""" - return internals.blpapi_SessionOptions_maxEventQueueSize(self.__handle) - - def defaultKeepAliveInactivityTime(self): - """Return the interval (in milliseconds) a connection has to remain - inactive (receive no data) before a keep alive probe will be sent.""" - return internals.blpapi_SessionOptions_defaultKeepAliveInactivityTime( - self.__handle) - - def defaultKeepAliveResponseTimeout(self): - """Return the time (in milliseconds) the library will wait for response - to a keep alive probe before declaring it lost.""" - return internals.blpapi_SessionOptions_defaultKeepAliveResponseTimeout( - self.__handle) - - def keepAliveEnabled(self): - """Return True if the keep-alive mechanism is enabled; otherwise - return False.""" - return internals.blpapi_SessionOptions_keepAliveEnabled(self.__handle) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/subscriptionlist.py b/blpapi/subscriptionlist.py deleted file mode 100644 index 0e16c0f..0000000 --- a/blpapi/subscriptionlist.py +++ /dev/null @@ -1,274 +0,0 @@ -# subscriptionlist.py - -"""Provide a list of subscriptions. - -This component provides a class to hold the data used (and returned) by the -'Session.subscribe', 'Session.resubscribe', and 'Session.unsubscribe' -methods. This class comprises a list in which each list entry contains two -primary fields: a 'CorrelationId' associated with the subscription, and a -string, called a *subscription* *string*, describing the data to be delivered -as a part of the subscription. - -STRUCTURE OF SUBSCRIPTION STRING ---------------------------------- -The simplest form of a subscription string is a *fully* *qualified* -subscription string, which has the following structure: - -"//blp/mktdata/ticker/IBM US Equity?fields=BID,ASK&interval=2" - \-----------/\------/\-----------/\------------------------/ - | | | | - Service Prefix Instrument Suffix - -Such a fully-qualified string is composed of: -: Service Identifier: a string matching the expression -: '^//[-_.a-zA-Z0-9]+/[-_.a-zA-Z0-9]+$', e.g. //blp/mktdata. See -: 'blpapi_abstractsession' for further details. -: -: Prefix: a string matching the expression '/([-_.a-zA-Z0-9]+/)?', often used -: as a symbology identifier. Common examples include '/ticker/' and -: '/cusip/'. Not all services make use of prefices. Note than an "empty" -: topic prefix consists of the string "/", so the topic prefix always -: separates the service string from the instrument string. -: -: Instrument: a non-empty string that does not contain the character '?' -: (i.e. a string matching '[^?]+') e.g. "IBM US Equity", or "SPX Index". -: The service, prefix, and instrument together uniquely identify a source -: for subscription data. -: -: Suffix: a suffix contains a question mark followed by a list of options -: which can affect the content delivery. The format of these options is -: service specific, but they generally follow URI query string conventions: -: a sequence of "key=value" pairs separated by "&" characters. Further, -: many common services follow the convention that the value given for the -: 'fields' key is formatted as a comma-separated list of field names. -: BLPAPI provides several convenience functions to assist in formatting -: subscription strings for services that make use of these conventions; -: see the 'SubscriptionList.add' methods for details. - -Subscription strings need not be fully qualified: BLPAPI allows the service and -prefix to be omitted from subscription strings, and automatically qualifies -these strings using information stored in a 'Session' object. - -QUALIFYING SUBSCRIPTION STRINGS -------------------------------- -The subscription strings passed to 'Session.subscribe' and -'Session.resubscribe' are automatically qualified if the service identifier is -missing (i.e. if the subscription string does not start with "//"). The -subscription parameters (i.e. the optional part after instrument identifier) -are never modified. - -The rules for qualifying the subscription string are: - -: o If the subscription string begins with "//" then it is assumed to be a -: a fully qualified subscription string including service identifier, -: prefix, and instrument. In this case the string will not be modified and -: session options defaults have no affect on the subscription. -: -: o If the subscription string begins with a '/' and the second character is -: not '/', then the string is assumed to begin with the topic prefix, but -: no service identifier. In this case the string is qualified by prepending -: the 'SessionOptions.defaultSubscriptionService()' to the specified -: string. -: -: o If the subscription string does not begin with a '/' it is assumed to -: begin with an instrument identifier. In this case the string is -: qualified by prepending the -: 'SessionOptions.defaultSubscriptionService()' followed by -: 'SessionOptions.defaultTopicPrefix()' to the specified string. -: If the 'defaultTopicPrefix' is empty or null, then the prefix used is -: '/'. Otherwise (in the case of a nontrivial prefix) if the separator '/' -: is not specified at the beginning or the end of the 'defaultTopicPrefix', -: then it will be added. -""" - -from __future__ import absolute_import - -from .exception import _ExceptionUtil -from . import internals -from .internals import CorrelationId -from .compat import conv2str, isstr - - -class SubscriptionList(object): - """A list of subscriptions. - - Contains a list of subscriptions used when subscribing and unsubscribing. - - A SubscriptionList is used when calling Session.subscribe(), - Session.resubscribe() and Session.unsubscribe(). The entries can be - constructed in a variety of ways. - - The two important elements when creating a subscription are - : Subscription String: A subscription string represents a topic whose - : updates user is interested in. A subscription string follows a - : structure as specified below. - : CorrelationId: the unique identifier to tag all data associated with - : this subscription. - - The following table describes how various operations use the above - elements: - |--------------|--------------------------------------------------------| - | OPERATION | SUBSCRIPTION STRING | CORRELATION ID | - |--------------|-----------------------+--------------------------------| - | 'subscribe' |Used to specify the |Identifier for the subscription.| - | |topic to subscribe to. |If uninitialized correlationid | - | | |was specified an internally | - | | |generated correlationId will be | - | | |set for the subscription. | - |--------------+-----------------------+--------------------------------| - |'resubscribe' |Used to specify the new|Identifier of the subscription | - | |topic to which the |which needs to be modified. | - | |subscription should be | | - | |modified to. | | - |--------------+-----------------------+--------------------------------| - |'unsubscribe' | NOT USED |Identifier of the subscription | - | | |which needs to be canceled. | - |-----------------------------------------------------------------------| - """ - def __init__(self): - """Create an empty SubscriptionList.""" - self.__handle = internals.blpapi_SubscriptionList_create() - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this SubscriptionList.""" - if self.__handle: - internals.blpapi_SubscriptionList_destroy(self.__handle) - self.__handle = None - - def add(self, topic, fields=None, options=None, correlationId=None): - """Add the specified 'topic' to this SubscriptionList. - - Add the specified 'topic', with the optionally specified 'fields' and - the 'options' to this SubscriptionList, associating the optionally - specified 'correlationId' with it. The 'fields' must be represented as - a comma separated string or a list of strings, 'options' - as an - ampersand separated string or list of strings or a name=>value - dictionary. - - Note that in case of unsubscribe, you can pass empty string or None for - 'topic' - """ - if correlationId is None: - correlationId = CorrelationId() - if topic is None: - topic = "" - - if fields is not None: - if isstr(fields): - fields = conv2str(fields) - else: - fields = ",".join(fields) - - if (options is not None): - if isstr(options): - options = conv2str(options) - elif isinstance(options, (list, tuple)): - options = "&".join(options) - elif isinstance(options, dict): - options = "&".join([key if val is None - else "{0}={1}".format(key, val) - for key, val in options.items()]) - - return internals.blpapi_SubscriptionList_addHelper( - self.__handle, - topic, - correlationId._handle(), - fields, - options) - - def append(self, other): - """Append a copy of the specified 'subscriptionList' to this list""" - return internals.blpapi_SubscriptionList_append( - self.__handle, - other.__handle) - - def clear(self): - """Remove all entries from this object.""" - return internals.blpapi_SubscriptionList_clear(self.__handle) - - def size(self): - """Return the number of subscriptions in this object.""" - return internals.blpapi_SubscriptionList_size(self.__handle) - - def correlationIdAt(self, index): - """Return the CorrelationId at the specified 'index'. - - Return the CorrelationId of the specified 'index'th entry - in this 'SubscriptionList' object. An exception is raised if - 'index >= size()'. - """ - errorCode, cid = internals.blpapi_SubscriptionList_correlationIdAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return cid - - def topicStringAt(self, index): - """Return the full topic string at the specified 'index'. - - Return the full topic string (including any field and option portions) - of the specified 'index'th entry in this SubscriptionList. An exception - is raised if 'index >= size()'. - """ - errorCode, topic = internals.blpapi_SubscriptionList_topicStringAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return topic - - def addResolved(self, subscriptionString, correlationId=None): - """Add the specified 'subscriptionString' to this 'SubscriptionList' - object, associating the specified 'correlationId' with it. The - subscription string may include options. The behavior of this - function, and of functions operating on this 'SubscriptionList' object, - is undefined unless 'subscriptionString' is a fully-resolved - subscription string; clients that cannot provide fully-resolved - subscription strings should use 'SubscriptionList.add' instead. Note - that it is at the discretion of each function operating on a - 'SubscriptionList' whether to perform resolution on this - subscription.""" - if correlationId is None: - correlationId = internals.CorrelationId() - return internals.blpapi_SubscriptionList_addResolved( - self.__handle, subscriptionString, correlationId._handle()) - - def isResolvedTopicAt(self, index): - """Return 'true' if the 'index'th entry in this 'SubscriptionList' - object was created using 'SubscriptionList.addResolved' and 'false' if - it was created using 'SubscriptionList.add'. An exception is thrown - if 'index >= size()'.""" - err, res = internals.blpapi_SubscriptionList_isResolvedAt( - self.__handle, index) - _ExceptionUtil.raiseOnError(err) - return res - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/testtools.py b/blpapi/testtools.py deleted file mode 100644 index 78a4b43..0000000 --- a/blpapi/testtools.py +++ /dev/null @@ -1,244 +0,0 @@ -# This tool tries to register every blpapi_*** function call in a database. -# Resulting information can be used later to generate test coverage report. -# This module doesn't ment to be used directly. - -import sqlite3 -import blpapi.internals as internals -from collections import defaultdict -from threading import Lock -import inspect - -#import blpapi-py modules -import blpapi - -__MODULES = [ - blpapi, - blpapi.abstractsession, - blpapi.constant, - blpapi.datatype, - blpapi.datetime, - blpapi.element, - blpapi.event, - blpapi.eventdispatcher, - blpapi.eventformatter, - #blpapi.exception, - blpapi.identity, - blpapi.message, - blpapi.name, - blpapi.providersession, - blpapi.request, - blpapi.resolutionlist, - blpapi.schema, - blpapi.service, - blpapi.session, - blpapi.sessionoptions, - blpapi.subscriptionlist, - blpapi.topic, - blpapi.topiclist, - blpapi.utils, -] - - -__DBNAME = 'coverage.db' -__connection = None -__cursor = None -__cursorLock = Lock() - -__EXCEPTIONS = set([ - "blpapi_Datetime_tag", -]) - -def __writeCallToDB(method_name, test_name, class_name=None): - global __cursor, __cursorLock - with __cursorLock: - query = """ - INSERT OR IGNORE INTO {table_name} (test_name, method_name) - VALUES ('{test_name}', '{method_name}'); - """ - table_name = None - if class_name is None: - full_method_name = method_name - table_name = 'api_calls_by_test' - else: - full_method_name = "{0}.{1}".format(class_name, method_name) - table_name = 'method_calls_by_test' - - if __cursor is not None: - __cursor.execute(query.format(test_name=test_name, - method_name=full_method_name, - table_name=table_name,)) - else: - print("No database connection, calling {method} from {test}".format( - method=full_method_name, test=test_name)) - -def logCallsToDB(method_name, test_name, obj, clsname=None): - """Basic logging decorator""" - def newcall(*args, **kwargs): - __writeCallToDB(method_name, test_name, clsname) - return obj(*args, **kwargs) - return newcall - -def getAllAPIFunctionNames(): - """Get list of all blpapi function names""" - global __EXCEPTIONS - results = [] - for name, obj in internals.__dict__.items(): - # Hack function that starts with 'blpapi_' signature - # this is an API methods. - signature = 'blpapi_' - if name.startswith(signature) and name not in __EXCEPTIONS: - if hasattr(obj, '__call__'): - # API function was found - results.append(name) - return results - -def alterClass(cls, clsName, testName, wrapper): - """Wrap each class method with decorator""" - for mname, value in cls.__dict__.items(): - if hasattr(value, '__call__'): - setattr(cls, mname, wrapper(mname, testName, value, clsName)) - -def hackInternalsModule(testname, wrap=logCallsToDB): - """Wraps all API calls with a decorator provided by user""" - for name in getAllAPIFunctionNames(): - obj = internals.__dict__[name] - # modify API function - internals.__dict__[name] = wrap(name, testname, obj) - # Wrap all blpapi class methods - global __MODULES - hackModules(__MODULES, testname, wrap) - -def getAllClasses(modules): - """List all classes in a modules list""" - result = {} - for module in modules: - for name, value in inspect.getmembers(module): - if inspect.isclass(value): - result[name] = value - return result - -def getAllClassMethods(modulesList): - """List all class methods in listed modules""" - result = [] - for module in modulesList: - for cname, cls in inspect.getmembers(module): - if inspect.isclass(cls): - for mname, mvalue in cls.__dict__.items(): - if hasattr(mvalue, '__call__'): - result.append('{0}.{1}'.format(cname, mname)) - return result - -def hackModules(modulesList, testname, wrap=logCallsToDB): - clsList = getAllClasses(modulesList) - for clsName, cls in clsList.items(): - alterClass(cls, clsName, testname, wrap) - -def init(): - """Initialize module state (sqlite database)""" - global __cursor, __connection, __DBNAME, __MODULES - conn = sqlite3.connect(__DBNAME, check_same_thread=False) - cursor = conn.cursor() - __connection = conn - __cursor = cursor - # There should be two tables, one with all API functions - # supported, other with all called functions by test. - query = """ - CREATE TABLE IF NOT EXISTS all_api_exists ( - method_name TEXT, - UNIQUE(method_name) - ) - """ - cursor.execute(query) - - query = """ - CREATE TABLE IF NOT EXISTS api_calls_by_test ( - test_name TEXT, - method_name TEXT, - UNIQUE(test_name, method_name) - ) - """ - cursor.execute(query) - - query = """ - CREATE TABLE IF NOT EXISTS all_class_methods ( - method_name TEXT, - UNIQUE(method_name) - ) - """ - cursor.execute(query) - - query = """ - CREATE TABLE IF NOT EXISTS method_calls_by_test ( - test_name TEXT, - method_name TEXT, - UNIQUE(test_name, method_name) - ) - """ - cursor.execute(query) - - # Initialize API table - for name in getAllAPIFunctionNames(): - query = """ - INSERT OR IGNORE INTO all_api_exists (method_name) - VALUES ('{method_name}'); - """ - if cursor is not None: - cursor.execute(query.format(method_name=name)) - - for name in getAllClassMethods(__MODULES): - query = """ - INSERT OR IGNORE INTO all_class_methods (method_name) - VALUES ('{method_name}'); - """ - if cursor is not None: - cursor.execute(query.format(method_name=name)) - conn.commit() - -def commit(): - global __connection, __cursor - __connection.commit() - -class Coverage: - def __init__(self, cur, api_table_name='all_api_exists', calls_table_name='api_calls_by_test'): - self.__api_table_name = api_table_name - self.__calls_table_name = calls_table_name - self.__tests = defaultdict(list) - self.__allfn = [] - self.__cursor = cur - self.readDB() - - def readDB(self): - query = """SELECT * from {0};""".format(self.__api_table_name) - for name, in self.__cursor.execute(query): - self.__allfn.append(name) - - query = """SELECT test_name, method_name FROM {0};""".format(self.__calls_table_name) - for test, method in self.__cursor.execute(query): - self.__tests[test].append(method) - - def getTotalCoverage(self): - from itertools import chain - allexists = set(self.__allfn) - alltested = set(chain(*self.__tests.values())) - uncovered = allexists - alltested - return { - "numtested": len(alltested), - "numexists": len(allexists), - "needcheck": len(uncovered), - "uncovered": uncovered, - } - -def getCodeCoverage(): - global __cursor - blpapi_coverage = Coverage(__cursor) - blpapipy_coverage = Coverage(__cursor, api_table_name="all_class_methods", - calls_table_name='method_calls_by_test') - return { - "blpapi": blpapi_coverage.getTotalCoverage(), - "blpapipy": blpapipy_coverage.getTotalCoverage(), - } - -# Init everything on module load -print("Initializing testtools, database name %s" % __DBNAME) -init() - diff --git a/blpapi/topic.py b/blpapi/topic.py deleted file mode 100644 index e15dea2..0000000 --- a/blpapi/topic.py +++ /dev/null @@ -1,108 +0,0 @@ -# topic.py - -"""Provide representation of a Topic - -This component provides a topic that is used for publishing data on. -""" - - - -from .exception import _ExceptionUtil -from .message import Message -from . import internals -from .internals import CorrelationId -from .service import Service - - -class Topic(object): - """Used to identify the stream on which a message is published. - - Topic objects are obtained from 'createTopic()' on 'ProviderSession'. They are - used when adding a message to an Event for publishing using 'appendMessage()' - on 'EventFormatter'. - """ - - def __init__(self, handle=None, sessions=None): - """Create a Topic object. - - Create a Topic object. A Topic created with 'handle' set to None is not - a valid topic and must be assigned to from a valid topic before it can - be used. - """ - self.__handle = handle - if handle is not None: - self.__handle = internals.blpapi_Topic_create(handle) - self.__sessions = sessions - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this Topic object.""" - if self.__handle: - internals.blpapi_Topic_destroy(self.__handle) - self.__handle = None - - def isValid(self): - """Return True if this Topic is valid. - - Return True if this Topic is valid and can be used to publish - a message on. - """ - return self.__handle is not None - - def isActive(self): - """Return True if this topic is the primary publisher. - - Return True if this topic was elected by the platform to become the - primary publisher. - """ - return bool(internals.blpapi_Topic_isActive(self.__handle)) - - def service(self): - """Return the service for which this topic was created. - - Return the service for which this topic was created. - """ - return Service(internals.blpapi_Topic_service(self.__handle), - self.__sessions) - - def __cmp__(self, other): - """3-way comparison of Topic objects.""" - return internals.blpapi_Topic_compare(self.__handle, other.__handle) - - def __lt__(self, other): - """2-way comparison of Topic objects.""" - return internals.blpapi_Topic_compare(self.__handle, other.__handle) < 0 - - def __eq__(self, other): - """2-way comparison of Topic objects.""" - return internals.blpapi_Topic_compare(self.__handle, other.__handle) == 0 - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/topiclist.py b/blpapi/topiclist.py deleted file mode 100644 index 4e3fba6..0000000 --- a/blpapi/topiclist.py +++ /dev/null @@ -1,228 +0,0 @@ -# topiclist.py - -"""Provide a representation of a list of topics. - -This component implements a list of topics which require topic creation. -""" - - - -from .exception import _ExceptionUtil -from .message import Message -from .resolutionlist import ResolutionList -from . import internals -from . import utils -from .internals import CorrelationId -from .compat import with_metaclass - - -@with_metaclass(utils.MetaClassForClassesWithEnums) -class TopicList(object): - """A list of topics which require creation. - - Contains a list of topics which require creation. - - Created from topic strings or from TOPIC_SUBSCRIBED or RESOLUTION_SUCCESS - messages. - This is passed to a 'createTopics()' call or 'createTopicsAsync()' call on a - ProviderSession. It is updated and returned by the 'createTopics()' call. - """ - - NOT_CREATED = internals.TOPICLIST_NOT_CREATED - CREATED = internals.TOPICLIST_CREATED - FAILURE = internals.TOPICLIST_FAILURE - - def __init__(self, original=None): - """Create an empty TopicList or TopicList based on 'original'. - - If 'original' is None - create empty TopicList. Otherwise create a - TopicList from 'original'. - """ - if isinstance(original, ResolutionList): - self.__handle = \ - internals.blpapi_TopicList_createFromResolutionList( - original._handle()) - self.__sessions = original._sessions() - else: - self.__handle = internals.blpapi_TopicList_create(None) - self.__sessions = set() - - def __del__(self): - try: - self.destroy() - except (NameError, AttributeError): - pass - - def destroy(self): - """Destroy this TopicList.""" - if self.__handle: - internals.blpapi_TopicList_destroy(self.__handle) - self.__handle = None - - def add(self, topicOrMessage, correlationId=None): - """Add the specified topic or topic from message to this TopicList. - - If topic is passed as 'topicOrMessage', add the topic to this list, - optionally specifying a 'correlationId'. Return 0 on success or - negative number on failure. After a successful call to 'add()' the - status for this entry is NOT_CREATED. - - If Message is passed as 'topicOrMessage', add the topic contained in - the specified 'topicSubscribedMessage' or 'resolutionSuccessMessage' to - this list, optionally specifying a 'correlationId'. Return 0 on - success or a negative number on failure. After a successful call to - 'add()' the status for this entry is NOT_CREATED. - """ - if correlationId is None: - correlationId = CorrelationId() - if not isinstance(correlationId, CorrelationId): - raise TypeError( - "correlationId should be an instance of 'CorrelationId'") - if isinstance(topicOrMessage, Message): - return internals.blpapi_TopicList_addFromMessage( - self.__handle, - topicOrMessage._handle(), - correlationId._handle()) - else: - return internals.blpapi_TopicList_add( - self.__handle, - topicOrMessage, - correlationId._handle()) - - def correlationIdAt(self, index): - """Return the CorrelationId at the specified 'index'. - - Return the CorrelationId of the specified 'index'th entry - in this TopicList. An exception is raised if 'index'>=size(). - """ - errorCode, cid = internals.blpapi_TopicList_correlationIdAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return cid - - def topicString(self, correlationId): - """Return the topic of the entry identified by 'correlationId'. - - Return the topic of the entry identified by 'correlationId'. If the - 'correlationId' does not identify an entry in this TopicList then an - exception is raised. - """ - errorCode, topic = internals.blpapi_TopicList_topicString( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return topic - - def topicStringAt(self, index): - """Return the full topic string at the specified 'index'. - - Return the full topic string of the specified 'index'th entry in this - TopicList. An exception is raised if 'index'>=size(). - """ - errorCode, topic = internals.blpapi_TopicList_topicStringAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return topic - - def status(self, correlationId): - """Return the status of the entry identified by 'correlationId'. - - Return the status of the entry in this TopicList identified by the - specified 'correlationId'. This may be NOT_CREATED, CREATED and - FAILURE. If the 'correlationId' does not identify an entry in this - TopicList then an exception is raised. - """ - errorCode, status = internals.blpapi_TopicList_status( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return status - - def statusAt(self, index): - """Return the status at the specified 'index'. - - Return the status of the specified 'index'th entry in this TopicList. - This may be NOT_CREATED, CREATED and FAILURE. - An exception is raised if 'index'>=size(). - """ - errorCode, status = internals.blpapi_TopicList_statusAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return status - - def message(self, correlationId): - """Return the message identified by 'correlationId'. - - Return the value of the message received during creation of the - topic identified by the specified 'correlationId'. If 'correlationId' - does not identify an entry in this TopicList or if the status of the - entry identify by 'correlationId' is not CREATED an exception is - raised. - - The message returned can be used when creating an instance of Topic. - """ - errorCode, message = internals.blpapi_TopicList_message( - self.__handle, - correlationId._handle()) - _ExceptionUtil.raiseOnError(errorCode) - return Message(message, sessions=self.__sessions) - - def messageAt(self, index): - """Return the message received during creation of entry at 'index'. - - Return the value of the message received during creation of the - specified 'index'th entry in this TopicList. If 'index' >= size() or if - the status of the 'index'th entry is not CREATED an exception is - raised. - - The message returned can be used when creating an instance of Topic. - """ - errorCode, message = internals.blpapi_TopicList_messageAt( - self.__handle, - index) - _ExceptionUtil.raiseOnError(errorCode) - return Message(message, sessions=self.__sessions) - - def size(self): - """Return the number of entries in this TopicList.""" - return internals.blpapi_TopicList_size(self.__handle) - - def _handle(self): - """Return the internal implementation.""" - return self.__handle - - def _sessions(self): - """Return session(s) that this 'ResolutionList' is related to. - - For internal use.""" - return self.__sessions - - def _addSession(self, session): - """Add a new session to this 'TopicList'. - - For internal use.""" - self.__sessions.add(session) - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/blpapi/utils.py b/blpapi/utils.py deleted file mode 100644 index 54315ba..0000000 --- a/blpapi/utils.py +++ /dev/null @@ -1,102 +0,0 @@ -# utils.py - -"""Internal utils.""" - - -class Iterator(object): - """Universal iterator for many of BLPAPI objects. - - It can be used to iterate any sub-items in an item which has - the following methods: - * method returning the number of sub-items - * method returning the 'index'ed sub-item - - For example, it is currently used as an iterator for Service's event - definition in the following way: - - class Service(object): - ... - # Return an iterator over this Service's event definitions. - def eventDefinitions(self): - return utils.Iterator( - self, - Service.numEventDefinitions, - Service.getEventDefinitionAt) - - ... - - """ - - def __init__(self, objToIterate, numFunc, getFunc): - self.__obj = objToIterate - self.__index = 0 - self.__num = numFunc(objToIterate) - self.__getter = getFunc - - def __iter__(self): - return self - - def __next__(self): - if self.__index == self.__num: - raise StopIteration() - else: - res = self.__getter(self.__obj, self.__index) - self.__index += 1 - return res - - next = __next__ - - -class MetaClassForClassesWithEnums(type): - """This meta class protects enums from changes. - - This meta class does not let change values of class members with names in - uppercase (a typical naming convention for enums). - - """ - - class EnumError(TypeError): - """Raise this on attempt to change value of an enumeration constant. - """ - pass - - def __setattr__(mcs, name, value): - """Change the value of an attribute if it is not an enum. - - Raise EnumError exception otherwise. - """ - if name.isupper() and name in mcs.__dict__: - raise mcs.EnumError("Can't change value of enum %s" % name) - else: - type.__setattr__(mcs, name, value) - - def __delattr__(mcs, name): - """Unbind the attribute if it is not an enum. - - Raise EnumError exception otherwise. - """ - if name.isupper() and name in mcs.__dict__: - raise mcs.EnumError("Can't unbind enum %s" % name) - else: - type.__delattr__(mcs, name) - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/changelog.txt b/changelog.txt index bb99836..e691a5e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,415 @@ +Version 3.24.11: +================ +- Stability and performance improvements + +Version 3.24.10: +================ +- Stability and performance improvements + +Version 3.24.9.3a1: +================ +- Stability and performance improvements + +Version 3.24.9.2-alpha: +================ +- Stability and performance improvements + +Version 3.24.9: +=============== +- Stability and performance improvements + +Version 3.24.8.3: +=============== +- Stability and performance improvements + +Version 3.24.8.2: +=============== +- Stability and performance improvements + +Version 3.24.8: +=============== +- Stability and performance improvements + +Version 3.24.7.1: +=============== +- Stability and performance improvements + +Version 3.24.7: +=============== +- Stability and performance improvements + +Version 3.24.6: +=============== +- Stability and performance improvements + +Version 3.24.5: +=============== +- Stability and performance improvements + +Version 3.24.4: +=============== +- Stability and performance improvements + +Version 3.24.3: +=============== +- Stability and performance improvements + +Version 3.24.2: +=============== +- Stability and performance improvements + +Version 3.24.1: +================ +- Added 'serverId' in subscription stream messages + 'serverId', which identifies the endpoint where a subscription is established, + has been added to 'SubscriptionStreamsActivated' and 'SubscriptionStreamsDeactivated' messages. +- Stability and performance improvements + +Version 3.23.12: +================ +- Stability and performance improvements + +Version 3.23.11: +=============== +- Versioning scheme change + BLPAPI now uses a versioning scheme that provides information about + the year and month the release was made. For example, '3.23.11' is the SDK + version 3 released in November of 2023. + - Automated cluster management for the public cloud + SDK now supports clustered configurations in the public cloud + that take advantage of horizontal scaling capabilities +- Stability and performance improvements + +Version 3.23.1: +=============== +- Stability and performance improvements + +Version 3.23.0: +=============== +- Stability and performance improvements + +Version 3.22.0: +=============== +- Added support for a named session + Users can now name a session by setting a 'sessionName' in + 'SessionOptions'. The name can be used to identify the log lines pertaining + to a given session and it can be retrieved via 'Session.sessionName()' method. +- Added names to threads provided by BLPAPI + Threads that are created by 'Session' are now named according to the + following scheme: blp. Component is a brief + descriptor of the thread function, for internal use. +- Stability and performance improvements + +Version 3.21.0: +=============== +- Horizontal scaling of requests + User requests will now be load-balanced across all connections for clients + using clustered farms. There is no change to the way clients send requests and + receive responses. +- Stability and performance improvements + +Version 3.20.3: +=============== +- Drop Python 3.7 support + Installation and use of the BLPAPI Python SDK now requires a Python 3.8+ runtime. +- Stability and performance improvements + +Version 3.20.2: +=============== +- Stability and performance improvements + +Version 3.20.1: +=============== +- Support for application identity key (AIK) + The application identity key (AIK) is obtained through Bloomberg for registered + applications. It uniquely identifies the registered application for a given Session + and can be provided by 'SessionOptions.setApplicationIdentityKey'. + +- Stability and performance improvements + +Version 3.20.0: +=============== +- Add SOCKS5 proxy support + Users can configure, per endpoint in `SessionOptions`, a single SOCKS5 + proxy host by using `Socks5Config` class. SOCKS5 authentication is not + supported. + +- Stability and performance improvements + +Version 3.19.3: +============== +- Add 'expected_cpp_sdk_version()' method that returns a minimum compatible + BLPAPI C++ SDK version. +- Drop Python 3.6 support + Installation and use of the BLPAPI Python SDK now requires a Python 3.7+ runtime. +- Add Python 3.11 support +- Stability and performance improvements + +Version 3.19.2: +=============== +- Remove Python 3.6 support from DPKG +- Stability and performance improvements + +Version 3.19.1: +=============== +- Stability and performance improvements + +Version 3.19.0: +=============== +- Add complete support for elements with bytearray data types ('bytes') + 'EventFormatter.setValue(Name, bytes)' can now be used to set elements + of type Bytearray and the value of these elements are retrievable via + 'Message.getElementAsBytes(Name)' or 'Element.getElementAsBytes(Name)' + or 'Element.getValueAsBytes()'. + +- Encourage usage of 'Name' in setters and getters taking the 'name' argument by string + Developers are encouraged to prefer 'Name' type parameter for methods + that accept either 'Name' or 'str' as the use of 'Name' is more + performant and functionally equivalent to 'str'. + + This recommendation is enforced for clients with strict type check enabled. + + Classes with such methods include 'Element', 'EventFormatter', 'Message', + 'MessageFormatter', 'Request', 'Service', 'Name' and 'Schema'. + +- Stability and performance improvements + +Version 3.18.3: +=============== +- Stability and performance improvements + +Version 3.18.2: +=============== +- Stability and performance improvements + +Version 3.18.1: +=============== +- Stability and performance improvements + +Version 3.18.0: +=============== +- Improved 'Session.subcribe' and 'Session.resubscribe' interface + The current 'Session.subscribe' and 'Session.resubscribe' raise an + exception when one of the subscriptions is invalid, e.g., subscribe + with a duplicate 'CorrelationId'. A new set of overloads are added + with parameter 'SubscriptionPreprocessMode', which could be + - 'FAIL_ON_FIRST_ERROR': an exception is raised on the first + invalid subscription in the list, and the entire batch will be + considered failed. + - 'RETURN_INDIVIDUAL_ERRORS': instead of raising exceptions, a + list of 'SubscriptionPreprocessError' is returned, each + representing an error due to an invalid subscription in the list. + The valid subscriptions will move forward. + +- Stability and performance improvements + +Version 3.17.1: +=============== +- Stability and performance improvements + +Version 3.17.0: +=============== +- Native-type formatting and message consumption + Add ability to format 'Event's and 'Request's from native Python types + using methods 'EventFormatter.fromPy' and 'Request.fromPy'. Add ability + to convert a 'Message' to 'dict' with 'Message.toPy'. 'Message's and + 'Request's have 'dict'-like behavior with '__getitem__' and + '__setitem__'. + +- A new method 'correlationId()' is added to 'blpapi.Message' + A new method 'Message.correlationId()' is added to return the + single CorrelationId associated with the message or None if the + message has no CorrelationIds. If the message has multiple + CorrelationIds, the first one is returned. + +- Constants for common used `Names` + A new utility class `blpapi.Names` has been added with common + message names. + +- Revamped examples + The 'examples' directory now contains 'demoapps' and 'unittests' + subdirectories. The 'demoapps' directory contains a consolidated set of + example applications. Within 'demoapps', the 'snippets' directory contains + sample code for creating and sending requests, and for processing + responses. Also within 'demoapps', the 'util' directory contains common + code shared between examples. The 'unittests' directory has been renamed + from 'mock-test-examples' and contains sample code for using the mock + testing interface. + +- End of Python 2 support + Installation and use of BLPAPI Python now requires a Python 3.6+ + runtime. + +- Stability and performance improvements + +Version 3.16.6: +=============== +- Stability and performance improvements + +Version 3.16.5: +=============== +- Stability and performance improvements + +Version 3.16.4: +=============== +- Stability and performance improvements + +Version 3.16.3: +=============== +- Stability and performance improvements + +Version 3.16.2: +=============== +- Stability and performance improvements + +Version 3.16.1: +=============== +- Stability and performance improvements + +Version 3.16.0: +=============== +- Attributes are no longer supported in 'blpapi.ResolutionList' + Support for attributes during resolution was never fully implemented + and is now deprecated. + +- Provide users ability to unit test applications offline using testing frameworks + The new utility module 'blpapi.test' can be used to create test events + and test messages. The test messages can be generated using Python + dictionaries, XML, JSON, or they can be built in a similar way to how + messages are normally constructed in the SDK. + +- Added unique request id to network interactions + A new, globally unique, request id has been added to network + interactions. The request id is a string that can be obtained by + calling 'Request.getRequestId()' before sending a request, and + 'Message.getRequestId()' for messages delivered to the application. + + Not all requests and messages will have a request id, notably + subscription data messages will *not* have a request id except + for recaps. + + This unique identifier will be useful when contacting support as it + will help quickly locate the interactions related to that event. + +- Stability and performance improvements + +Version 3.15.2: +=============== +- Stability and performance improvements + +Version 3.15.1: +=============== +- 'blpapi.Service.createAdminEvent()' is now deprecated. Use 'blpapi.Service.createPublishEvent()' instead + +- Stability and performance improvements + +Version 3.15.0: +=============== +- Provided a simplified interface to handle authentication and authorization + - Simplified authentication settings through the new set of strongly-typed + overloads described with 'AuthOptions' class. + + - Simplified existing multi-phased approach to authorization so that both + token generation and authorization can be done by the SDK. + - If 'AuthOptions' instance is provided to the session through the + newly introduced 'setSessionIdentityOptions' (part of 'SessionOptions'), + both token generation and subsequent authorization will be done by the + SDK. Successfully authorized identity would become the default + identity for the session that's used for all future requests unless + a different one is specified explicitly. + + - Additionally, two new session methods that simplify creation of + additional identities have been introduced: + - 'generateAuthorizedIdentity' - generates authorized identity + based on the provided 'AuthOptions'. + - 'getAuthorizedIdentity' - returns authorized identity that's + associated with the 'generateAuthorizedIdentity' call. + +- Improved usage of network bandwidth through support for compression + +- 'blpapi.Message.topicName()' is now deprecated + +- Stability and performance improvements + +Version 3.14.1: +=============== +- Stability and performance improvements + +Version 3.14.0: +=============== +- Improved usage of network bandwidth for snapshot requests + Optimized the network bandwidth usage between endpoints and Bloomberg data + centers for snapshot requests. Customers can request to disable the + optimization by setting the 'bandwidthSaveModeDisabled' session option. + +- Stability and performance improvements + +Version 3.13.1: +=============== +- Conversions to string using print helpers ignore null-terminators + Previously, when converting an e.g., Element to string explicitly, + or when printing it, null-terminators embedded in strings + would cause the resulting string to be truncated to the first one. + +- Format docstrings to be rendered by the Sphinx documentation generator +- Stability and performance improvements + +Version 3.13.0: +=============== +- Automated network configuration for ZFP over leased lines + Allow customers that leverage leased lines/routers for Bloomberg services + (such as existing Bloomberg terminals) to use this infrastructure to + connect their applications to Zero Foot-Print (ZFP) instances. + + A new utility class, 'blpapi.ZfpUtil', can be used to create a + 'SessionOptions' object with the appropriate servers. Applications can + update the options, including authorization settings, but should not + change the servers. + + Added a new example ZfpOverLeasedLinesSessionExample.py to demonstrate + how to create a session over ZFP leased lines. + +- Stability and performance improvements + +Version 3.12.3: +=============== +- Improve error reporting on failure to load the blpapi package +- Remove dependency on the C++ runtime + +Version 3.12.2: +=============== +- Stability and performance improvements + +Version 3.12.1: +=============== +- Stability and performance improvements + +Version 3.12.0: +=============== +- Add SessionOptions.toString() and SessionOptions.__str__ +- Add version helpers +- Python3.7 compatibility + - Deprecated the named parameter 'async' for blpapi.EventFormatter.stop in + favor of 'async_'. 'async' is a reserved keyword with Python3.7. + +Version 3.11.0: +=============== +- Add support for zero footprint connections +- Add support for fragmented recaps +- Add support for consuming microseconds + +Version 3.10.0: +=============== +- Documentation change + Clarify the meaning of integer priorities in 'ProviderSession'. Greater + values indicate higher priorities. + +- Add support for 3.10 features + - Provide access to the Message recap type + - Enable configuration of service timeouts in SessionOptions + - Add support for publisher terminated subscriptions + For more details on these features, please refer to the C++ release notes + Version 3.9.2: ============== - Fix Message.fragmentType @@ -33,4 +445,4 @@ Version 3.5.3: Version 3.5.2: ============== -- Initial public release of Python SDK \ No newline at end of file +- Initial public release of Python SDK diff --git a/examples/ContributionsMktdataExample.py b/examples/ContributionsMktdataExample.py deleted file mode 100644 index 7f593ee..0000000 --- a/examples/ContributionsMktdataExample.py +++ /dev/null @@ -1,288 +0,0 @@ -# ContributionsMktdataExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import time -from optparse import OptionParser, OptionValueError -import datetime -import threading - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -TOKEN = blpapi.Name("token") -MARKET_DATA = blpapi.Name("MarketData") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") - - -g_running = True -g_mutex = threading.Lock() - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyStream(object): - def __init__(self, id=""): - self.id = id - - -class MyEventHandler(object): - def processEvent(self, event, session): - global g_running - - for msg in event: - print(msg) - if event.eventType() == blpapi.Event.SESSION_STATUS: - if msg.messageType() == SESSION_TERMINATED: - g_running = False - continue - - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Market data contribution.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//blp/mpfbapi") - parser.add_option("-t", - dest="topic", - help="topic (default: %default)", - metavar="topic", - default="/ticker/AUDEUR Curncy") - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - return options - - -def authorize(authService, identity, session, cid): - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = datetime.timedelta(seconds=10) - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == \ - g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > WAIT_TIME_SECONDS: - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - sessionOptions.setNumStartAttempts(len(options.hosts)) - - myEventHandler = MyEventHandler() - - # Create a Session - session = blpapi.ProviderSession(sessionOptions, - myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - topicList = blpapi.TopicList() - topicList.add(options.service + options.topic, - blpapi.CorrelationId(MyStream(options.topic))) - - # Create topics - session.createTopics(topicList, - blpapi.ProviderSession.AUTO_REGISTER_SERVICES, - providerIdentity) - # createTopics() is synchronous, topicList will be updated - # with the results of topic creation (resolution will happen - # under the covers) - - streams = [] - for i in range(topicList.size()): - stream = topicList.correlationIdAt(i).value() - status = topicList.statusAt(i) - topicString = topicList.topicStringAt(i) - - if (status == blpapi.TopicList.CREATED): - stream.topic = session.getTopic(topicList.messageAt(i)) - streams.append(stream) - else: - print("Stream '%s': topic not resolved, status = %d" % ( - stream.id, status)) - - service = session.getService(options.service) - - try: - # Now we will start publishing - value = 1 - while streams and g_running: - event = service.createPublishEvent() - eventFormatter = blpapi.EventFormatter(event) - - for stream in streams: - value += 1 - eventFormatter.appendMessage(MARKET_DATA, stream.topic) - eventFormatter.setElement("BID", 0.5 * value) - eventFormatter.setElement("ASK", value) - - for msg in event: - print(msg) - - session.publish(event) - time.sleep(10) - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("ContributionsMktdataExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/ContributionsPageExample.py b/examples/ContributionsPageExample.py deleted file mode 100644 index cde5ab1..0000000 --- a/examples/ContributionsPageExample.py +++ /dev/null @@ -1,353 +0,0 @@ -# ContributionsPageExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import time -from optparse import OptionParser, OptionValueError -import datetime -import threading -import time - - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -TOKEN = blpapi.Name("token") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") - - -g_running = True -g_mutex = threading.Lock() - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyStream(object): - def __init__(self, id=""): - self.id = id - - -class MyEventHandler(object): - def processEvent(self, event, session): - global g_running - - for msg in event: - print(msg) - if event.eventType() == blpapi.Event.SESSION_STATUS: - if msg.messageType() == SESSION_TERMINATED: - g_running = False - continue - - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Publish on a topic.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//blp/mpfbapi") - parser.add_option("-t", - dest="topic", - help="topic (default: %default)", - metavar="topic", - default="220/660/1") - parser.add_option("-c", - dest="contributorId", - type="int", - help="contributor id (default: %default)", - metavar="contributorId", - default=8563) - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - return options - - -def authorize(authService, identity, session, cid): - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = datetime.timedelta(seconds=10) - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == \ - g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > WAIT_TIME_SECONDS: - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - sessionOptions.setNumStartAttempts(len(options.hosts)) - - myEventHandler = MyEventHandler() - - # Create a Session - session = blpapi.ProviderSession(sessionOptions, - myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - topicList = blpapi.TopicList() - topicList.add(options.service + "/" + options.topic, - blpapi.CorrelationId(MyStream(options.topic))) - - # Create topics - session.createTopics(topicList, - blpapi.ProviderSession.AUTO_REGISTER_SERVICES, - providerIdentity) - # createTopics() is synchronous, topicList will be updated - # with the results of topic creation (resolution will happen - # under the covers) - - streams = [] - for i in range(topicList.size()): - stream = topicList.correlationIdAt(i).value() - status = topicList.statusAt(i) - topicString = topicList.topicStringAt(i) - - if (status == blpapi.TopicList.CREATED): - stream.topic = session.getTopic(topicList.messageAt(i)) - streams.append(stream) - else: - print("Stream '%s': topic not resolved, status = %d" % ( - stream.id, status)) - - service = session.getService(options.service) - - try: - # Now we will start publishing - while streams and g_running: - event = service.createPublishEvent() - eventFormatter = blpapi.EventFormatter(event) - - for stream in streams: - eventFormatter.appendMessage("PageData", stream.topic) - eventFormatter.pushElement("rowUpdate") - - eventFormatter.appendElement() - eventFormatter.setElement("rowNum", 1) - eventFormatter.pushElement("spanUpdate") - - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 20) - eventFormatter.setElement("length", 4) - eventFormatter.setElement("text", "TEST") - eventFormatter.popElement() - - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 25) - eventFormatter.setElement("length", 4) - eventFormatter.setElement("text", "PAGE") - eventFormatter.popElement() - - tm = time.strftime("%X") - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 30) - eventFormatter.setElement("length", len(tm)) - eventFormatter.setElement("text", tm) - eventFormatter.setElement("attr", "BLINK") - eventFormatter.popElement() - - eventFormatter.popElement() - eventFormatter.popElement() - - eventFormatter.appendElement() - eventFormatter.setElement("rowNum", 2) - eventFormatter.pushElement("spanUpdate") - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 20) - eventFormatter.setElement("length", 9) - eventFormatter.setElement("text", "---------") - eventFormatter.setElement("attr", "UNDERLINE") - eventFormatter.popElement() - eventFormatter.popElement() - eventFormatter.popElement() - - eventFormatter.appendElement() - eventFormatter.setElement("rowNum", 3) - eventFormatter.pushElement("spanUpdate") - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 10) - eventFormatter.setElement("length", 9) - eventFormatter.setElement("text", "TEST LINE") - eventFormatter.popElement() - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 23) - eventFormatter.setElement("length", 5) - eventFormatter.setElement("text", "THREE") - eventFormatter.popElement() - eventFormatter.popElement() - eventFormatter.popElement() - eventFormatter.popElement() - - eventFormatter.setElement("contributorId", - options.contributorId) - eventFormatter.setElement("productCode", 1) - eventFormatter.setElement("pageNumber", 1) - - for msg in event: - print(msg) - - session.publish(event) - time.sleep(10) - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("ContributionsPageExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/CorrelationExample.py b/examples/CorrelationExample.py deleted file mode 100644 index 31965dd..0000000 --- a/examples/CorrelationExample.py +++ /dev/null @@ -1,124 +0,0 @@ -# CorrelationExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -class Window(object): - def __init__(self, name): - self.name = name - - def displaySecurityInfo(self, msg): - print("%s: %s" % (self.name, msg)) - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def startSession(session): - if not session.start(): - print("Failed to connect!") - return False - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - session.stop() - return False - - return True - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not startSession(session): - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - request.append("securities", "IBM US Equity") - request.append("fields", "PX_LAST") - request.append("fields", "DS002") - - secInfoWindow = Window("SecurityInfo") - cid = blpapi.CorrelationId(secInfoWindow) - - print("Sending Request:", request) - session.sendRequest(request, correlationId=cid) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - for msg in event: - if event.eventType() == blpapi.Event.RESPONSE or \ - event.eventType() == blpapi.Event.PARTIAL_RESPONSE: - window = msg.correlationIds()[0].value() - window.displaySecurityInfo(msg) - - # Response completly received, so we could exit - if event.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("CorrelationExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/EntitlementsVerificationTokenExample.py b/examples/EntitlementsVerificationTokenExample.py deleted file mode 100644 index 1279829..0000000 --- a/examples/EntitlementsVerificationTokenExample.py +++ /dev/null @@ -1,249 +0,0 @@ -# EntitlementsVerificationTokenExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - -SECURITY_DATA = blpapi.Name("securityData") -SECURITY = blpapi.Name("security") -EID_DATA = blpapi.Name("eidData") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") - -REFRENCEDATA_REQUEST = "ReferenceDataRequest" -APIAUTH_SVC = "//blp/apiauth" -REFDATA_SVC = "//blp/refdata" - -g_securities = None -g_tokens = None -g_session = None -g_identities = [] - - -def printEvent(event): - for msg in event: - corrId = msg.correlationIds()[0] - if corrId.value(): - print("Correlator:", corrId.value()) - print(msg) - - -class SessionEventHandler(object): - def printFailedEntitlements(self, listOfFailedEIDs): - print(listOfFailedEIDs) - - def distributeMessage(self, msg): - service = msg.service() - securities = msg.getElement(SECURITY_DATA) - numSecurities = securities.numValues() - print("Processing %s securities" % numSecurities) - for i in range(numSecurities): - security = securities.getValueAsElement(i) - ticker = security.getElementAsString(SECURITY) - entitlements = None - if security.hasElement(EID_DATA): - entitlements = security.getElement(EID_DATA) - if (entitlements is not None and - entitlements.isValid() and - entitlements.numValues() > 0): - for j, identity in enumerate(g_identities): - if identity.hasEntitlements(service, entitlements): - print("User: %s is entitled to get data for: %s" % \ - (j + 1, ticker)) - else: - print("User: %s is NOT entitled to get data for: %s " \ - "- Failed eids:" % (j + 1, ticker)) - self.printFailedEntitlements( - identity.getFailedEntitlements(service, - entitlements)[1]) - else: - for token in g_tokens: - print("User: %s is entitled to get data for: %s" % \ - (token, ticker)) - # Now Distribute message to the user. - - def processResponseEvent(self, event): - for msg in event: - if msg.hasElement("RESPONSE_ERROR"): - print(msg) - continue - self.distributeMessage(msg) - - def processEvent(self, event, session): - if (event.eventType() == blpapi.Event.SESSION_STATUS or - event.eventType() == blpapi.Event.SERVICE_STATUS or - event.eventType() == blpapi.Event.REQUEST_STATUS or - event.eventType() == blpapi.Event.AUTHORIZATION_STATUS): - printEvent(event) - elif (event.eventType() == blpapi.Event.RESPONSE or - event.eventType() == blpapi.Event.PARTIAL_RESPONSE): - try: - self.processResponseEvent(event) - except blpapi.Exception as e: - print("Library Exception !!! %s" % e.description()) - return True - - -def parseCmdLine(): - # Parse command-line parameters - parser = OptionParser( - description="Entitlements verification token example") - parser.add_option("-s", - dest="securities", - help="security (default: IBM US Equity)", - metavar="security", - action="append", - default=[]) - parser.add_option("-t", - "--token", - dest="tokens", - help="token value returned in generateToken response", - metavar="token", - action="append", - default=[]) - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - if not options.securities: - options.securities = ["MSFT US Equity"] - - return options - - -def authorizeUsers(): - authService = g_session.getService(APIAUTH_SVC) - is_any_user_authorized = False - - # Authorize each of the users - for index, token in enumerate(g_tokens): - identity = g_session.createIdentity() - g_identities.append(identity) - authRequest = authService.createAuthorizationRequest() - authRequest.set("token", token) - correlator = blpapi.CorrelationId(token) - eventQueue = blpapi.EventQueue() - g_session.sendAuthorizationRequest(authRequest, - identity, - correlator, - eventQueue) - event = eventQueue.nextEvent() - if (event.eventType() == blpapi.Event.RESPONSE or - event.eventType() == blpapi.Event.REQUEST_STATUS): - for msg in event: - if msg.messageType() == AUTHORIZATION_SUCCESS: - print("User %s authorization success" % (index + 1)) - is_any_user_authorized = True - else: - print("User %s authorization failed" % (index + 1)) - printEvent(event) - return is_any_user_authorized - - -def sendRefDataRequest(): - refDataService = g_session.getService(REFDATA_SVC) - request = refDataService.createRequest(REFRENCEDATA_REQUEST) - - # Add securities to the request - securities = request.getElement("securities") - for security in g_securities: - securities.appendValue(security) - - # Add fields to the request - fields = request.getElement("fields") - fields.appendValue("PX_LAST") - fields.appendValue("DS002") - - request.set("returnEids", True) - - # Send the request using the server's credentials - print("Sending RefDataRequest using server credentials...") - g_session.sendRequest(request) - - -def main(): - global g_session, g_securities, g_tokens - options = parseCmdLine() - - # Create SessionOptions object and populate it with data - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - g_securities = options.securities - if not options.tokens: - print("No tokens were specified") - return - - g_tokens = options.tokens - print(g_tokens) - - # Create Session object and connect to Bloomberg services - print("Connecting to %s:%s" % (options.host, options.port)) - eventHandler = SessionEventHandler() - g_session = blpapi.Session(sessionOptions, eventHandler.processEvent) - if not g_session.start(): - print("Failed to start session.") - return - - # Open authorization service - if not g_session.openService("//blp/apiauth"): - print("Failed to open //blp/apiauth") - return - - # Open reference data service - if not g_session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - # Authorize all the users that are interested in receiving data - if authorizeUsers(): - # Make the various requests that we need to make - sendRefDataRequest() - - try: - # Wait for enter key to exit application - print("Press ENTER to quit") - input() - finally: - # Stop the session - g_session.stop() - -if __name__ == "__main__": - print("EntitlementsVerificationTokenExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/GenerateTokenExample.py b/examples/GenerateTokenExample.py deleted file mode 100644 index 2b82cc0..0000000 --- a/examples/GenerateTokenExample.py +++ /dev/null @@ -1,207 +0,0 @@ -# GenerateTokenExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser -import traceback - -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -AUTHORIZATION_FAILURE = blpapi.Name("AuthorizationFailure") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") - - -g_session = None -g_identity = None -g_securities = None -g_fields = None - - -def parseCmdLine(): - # Parse command-line parameters - parser = OptionParser(description="Generate a token for authorization") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="securities", - help="security (default: IBM US Equity)", - metavar="security", - action="append", - default=[]) - parser.add_option("-f", - dest="fields", - help="field to subscribe to (default: PX_LAST)", - metavar="field", - action="append", - default=[]) - parser.add_option("-d", - dest="dirSvcProperty", - help="dirSvcProperty", - metavar="dirSvcProperty") - - (options, args) = parser.parse_args() - - if not options.securities: - options.securities = ["IBM US Equity"] - - if not options.fields: - options.fields = ["PX_LAST"] - - return options - - -def sendRequest(): - refDataService = g_session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - - # Add securities to the request - securities = request.getElement("securities") - for security in g_securities: - securities.appendValue(security) - - # Add fields to the request - fields = request.getElement("fields") - for field in g_fields: - fields.appendValue(field) - - print("Sending request: %s" % request) - g_session.sendRequest(request, g_identity) - - -def processTokenStatus(event): - global g_identity - print("processTokenEvents") - - # Handle response to token generation request - for msg in event: - if msg.messageType() == TOKEN_SUCCESS: - print(msg) - - # Authentication phase has passed; send authorization request - authService = g_session.getService("//blp/apiauth") - authRequest = authService.createAuthorizationRequest() - authRequest.set("token", - msg.getElementAsString("token")) - - g_identity = g_session.createIdentity() - g_session.sendAuthorizationRequest( - authRequest, - g_identity, - blpapi.CorrelationId(1)) - elif msg.messageType() == TOKEN_FAILURE: - # Token generation failure - print(msg) - return False - return True - - -def processEvent(event): - print("processEvent") - - # Handle response to authorization request; handle reference data - for msg in event: - if msg.messageType() == AUTHORIZATION_SUCCESS: - # Authorization phase has passed; request data - print("Authorization SUCCESS") - sendRequest() - elif msg.messageType() == AUTHORIZATION_FAILURE: - # Authorization failure - print("Authorization FAILED") - print(msg) - return False - else: - # Handle reference data. RESPONSE event indicates end-of-data - print(msg) - if event.eventType() == blpapi.Event.RESPONSE: - print("Got Final Response") - return False - return True - - -def main(): - global g_session, g_securities, g_fields - options = parseCmdLine() - - # Create SessionOptions object and populate it with data - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - authOptions = "AuthenticationType=OS_LOGON" - if options.dirSvcProperty: - authOptions = "AuthenticationType=DIRECTORY_SERVICE;" + \ - "DirSvcPropertyName=" + options.dirSvcProperty - print("authOptions = %s" % authOptions) - sessionOptions.setAuthenticationOptions(authOptions) - - g_securities = options.securities - g_fields = options.fields - - # Create Session object and connect to Bloomberg services - print("Connecting to %s:%s" % (options.host, options.port)) - g_session = blpapi.Session(sessionOptions) - if not g_session.start(): - print("Failed to start session.") - return - - # Open reference data service - if not g_session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - # Open authorization service - if not g_session.openService("//blp/apiauth"): - print("Failed to open //blp/apiauth") - return - - # Submit a token generation request - tokenReqId = blpapi.CorrelationId(99) - g_session.generateToken(tokenReqId) - - while True: - event = g_session.nextEvent() - if event.eventType() == blpapi.Event.TOKEN_STATUS: - if not processTokenStatus(event): - break - else: - if not processEvent(event): - break - - -if __name__ == "__main__": - print("GenerateTokenExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/GenerateTokenSubscriptionExample.py b/examples/GenerateTokenSubscriptionExample.py deleted file mode 100644 index 2c8ba4e..0000000 --- a/examples/GenerateTokenSubscriptionExample.py +++ /dev/null @@ -1,208 +0,0 @@ -# GenerateTokenSubscriptionExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser -import traceback - -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -AUTHORIZATION_FAILURE = blpapi.Name("AuthorizationFailure") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") - - -g_session = None -g_identity = None -g_securities = None -g_fields = None -g_options = None - - -def parseCmdLine(): - parser = OptionParser(description="Generate a token for authorization") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="securities", - help="security (default: IBM US Equity)", - metavar="security", - action="append", - default=[]) - parser.add_option("-f", - dest="fields", - help="field to subscribe to (default: LAST_PRICE)", - metavar="field", - action="append", - default=[]) - parser.add_option("-o", - dest="options", - help="subscribtion options", - metavar="options", - action="append", - default=[]) - parser.add_option("-d", - dest="dirSvcProperty", - help="dirSvcProperty", - metavar="dirSvcProperty") - - (options, args) = parser.parse_args() - - if not options.securities: - options.securities = ["IBM US Equity"] - - if not options.fields: - options.fields = ["LAST_PRICE"] - - return options - - -def subscribe(): - # Create a SubscriptionList and populate it with securities, fields etc - subscriptions = blpapi.SubscriptionList() - - for i, security in enumerate(g_securities): - subscriptions.add(security, - g_fields, - g_options, - blpapi.CorrelationId(i)) - - print("Subscribing...") - g_session.subscribe(subscriptions, g_identity) - - -def processTokenStatus(event): - global g_identity - print("processTokenEvents") - - for msg in event: - if msg.messageType() == TOKEN_SUCCESS: - print(msg) - - # Authentication phase has passed; send authorization request - authService = g_session.getService("//blp/apiauth") - authRequest = authService.createAuthorizationRequest() - authRequest.set("token", msg.getElementAsString("token")) - g_identity = g_session.createIdentity() - g_session.sendAuthorizationRequest( - authRequest, - g_identity, - blpapi.CorrelationId(1)) - elif msg.messageType() == TOKEN_FAILURE: - # Token generation failure - print(msg) - return False - return True - - -def processEvent(event): - print("processEvent") - - for msg in event: - if msg.messageType() == AUTHORIZATION_SUCCESS: - # Authorization phase has passed; subscribe to market data - print("Authorization SUCCESS") - subscribe() - elif msg.messageType() == AUTHORIZATION_FAILURE: - # Authorization failure - print("Authorization FAILED") - print(msg) - return False - else: - print(msg) - return True - - -def main(): - global g_session, g_securities, g_fields - - print("GenerateTokenSubscriptionExample") - options = parseCmdLine() - - # Create SessionOptions object and populate it with data - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - authOptions = "AuthenticationType=OS_LOGON" - if options.dirSvcProperty: - authOptions = "AuthenticationType=DIRECTORY_SERVICE;" + \ - "DirSvcPropertyName=" + options.dirSvcProperty - print("authOptions = %s" % authOptions) - sessionOptions.setAuthenticationOptions(authOptions) - - g_securities = options.securities - g_fields = options.fields - - print("Connecting to %s:%s" % (options.host, options.port)) - g_session = blpapi.Session(sessionOptions) - if not g_session.start(): - print("Failed to start session.") - return - - # Open market data service - if not g_session.openService("//blp/mktdata"): - print("Failed to open //blp/mktdata") - return - - # Open authorization service - if not g_session.openService("//blp/apiauth"): - print("Failed to open //blp/apiauth") - return - - # Submit a token generation request - tokenReqId = blpapi.CorrelationId(99) - g_session.generateToken(tokenReqId) - - # Handle and respond to incoming events - while True: - # nextEvent() method below is called with a timeout to let - # the program catch Ctrl-C between arrivals of new events - event = g_session.nextEvent(1000) - if event.eventType() != blpapi.Event.TIMEOUT: - if event.eventType() == blpapi.Event.TOKEN_STATUS: - # Handle response to token generation request - if not processTokenStatus(event): - break - else: - # Handle all other events - if not processEvent(event): - break - - -if __name__ == "__main__": - print("GenerateTokenSubscriptionExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/IntradayBarExample.py b/examples/IntradayBarExample.py deleted file mode 100644 index e9e8895..0000000 --- a/examples/IntradayBarExample.py +++ /dev/null @@ -1,253 +0,0 @@ -# IntradayBarExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import copy -import datetime -from optparse import OptionParser, Option, OptionValueError - - -BAR_DATA = blpapi.Name("barData") -BAR_TICK_DATA = blpapi.Name("barTickData") -OPEN = blpapi.Name("open") -HIGH = blpapi.Name("high") -LOW = blpapi.Name("low") -CLOSE = blpapi.Name("close") -VOLUME = blpapi.Name("volume") -NUM_EVENTS = blpapi.Name("numEvents") -TIME = blpapi.Name("time") -RESPONSE_ERROR = blpapi.Name("responseError") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") -CATEGORY = blpapi.Name("category") -MESSAGE = blpapi.Name("message") - - -def checkDateTime(option, opt, value): - try: - return datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S") - except ValueError as ex: - raise OptionValueError( - "option {0}: invalid datetime value: {1} ({2})".format( - opt, value, ex)) - - -class ExampleOption(Option): - TYPES = Option.TYPES + ("datetime",) - TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER) - TYPE_CHECKER["datetime"] = checkDateTime - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve intraday bars.", - epilog="Notes: " + - "1) All times are in GMT. " + - "2) Only one security can be specified. " + - "3) Only one event can be specified.", - option_class=ExampleOption) - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="security", - help="security (default: %default)", - metavar="security", - default="IBM US Equity") - parser.add_option("-e", - dest="event", - help="event (default: %default)", - metavar="event", - default="TRADE") - parser.add_option("-b", - dest="barInterval", - type="int", - help="bar interval (default: %default)", - metavar="barInterval", - default=60) - parser.add_option("--sd", - dest="startDateTime", - type="datetime", - help="start date/time (default: %default)", - metavar="startDateTime", - default=datetime.datetime(2008, 8, 11, 15, 30, 0)) - parser.add_option("--ed", - dest="endDateTime", - type="datetime", - help="end date/time (default: %default)", - metavar="endDateTime", - default=datetime.datetime(2008, 8, 11, 15, 35, 0)) - parser.add_option("-g", - dest="gapFillInitialBar", - help="gapFillInitialBar", - action="store_true", - default=False) - - (options, args) = parser.parse_args() - - return options - - -def printErrorInfo(leadingStr, errorInfo): - print("%s%s (%s)" % (leadingStr, errorInfo.getElementAsString(CATEGORY), - errorInfo.getElementAsString(MESSAGE))) - - -def processMessage(msg): - data = msg.getElement(BAR_DATA).getElement(BAR_TICK_DATA) - print("Datetime\t\tOpen\t\tHigh\t\tLow\t\tClose\t\tNumEvents\tVolume") - - for bar in data.values(): - time = bar.getElementAsDatetime(TIME) - open = bar.getElementAsFloat(OPEN) - high = bar.getElementAsFloat(HIGH) - low = bar.getElementAsFloat(LOW) - close = bar.getElementAsFloat(CLOSE) - numEvents = bar.getElementAsInteger(NUM_EVENTS) - volume = bar.getElementAsInteger(VOLUME) - - print("%s\t\t%.3f\t\t%.3f\t\t%.3f\t\t%.3f\t\t%d\t\t%d" % \ - (time.strftime("%m/%d/%y %H:%M"), open, high, low, close, - numEvents, volume)) - - -def processResponseEvent(event): - for msg in event: - print(msg) - if msg.hasElement(RESPONSE_ERROR): - printErrorInfo("REQUEST FAILED: ", msg.getElement(RESPONSE_ERROR)) - continue - processMessage(msg) - - -def sendIntradayBarRequest(session, options): - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("IntradayBarRequest") - - # only one security/eventType per request - request.set("security", options.security) - request.set("eventType", options.event) - request.set("interval", options.barInterval) - - # All times are in GMT - if not options.startDateTime or not options.endDateTime: - tradedOn = getPreviousTradingDate() - if tradedOn: - startTime = datetime.datetime.combine(tradedOn, - datetime.time(15, 30)) - request.set("startDateTime", startTime) - endTime = datetime.datetime.combine(tradedOn, - datetime.time(15, 35)) - request.set("endDateTime", endTime) - else: - if options.startDateTime and options.endDateTime: - request.set("startDateTime", options.startDateTime) - request.set("endDateTime", options.endDateTime) - - if options.gapFillInitialBar: - request.set("gapFillInitialBar", True) - - print("Sending Request:", request) - session.sendRequest(request) - - -def eventLoop(session): - done = False - while not done: - # nextEvent() method below is called with a timeout to let - # the program catch Ctrl-C between arrivals of new events - event = session.nextEvent(500) - if event.eventType() == blpapi.Event.PARTIAL_RESPONSE: - print("Processing Partial Response") - processResponseEvent(event) - elif event.eventType() == blpapi.Event.RESPONSE: - print("Processing Response") - processResponseEvent(event) - done = True - else: - for msg in event: - if event.eventType() == blpapi.Event.SESSION_STATUS: - if msg.messageType() == SESSION_TERMINATED: - done = True - - -def getPreviousTradingDate(): - tradedOn = datetime.date.today() - - while True: - try: - tradedOn -= datetime.timedelta(days=1) - except OverflowError: - return None - - if tradedOn.weekday() not in [5, 6]: - return tradedOn - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%s" % (options.host, options.port)) - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - try: - # Open service to get historical data from - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - sendIntradayBarRequest(session, options) - - # wait for events from session. - eventLoop(session) - - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("IntradayBarExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/IntradayTickExample.py b/examples/IntradayTickExample.py deleted file mode 100644 index 78f0239..0000000 --- a/examples/IntradayTickExample.py +++ /dev/null @@ -1,251 +0,0 @@ -# IntradayTickExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import copy -import datetime -from optparse import OptionParser, Option, OptionValueError - - -TICK_DATA = blpapi.Name("tickData") -COND_CODE = blpapi.Name("conditionCodes") -TICK_SIZE = blpapi.Name("size") -TIME = blpapi.Name("time") -TYPE = blpapi.Name("type") -VALUE = blpapi.Name("value") -RESPONSE_ERROR = blpapi.Name("responseError") -CATEGORY = blpapi.Name("category") -MESSAGE = blpapi.Name("message") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") - - -def checkDateTime(option, opt, value): - try: - return datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S") - except ValueError as ex: - raise OptionValueError( - "option {0}: invalid datetime value: {1} ({2})".format( - opt, value, ex)) - - -class ExampleOption(Option): - TYPES = Option.TYPES + ("datetime",) - TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER) - TYPE_CHECKER["datetime"] = checkDateTime - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve intraday rawticks.", - epilog="Notes: " + - "1) All times are in GMT. " + - "2) Only one security can be specified.", - option_class=ExampleOption) - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="security", - help="security (default: %default)", - metavar="security", - default="IBM US Equity") - parser.add_option("-e", - dest="events", - help="events (default: TRADE)", - metavar="event", - action="append", - default=[]) - parser.add_option("--sd", - dest="startDateTime", - type="datetime", - help="start date/time (default: %default)", - metavar="startDateTime", - default=datetime.datetime(2008, 8, 11, 15, 30, 0)) - parser.add_option("--ed", - dest="endDateTime", - type="datetime", - help="end date/time (default: %default)", - metavar="endDateTime", - default=datetime.datetime(2008, 8, 11, 15, 35, 0)) - parser.add_option("--cc", - dest="conditionCodes", - help="include condition codes", - action="store_true", - default=False) - - (options, args) = parser.parse_args() - - if not options.events: - options.events = ["TRADE"] - - return options - - -def printErrorInfo(leadingStr, errorInfo): - print("%s%s (%s)" % (leadingStr, errorInfo.getElementAsString(CATEGORY), - errorInfo.getElementAsString(MESSAGE))) - - -def processMessage(msg): - data = msg.getElement(TICK_DATA).getElement(TICK_DATA) - print("TIME\t\t\t\tTYPE\tVALUE\t\tSIZE\tCC") - print("----\t\t\t\t----\t-----\t\t----\t--") - - for item in data.values(): - time = item.getElementAsDatetime(TIME) - timeString = item.getElementAsString(TIME) - type = item.getElementAsString(TYPE) - value = item.getElementAsFloat(VALUE) - size = item.getElementAsInteger(TICK_SIZE) - if item.hasElement(COND_CODE): - cc = item.getElementAsString(COND_CODE) - else: - cc = "" - - print("%s\t%s\t%.3f\t\t%d\t%s" % (timeString, type, value, size, cc)) - - -def processResponseEvent(event): - for msg in event: - print(msg) - if msg.hasElement(RESPONSE_ERROR): - printErrorInfo("REQUEST FAILED: ", msg.getElement(RESPONSE_ERROR)) - continue - processMessage(msg) - - -def sendIntradayTickRequest(session, options): - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("IntradayTickRequest") - - # only one security/eventType per request - request.set("security", options.security) - - # Add fields to request - eventTypes = request.getElement("eventTypes") - for event in options.events: - eventTypes.appendValue(event) - - # All times are in GMT - if not options.startDateTime or not options.endDateTime: - tradedOn = getPreviousTradingDate() - if tradedOn: - startTime = datetime.datetime.combine(tradedOn, - datetime.time(15, 30)) - request.set("startDateTime", startTime) - endTime = datetime.datetime.combine(tradedOn, - datetime.time(15, 35)) - request.set("endDateTime", endTime) - else: - if options.startDateTime and options.endDateTime: - request.set("startDateTime", options.startDateTime) - request.set("endDateTime", options.endDateTime) - - if options.conditionCodes: - request.set("includeConditionCodes", True) - - print("Sending Request:", request) - session.sendRequest(request) - - -def eventLoop(session): - done = False - while not done: - # nextEvent() method below is called with a timeout to let - # the program catch Ctrl-C between arrivals of new events - event = session.nextEvent(500) - if event.eventType() == blpapi.Event.PARTIAL_RESPONSE: - print("Processing Partial Response") - processResponseEvent(event) - elif event.eventType() == blpapi.Event.RESPONSE: - print("Processing Response") - processResponseEvent(event) - done = True - else: - for msg in event: - if event.eventType() == blpapi.Event.SESSION_STATUS: - if msg.messageType() == SESSION_TERMINATED: - done = True - - -def getPreviousTradingDate(): - tradedOn = datetime.date.today() - - while True: - try: - tradedOn -= datetime.timedelta(days=1) - except OverflowError: - return None - - if tradedOn.weekday() not in [5, 6]: - return tradedOn - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%s" % (options.host, options.port)) - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - try: - # Open service to get historical data from - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - sendIntradayTickRequest(session, options) - - # wait for events from session. - eventLoop(session) - - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("IntradayTickExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/LocalMktdataSubscriptionExample.py b/examples/LocalMktdataSubscriptionExample.py deleted file mode 100644 index 61052ea..0000000 --- a/examples/LocalMktdataSubscriptionExample.py +++ /dev/null @@ -1,253 +0,0 @@ -# LocalMktdataSubscriptionExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import datetime -import time -import traceback -import weakref -from optparse import OptionParser, OptionValueError -from blpapi import Event as EventType - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -TOKEN = blpapi.Name("token") - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve realtime data.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//viper/mktdata") - parser.add_option("-t", - dest="topics", - help="topic name (default: /ticker/IBM Equity)", - metavar="topic", - action="append", - default=[]) - parser.add_option("-f", - dest="fields", - help="field to subscribe to (default: empty)", - metavar="field", - action="append", - default=[]) - parser.add_option("-o", - dest="options", - help="subscription options (default: empty)", - metavar="option", - action="append", - default=[]) - parser.add_option("--me", - dest="maxEvents", - type="int", - help="stop after this many events (default: %default)", - metavar="maxEvents", - default=1000000) - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - if not options.topics: - options.topics = ["/ticker/IBM Equity"] - - return options - - -def authorize(authService, identity, session, cid): - tokenEventQueue = blpapi.EventQueue() - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - - if not token: - print("Failed to get token") - return False - - # Create and fill the authorization request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorization request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = 10 - while True: - event = session.nextEvent(WAIT_TIME_SECONDS * 1000) - if event.eventType() == blpapi.Event.RESPONSE or \ - event.eventType() == blpapi.Event.REQUEST_STATUS or \ - event.eventType() == blpapi.Event.PARTIAL_RESPONSE: - for msg in event: - print(msg) - if msg.messageType() == AUTHORIZATION_SUCCESS: - return True - print("Authorization failed") - return False - - endTime = datetime.datetime.today() - if endTime - startTime > datetime.timedelta(seconds=WAIT_TIME_SECONDS): - return False - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - - # NOTE: If running without a backup server, make many attempts to - # connect/reconnect to give that host a chance to come back up (the - # larger the number, the longer it will take for SessionStartupFailure - # to come on startup, or SessionTerminated due to inability to fail - # over). We don't have to do that in a redundant configuration - it's - # expected at least one server is up and reachable at any given time, - # so only try to connect to each server once. - sessionOptions.setNumStartAttempts(1 if len(options.hosts) > 1 else 1000) - - print("Connecting to port %d on %s" % ( - options.port, ", ".join(options.hosts))) - - session = blpapi.Session(sessionOptions) - - if not session.start(): - print("Failed to start session.") - return - - subscriptionIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, subscriptionIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - subscriptions = blpapi.SubscriptionList() - for t in options.topics: - topic = options.service + t - subscriptions.add(topic, - options.fields, - options.options, - blpapi.CorrelationId(topic)) - - session.subscribe(subscriptions, subscriptionIdentity) - - try: - eventCount = 0 - while True: - # Specify timeout to give a chance for Ctrl-C - event = session.nextEvent(1000) - for msg in event: - if event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS or \ - event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - print("%s - %s" % (msg.correlationIds()[0].value(), msg)) - else: - print(msg) - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - eventCount += 1 - if eventCount >= options.maxEvents: - break - finally: - session.stop() - - -if __name__ == "__main__": - print("LocalMktdataSubscriptionExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/LocalPageSubscriptionExample.py b/examples/LocalPageSubscriptionExample.py deleted file mode 100644 index 2d9747f..0000000 --- a/examples/LocalPageSubscriptionExample.py +++ /dev/null @@ -1,229 +0,0 @@ -# LocalPageSubscriptionExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import datetime -import time -import traceback -import weakref -from optparse import OptionParser, OptionValueError -from blpapi import Event as EventType - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -TOKEN = blpapi.Name("token") - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Page monitor.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//viper/page") - parser.add_option("--me", - dest="maxEvents", - type="int", - help="number of events to retrieve (default: %default)", - metavar="maxEvents", - default=1000000) - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - return options - - -def authorize(authService, identity, session, cid): - tokenEventQueue = blpapi.EventQueue() - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = 10 - while True: - event = session.nextEvent(WAIT_TIME_SECONDS * 1000) - if event.eventType() == blpapi.Event.RESPONSE or \ - event.eventType() == blpapi.Event.REQUEST_STATUS or \ - event.eventType() == blpapi.Event.PARTIAL_RESPONSE: - for msg in event: - print(msg) - if msg.messageType() == AUTHORIZATION_SUCCESS: - return True - print("Authorization failed") - return False - - endTime = datetime.datetime.today() - if endTime - startTime > datetime.timedelta(seconds=WAIT_TIME_SECONDS): - return False - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - - # NOTE: If running without a backup server, make many attempts to - # connect/reconnect to give that host a chance to come back up (the - # larger the number, the longer it will take for SessionStartupFailure - # to come on startup, or SessionTerminated due to inability to fail - # over). We don't have to do that in a redundant configuration - it's - # expected at least one server is up and reachable at any given time, - # so only try to connect to each server once. - sessionOptions.setNumStartAttempts(1 if len(options.hosts) > 1 else 1000) - - print("Connecting to port %d on %s" % ( - options.port, ", ".join(options.hosts))) - - session = blpapi.Session(sessionOptions) - - if not session.start(): - print("Failed to start session.") - return - - subscriptionIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, subscriptionIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - topic = options.service + "/1245/4/5" - topic2 = options.service + "/330/1/1" - subscriptions = blpapi.SubscriptionList() - subscriptions.add(topic, correlationId=blpapi.CorrelationId(topic)) - subscriptions.add(topic2, correlationId=blpapi.CorrelationId(topic2)) - - session.subscribe(subscriptions, subscriptionIdentity) - - try: - eventCount = 0 - while True: - # Specify timeout to give a chance for Ctrl-C - event = session.nextEvent(1000) - for msg in event: - if event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS or \ - event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - print("%s - %s" % (msg.correlationIds()[0].value(), msg)) - else: - print(msg) - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - eventCount += 1 - if eventCount >= options.maxEvents: - break - finally: - session.stop() - - -if __name__ == "__main__": - print("LocalPageSubscriptionExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/MktdataBroadcastPublisherExample.py b/examples/MktdataBroadcastPublisherExample.py deleted file mode 100644 index 190bc1a..0000000 --- a/examples/MktdataBroadcastPublisherExample.py +++ /dev/null @@ -1,331 +0,0 @@ -# MktdataBroadcastPublisherExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import time -from optparse import OptionParser, OptionValueError -import datetime -import threading - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -TOKEN = blpapi.Name("token") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") - - -g_running = True -g_mutex = threading.Lock() - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyStream(object): - def __init__(self, id=""): - self.id = id - - -class MyEventHandler(object): - def processEvent(self, event, session): - global g_running - - for msg in event: - print(msg) - if event.eventType() == blpapi.Event.SESSION_STATUS: - if msg.messageType() == SESSION_TERMINATED: - g_running = False - continue - - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Publish market data.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//viper/mktdata") - parser.add_option("-f", - dest="fields", - help="fields (default: LAST_PRICE)", - metavar="field", - action="append", - default=[]) - parser.add_option("-m", - dest="messageType", - help="type of published event (default: %default)", - metavar="messageType", - default="MarketDataEvents") - parser.add_option("-t", - dest="topic", - help="topic (default: %default)", - metavar="topic", - default="IBM Equity") - parser.add_option("-g", - dest="groupId", - help="publisher groupId (defaults to unique value)") - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - if not options.fields: - options.fields = ["BID", "ASK"] - - return options - - -def authorize(authService, identity, session, cid): - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = datetime.timedelta(seconds=10) - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == \ - g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > WAIT_TIME_SECONDS: - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - - # NOTE: If running without a backup server, make many attempts to - # connect/reconnect to give that host a chance to come back up (the - # larger the number, the longer it will take for SessionStartupFailure - # to come on startup, or SessionTerminated due to inability to fail - # over). We don't have to do that in a redundant configuration - it's - # expected at least one server is up and reachable at any given time, - # so only try to connect to each server once. - sessionOptions.setNumStartAttempts(1 if len(options.hosts) > 1 else 1000) - - myEventHandler = MyEventHandler() - - # Create a Session - session = blpapi.ProviderSession(sessionOptions, - myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - if options.groupId is not None: - # NOTE: will perform explicit service registration here, instead - # of letting createTopics do it, as the latter approach doesn't - # allow for custom ServiceRegistrationOptions. - serviceOptions = blpapi.ServiceRegistrationOptions() - serviceOptions.setGroupId(options.groupId) - if not session.registerService(options.service, - identity, - serviceOptions): - print("Failed to register %s" % options.service) - return - - topicList = blpapi.TopicList() - topicList.add(options.service + "/ticker/" + options.topic, - blpapi.CorrelationId(MyStream(options.topic))) - - # Create topics - session.createTopics(topicList, - blpapi.ProviderSession.AUTO_REGISTER_SERVICES, - providerIdentity) - # createTopics() is synchronous, topicList will be updated - # with the results of topic creation (resolution will happen - # under the covers) - - streams = [] - for i in range(topicList.size()): - stream = topicList.correlationIdAt(i).value() - status = topicList.statusAt(i) - topicString = topicList.topicStringAt(i) - - if (status == blpapi.TopicList.CREATED): - print("Start publishing on topic: %s" % topicString) - stream.topic = session.getTopic(topicList.messageAt(i)) - streams.append(stream) - else: - print("Stream '%s': topic not created, status = %d" % ( - stream.id, status)) - - service = session.getService(options.service) - PUBLISH_MESSAGE_TYPE = blpapi.Name(options.messageType) - - try: - # Now we will start publishing - tickCount = 1 - while streams and g_running: - event = service.createPublishEvent() - eventFormatter = blpapi.EventFormatter(event) - - for stream in streams: - topic = stream.topic - if not topic.isActive(): - print("[WARN] Publishing on an inactive topic.") - eventFormatter.appendMessage(PUBLISH_MESSAGE_TYPE, topic) - - for i, f in enumerate(options.fields): - eventFormatter.setElement(f, tickCount + i + 1.0) - - tickCount += 1 - - for msg in event: - print(msg) - - session.publish(event) - time.sleep(10) - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("MktdataBroadcastPublisherExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/MktdataPublisher.py b/examples/MktdataPublisher.py deleted file mode 100644 index 50398db..0000000 --- a/examples/MktdataPublisher.py +++ /dev/null @@ -1,640 +0,0 @@ -# MktdataPublisher.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import time -from optparse import OptionParser, OptionValueError -import datetime -import threading - -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -PERMISSION_REQUEST = blpapi.Name("PermissionRequest") -RESOLUTION_SUCCESS = blpapi.Name("ResolutionSuccess") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") -TOKEN = blpapi.Name("token") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -TOPICS = blpapi.Name("topics") -TOPIC_CREATED = blpapi.Name("TopicCreated") -TOPIC_SUBSCRIBED = blpapi.Name("TopicSubscribed") -TOPIC_UNSUBSCRIBED = blpapi.Name("TopicUnsubscribed") -TOPIC_RECAP = blpapi.Name("TopicRecap") - - -g_running = True - - -class MyStream(object): - def __init__(self, id="", fields=None): - self.id = id - self.fields = fields if fields else [] - self.lastValue = 0 - self.topic = blpapi.Topic() - self.isSubscribed = False - - def fillData(self, eventFormatter, elementDef): - for i, f in enumerate(self.fields): - if not elementDef.typeDefinition().hasElementDefinition(f): - print("Invalid field '%s'" % f) - continue - - fieldDef = elementDef.typeDefinition().getElementDefinition(f) - fieldType = fieldDef.typeDefinition().datatype() - value = None - - if fieldType == blpapi.DataType.BOOL: - value = bool((self.lastValue + i) % 2 == 0) - elif fieldType == blpapi.DataType.CHAR: - value = chr((self.lastValue + i) % 100 + 32) - elif fieldType == blpapi.DataType.INT32 or \ - fieldType == blpapi.DataType.INT64: - value = self.lastValue + i - elif fieldType == blpapi.DataType.FLOAT32 or \ - fieldType == blpapi.DataType.FLOAT64: - value = (self.lastValue + i) * 1.1 - elif fieldType == blpapi.DataType.STRING: - value = "S%d" % (self.lastValue + i) - elif fieldType == blpapi.DataType.DATE or \ - fieldType == blpapi.DataType.TIME or \ - fieldType == blpapi.DataType.DATETIME: - value = datetime.datetime.today() - value.replace(day=(self.lastValue / 100) % 28 + 1) - value.replace(microsecond=i * 1000) - - eventFormatter.setElement(f, value) - - def fillDataNull(self, eventFormatter, elementDef): - for i, f in enumerate(self.fields): - if not elementDef.typeDefinition().hasElementDefinition(f): - print("Invalid field '%s'" % f) - continue - - fieldDef = elementDef.typeDefinition().getElementDefinition(f) - if fieldDef.typeDefinition().isSimpleType(): - # Publishing NULL value - eventFormatter.setElementNull(f) - - def __next__(self): - self.lastValue += 1 - - def isAvailable(self): - return self.topic.isValid() and self.isSubscribed - - -g_streams = dict() -g_availableTopicCount = 0 -g_mutex = threading.Lock() -# Indicates if g_availableTopicCount is non-zero -g_condition = threading.Condition(g_mutex) - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyEventHandler(object): - def __init__(self, - serviceName, - messageType, - fields, - eids, - resolveSubServiceCode): - self.serviceName = serviceName - self.messageType = messageType - self.fields = fields - self.eids = eids - self.resolveSubServiceCode = resolveSubServiceCode - - def processEvent(self, event, session): - global g_availableTopicCount, g_running - - if event.eventType() == blpapi.Event.SESSION_STATUS: - for msg in event: - print(msg) - if msg.messageType() == SESSION_TERMINATED: - g_running = False - - elif event.eventType() == blpapi.Event.TOPIC_STATUS: - topicList = blpapi.TopicList() - - for msg in event: - print(msg) - if msg.messageType() == TOPIC_SUBSCRIBED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - # TopicList knows how to add an entry based on a - # TOPIC_SUBSCRIBED message. - topicList.add(msg) - g_streams[topicStr] = MyStream(topicStr, - self.fields) - stream = g_streams[topicStr] - stream.isSubscribed = True - if stream.isAvailable(): - g_availableTopicCount += 1 - g_condition.notifyAll() - - elif msg.messageType() == TOPIC_UNSUBSCRIBED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - # We should never be coming here. - # TOPIC_UNSUBSCRIBED can not come before - # a TOPIC_SUBSCRIBED or TOPIC_CREATED - continue - stream = g_streams[topicStr] - if stream.isAvailable(): - g_availableTopicCount -= 1 - g_condition.notifyAll() - stream.isSubscribed = False - - elif msg.messageType() == TOPIC_CREATED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - g_streams[topicStr] = MyStream(topicStr, - self.fields) - stream = g_streams[topicStr] - try: - stream.topic = session.getTopic(msg) - except blpapi.Exception as e: - print("Exception while processing " \ - "TOPIC_CREATED: %s" % e) - continue - - if stream.isAvailable(): - g_availableTopicCount = g_availableTopicCount + 1 - g_condition.notifyAll() - - elif msg.messageType() == TOPIC_RECAP: - # Here we send a recap in response to a Recap request. - try: - topicStr = msg.getElementAsString("topic") - recapEvent = None - - with g_mutex: - if topicStr not in g_streams: - continue - stream = g_streams[topicStr] - if not stream.isAvailable(): - continue - - topic = session.getTopic(msg) - service = topic.service() - recapCid = msg.correlationIds()[0] - - recapEvent = service.createPublishEvent() - elementDef = \ - service.getEventDefinition(self.messageType) - - eventFormatter = blpapi.EventFormatter(recapEvent) - eventFormatter.appendRecapMessage(topic, recapCid) - - stream.fillData(eventFormatter, elementDef) - - session.publish(recapEvent) - - except blpapi.Exception as e: - print("Exception while processing TOPIC_RECAP: %s" % e) - continue - - if topicList.size() > 0: - # createTopicsAsync will result in RESOLUTION_STATUS, - # TOPIC_CREATED events. - session.createTopicsAsync(topicList) - - elif event.eventType() == blpapi.Event.RESOLUTION_STATUS: - for msg in event: - print(msg) - - elif event.eventType() == blpapi.Event.REQUEST: - service = session.getService(self.serviceName) - for msg in event: - print(msg) - - if msg.messageType() == PERMISSION_REQUEST: - # Similar to createPublishEvent. We assume just one - # service - self.serviceName. A responseEvent can only be - # for single request so we can specify the correlationId - - # which establishes context - when we create the Event. - - response = \ - service.createResponseEvent(msg.correlationIds()[0]) - permission = 1 # ALLOWED: 0, DENIED: 1 - ef = blpapi.EventFormatter(response) - if msg.hasElement("uuid"): - uuid = msg.getElementAsInteger("uuid") - permission = 0 - if msg.hasElement("applicationId"): - applicationId = \ - msg.getElementAsInteger("applicationId") - permission = 0 - - # In appendResponse the string is the name of the - # operation, the correlationId indicates which request we - # are responding to. - ef.appendResponse("PermissionResponse") - ef.pushElement("topicPermissions") - - # For each of the topics in the request, add an entry to - # the response. - topicsElement = msg.getElement(TOPICS).values() - for topic in topicsElement: - ef.appendElement() - ef.setElement("topic", topic) - if self.resolveSubServiceCode: - try: - ef.setElement("subServiceCode", - self.resolveSubServiceCode) - print(("Mapping topic %s to subServiceCode %s" % - (topic, self.resolveSubServiceCode))) - except blpapi.Exception: - print("subServiceCode could not be set." - " Resolving without subServiceCode") - ef.setElement("result", permission) - if permission == 1: # DENIED - ef.pushElement("reason") - ef.setElement("source", "My Publisher Name") - ef.setElement("category", "NOT_AUTHORIZED") - ef.setElement("subcategory", - "Publisher Controlled") - ef.setElement( - "description", - "Permission denied by My Publisher Name") - ef.popElement() - elif self.eids: - ef.pushElement("permissions") - ef.appendElement() - ef.setElement("permissionService", "//blp/blpperm") - ef.pushElement("eids") - for e in self.eids: - ef.appendValue(e) - ef.popElement() - ef.popElement() - ef.popElement() - ef.popElement() - ef.popElement() - - # Service is implicit in the Event. sendResponse has a - # second parameter - partialResponse - that defaults to - # false. - session.sendResponse(response) - - else: - for msg in event: - print(msg) - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - return True - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Publish market data.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//viper/mktdata") - parser.add_option("-f", - dest="fields", - help="field to subscribe to (default: LAST_PRICE)", - metavar="field", - action="append", - default=[]) - parser.add_option("-m", - dest="messageType", - help="type of published event (default: %default)", - metavar="messageType", - default="MarketDataEvents") - parser.add_option("-e", - dest="eids", - help="permission eid for all subscriptions", - metavar="EID", - action="append", - default=[]) - parser.add_option("-g", - dest="groupId", - help="publisher groupId (defaults to unique value)", - metavar="groupId") - parser.add_option("-r", - "--pri", - type="int", - dest="priority", - help="set publisher priority level (default: %default)", - metavar="priority", - default=10) - parser.add_option("-c", - type="int", - dest="clearInterval", - help="number of events after which cache will be " - "cleared (default: 0 i.e cache never cleared)", - metavar="clearInterval", - default=0) - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - parser.add_option("--ssc", - dest="ssc", - help="active sub-service code option: " - ",,", - metavar="ssc", - default="") - parser.add_option("--rssc", - dest="rssc", - help="sub-service code to be used in resolves", - metavar="rssc", - default="") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - if not options.fields: - options.fields = ["LAST_PRICE"] - - return options - - -def activate(options, session): - if options.ssc: - sscBegin, sscEnd, sscPriority = map(int, options.ssc.split(",")) - print(("Activating sub service code range [%s, %s] @ %s" % - (sscBegin, sscEnd, sscPriority))) - session.activateSubServiceCodeRange(options.service, - sscBegin, - sscEnd, - sscPriority) - - -def deactivate(options, session): - if options.ssc: - sscBegin, sscEnd, sscPriority = map(int, options.ssc.split(",")) - print(("DeActivating sub service code range [%s, %s] @ %s" % - (sscBegin, sscEnd, sscPriority))) - session.deactivateSubServiceCodeRange(options.service, - sscBegin, - sscEnd) - - -def authorize(authService, identity, session, cid): - global g_mutex, g_authorizationStatus - - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = datetime.timedelta(seconds=10) - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == \ - g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > WAIT_TIME_SECONDS: - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - - # NOTE: If running without a backup server, make many attempts to - # connect/reconnect to give that host a chance to come back up (the - # larger the number, the longer it will take for SessionStartupFailure - # to come on startup, or SessionTerminated due to inability to fail - # over). We don't have to do that in a redundant configuration - it's - # expected at least one server is up and reachable at any given time, - # so only try to connect to each server once. - sessionOptions.setNumStartAttempts(1 if len(options.hosts) > 1 else 1000) - - print("Connecting to port %d on %s" % ( - options.port, " ".join(options.hosts))) - - PUBLISH_MESSAGE_TYPE = blpapi.Name(options.messageType) - - myEventHandler = MyEventHandler(options.service, - PUBLISH_MESSAGE_TYPE, - options.fields, - options.eids, - options.rssc) - - # Create a Session - session = blpapi.ProviderSession(sessionOptions, - myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - serviceOptions = blpapi.ServiceRegistrationOptions() - if options.groupId is not None: - serviceOptions.setGroupId(options.groupId) - serviceOptions.setServicePriority(options.priority) - - if options.ssc: - sscBegin, sscEnd, sscPriority = map(int, options.ssc.split(",")) - print(("Adding active sub service code range [%s, %s] @ %s" % - (sscBegin, sscEnd, sscPriority))) - try: - serviceOptions.addActiveSubServiceCodeRange(sscBegin, - sscEnd, - sscPriority) - except blpapi.Exception as e: - print(("FAILED to add active sub service codes." - " Exception %s" % e.description())) - - if not session.registerService(options.service, - providerIdentity, - serviceOptions): - print("Failed to register '%s'" % options.service) - return - - service = session.getService(options.service) - elementDef = service.getEventDefinition(PUBLISH_MESSAGE_TYPE) - eventCount = 0 - - try: - numPublished = 0 - while g_running: - event = service.createPublishEvent() - - with g_condition: - while g_availableTopicCount == 0: - # Set timeout to 1 - give a chance for CTRL-C - g_condition.wait(1) - if not g_running: - return - - publishNull = False - if (options.clearInterval > 0 and - eventCount == options.clearInterval): - eventCount = 0 - publishNull = True - eventFormatter = blpapi.EventFormatter(event) - for topicName, stream in g_streams.items(): - if not stream.isAvailable(): - continue - eventFormatter.appendMessage(PUBLISH_MESSAGE_TYPE, - stream.topic) - if publishNull: - stream.fillDataNull(eventFormatter, elementDef) - else: - eventCount += 1 - next(stream) - stream.fillData(eventFormatter, elementDef) - - for msg in event: - print(msg) - - session.publish(event) - time.sleep(1) - numPublished += 1 - if numPublished % 10 == 0: - deactivate(options, session) - time.sleep(30) - activate(options, session) - - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("MktdataPublisher") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/PagePublisherExample.py b/examples/PagePublisherExample.py deleted file mode 100644 index cc01dd5..0000000 --- a/examples/PagePublisherExample.py +++ /dev/null @@ -1,481 +0,0 @@ -# PagePublisherExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import time -from optparse import OptionParser, OptionValueError -import datetime -import threading - -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -RESOLUTION_SUCCESS = blpapi.Name("ResolutionSuccess") -PERMISSION_REQUEST = blpapi.Name("PermissionRequest") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") -TOKEN = blpapi.Name("token") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -TOPICS = blpapi.Name("topics") -TOPIC_CREATED = blpapi.Name("TopicCreated") -TOPIC_RECAP = blpapi.Name("TopicRecap") -TOPIC_SUBSCRIBED = blpapi.Name("TopicSubscribed") -TOPIC_UNSUBSCRIBED = blpapi.Name("TopicUnsubscribed") - - -g_running = True -g_mutex = threading.Lock() - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyStream(object): - def __init__(self, id=""): - self.id = id - self.isInitialPaintSent = False - self.topic = blpapi.Topic() - self.isSubscribed = False - - def isAvailable(self): - return self.topic.isValid() and self.isSubscribed - -g_streams = dict() -g_availableTopicCount = 0 -g_mutex = threading.Lock() -# Indicates if g_availableTopicCount is non-zero -g_condition = threading.Condition(g_mutex) - - -class MyEventHandler(object): - def __init__(self, serviceName): - self.serviceName = serviceName - - def processEvent(self, event, session): - global g_availableTopicCount, g_running - - if event.eventType() == blpapi.Event.SESSION_STATUS: - for msg in event: - print(msg) - if msg.messageType() == SESSION_TERMINATED: - g_running = False - - elif event.eventType() == blpapi.Event.TOPIC_STATUS: - topicList = blpapi.TopicList() - - for msg in event: - print(msg) - if msg.messageType() == TOPIC_SUBSCRIBED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - # TopicList knows how to add an entry based on a - # TOPIC_SUBSCRIBED message. - topicList.add(msg) - g_streams[topicStr] = MyStream(topicStr) - stream = g_streams[topicStr] - stream.isSubscribed = True - if stream.isAvailable(): - g_availableTopicCount += 1 - g_condition.notifyAll() - - elif msg.messageType() == TOPIC_UNSUBSCRIBED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - # We should never be coming here. - # TOPIC_UNSUBSCRIBED can not come before - # a TOPIC_SUBSCRIBED or TOPIC_CREATED - continue - stream = g_streams[topicStr] - if stream.isAvailable(): - g_availableTopicCount -= 1 - g_condition.notifyAll() - stream.isSubscribed = False - - elif msg.messageType() == TOPIC_CREATED: - topicStr = msg.getElementAsString("topic") - with g_mutex: - if topicStr not in g_streams: - g_streams[topicStr] = MyStream(topicStr) - stream = g_streams[topicStr] - try: - stream.topic = session.getTopic(msg) - except blpapi.Exception as e: - print("Exception while processing " \ - "TOPIC_CREATED: %s" % e) - continue - - if stream.isAvailable(): - g_availableTopicCount += 1 - g_condition.notifyAll() - - elif msg.messageType() == TOPIC_RECAP: - # Here we send a recap in response to a Recap request. - try: - topicStr = msg.getElementAsString("topic") - recapEvent = None - - with g_mutex: - if topicStr not in g_streams: - continue - stream = g_streams[topicStr] - if not stream.isAvailable(): - continue - - topic = session.getTopic(msg) - service = topic.service() - recapCid = msg.correlationIds()[0] - - recapEvent = service.createPublishEvent() - evFormatter = blpapi.EventFormatter(recapEvent) - evFormatter.appendRecapMessage(topic, recapCid) - evFormatter.setElement("numRows", 25) - evFormatter.setElement("numCols", 80) - evFormatter.pushElement("rowUpdate") - - for i in range(1, 6): - evFormatter.appendElement() - evFormatter.setElement("rowNum", i) - evFormatter.pushElement("spanUpdate") - evFormatter.appendElement() - evFormatter.setElement("startCol", 1) - evFormatter.setElement("length", 10) - evFormatter.setElement("text", "RECAP") - evFormatter.popElement() - evFormatter.popElement() - evFormatter.popElement() - - evFormatter.popElement() - - session.publish(recapEvent) - - except blpapi.Exception as e: - print("Exception while processing TOPIC_RECAP: %s" % e) - continue - - if topicList.size() > 0: - # createTopicsAsync will result in RESOLUTION_STATUS, - # TOPIC_CREATED events. - session.createTopicsAsync(topicList) - - elif event.eventType() == blpapi.Event.RESOLUTION_STATUS: - for msg in event: - print(msg) - - elif event.eventType() == blpapi.Event.REQUEST: - service = session.getService(self.serviceName) - for msg in event: - print(msg) - - if msg.messageType() == PERMISSION_REQUEST: - # This example always sends a 'PERMISSIONED' response. - # See 'MktdataPublisherExample' on how to parse a - # Permission request and send an appropriate - # 'PermissionResponse'. - - response = \ - service.createResponseEvent(msg.correlationIds()[0]) - permission = 0 # ALLOWED: 0, DENIED: 1 - ef = blpapi.EventFormatter(response) - ef.appendResponse("PermissionResponse") - ef.pushElement("topicPermissions") - - # For each of the topics in the request, add an entry to - # the response. - topicsElement = msg.getElement(TOPICS).values() - for topic in topicsElement: - ef.appendElement() - ef.setElement("topic", topic) - ef.setElement("result", permission) - ef.popElement() - ef.popElement() - - session.sendResponse(response) - - else: - for msg in event: - print(msg) - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - return True - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser(description="Publish on a topic.") - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-s", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//viper/page") - parser.add_option("-g", - dest="groupId", - help="publisher groupId (defaults to unique value)", - metavar="groupId") - parser.add_option("-r", - "--pri", - type="int", - dest="priority", - help="set publisher priority level (default: %default)", - metavar="priority", - default=10) - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - return options - - -def authorize(authService, identity, session, cid): - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = datetime.timedelta(seconds=10) - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == \ - g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > WAIT_TIME_SECONDS: - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - sessionOptions.setNumStartAttempts(len(options.hosts)) - - print("Connecting to port %d on %s" % ( - options.port, " ".join(options.hosts))) - - myEventHandler = MyEventHandler(options.service) - - # Create a Session - session = blpapi.ProviderSession(sessionOptions, - myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("auth")) - if not isAuthorized: - print("No authorization") - return - - serviceOptions = blpapi.ServiceRegistrationOptions() - if options.groupId is not None: - serviceOptions.setGroupId(options.groupId) - serviceOptions.setServicePriority(options.priority) - - if not session.registerService(options.service, - providerIdentity, - serviceOptions): - print("Failed to register '%s'" % options.service) - return - - service = session.getService(options.service) - - try: - # Now we will start publishing - value = 1 - while g_running: - event = service.createPublishEvent() - - with g_condition: - while g_availableTopicCount == 0: - # Set timeout to 1 - give a chance for CTRL-C - g_condition.wait(1) - if not g_running: - return - - eventFormatter = blpapi.EventFormatter(event) - for topicName, stream in g_streams.items(): - if not stream.isAvailable(): - continue - - value += 1 - - if not stream.isInitialPaintSent: - eventFormatter.appendRecapMessage(stream.topic) - eventFormatter.setElement("numRows", 25) - eventFormatter.setElement("numCols", 80) - eventFormatter.pushElement("rowUpdate") - for i in range(1, 6): - eventFormatter.appendElement() - eventFormatter.setElement("rowNum", i) - eventFormatter.pushElement("spanUpdate") - eventFormatter.appendElement() - eventFormatter.setElement("startCol", 1) - eventFormatter.setElement("length", 10) - eventFormatter.setElement("text", "INITIAL") - eventFormatter.setElement("fgColor", "RED") - eventFormatter.popElement() - eventFormatter.popElement() - eventFormatter.popElement() - eventFormatter.popElement() - stream.isInitialPaintSent = True - - eventFormatter.appendMessage("RowUpdate", stream.topic) - eventFormatter.setElement("rowNum", 1) - eventFormatter.pushElement("spanUpdate") - eventFormatter.appendElement() - START_COL = blpapi.Name("startCol") - eventFormatter.setElement(START_COL, 1) - strValue = str(value) - eventFormatter.setElement("length", len(strValue)) - eventFormatter.setElement("text", strValue) - eventFormatter.popElement() - eventFormatter.popElement() - - for msg in event: - print(msg) - - session.publish(event) - time.sleep(10) - - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("PagePublisherExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/RefDataTableOverrideExample.py b/examples/RefDataTableOverrideExample.py deleted file mode 100644 index 4d3019f..0000000 --- a/examples/RefDataTableOverrideExample.py +++ /dev/null @@ -1,181 +0,0 @@ -# RefDataTableOverrideExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -SECURITY_DATA = blpapi.Name("securityData") -SECURITY = blpapi.Name("security") -FIELD_DATA = blpapi.Name("fieldData") -FIELD_EXCEPTIONS = blpapi.Name("fieldExceptions") -FIELD_ID = blpapi.Name("fieldId") -ERROR_INFO = blpapi.Name("errorInfo") - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def processMessage(msg): - securityDataArray = msg.getElement(SECURITY_DATA) - for securityData in securityDataArray.values(): - print(securityData.getElementAsString(SECURITY)) - fieldData = securityData.getElement(FIELD_DATA) - for field in fieldData.elements(): - if not field.isValid(): - print(field.name(), "is NULL.") - elif field.isArray(): - # The following illustrates how to iterate over complex - # data returns. - for i, row in enumerate(field.values()): - print("Row %d: %s" % (i, row)) - else: - print("%s = %s" % (field.name(), field.getValueAsString())) - - fieldExceptionArray = securityData.getElement(FIELD_EXCEPTIONS) - for fieldException in fieldExceptionArray.values(): - errorInfo = fieldException.getElement(ERROR_INFO) - print("%s: %s" % (errorInfo.getElementAsString("category"), - fieldException.getElementAsString(FIELD_ID))) - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - - # Add securities to request. - request.append("securities", "CWHL 2006-20 1A1 Mtge") - # ... - - # Add fields to request. Cash flow is a table (data set) field. - - request.append("fields", "MTG_CASH_FLOW") - request.append("fields", "SETTLE_DT") - - # Add scalar overrides to request. - - overrides = request.getElement("overrides") - override1 = overrides.appendElement() - override1.setElement("fieldId", "ALLOW_DYNAMIC_CASHFLOW_CALCS") - override1.setElement("value", "Y") - override2 = overrides.appendElement() - override2.setElement("fieldId", "LOSS_SEVERITY") - override2.setElement("value", 31) - - # Add table overrides to request. - - tableOverrides = request.getElement("tableOverrides") - tableOverride = tableOverrides.appendElement() - tableOverride.setElement("fieldId", "DEFAULT_VECTOR") - rows = tableOverride.getElement("row") - - # Layout of input table is specified by the definition of - # 'DEFAULT_VECTOR'. Attributes are specified in the first rows. - # Subsequent rows include rate, duration, and transition. - - row = rows.appendElement() - cols = row.getElement("value") - cols.appendValue("Anchor") # Anchor type - cols.appendValue("PROJ") # PROJ = Projected - row = rows.appendElement() - cols = row.getElement("value") - cols.appendValue("Type") # Type of default - cols.appendValue("CDR") # CDR = Conditional Default Rate - - rateVectors = [ - [1.0, 12, "S"], # S = Step - [2.0, 12, "R"] # R = Ramp - ] - - for rateVector in rateVectors: - row = rows.appendElement() - cols = row.getElement("value") - for value in rateVector: - cols.appendValue(value) - - print("Sending Request:", request) - cid = session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - if cid in msg.correlationIds(): - # Process the response generically. - processMessage(msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("RefDataTableOverrideExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/RequestServiceExample.py b/examples/RequestServiceExample.py deleted file mode 100644 index 8bcf5f9..0000000 --- a/examples/RequestServiceExample.py +++ /dev/null @@ -1,427 +0,0 @@ -# RequestServiceExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -# compatibility between python 2 and 3 -from blpapi.compat import with_metaclass -import datetime -import time -import threading -from optparse import OptionParser, OptionValueError - -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -RESOLUTION_SUCCESS = blpapi.Name("ResolutionSuccess") -SESSION_TERMINATED = blpapi.Name("SessionTerminated") -TOKEN = blpapi.Name("token") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") - - -g_running = True -g_mutex = threading.Lock() - - -@with_metaclass(blpapi.utils.MetaClassForClassesWithEnums) -class AuthorizationStatus: - WAITING = 1 - AUTHORIZED = 2 - FAILED = 3 - - -g_authorizationStatus = dict() - - -class MyProviderEventHandler(object): - def __init__(self, serviceName): - self.serviceName = serviceName - - def processEvent(self, event, session): - global g_running - - print("Server received an event") - if event.eventType() == blpapi.Event.SESSION_STATUS: - for msg in event: - print(msg) - if msg.messageType() == SESSION_TERMINATED: - g_running = False - - elif event.eventType() == blpapi.Event.RESOLUTION_STATUS: - for msg in event: - print(msg) - - elif event.eventType() == blpapi.Event.REQUEST: - service = session.getService(self.serviceName) - for msg in event: - print(msg) - - if msg.messageType() == blpapi.Name("ReferenceDataRequest"): - # Similar to createPublishEvent. We assume just one - # service - self.serviceName. A responseEvent can only be - # for single request so we can specify the correlationId - - # which establishes context - when we create the Event. - - if msg.hasElement("timestamp"): - requestTime = msg.getElementAsFloat("timestamp") - latency = time.time() - requestTime - print("Response latency =", latency) - - response = \ - service.createResponseEvent(msg.correlationIds()[0]) - ef = blpapi.EventFormatter(response) - - # In appendResponse the string is the name of the - # operation, the correlationId indicates which request we - # are responding to. - ef.appendResponse("ReferenceDataRequest") - securities = msg.getElement("securities") - fields = msg.getElement("fields") - ef.setElement("timestamp", time.time()) - ef.pushElement("securityData") - for security in securities.values(): - ef.appendElement() - ef.setElement("security", security) - ef.pushElement("fieldData") - - for field in fields.values(): - ef.appendElement() - ef.setElement("fieldId", field) - ef.pushElement("data") - ef.setElement("doubleValue", time.time()) - ef.popElement() - ef.popElement() - - ef.popElement() - ef.popElement() - - # Service is implicit in the Event. sendResponse has a - # second parameter - partialResponse - that defaults to - # false. - session.sendResponse(response) - - else: - for msg in event: - print(msg) - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - return True - - -class MyRequesterEventHandler(object): - def processEvent(self, event, session): - print("Client received an event") - for msg in event: - print(msg) - cids = msg.correlationIds() - with g_mutex: - for cid in cids: - if cid in g_authorizationStatus: - if msg.messageType() == AUTHORIZATION_SUCCESS: - g_authorizationStatus[cid] = \ - AuthorizationStatus.AUTHORIZED - else: - g_authorizationStatus[cid] = \ - AuthorizationStatus.FAILED - - -def authOptionCallback(option, opt, value, parser): - vals = value.split('=', 1) - - if value == "user": - parser.values.auth = "AuthenticationType=OS_LOGON" - elif value == "none": - parser.values.auth = None - elif vals[0] == "app" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "userapp" and len(vals) == 2: - parser.values.auth = "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + vals[1] - elif vals[0] == "dir" and len(vals) == 2: - parser.values.auth = "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + vals[1] - else: - raise OptionValueError("Invalid auth option '%s'" % value) - - -def parseCmdLine(): - parser = OptionParser() - parser.add_option("-a", - "--ip", - dest="hosts", - help="server name or IP (default: localhost)", - metavar="ipAddress", - action="append", - default=[]) - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("--service", - dest="service", - help="service name (default: %default)", - metavar="service", - default="//example/refdata") - parser.add_option("-s", - dest="securities", - help="request security (default: IBM US Equity)", - metavar="security", - action="append", - default=[]) - parser.add_option("-f", - dest="fields", - help="request field (default: PX_LAST)", - metavar="field", - action="append", - default=[]) - parser.add_option("-r", - dest="role", - type="choice", - choices=["server", "client", "both"], - help="service role option: server|client|both " + - "(default: %default)", - metavar="option", - default="both") - parser.add_option("--auth", - dest="auth", - help="authentication option: " - "user|none|app=|userapp=|dir=" - " (default: %default)", - metavar="option", - action="callback", - callback=authOptionCallback, - type="string", - default="user") - - (options, args) = parser.parse_args() - - if not options.hosts: - options.hosts = ["localhost"] - - if not options.securities: - options.securities = ["IBM US Equity"] - - if not options.fields: - options.fields = ["PX_LAST"] - - return options - - -def serverRun(session, options): - print("Server is starting------") - - if not session.start(): - print("Failed to start server session.") - return - - providerIdentity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, providerIdentity, session, - blpapi.CorrelationId("sauth")) - if not isAuthorized: - print("No authorization") - return - - if not session.registerService(options.service, providerIdentity): - print("Failed to register", options.service) - return - - -def clientRun(session, options): - print("Client is starting------") - - if not session.start(): - print("Failed to start client session.") - return - - identity = session.createIdentity() - - if options.auth: - isAuthorized = False - authServiceName = "//blp/apiauth" - if session.openService(authServiceName): - authService = session.getService(authServiceName) - isAuthorized = authorize( - authService, identity, session, - blpapi.CorrelationId("cauth")) - if not isAuthorized: - print("No authorization") - return - - if not session.openService(options.service): - print("Failed to open", options.service) - return - - service = session.getService(options.service) - request = service.createRequest("ReferenceDataRequest") - - # append securities to request - # Add securities to request - securities = request.getElement("securities") - for security in options.securities: - securities.appendValue(security) - - # Add fields to request - fields = request.getElement("fields") - for field in options.fields: - fields.appendValue(field) - - request.set("timestamp", time.time()) - - print("Sendind Request:", request) - - eventQueue = blpapi.EventQueue() - session.sendRequest(request, identity, blpapi.CorrelationId("AddRequest"), - eventQueue) - - while True: - # Specify timeout to give a chance for Ctrl-C - event = eventQueue.nextEvent(500) - - if event.eventType() == blpapi.Event.TIMEOUT: - continue - - print("Client received an event") - for msg in event: - with g_mutex: - if event.eventType() == blpapi.Event.RESPONSE: - if msg.hasElement("timestamp"): - responseTime = msg.getElementAsFloat("timestamp") - print("Response latency =", time.time() - responseTime) - print(msg) - - if event.eventType() == blpapi.Event.RESPONSE: - break - - -def authorize(authService, identity, session, cid): - with g_mutex: - g_authorizationStatus[cid] = AuthorizationStatus.WAITING - - tokenEventQueue = blpapi.EventQueue() - session.generateToken(eventQueue=tokenEventQueue) - - # Process related response - ev = tokenEventQueue.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS or \ - ev.eventType() == blpapi.Event.REQUEST_STATUS: - for msg in ev: - print(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - - if not token: - print("Failed to get token") - return False - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, cid) - - # Process related responses - startTime = datetime.datetime.today() - WAIT_TIME_SECONDS = 10 - while True: - with g_mutex: - if AuthorizationStatus.WAITING != g_authorizationStatus[cid]: - return AuthorizationStatus.AUTHORIZED == g_authorizationStatus[cid] - - endTime = datetime.datetime.today() - if endTime - startTime > datetime.timedelta(seconds=WAIT_TIME_SECONDS): - return False - - time.sleep(1) - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - for idx, host in enumerate(options.hosts): - sessionOptions.setServerAddress(host, options.port, idx) - sessionOptions.setAuthenticationOptions(options.auth) - sessionOptions.setAutoRestartOnDisconnection(True) - sessionOptions.setNumStartAttempts(len(options.hosts)) - - print("Connecting to port %d on %s" % ( - options.port, ", ".join(options.hosts))) - - providerEventHandler = MyProviderEventHandler(options.service) - providerSession = blpapi.ProviderSession(sessionOptions, - providerEventHandler.processEvent) - - requesterEventHandler = MyRequesterEventHandler() - requesterSession = blpapi.Session(sessionOptions, - requesterEventHandler.processEvent) - - if options.role in ["server", "both"]: - serverRun(providerSession, options) - - if options.role in ["client", "both"]: - clientRun(requesterSession, options) - - # wait for enter key to exit application - print("Press ENTER to quit") - input() - - if options.role in ["server", "both"]: - providerSession.stop() - - if options.role in ["client", "both"]: - requesterSession.stop() - - -if __name__ == "__main__": - print("RequestServiceExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/ServiceSchema.py b/examples/ServiceSchema.py deleted file mode 100644 index dcf1dfd..0000000 --- a/examples/ServiceSchema.py +++ /dev/null @@ -1,350 +0,0 @@ -# ServiceSchema.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import time -from optparse import OptionParser - -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -REFERENCE_DATA_RESPONSE = blpapi.Name("ReferenceDataResponse") -TOKEN = blpapi.Name("token") -AUTH_SERVICE = "//blp/apiauth" - - -ELEMENT_DATATYPE_NAMES = { - blpapi.DataType.BOOL: "BOOL", - blpapi.DataType.CHAR: "CHAR", - blpapi.DataType.BYTE: "BYTE", - blpapi.DataType.INT32: "INT32", - blpapi.DataType.INT64: "INT64", - blpapi.DataType.FLOAT32: "FLOAT32", - blpapi.DataType.FLOAT64: "FLOAT64", - blpapi.DataType.STRING: "STRING", - blpapi.DataType.BYTEARRAY: "BYTEARRAY", - blpapi.DataType.DATE: "DATE", - blpapi.DataType.TIME: "TIME", - blpapi.DataType.DECIMAL: "DECIMAL", - blpapi.DataType.DATETIME: "DATETIME", - blpapi.DataType.ENUMERATION: "ENUMERATION", - blpapi.DataType.SEQUENCE: "SEQUENCE", - blpapi.DataType.CHOICE: "CHOICE", - blpapi.DataType.CORRELATION_ID: "CORRELATION_ID" -} - - -SCHEMA_STATUS_NAMES = { - blpapi.SchemaStatus.ACTIVE: "ACTIVE", - blpapi.SchemaStatus.DEPRECATED: "DEPRECATED", - blpapi.SchemaStatus.INACTIVE: "INACTIVE", - blpapi.SchemaStatus.PENDING_DEPRECATION: "PENDING" -} - - -def parseCmdLine(): - parser = OptionParser() - parser.add_option("-a", - "--host", - dest="host", - help="HOST address to connect to", - metavar="HOST", - default="localhost") - parser.add_option("-p", - "--port", - dest="port", - type="int", - help="PORT to connect to (%default)", - metavar="PORT", - default=8194) - parser.add_option("-s", - "--service", - default="//blp/apiflds", - help="SERVICE to print the schema of " - "('//blp/apiflds' by default)") - parser.add_option("", - "--auth-type", - type="choice", - choices=["LOGON", "NONE", "APPLICATION", "DIRSVC", - "USER_APP"], - dest="authType", - help="Authentification type: LOGON (default), NONE, " - "APPLICATION, DIRSVC or USER_APP", - default="LOGON") - parser.add_option("", - "--auth-name", - dest="authName", - help="The name of application or directory service", - default="") - - (options, args) = parser.parse_args() - - options.auth = getAuthentificationOptions(options.authType, - options.authName) - - return options - - -def getAuthentificationOptions(type, name): - if type == "NONE": - return None - elif type == "USER_APP": - return "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + name - elif type == "APPLICATION": - return "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + name - elif type == "DIRSVC": - return "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + name - else: - return "AuthenticationType=OS_LOGON" - - -def printMessage(msg): - if msg.messageType() != REFERENCE_DATA_RESPONSE: - print("[{0}]: {1}".format(", ".join(map(str, msg.correlationIds())), - msg)) - else: - # This case demonstrates how to get values of individual elements - securityDataArray = msg.getElement("securityData") - for securityData in securityDataArray.values(): - securityName = securityData.getElementValue("security") - print(securityName) - fieldData = securityData.getElement("fieldData") - for fieldName in options.field: - try: - fieldValue = fieldData.getElementValue(fieldName) - print(("%s %s" % (fieldName, fieldValue))) - except: - print(("%s n/a" % fieldName)) - - -def auth(session): - eq = blpapi.EventQueue() - - # Generate token - session.generateToken(eventQueue=eq) - - # Process related response - ev = eq.nextEvent() - token = None - if ev.eventType() == blpapi.Event.TOKEN_STATUS: - for msg in ev: - printMessage(msg) - if msg.messageType() == TOKEN_SUCCESS: - token = msg.getElementAsString(TOKEN) - elif msg.messageType() == TOKEN_FAILURE: - break - if not token: - raise Exception("Failed to get token") - - # Purge EventQueue to reuse one for the next request - eq.purge() - - # Open authentification service - if not session.openService(AUTH_SERVICE): - raise Exception("Failed to open auth service") - - # Obtain opened service - authService = session.getService(AUTH_SERVICE) - - # Create and fill the authorithation request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - - # Create Identity - identity = session.createIdentity() - - # Send authorithation request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity, eventQueue=eq) - - # Process related responses - while True: - ev = eq.nextEvent() - if ev.eventType() in set([ - blpapi.Event.RESPONSE, - blpapi.Event.PARTIAL_RESPONSE, - blpapi.Event.REQUEST_STATUS]): - for msg in ev: - printMessage(msg) - if msg.messageType() == AUTHORIZATION_SUCCESS: - # auth passed, identity "filled" - return identity - else: - raise Exception("Authorization failed") - - -def getIndent(level): - return "" if level == 0 else " ".ljust(level * 2) - - -# Print enumeration (constant list) -def printEnumeration(cl, level): - indent = getIndent(level + 1) - print(indent + " {0} {1} {2} \"{3}\" possible values:".format( - cl.name(), - SCHEMA_STATUS_NAMES[cl.status()], - ELEMENT_DATATYPE_NAMES[cl.datatype()], - cl.description())) - - # Enumerate and print all constant list's values (constants) - for i in cl: - print(indent + " {0} {1} {2} \"{3}\" = {4!s}".format( - i.name(), - SCHEMA_STATUS_NAMES[i.status()], - ELEMENT_DATATYPE_NAMES[i.datatype()], - i.description(), - i.getValue())) - - -# Recursively print element definition -def printElementDefinition(ed, level=0): - indent = getIndent(level) - - maxValues = ed.maxValues() - if maxValues == blpapi.SchemaElementDefinition.UNBOUNDED: - valuesRange = "[{0}, INF)".format(ed.minValues()) - else: - valuesRange = "[{0}, {1}]".format(ed.minValues(), maxValues) - - # Get and print alternate element names - alternateNames = ed.alternateNames() - if alternateNames: - alternateNames = "[{0}]".format(",".join(map(str, alternateNames))) - else: - alternateNames = "" - - print(indent + "* {0} {1} {2} {3} \"{4}\"".format( - ed.name(), - SCHEMA_STATUS_NAMES[ed.status()], - valuesRange, - alternateNames, - ed.description())) - - # Get and print related type definition - td = ed.typeDefinition() - - print(indent + " {0} {1} {2} {3}{4}{5}\"{6}\"".format( - td.name(), - SCHEMA_STATUS_NAMES[td.status()], - ELEMENT_DATATYPE_NAMES[td.datatype()], - "complex " if td.isComplexType() else "", - "simple " if td.isSimpleType() else "", - "enum " if td.isEnumerationType() else "", - td.description())) - - # Get and print all possible values for enumeration type - enumeration = td.enumeration() - if not enumeration is None: - printEnumeration(enumeration, level) - - if td.numElementDefinitions(): - print(indent + " Elements[{0}]:".format( - td.numElementDefinitions())) - # Enumerate and print all sub-element definitions - for i in td.elementDefinitions(): - printElementDefinition(i, level + 1) - - -def printOperation(operation, service): - print("{0} \"{1}\" Request:".format( - operation.name(), - operation.description())) - - # Print operation's request definition - printElementDefinition(operation.requestDefinition(), 1) - print("Responses[{0}]:".format(operation.numResponseDefinitions())) - - # Enumerate and print all operation's response definitions - for r in operation.responseDefinitions(): - printElementDefinition(r, 1) - print() - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - if options.auth: - sessionOptions.setAuthenticationOptions(options.auth) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - raise Exception("Can't start session.") - - try: - print("Session started.") - - # Perform authentification - if options.auth: - identity = auth(session) - print("Authentification passed ({0})".format( - {-1: "Unknown seat type", - 0: "BPS", - 1: "No BPS"}[identity.getSeatType()])) - else: - identity = None - print("No authentification specified") - - # Open service to get reference data from - if not session.openService(options.service): - raise Exception("Can't open '{0}' service.".format( - options.service)) - - # Obtain previously opened service - service = session.getService(options.service) - print("Service {0}:".format(options.service)) - - print("Service event definitions[{0}]:".format( - service.numEventDefinitions())) - # Enumerate and print all service's event definitions - for ed in service.eventDefinitions(): - printElementDefinition(ed) - print() - - print("Operations[{0}]:".format(service.numOperations())) - # Enumerate and print all service's operations - for operation in service.operations(): - printOperation(operation, service) - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("ServiceSchema") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleAsyncSubscription.py b/examples/SimpleAsyncSubscription.py deleted file mode 100644 index 242ced1..0000000 --- a/examples/SimpleAsyncSubscription.py +++ /dev/null @@ -1,275 +0,0 @@ -# SimpleAsyncSubscription.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import time -import traceback -try: - import thread -except ImportError: - import _thread as thread -import weakref -from optparse import OptionParser -from blpapi import Event as EventType - -SESSION_STARTED = blpapi.Name("SessionStarted") -SESSION_STARTUP_FAILURE = blpapi.Name("SessionStartupFailure") -TOKEN_SUCCESS = blpapi.Name("TokenGenerationSuccess") -TOKEN_FAILURE = blpapi.Name("TokenGenerationFailure") -AUTHORIZATION_SUCCESS = blpapi.Name("AuthorizationSuccess") -AUTHORIZATION_FAILURE = blpapi.Name("AuthorizationFailure") -TOKEN = blpapi.Name("token") -AUTH_SERVICE = "//blp/apiauth" - - -EVENT_TYPE_NAMES = { - EventType.ADMIN: "ADMIN", - EventType.SESSION_STATUS: "SESSION_STATUS", - EventType.SUBSCRIPTION_STATUS: "SUBSCRIPTION_STATUS", - EventType.REQUEST_STATUS: "REQUEST_STATUS", - EventType.RESPONSE: "RESPONSE", - EventType.PARTIAL_RESPONSE: "PARTIAL_RESPONSE", - EventType.SUBSCRIPTION_DATA: "SUBSCRIPTION_DATA", - EventType.SERVICE_STATUS: "SERVICE_STATUS", - EventType.TIMEOUT: "TIMEOUT", - EventType.AUTHORIZATION_STATUS: "AUTHORIZATION_STATUS", - EventType.RESOLUTION_STATUS: "RESOLUTION_STATUS", - EventType.TOPIC_STATUS: "TOPIC_STATUS", - EventType.TOKEN_STATUS: "TOKEN_STATUS", - EventType.REQUEST: "REQUEST" -} - - -class Error(Exception): - pass - - -def getAuthentificationOptions(type, name): - if type == "NONE": - return None - elif type == "USER_APP": - return "AuthenticationMode=USER_AND_APPLICATION;"\ - "AuthenticationType=OS_LOGON;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + name - elif type == "APPLICATION": - return "AuthenticationMode=APPLICATION_ONLY;"\ - "ApplicationAuthenticationType=APPNAME_AND_KEY;"\ - "ApplicationName=" + name - elif type == "DIRSVC": - return "AuthenticationType=DIRECTORY_SERVICE;"\ - "DirSvcPropertyName=" + name - else: - return "AuthenticationType=OS_LOGON" - - -def topicName(security): - if security.startswith("//"): - return security - else: - return "//blp/mktdata/" + security - - -def printMessage(msg, eventType): - print("#{0} msg received: [{1}] => {2}/{3}".format( - thread.get_ident(), - ", ".join(map(str, msg.correlationIds())), - EVENT_TYPE_NAMES[eventType], - msg)) - - -def parseCmdLine(): - parser = OptionParser() - parser.add_option("-a", - "--host", - dest="host", - help="HOST address to connect to", - metavar="HOST", - default="localhost") - parser.add_option("-p", - "--port", - dest="port", - type="int", - help="PORT to connect to (%default)", - metavar="PORT", - default=8194) - parser.add_option("-s", - "--security", - dest="securities", - help="security to subscribe to " - "('IBM US Equity' by default)", - metavar="SECURITY", - action="append", - default=[]) - parser.add_option("-f", - "--fields", - dest="fields", - help="comma " - "separated list of FIELDS to subscribe to " - "('LAST_PRICE,BID,ASK' by default)", - metavar="FIELDS", - default="LAST_PRICE,BID,ASK") - parser.add_option("", - "--auth-type", - type="choice", - choices=["LOGON", "NONE", "APPLICATION", "DIRSVC", - "USER_APP"], - dest="authType", - help="Authentification type: LOGON (default), NONE, " - "APPLICATION, DIRSVC or USER_APP", - default="LOGON") - parser.add_option("", - "--auth-name", - dest="authName", - help="The name of application or directory service", - default="") - - (options, args) = parser.parse_args() - - if not options.securities: - options.securities = ["IBM US Equity"] - - options.auth = getAuthentificationOptions(options.authType, - options.authName) - return options - - -# Subscribe 'session' for the securities and fields specified in 'options' -def subscribe(session, options, identity=None): - sl = blpapi.SubscriptionList() - for s in options.securities: - topic = topicName(s) - cid = blpapi.CorrelationId(s) - print("Subscribing {0} => {1}".format(cid, topic)) - sl.add(topic, options.fields, correlationId=cid) - session.subscribe(sl, identity) - - -# Event handler -def processEvent(event, session): - global identity - global options - - try: - eventType = event.eventType() - for msg in event: - # Print all aincoming messages including the SubscriptionData - printMessage(msg, eventType) - - if eventType == EventType.SESSION_STATUS: - if msg.messageType() == SESSION_STARTED: - # Session.startAsync completed successfully - # Start the authorization if needed - if options.auth: - # Generate token - session.generateToken() - else: - identity = None - # Subscribe for the specified securities/fields - subscribe(session, options) - elif msg.messageType() == SESSION_STARTUP_FAILURE: - # Session.startAsync failed, raise exception to exit - raise Error("Can't start session") - - elif eventType == EventType.TOKEN_STATUS: - if msg.messageType() == TOKEN_SUCCESS: - # Token generated successfully - # Continue the authorization - # Get generated token - token = msg.getElementAsString(TOKEN) - # Open auth service (we do it syncroniously, just in case) - if not session.openService(AUTH_SERVICE): - raise Error("Failed to open auth service") - # Obtain opened service - authService = session.getService(AUTH_SERVICE) - # Create and fill the authorization request - authRequest = authService.createAuthorizationRequest() - authRequest.set(TOKEN, token) - # Create Identity - identity = session.createIdentity() - # Send authorization request to "fill" the Identity - session.sendAuthorizationRequest(authRequest, identity) - else: - # Token generation failed, raise exception to exit - raise Error("Failed to generate token") - - elif eventType == EventType.RESPONSE \ - or eventType == EventType.PARTIAL_RESPONSE: - if msg.messageType() == AUTHORIZATION_SUCCESS: - # Authorization passed, identity "filled" and can be used - # Subscribe for the specified securities/fields with using - # of the identity - subscribe(session, options, identity) - elif msg.messageType() == AUTHORIZATION_FAILURE: - # Authorization failed, raise exception to exit - raise Error("Failed to pass authorization") - except Error as ex: - print("Error in event handler:", ex) - # Interrupt a "sleep loop" in main thread - thread.interrupt_main() - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - if options.auth: - sessionOptions.setAuthenticationOptions(options.auth) - - # Create an EventDispatcher with 2 processing threads - dispatcher = blpapi.EventDispatcher(2) - - # Create a Session - session = blpapi.Session(sessionOptions, processEvent, dispatcher) - - # Start dispatcher to "pump" the received events - dispatcher.start() - - # Start session asynchronously - if not session.startAsync(): - raise Exception("Can't initiate session start.") - - # Sleep until application will be interrupted by user (Ctrl+C pressed) - # or because of the exception in event handler - try: - # Note that: 'thread.interrupt_main()' could be used to - # correctly stop the application from 'processEvent' - while True: - time.sleep(1) - finally: - session.stop() - dispatcher.stop() - - -if __name__ == "__main__": - print("SimpleAsyncSubscription") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleBlockingRequestExample.py b/examples/SimpleBlockingRequestExample.py deleted file mode 100644 index 0a786aa..0000000 --- a/examples/SimpleBlockingRequestExample.py +++ /dev/null @@ -1,134 +0,0 @@ -# SimpleBlockingRequestExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -LAST_PRICE = blpapi.Name("LAST_PRICE") - - -class MyEventHandler(object): - def processEvent(self, event, session): - try: - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - for msg in event: - if msg.hasElement(LAST_PRICE): - field = msg.getElement(LAST_PRICE) - print(field.name(), "=", field.getValueAsString()) - return True - except Exception as e: - print("Exception:", e) - return False - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - myEventHandler = MyEventHandler() - # Create a Session - session = blpapi.Session(sessionOptions, myEventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/mktdata"): - print("Failed to open //blp/mktdata") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - print("Subscribing to IBM US Equity") - cid = blpapi.CorrelationId(1) - subscriptions = blpapi.SubscriptionList() - subscriptions.add("IBM US Equity", "LAST_PRICE", "", cid) - session.subscribe(subscriptions) - - print("Requesting reference data IBM US Equity") - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - request.append("securities", "IBM US Equity") - request.append("fields", "DS002") - - cid2 = blpapi.CorrelationId(2) - eventQueue = blpapi.EventQueue() - session.sendRequest(request, correlationId=cid2, eventQueue=eventQueue) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = eventQueue.nextEvent(500) - for msg in ev: - print(msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - - # Wait for enter key to exit application - print("Press ENTER to quit") - input() - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleBlockingRequestExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleCategorizedFieldSearchExample.py b/examples/SimpleCategorizedFieldSearchExample.py deleted file mode 100644 index e384d6a..0000000 --- a/examples/SimpleCategorizedFieldSearchExample.py +++ /dev/null @@ -1,166 +0,0 @@ -# SimpleCategorizedFieldSearchExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -APIFLDS_SVC = "//blp/apiflds" -PADDING = " " - -FIELD_ID = blpapi.Name("id") -FIELD_MNEMONIC = blpapi.Name("mnemonic") -FIELD_DATA = blpapi.Name("fieldData") -FIELD_DESC = blpapi.Name("description") -FIELD_INFO = blpapi.Name("fieldInfo") -FIELD_ERROR = blpapi.Name("fieldError") -FIELD_MSG = blpapi.Name("message") -CATEGORY = blpapi.Name("category") -CATEGORY_NAME = blpapi.Name("categoryName") -CATEGORY_ID = blpapi.Name("categoryId") -FIELD_SEARCH_ERROR = blpapi.Name("fieldSearchError") - -ID_LEN = 13 -MNEMONIC_LEN = 36 -DESC_LEN = 40 -CAT_NAME_LEN = 40 - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def printField(field): - fldId = field.getElementAsString(FIELD_ID) - if field.hasElement(FIELD_INFO): - fldInfo = field.getElement(FIELD_INFO) - fldMnemonic = fldInfo.getElementAsString(FIELD_MNEMONIC) - fldDesc = fldInfo.getElementAsString(FIELD_DESC) - - print("%s%s%s" % (fldId.ljust(ID_LEN), fldMnemonic.ljust(MNEMONIC_LEN), - fldDesc.ljust(DESC_LEN))) - else: - fldError = field.getElement(FIELD_ERROR) - errorMsg = fldError.getElementAsString(FIELD_MSG) - - print() - print(" ERROR: %s - %s" % (fldId, errorMsg)) - - -def printHeader(): - print("%s%s%s" % ("FIELD ID".ljust(ID_LEN), "MNEMONIC".ljust(MNEMONIC_LEN), - "DESCRIPTION".ljust(DESC_LEN))) - print("%s%s%s" % ("-----------".ljust(ID_LEN), "-----------".ljust(MNEMONIC_LEN), - "-----------".ljust(DESC_LEN))) - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService(APIFLDS_SVC): - print("Failed to open", APIFLDS_SVC) - return - - fieldInfoService = session.getService(APIFLDS_SVC) - request = fieldInfoService.createRequest("CategorizedFieldSearchRequest") - request.set("searchSpec", "last price") - exclude = request.getElement("exclude") - exclude.setElement("fieldType", "Static") - request.set("returnFieldDocumentation", False) - - print("Sending Request:", request) - session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - if event.eventType() != blpapi.Event.RESPONSE and \ - event.eventType() != blpapi.Event.PARTIAL_RESPONSE: - continue - for msg in event: - if msg.hasElement(FIELD_SEARCH_ERROR): - print(msg) - continue - - categories = msg.getElement("category") - for category in categories.values(): - Name = category.getElementAsString("categoryName") - Id = category.getElementAsString("categoryId") - print("\n Category Name:%s\tId:%s" % \ - (Name.ljust(CAT_NAME_LEN), Id)) - - printHeader() - fields = category.getElement("fieldData") - for field in fields.values(): - printField(field) - print() - - # Response completly received, so we could exit - if event.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleCategorizedFieldSearchExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleFieldInfoExample.py b/examples/SimpleFieldInfoExample.py deleted file mode 100644 index b0524ad..0000000 --- a/examples/SimpleFieldInfoExample.py +++ /dev/null @@ -1,150 +0,0 @@ -# SimpleFieldInfoExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -APIFLDS_SVC = "//blp/apiflds" -PADDING = " " - -FIELD_ID = blpapi.Name("id") -FIELD_MNEMONIC = blpapi.Name("mnemonic") -FIELD_DATA = blpapi.Name("fieldData") -FIELD_DESC = blpapi.Name("description") -FIELD_INFO = blpapi.Name("fieldInfo") -FIELD_ERROR = blpapi.Name("fieldError") -FIELD_MSG = blpapi.Name("message") - -ID_LEN = 13 -MNEMONIC_LEN = 36 -DESC_LEN = 40 - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def printField(field): - fldId = field.getElementAsString(FIELD_ID) - if field.hasElement(FIELD_INFO): - fldInfo = field.getElement(FIELD_INFO) - fldMnemonic = fldInfo.getElementAsString(FIELD_MNEMONIC) - fldDesc = fldInfo.getElementAsString(FIELD_DESC) - - print("%s%s%s" % (fldId.ljust(ID_LEN), fldMnemonic.ljust(MNEMONIC_LEN), - fldDesc.ljust(DESC_LEN))) - else: - fldError = field.getElement(FIELD_ERROR) - errorMsg = fldError.getElementAsString(FIELD_MSG) - - print() - print(" ERROR: %s - %s" % (fldId, errorMsg)) - - -def printHeader(): - print("%s%s%s" % ("FIELD ID".ljust(ID_LEN), "MNEMONIC".ljust(MNEMONIC_LEN), - "DESCRIPTION".ljust(DESC_LEN))) - print("%s%s%s" % ("-----------".ljust(ID_LEN), "-----------".ljust(MNEMONIC_LEN), - "-----------".ljust(DESC_LEN))) - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService(APIFLDS_SVC): - print("Failed to open", APIFLDS_SVC) - return - - fieldInfoService = session.getService(APIFLDS_SVC) - request = fieldInfoService.createRequest("FieldInfoRequest") - request.append("id", "LAST_PRICE") - request.append("id", "pq005") - request.append("id", "zz0002") - - request.set("returnFieldDocumentation", True) - - print("Sending Request:", request) - session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - if event.eventType() != blpapi.Event.RESPONSE and \ - event.eventType() != blpapi.Event.PARTIAL_RESPONSE: - continue - for msg in event: - fields = msg.getElement("fieldData") - printHeader() - for field in fields.values(): - printField(field) - print() - # Response completly received, so we could exit - if event.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleFieldInfoExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleFieldSearchExample.py b/examples/SimpleFieldSearchExample.py deleted file mode 100644 index 752f6bb..0000000 --- a/examples/SimpleFieldSearchExample.py +++ /dev/null @@ -1,149 +0,0 @@ -# SimpleFieldSearchExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -APIFLDS_SVC = "//blp/apiflds" -PADDING = " " - -FIELD_ID = blpapi.Name("id") -FIELD_MNEMONIC = blpapi.Name("mnemonic") -FIELD_DATA = blpapi.Name("fieldData") -FIELD_DESC = blpapi.Name("description") -FIELD_INFO = blpapi.Name("fieldInfo") -FIELD_ERROR = blpapi.Name("fieldError") -FIELD_MSG = blpapi.Name("message") - -ID_LEN = 13 -MNEMONIC_LEN = 36 -DESC_LEN = 40 - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def printField(field): - fldId = field.getElementAsString(FIELD_ID) - if field.hasElement(FIELD_INFO): - fldInfo = field.getElement(FIELD_INFO) - fldMnemonic = fldInfo.getElementAsString(FIELD_MNEMONIC) - fldDesc = fldInfo.getElementAsString(FIELD_DESC) - - print("%s%s%s" % (fldId.ljust(ID_LEN), fldMnemonic.ljust(MNEMONIC_LEN), - fldDesc.ljust(DESC_LEN))) - else: - fldError = field.getElement(FIELD_ERROR) - errorMsg = fldError.getElementAsString(FIELD_MSG) - - print() - print(" ERROR: %s - %s" % (fldId, errorMsg)) - - -def printHeader(): - print("%s%s%s" % ("FIELD ID".ljust(ID_LEN), "MNEMONIC".ljust(MNEMONIC_LEN), - "DESCRIPTION".ljust(DESC_LEN))) - print("%s%s%s" % ("-----------".ljust(ID_LEN), "-----------".ljust(MNEMONIC_LEN), - "-----------".ljust(DESC_LEN))) - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService(APIFLDS_SVC): - print("Failed to open", APIFLDS_SVC) - return - - fieldInfoService = session.getService(APIFLDS_SVC) - request = fieldInfoService.createRequest("FieldSearchRequest") - request.set("searchSpec", "last price") - exclude = request.getElement("exclude") - exclude.setElement("fieldType", "Static") - request.set("returnFieldDocumentation", False) - - print("Sending Request:", request) - session.sendRequest(request) - - printHeader() - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - if event.eventType() != blpapi.Event.RESPONSE and \ - event.eventType() != blpapi.Event.PARTIAL_RESPONSE: - continue - for msg in event: - fields = msg.getElement("fieldData") - for field in fields.values(): - printField(field) - print() - # Response completly received, so we could exit - if event.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleFieldSearchExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleHistoryExample.py b/examples/SimpleHistoryExample.py deleted file mode 100644 index 039693c..0000000 --- a/examples/SimpleHistoryExample.py +++ /dev/null @@ -1,111 +0,0 @@ -# SimpleHistoryExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%s" % (options.host, options.port)) - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - try: - # Open service to get historical data from - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - # Obtain previously opened service - refDataService = session.getService("//blp/refdata") - - # Create and fill the request for the historical data - request = refDataService.createRequest("HistoricalDataRequest") - request.getElement("securities").appendValue("IBM US Equity") - request.getElement("securities").appendValue("MSFT US Equity") - request.getElement("fields").appendValue("PX_LAST") - request.getElement("fields").appendValue("OPEN") - request.set("periodicityAdjustment", "ACTUAL") - request.set("periodicitySelection", "MONTHLY") - request.set("startDate", "20060101") - request.set("endDate", "20061231") - request.set("maxDataPoints", 100) - - print("Sending Request:", request) - # Send the request - session.sendRequest(request) - - # Process received events - while(True): - # We provide timeout to give the chance for Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - print(msg) - - if ev.eventType() == blpapi.Event.RESPONSE: - # Response completly received, so we could exit - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleHistoryExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleIntradayBarExample.py b/examples/SimpleIntradayBarExample.py deleted file mode 100644 index 227fc11..0000000 --- a/examples/SimpleIntradayBarExample.py +++ /dev/null @@ -1,126 +0,0 @@ -# SimpleIntradayBarExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import datetime -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def getPreviousTradingDate(): - tradedOn = datetime.date.today() - - while True: - try: - tradedOn -= datetime.timedelta(days=1) - except OverflowError: - return None - - if tradedOn.weekday() not in [5, 6]: - return tradedOn - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("IntradayBarRequest") - request.set("security", "IBM US Equity") - request.set("eventType", "TRADE") - request.set("interval", 60) # bar interval in minutes - - tradedOn = getPreviousTradingDate() - if not tradedOn: - print("unable to get previous trading date") - return - - startTime = datetime.datetime.combine(tradedOn, datetime.time(13, 30)) - request.set("startDateTime", startTime) - - endTime = datetime.datetime.combine(tradedOn, datetime.time(21, 30)) - request.set("endDateTime", endTime) - - print("Sending Request:", request) - session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - print(msg.messageType(), msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleIntradayBarExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleIntradayTickExample.py b/examples/SimpleIntradayTickExample.py deleted file mode 100644 index f0c9050..0000000 --- a/examples/SimpleIntradayTickExample.py +++ /dev/null @@ -1,127 +0,0 @@ -# SimpleIntradayTickExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import datetime -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def getPreviousTradingDate(): - tradedOn = datetime.date.today() - - while True: - try: - tradedOn -= datetime.timedelta(days=1) - except OverflowError: - return None - - if tradedOn.weekday() not in [5, 6]: - return tradedOn - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("IntradayTickRequest") - request.set("security", "VOD LN Equity") - request.getElement("eventTypes").appendValue("TRADE") - request.getElement("eventTypes").appendValue("AT_TRADE") - request.set("includeConditionCodes", True) - - tradedOn = getPreviousTradingDate() - if not tradedOn: - print("unable to get previous trading date") - return - - startTime = datetime.datetime.combine(tradedOn, datetime.time(13, 30)) - request.set("startDateTime", startTime) - - endTime = datetime.datetime.combine(tradedOn, datetime.time(13, 35)) - request.set("endDateTime", endTime) - - print("Sending Request:", request) - session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - print(msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleIntradayTickExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleRefDataExample.py b/examples/SimpleRefDataExample.py deleted file mode 100644 index fb8125e..0000000 --- a/examples/SimpleRefDataExample.py +++ /dev/null @@ -1,106 +0,0 @@ -# SimpleRefDataExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - - # append securities to request - request.append("securities", "IBM US Equity") - request.append("securities", "MSFT US Equity") - - # append fields to request - request.append("fields", "PX_LAST") - request.append("fields", "DS002") - - print("Sending Request:", request) - session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - print(msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleRefDataExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleRefDataOverrideExample.py b/examples/SimpleRefDataOverrideExample.py deleted file mode 100644 index a4cad1e..0000000 --- a/examples/SimpleRefDataOverrideExample.py +++ /dev/null @@ -1,149 +0,0 @@ -# SimpleRefDataOverrideExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - -SECURITY_DATA = blpapi.Name("securityData") -SECURITY = blpapi.Name("security") -FIELD_DATA = blpapi.Name("fieldData") -FIELD_EXCEPTIONS = blpapi.Name("fieldExceptions") -FIELD_ID = blpapi.Name("fieldId") -ERROR_INFO = blpapi.Name("errorInfo") - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve reference data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - - (options, args) = parser.parse_args() - - return options - - -def processMessage(msg): - if not msg.hasElement(SECURITY_DATA): - print("Unexpected message:") - print(msg) - return - - securityDataArray = msg.getElement(SECURITY_DATA) - for securityData in securityDataArray.values(): - print(securityData.getElementAsString(SECURITY)) - fieldData = securityData.getElement(FIELD_DATA) - for field in fieldData.elements(): - if field.isValid(): - print(field.name(), "=", field.getValueAsString()) - else: - print(field.name(), " is NULL") - - fieldExceptionArray = securityData.getElement(FIELD_EXCEPTIONS) - for fieldException in fieldExceptionArray.values(): - errorInfo = fieldException.getElement(ERROR_INFO) - print(errorInfo.getElementAsString("category"), ":", \ - fieldException.getElementAsString(FIELD_ID)) - - print() - - -def main(): - global options - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/refdata"): - print("Failed to open //blp/refdata") - return - - refDataService = session.getService("//blp/refdata") - request = refDataService.createRequest("ReferenceDataRequest") - - # append securities to request - request.append("securities", "IBM US Equity") - request.append("securities", "MSFT US Equity") - - # append fields to request - request.append("fields", "PX_LAST") - request.append("fields", "DS002") - request.append("fields", "EQY_WEIGHTED_AVG_PX") - - # add overrides - overrides = request.getElement("overrides") - override1 = overrides.appendElement() - override1.setElement("fieldId", "VWAP_START_TIME") - override1.setElement("value", "9:30") - override2 = overrides.appendElement() - override2.setElement("fieldId", "VWAP_END_TIME") - override2.setElement("value", "11:30") - - print("Sending Request:", request) - cid = session.sendRequest(request) - - try: - # Process received events - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - ev = session.nextEvent(500) - for msg in ev: - if cid in msg.correlationIds(): - processMessage(msg) - # Response completly received, so we could exit - if ev.eventType() == blpapi.Event.RESPONSE: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleRefDataOverrideExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleSubscriptionExample.py b/examples/SimpleSubscriptionExample.py deleted file mode 100644 index 422b869..0000000 --- a/examples/SimpleSubscriptionExample.py +++ /dev/null @@ -1,119 +0,0 @@ -# SimpleSubscriptionExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import time -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve realtime data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("--me", - dest="maxEvents", - type="int", - help="stop after this many events (default: %default)", - metavar="maxEvents", - default=1000000) - - (options, args) = parser.parse_args() - - return options - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/mktdata"): - print("Failed to open //blp/mktdata") - return - - security1 = "IBM US Equity" - security2 = "/cusip/912828GM6@BGN" - - subscriptions = blpapi.SubscriptionList() - subscriptions.add(security1, - "LAST_PRICE,BID,ASK", - "", - blpapi.CorrelationId(security1)) - subscriptions.add(security2, - "LAST_PRICE,BID,ASK,BID_YIELD,ASK_YIELD", - "", - blpapi.CorrelationId(security2)) - - session.subscribe(subscriptions) - - try: - # Process received events - eventCount = 0 - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - for msg in event: - if event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS or \ - event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - print("%s - %s" % (msg.correlationIds()[0].value(), msg)) - else: - print(msg) - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - eventCount += 1 - if eventCount >= options.maxEvents: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleSubscriptionExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SimpleSubscriptionIntervalExample.py b/examples/SimpleSubscriptionIntervalExample.py deleted file mode 100644 index 283c148..0000000 --- a/examples/SimpleSubscriptionIntervalExample.py +++ /dev/null @@ -1,119 +0,0 @@ -# SimpleSubscriptionIntervalExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -import time -from optparse import OptionParser - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve realtime data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("--me", - dest="maxEvents", - type="int", - help="stop after this many events (default: %default)", - metavar="maxEvents", - default=1000000) - - (options, args) = parser.parse_args() - - return options - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/mktdata"): - print("Failed to open //blp/mktdata") - return - - security1 = "IBM US Equity" - security2 = "/cusip/912828GM6@BGN" - - subscriptions = blpapi.SubscriptionList() - subscriptions.add(security1, - "LAST_PRICE,BID,ASK", - "interval=1.0", - blpapi.CorrelationId(security1)) - subscriptions.add(security2, - "LAST_PRICE,BID,ASK,BID_YIELD,ASK_YIELD", - "interval=1.0", - blpapi.CorrelationId(security2)) - - session.subscribe(subscriptions) - - try: - # Process received events - eventCount = 0 - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - for msg in event: - if event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS or \ - event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - print("%s - %s" % (msg.correlationIds()[0].value(), msg)) - else: - print(msg) - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - eventCount += 1 - if eventCount >= options.maxEvents: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SimpleSubscriptionIntervalExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SubscriptionCorrelationExample.py b/examples/SubscriptionCorrelationExample.py deleted file mode 100644 index 0a472c2..0000000 --- a/examples/SubscriptionCorrelationExample.py +++ /dev/null @@ -1,123 +0,0 @@ -# SubscriptionCorrelationExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser - - -class GridWindow(object): - def __init__(self, name, securities): - self.name = name - self.securities = securities - - def processSecurityUpdate(self, msg, row): - topicName = self.securities[row] - print("%s:%s,%s" % (self.name, row, topicName)) - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve realtime data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("--me", - dest="maxEvents", - type="int", - help="stop after this many events (default: %default)", - metavar="maxEvents", - default=1000000) - - (options, args) = parser.parse_args() - - return options - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - # Create a Session - session = blpapi.Session(sessionOptions) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - if not session.openService("//blp/mktdata"): - print("Failed to open //blp/mktdata") - return - - securities = ["IBM US Equity", "VOD LN Equity"] - gridWindow = GridWindow("SecurityInfo", securities) - - subscriptions = blpapi.SubscriptionList() - for i, security in enumerate(securities): - subscriptions.add(security, - "LAST_PRICE", - "", - blpapi.CorrelationId(i)) - - session.subscribe(subscriptions) - - try: - # Process received events - eventCount = 0 - while(True): - # We provide timeout to give the chance to Ctrl+C handling: - event = session.nextEvent(500) - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - for msg in event: - row = msg.correlationIds()[0].value() - gridWindow.processSecurityUpdate(msg, row) - - eventCount += 1 - if eventCount >= options.maxEvents: - break - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SubscriptionCorrelationExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/SubscriptionWithEventHandlerExample.py b/examples/SubscriptionWithEventHandlerExample.py deleted file mode 100644 index 993fd16..0000000 --- a/examples/SubscriptionWithEventHandlerExample.py +++ /dev/null @@ -1,197 +0,0 @@ -# SubscriptionWithEventHandlerExample.py -from __future__ import print_function -from __future__ import absolute_import - -import blpapi -from optparse import OptionParser -import time - - -EXCEPTIONS = blpapi.Name("exceptions") -FIELD_ID = blpapi.Name("fieldId") -REASON = blpapi.Name("reason") -CATEGORY = blpapi.Name("category") -DESCRIPTION = blpapi.Name("description") -ERROR_INFO = blpapi.Name("ErrorInfo") - -class SubscriptionEventHandler(object): - def getTimeStamp(self): - return time.strftime("%Y/%m/%d %X") - - def processSubscriptionStatus(self, event): - timeStamp = self.getTimeStamp() - print("Processing SUBSCRIPTION_STATUS") - for msg in event: - topic = msg.correlationIds()[0].value() - print("%s: %s - %s" % (timeStamp, topic, msg.messageType())) - - if msg.hasElement(REASON): - # This can occur on SubscriptionFailure. - reason = msg.getElement(REASON) - if reason.elementDefinition().name() == ERROR_INFO: - print(" %s: %s" % ( - reason.getElement(CATEGORY).getValueAsString(), - reason.getElement(DESCRIPTION).getValueAsString())) - - if msg.hasElement(EXCEPTIONS): - # This can occur on SubscriptionStarted if at least - # one field is good while the rest are bad. - exceptions = msg.getElement(EXCEPTIONS) - for exInfo in exceptions.values(): - fieldId = exInfo.getElement(FIELD_ID) - reason = exInfo.getElement(REASON) - print(" %s: %s" % ( - fieldId.getValueAsString(), - reason.getElement(CATEGORY).getValueAsString())) - - def processSubscriptionDataEvent(self, event): - timeStamp = self.getTimeStamp() - print() - print("Processing SUBSCRIPTION_DATA") - for msg in event: - topic = msg.correlationIds()[0].value() - print("%s: %s - %s" % (timeStamp, topic, msg.messageType())) - for field in msg.asElement().elements(): - if field.numValues() < 1: - print(" %s is NULL" % field.name()) - continue - - # Assume all values are scalar. - print(" %s = %s" % (field.name(), - field.getValueAsString())) - - def processMiscEvents(self, event): - timeStamp = self.getTimeStamp() - for msg in event: - print("%s: %s" % (timeStamp, msg.messageType())) - - def processEvent(self, event, session): - try: - if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: - return self.processSubscriptionDataEvent(event) - elif event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS: - return self.processSubscriptionStatus(event) - else: - return self.processMiscEvents(event) - except blpapi.Exception as e: - print("Library Exception !!! %s" % e.description()) - return False - - -def parseCmdLine(): - parser = OptionParser(description="Retrieve realtime data.") - parser.add_option("-a", - "--ip", - dest="host", - help="server name or IP (default: %default)", - metavar="ipAddress", - default="localhost") - parser.add_option("-p", - dest="port", - type="int", - help="server port (default: %default)", - metavar="tcpPort", - default=8194) - parser.add_option("-t", - dest="topics", - help="topic name (default: IBM US Equity)", - metavar="topic", - action="append", - default=[]) - parser.add_option("-f", - dest="fields", - help="field to subscribe to (default: LAST_PRICE)", - metavar="field", - action="append", - default=[]) - parser.add_option("-o", - dest="options", - help="subscription options (default: empty)", - metavar="option", - action="append", - default=[]) - - (options, args) = parser.parse_args() - - if not options.topics: - options.topics = ["IBM US Equity"] - - if not options.fields: - options.fields = ["LAST_PRICE"] - - return options - - -def main(): - options = parseCmdLine() - - # Fill SessionOptions - sessionOptions = blpapi.SessionOptions() - sessionOptions.setServerHost(options.host) - sessionOptions.setServerPort(options.port) - - print("Connecting to %s:%d" % (options.host, options.port)) - - eventHandler = SubscriptionEventHandler() - # Create a Session - session = blpapi.Session(sessionOptions, eventHandler.processEvent) - - # Start a Session - if not session.start(): - print("Failed to start session.") - return - - print("Connected successfully") - - service = "//blp/mktdata" - if not session.openService(service): - print("Failed to open %s service" % service) - return - - subscriptions = blpapi.SubscriptionList() - for t in options.topics: - topic = service - if not t.startswith("/"): - topic += "/" - topic += t - subscriptions.add(topic, options.fields, options.options, - blpapi.CorrelationId(t)) - - print("Subscribing...") - session.subscribe(subscriptions) - - try: - # Wait for enter key to exit application - print("Press ENTER to quit") - input() - finally: - # Stop the session - session.stop() - -if __name__ == "__main__": - print("SubscriptionWithEventHandlerExample") - try: - main() - except KeyboardInterrupt: - print("Ctrl+C pressed. Stopping...") - -__copyright__ = """ -Copyright 2012. Bloomberg Finance L.P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: The above -copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/examples/demoapps/ApiFieldsExample.py b/examples/demoapps/ApiFieldsExample.py new file mode 100644 index 0000000..d20dcfd --- /dev/null +++ b/examples/demoapps/ApiFieldsExample.py @@ -0,0 +1,146 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) + +from snippets.apiflds import CategorizedFieldSearchRequests +from snippets.apiflds import FieldInfoRequests +from snippets.apiflds import FieldListRequests +from snippets.apiflds import FieldSearchRequests + +APIFLDS_SVC = "//blp/apiflds" + +CATEGORIZED_FIELD_SEARCH_REQUEST = "CategorizedFieldSearchRequest" +FIELD_INFO_REQUEST = "FieldInfoRequest" +FIELD_LIST_REQUEST = "FieldListRequest" +FIELD_SEARCH_REQUEST = "FieldSearchRequest" + + +def createRequest(requestType, session): + """Sends a request based on the request type.""" + + apifldsService = session.getService(APIFLDS_SVC) + if requestType == CATEGORIZED_FIELD_SEARCH_REQUEST: + return CategorizedFieldSearchRequests.createRequest(apifldsService) + + if requestType == FIELD_INFO_REQUEST: + return FieldInfoRequests.createRequest(apifldsService) + + if requestType == FIELD_LIST_REQUEST: + return FieldListRequests.createRequest(apifldsService) + + if requestType == FIELD_SEARCH_REQUEST: + return FieldSearchRequests.createRequest(apifldsService) + + +def processResponse(requestType, event): + """Processes a response to the request.""" + + if requestType == CATEGORIZED_FIELD_SEARCH_REQUEST: + return CategorizedFieldSearchRequests.processResponse(event) + + if requestType == FIELD_INFO_REQUEST: + return FieldInfoRequests.processResponse(event) + + if requestType == FIELD_LIST_REQUEST: + return FieldListRequests.processResponse(event) + + if requestType == FIELD_SEARCH_REQUEST: + return FieldSearchRequests.processResponse(event) + + +def main(): + parser = ArgumentParser( + description="Retrieve API data fields", + formatter_class=RawTextHelpFormatter, + ) + addConnectionAndAuthOptions(parser) + parser.add_argument( + "-r", + "--request", + dest="requestType", + help="API fields request type, choices are: %(choices)s", + required=True, + choices=[ + CATEGORIZED_FIELD_SEARCH_REQUEST, + FIELD_INFO_REQUEST, + FIELD_LIST_REQUEST, + FIELD_SEARCH_REQUEST, + ], + metavar="requestType", + ) + + options = parser.parse_args() + + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("apifields") + + session = blpapi.Session(sessionOptions) + + try: + if not session.start(): + print("Failed to start session.") + return + + if not session.openService(APIFLDS_SVC): + print(f"Failed to open {APIFLDS_SVC}.") + return + + request = createRequest(options.requestType, session) + print(f"Sending Request: {request}") + session.sendRequest(request) + + done = False + while not done: + event = session.nextEvent() + eventType = event.eventType() + if eventType == blpapi.Event.REQUEST_STATUS: + for msg in event: + if msg.messageType() == blpapi.Names.REQUEST_FAILURE: + # Request has failed, exit + print(msg) + done = True + break + elif eventType in [ + blpapi.Event.RESPONSE, + blpapi.Event.PARTIAL_RESPONSE, + ]: + processResponse(options.requestType, event) + + # Received the final response, no further response events are + # expected. + if eventType == blpapi.Event.RESPONSE: + done = True + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/BroadcastPublisherExample.py b/examples/demoapps/BroadcastPublisherExample.py new file mode 100644 index 0000000..68f607b --- /dev/null +++ b/examples/demoapps/BroadcastPublisherExample.py @@ -0,0 +1,270 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from util.MaxEventsOption import addMaxEventsOption + +from threading import Event +import time + +DEFAULT_MARKET_DATA_TOPIC = "IBM Equity" +DEFAULT_PAGE_TOPIC = "1245/4/5" + +MARKET_DATA_EVENTS = blpapi.Name("MarketDataEvents") +HIGH = blpapi.Name("HIGH") +LOW = blpapi.Name("LOW") +MESSAGE_TYPE_ROW_UPDATE = blpapi.Name("RowUpdate") +ROW_NUM = blpapi.Name("rowNum") +SPAN_UPDATE = blpapi.Name("spanUpdate") +START_COL = blpapi.Name("startCol") +LENGTH = blpapi.Name("length") +TEXT = blpapi.Name("text") + + +class MyStream(object): + def __init__(self, sid=""): + self.id = sid + + +class MyEventHandler(object): + def __init__(self, stop): + self.stop = stop + + def processEvent(self, event, _session): + for msg in event: + print(msg) + if event.eventType() == blpapi.Event.SESSION_STATUS: + if msg.messageType() == blpapi.Names.SESSION_TERMINATED: + print("Received session terminated, stopping session") + self.stop.set() + continue + + +def parseCmdLine(): + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Broadcast data publisher.", + ) + + addConnectionAndAuthOptions(parser) + + publisher_group = parser.add_argument_group("Broadcast Publisher Options") + publisher_group.add_argument( + "-s", + "--service", + dest="service", + help="the service name", + required=True, + metavar="service", + ) + publisher_group.add_argument( + "-t", + "--topic", + dest="topics", + help="topic to publish (default: " + f"{DEFAULT_MARKET_DATA_TOPIC}; or for page " + f"data {DEFAULT_PAGE_TOPIC})." + "Can be specified multiple times.", + metavar="topic", + action="append", + default=[], + ) + publisher_group.add_argument( + "-g", + "--group-id", + dest="groupId", + metavar="groupId", + help="publisher groupId (default to an " + "automatically generated unique value)", + ) + publisher_group.add_argument( + "-p", + "--priority", + dest="priority", + metavar="priority", + type=int, + help="publisher's priority (default: %(default)d)", + default=blpapi.ServiceRegistrationOptions.PRIORITY_HIGH, + ) + publisher_group.add_argument( + "--page", + dest="isPageData", + help="publish as page data", + action="store_true", + default=False, + ) + + addMaxEventsOption(parser) + + options = parser.parse_args() + + if not options.topics: + options.topics = ( + [DEFAULT_PAGE_TOPIC] + if options.isPageData + else [DEFAULT_MARKET_DATA_TOPIC] + ) + + return options + + +def formatMarketData(eventFormatter, topic): + # NOTE: This function demonstrates how to use `EventFormatter.fromPy` to + # format an `Event`. For an example of formatting an `Event` using the + # `Element`-based` interface of `EventFormatter`, see + # `InteractivePublisherExample.formatMarketDataEvent`. + eventFormatter.appendMessage(MARKET_DATA_EVENTS, topic) + + secondsStr = time.strftime("%S", time.localtime()) + seconds = int(secondsStr) + messageDict = {HIGH: seconds * 1.0, LOW: seconds * 0.5} + + eventFormatter.fromPy(messageDict) + + +def formatPageData(eventFormatter, topic): + # NOTE: This function demonstrates how to use the `Element`-based interface + # of `EventFormatter` to format an `Event`. For an example of formatting an + # `Event` using `EventFormatter.fromPy`, see + # `InteractivePublisherExample.formatPageEvent`. + numRows = 5 + for i in range(1, numRows + 1): + eventFormatter.appendMessage(MESSAGE_TYPE_ROW_UPDATE, topic) + eventFormatter.setElement(ROW_NUM, i) + eventFormatter.pushElement(SPAN_UPDATE) + eventFormatter.appendElement() + eventFormatter.setElement(START_COL, 1) + secondsStr = time.strftime("%S", time.localtime()) + eventFormatter.setElement(LENGTH, len(secondsStr)) + eventFormatter.setElement(TEXT, secondsStr) + eventFormatter.popElement() + + eventFormatter.popElement() + + +def main(): + options = parseCmdLine() + + stop = Event() + myEventHandler = MyEventHandler(stop) + + # Create a Session + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("broadcastpublisherexample") + session = blpapi.ProviderSession( + sessionOptions, myEventHandler.processEvent + ) + + # Start a Session + if not session.start(): + print("Failed to start session.") + return + + if options.groupId is not None: + # NOTE: perform explicit service registration here, instead + # of letting createTopics() do it, as the latter approach doesn't + # allow for custom ServiceRegistrationOptions. + serviceOptions = blpapi.ServiceRegistrationOptions() + serviceOptions.setGroupId(options.groupId) + serviceOptions.setServicePriority(options.priority) + if not session.registerService( + options.service, session.getAuthorizedIdentity(), serviceOptions + ): + print(f"Failed to register {options.service}") + session.stop() + return + + topicList = blpapi.TopicList() + for topic in options.topics: + userTopic = topic + if userTopic and not userTopic.startswith("/"): + userTopic = "/" + userTopic + topicList.add( + f"{options.service}{userTopic}", + blpapi.CorrelationId(MyStream(topic)), + ) + + # createTopics() is synchronous, topicList will be updated with the + # results of topic creation (resolution will happen under the covers) + session.createTopics( + topicList, blpapi.ProviderSession.AUTO_REGISTER_SERVICES + ) + + streams = [] + for i in range(topicList.size()): + stream = topicList.correlationIdAt(i).value() + status = topicList.statusAt(i) + topicString = topicList.topicStringAt(i) + + if status == blpapi.TopicList.CREATED: + print(f"Start publishing on topic: {topicString}") + stream.topic = session.getTopic(topicList.messageAt(i)) + streams.append(stream) + else: + print( + f"Stream '{stream.id}': topic not created, status = {status}" + ) + + service = session.getService(options.service) + + if not streams: + return + + try: + eventCount = 0 + + # Now we will start publishing + while not stop.is_set() and eventCount < options.maxEvents: + event = service.createPublishEvent() + eventFormatter = blpapi.EventFormatter(event) + + for stream in streams: + topic = stream.topic + if options.isPageData: + formatPageData(eventFormatter, topic) + else: + formatMarketData(eventFormatter, topic) + + print("Publishing event:") + for msg in event: + print(msg) + + session.publish(event) + eventCount += 1 + time.sleep(10) + finally: + # Stop the session + print("Stopping the session") + session.stop() + + +if __name__ == "__main__": + print("BroadcastPublisherExample") + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/ContributionsExample.py b/examples/demoapps/ContributionsExample.py new file mode 100644 index 0000000..a60b207 --- /dev/null +++ b/examples/demoapps/ContributionsExample.py @@ -0,0 +1,259 @@ +import time +from threading import Event +from argparse import ArgumentParser, RawTextHelpFormatter +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from util.MaxEventsOption import addMaxEventsOption + +MARKET_DATA = blpapi.Name("MarketData") +PAGE_DATA = blpapi.Name("PageData") +SESSION_TERMINATED = blpapi.Name("SessionTerminated") +BID = blpapi.Name("BID") +ASK = blpapi.Name("ASK") +ROW_UPDATE = blpapi.Name("rowUpdate") +ROW_NUM = blpapi.Name("rowNum") +SPAN_UPDATE = blpapi.Name("spanUpdate") +START_COL = blpapi.Name("startCol") +LENGTH = blpapi.Name("length") +TEXT = blpapi.Name("text") +ATTR = blpapi.Name("attr") +CONTRIBUTION_ID = blpapi.Name("contributorId") +PRODUCT_CODE = blpapi.Name("productCode") +PAGE_NUMBER = blpapi.Name("pageNumber") +DEFAULT_MKT_DATA_TOPIC = "/ticker/AUDEUR Curncy" +DEFAULT_PAGE_DATA_TOPIC = "/page/220/660/1" +DATETIME_FORMAT = "%m/%d/%Y %H:%M" + + +class MyEventHandler(object): + """Event handler for the session""" + + def __init__(self, stop): + """Construct a handler""" + self.stop = stop + + def processEvent(self, event, _sesssion): + """Process session event""" + + for msg in event: + print(msg) + if event.eventType() == blpapi.Event.SESSION_STATUS: + if msg.messageType() == SESSION_TERMINATED: + self.stop.set() + continue + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + description="Contribute market or page data to a topic", + formatter_class=RawTextHelpFormatter, + ) + addConnectionAndAuthOptions(parser) + addMaxEventsOption(parser) + + parser.add_argument( + "-s", + "--service", + dest="service", + help="service name (default: %(default)s)", + metavar="service", + default="//blp/mpfbapi", + ) + parser.add_argument( + "-t", + "--topic", + dest="topic", + help=f"topic to contribute (mktdata default: '{DEFAULT_MKT_DATA_TOPIC}'" + f", page default: '{DEFAULT_PAGE_DATA_TOPIC}')", + metavar="topic", + ) + + # Page contributions options + parser.add_argument( + "-P", + "--page", + dest="page_enabled", + action="store_true", + help="enable page contributions", + ) + parser.add_argument( + "-C", + "--contribution-id", + dest="contributionId", + help="contributor id (default: %(default)d), ignored unless page is enabled", + metavar="contributionId", + type=int, + default=8563, + ) + + options = parser.parse_args() + + if not options.topic: + options.topic = DEFAULT_MKT_DATA_TOPIC + if options.page_enabled: + options.topic = DEFAULT_PAGE_DATA_TOPIC + elif options.topic[0] != "/": + options.topic = f"/{options.topic}" + + return options + + +def formatMktDataEvent(eventFormatter, topic, value): + """Format a Mktdata event.""" + eventFormatter.appendMessage(MARKET_DATA, topic) + eventFormatter.setElement(BID, 0.5 * value) + eventFormatter.setElement(ASK, value) + + +def formatPageDataEvent(eventFormatter, topic, contributorId): + """Format a PageData event.""" + tm = time.strftime("%X") + messageDict = { + ROW_UPDATE: [ + { + ROW_NUM: 1, + SPAN_UPDATE: [ + {START_COL: 20, LENGTH: 4, TEXT: "TEST"}, + {START_COL: 25, LENGTH: 4, TEXT: "PAGE"}, + {START_COL: 30, LENGTH: len(tm), TEXT: tm, ATTR: "BLINK"}, + ], + }, + { + ROW_NUM: 2, + SPAN_UPDATE: [ + { + START_COL: 20, + LENGTH: 9, + TEXT: "---------", + ATTR: "UNDERLINE", + }, + ], + }, + { + ROW_NUM: 3, + SPAN_UPDATE: [ + { + START_COL: 10, + LENGTH: 9, + TEXT: "TEST LINE", + }, + { + START_COL: 23, + LENGTH: 5, + TEXT: "THREE", + }, + ], + }, + ], + CONTRIBUTION_ID: contributorId, + PRODUCT_CODE: 1, + PAGE_NUMBER: 1, + } + + eventFormatter.appendMessage(PAGE_DATA, topic) + eventFormatter.fromPy(messageDict) + + +def main(): + """Main function""" + + options = parseCmdLine() + + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("contributions") + + stop = Event() + myEventHandler = MyEventHandler(stop) + + # Create a Session + session = blpapi.ProviderSession( + sessionOptions, myEventHandler.processEvent + ) + + try: + # Start a Session + if not session.start(): + print("Failed to start session.") + return + + topicList = blpapi.TopicList() + topicList.add( + options.service + options.topic, + blpapi.CorrelationId(options.topic), + ) + + # Create topics + session.createTopics( + topicList, blpapi.ProviderSession.AUTO_REGISTER_SERVICES + ) + # createTopics() is synchronous, topicList will be updated + # with the results of topic creation (resolution will happen + # under the covers) + + status = topicList.statusAt(0) + + if status == blpapi.TopicList.CREATED: + topic = session.getTopic(topicList.messageAt(0)) + else: + print(f"Topic not resolved, status = {status}") + return + + service = session.getService(options.service) + + for i in range(int(options.maxEvents)): + if stop.is_set(): + break + + # Now we will start publishing + event = service.createPublishEvent() + eventFormatter = blpapi.EventFormatter(event) + + if options.page_enabled: + formatPageDataEvent( + eventFormatter, topic, options.contributionId + ) + else: + formatMktDataEvent(eventFormatter, topic, i) + + print(time.strftime("%X") + " -\nPublishing event: ") + for msg in event: + print(msg) + + session.publish(event) + time.sleep(10) + finally: + # Stop the session + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/EntitlementsVerificationRequestResponseExample.py b/examples/demoapps/EntitlementsVerificationRequestResponseExample.py new file mode 100644 index 0000000..db7b194 --- /dev/null +++ b/examples/demoapps/EntitlementsVerificationRequestResponseExample.py @@ -0,0 +1,324 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from blpapi import CorrelationId, Event, Name, Names, Session +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createClientServerSetupAuthOptions, + createSessionOptions, +) +from util.events.SessionRouter import SessionRouter +from threading import Event as ThreadingEvent +from time import sleep + +REFDATA_SVC_NAME = "//blp/refdata" + +RESPONSE_ERROR = Name("responseError") +SECURITY_DATA = Name("securityData") +SECURITY = Name("security") +EID_DATA = Name("eidData") +ENTITLEMENT_CHANGED = Name("EntitlementChanged") +SECURITIES = Name("securities") +FIELDS = Name("fields") +RETURN_EIDS = Name("returnEids") +SERVICE_NAME = Name("serviceName") + + +class EntitlementsVerificationRequestResponseExample: + def __init__(self, options): + self._options = options + self._router = SessionRouter() + self._exampleStoppedThreadingEvent = ThreadingEvent() + self._identitiesByCorrelationId = {} + self._responses = [] + self._finalResponseReceived = False + + self._router.addExceptionHandler(self._handleException) + + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTED, self._handleSessionStarted + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTUP_FAILURE, self._handleSessionStartupFailure + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_TERMINATED, self._handleSessionTerminated + ) + + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPENED, self._handleServiceOpened + ) + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPEN_FAILURE, self._handleServiceOpenFailure + ) + self._router.addMessageHandlerByMessageType( + ENTITLEMENT_CHANGED, self._handleEntitlementChanged + ) + + @property + def stopped(self): + return self._exampleStoppedThreadingEvent.is_set() + + def createAndStartSession(self): + # Use the specified application as the session identity to + # authorize. This may cause the session to stop and the example + # to terminate if the identity is revoked. + sessionOptions = createSessionOptions(self._options) + sessionOptions.setSessionName( + "entitlementsverificationrequestresponse" + ) + session = Session(sessionOptions, self._router.processEvent) + session.startAsync() + + def _stop(self, session): + # Cancel all the authorized identities + session.cancel(self._identitiesByCorrelationId.keys()) + session.stopAsync() + + def _handleException(self, session, _2, exception): + print(exception) + self._stop(session) + + def _handleSessionStarted(self, session, _1, _2): + # Add the authorization message handlers after the session + # started to only react to the authorization messages of users, + # i.e., avoid those of the session identity. + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_SUCCESS, self._handleAuthorizationSuccess + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_FAILURE, self._handleAuthorizationFailure + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_REVOKED, self._handleAuthorizationRevoked + ) + + self._authorizeUsers(session) + self._openServices(session) + + def _handleSessionStartupFailure(self, _1, _2, _3): + print("Failed to start session. Exiting...") + self._exampleStoppedThreadingEvent.set() + + def _handleSessionTerminated(self, _1, _2, _3): + print("Session terminated. Exiting...") + self._exampleStoppedThreadingEvent.set() + + @staticmethod + def _openServices(session): + session.openServiceAsync(REFDATA_SVC_NAME) + + def _handleServiceOpened(self, session, _1, message): + serviceName = message[SERVICE_NAME] + service = session.getService(serviceName) + + if serviceName == REFDATA_SVC_NAME: + self._sendRefDataRequest(session, service) + return + + def _handleServiceOpenFailure(self, session, _1, message): + serviceName = message[SERVICE_NAME] + if serviceName == REFDATA_SVC_NAME: + print(f"Failed to open service '{serviceName}', stopping...") + self._stop(session) + return + + raise RuntimeError(f"A unknown service failed to open: {serviceName}") + + def _sendRefDataRequest(self, session, refDataService): + request = refDataService.createRequest("ReferenceDataRequest") + requestDict = { + SECURITIES: self._options.securities, + FIELDS: ["PX_LAST", "DS002"], + RETURN_EIDS: True, + } + + request.fromPy(requestDict) + + print(f"Sending RefDataRequest {request}") + self._router.addEventHandlerByEventType( + Event.REQUEST_STATUS, self._processRequestStatus + ) + self._router.addEventHandlerByEventType( + Event.PARTIAL_RESPONSE, self._processPartialResponse + ) + self._router.addEventHandlerByEventType( + Event.RESPONSE, self._processResponse + ) + session.sendRequest(request, correlationId=CorrelationId("example")) + + def _processRequestStatus(self, session, event): + for message in event: + if message.messageType() == Names.REQUEST_FAILURE: + print("Request failed, stopping...") + self._stop(session) + + def _processPartialResponse(self, _, event): + # Save the response + self._responses.append(event) + print("Received partial response") + + def _processResponse(self, _, event): + print("Received final response") + self._finalResponseReceived = True + self._responses.append(event) + + # Distributes all the cached responses to the identities that have + # been authorized so far. + for ( + correlationId, + identity, + ) in self._identitiesByCorrelationId.items(): + userIdentifier = correlationId.value() + self._distributeResponses(userIdentifier, identity) + + def _authorizeUsers(self, session): + # Authorize each of the users + authOptionsByIdentifier = createClientServerSetupAuthOptions( + self._options + ) + for userIdentifier, authOptions in authOptionsByIdentifier.items(): + correlationId = blpapi.CorrelationId(userIdentifier) + session.generateAuthorizedIdentity(authOptions, correlationId) + + def _handleAuthorizationSuccess(self, session, _1, message): + correlationId = message.correlationId() + userIdentifier = correlationId.value() + print(f"Successfully authorized {userIdentifier}") + identity = session.getAuthorizedIdentity(correlationId) + self._identitiesByCorrelationId[correlationId] = identity + + if self._finalResponseReceived: + self._distributeResponses(userIdentifier, identity) + + def _handleAuthorizationFailure(self, _1, _2, message): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Failed to authorize {userIdentifier}") + + def _handleAuthorizationRevoked(self, _1, _2, message): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Authorization revoked for {userIdentifier}") + + # Remove the identity + self._identitiesByCorrelationId.pop(correlationId, None) + + def _handleEntitlementChanged(self, _1, _2, message): + # This is just informational. Continue to use existing identity. + correlationId = message.correlationId() + userIdentifier = correlationId.value() + print(f"Entitlements updated for {userIdentifier}") + + def _distributeResponses(self, userIdentifier, identity): + for event in self._responses: + self._distributeResponse(event, userIdentifier, identity) + + def _distributeResponse(self, event, userIdentifier, identity): + for msg in event: + if msg.hasElement(RESPONSE_ERROR, excludeNullElements=True): + continue + + service = msg.service() + securityDataElement = msg[SECURITY_DATA] + + print(f"Processing {securityDataElement.numValues()} securities:") + for securityData in securityDataElement: + ticker = securityData[SECURITY] + + if securityData.hasElement(EID_DATA, excludeNullElements=True): + # Entitlements are required to access this data + entitlements = securityData[EID_DATA] + + ( + entitled, + failedEntitlements, + ) = identity.getFailedEntitlements(service, entitlements) + if entitled: + print( + f"{userIdentifier} is entitled to get data " + f"for: {ticker}" + ) + + # Now Distribute message to the user. + else: + print( + f"{userIdentifier} is NOT entitled to get " + f"data for: {ticker} - Failed EIDs: {failedEntitlements}" + ) + else: + print(f"No entitlements are required for: {ticker}") + + # Now Distribute message to the user. + + +def parseCmdLine(): + parser = ArgumentParser( + description="Entitlements Verification Request/Response Example", + formatter_class=RawTextHelpFormatter, + ) + addConnectionAndAuthOptions(parser, forClientServerSetup=True) + + parser.add_argument( + "-S", + "--security", + dest="securities", + help="security used in ReferenceDataRequest (default:" + " IBM US Equity). Can be specified multiple times", + metavar="security", + action="append", + default=[], + ) + + options = parser.parse_args() + + if not options.securities: + options.securities.append("IBM US Equity") + + if not options.userIdAndIps and not options.tokens: + parser.error("No userId:IP or token specified") + + return options + + +def main(): + options = parseCmdLine() + + example = EntitlementsVerificationRequestResponseExample(options) + example.createAndStartSession() + + # The main thread is not blocked and the example is running asynchronously. + while not example.stopped: + sleep(1) + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/EntitlementsVerificationSubscriptionExample.py b/examples/demoapps/EntitlementsVerificationSubscriptionExample.py new file mode 100644 index 0000000..91658a6 --- /dev/null +++ b/examples/demoapps/EntitlementsVerificationSubscriptionExample.py @@ -0,0 +1,287 @@ +from argparse import ArgumentParser, RawTextHelpFormatter +from threading import Event as ThreadingEvent +import time + +from blpapi_import_helper import blpapi +from blpapi import AbstractSession, Message, Name, Names, Session, Event +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createClientServerSetupAuthOptions, + createSessionOptions, +) +from util.SubscriptionOptions import ( + addSubscriptionOptions, + createSubscriptionList, +) +from util.events.SessionRouter import SessionRouter + + +EID = Name("EID") +ENTITLEMENT_CHANGED = Name("EntitlementChanged") +SERVICE_NAME = Name("serviceName") + + +def parseCmdLine(): + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Entitlements verification subscription example", + ) + addConnectionAndAuthOptions(parser, forClientServerSetup=True) + addSubscriptionOptions(parser) + + options = parser.parse_args() + + if not options.userIdAndIps and not options.tokens: + parser.error("No userId:IP or token specified") + + if str(EID) not in options.fields: + options.fields.append(str(EID)) + + return options + + +class EntitlementsVerificationSubscriptionExample: + def __init__(self, options): + self._options = options + self._router = SessionRouter() + self._exampleStoppedThreadingEvent = ThreadingEvent() + self._identitiesByCorrelationId = {} + self._session = None + + self._router.addExceptionHandler(self._handleException) + + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTED, self._handleSessionStarted + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTUP_FAILURE, self._handleSessionStartupFailure + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_TERMINATED, self._handleSessionTerminated + ) + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPENED, self._handleServiceOpened + ) + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPEN_FAILURE, self._handleServiceOpenFailure + ) + self._router.addMessageHandlerByMessageType( + Name("EntitlementChanged"), self._handleEntitlementChanged + ) + + @property + def stopped(self): + return self._exampleStoppedThreadingEvent.is_set() + + def run(self): + self._createAndStartSession() + + def _createAndStartSession(self): + # Use the specified application as the session identity to authorize. + # This may cause the session to stop and the example to terminate if + # the identity is revoked. + sessionOptions = createSessionOptions(self._options) + sessionOptions.setSessionName("entitlementsverificationsubscription") + self._session = Session(sessionOptions, self._router.processEvent) + self._session.startAsync() + + def _openServices(self): + self._session.openServiceAsync(self._options.service) + + def _authorizeUsers(self): + # Authorize each of the users + authOptionsByIdentifier = createClientServerSetupAuthOptions( + self._options + ) + + for identifier, authOptions in authOptionsByIdentifier.items(): + cid = blpapi.CorrelationId(identifier) + self._session.generateAuthorizedIdentity(authOptions, cid) + + def _subscribe(self): + self._router.addEventHandlerByEventType( + blpapi.Event.SUBSCRIPTION_DATA, self._handleSubscriptionData + ) + self._router.addMessageHandlerByMessageType( + Names.SUBSCRIPTION_FAILURE, self._handleSubscriptionFailure + ) + self._router.addMessageHandlerByMessageType( + Names.SUBSCRIPTION_TERMINATED, self._handleSubscriptionTerminated + ) + + print("Subscribing...") + subscriptionList = createSubscriptionList(self._options) + self._session.subscribe(subscriptionList) + + def _handleException(self, _1, _2, exception: Exception): + print(exception) + self._stop() + + def _handleSessionStarted(self, *_): + # Add the authorization messages handlers after the session + # started to only react to the authorization messages of users, + # i.e., avoid those of the session identity. + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_SUCCESS, self._handleAuthorizationSuccess + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_FAILURE, self._handleAuthorizationFailure + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_REVOKED, self._handleAuthorizationRevoked + ) + + self._authorizeUsers() + self._openServices() + + def _handleSessionStartupFailure(self, *_): + print("Failed to start session. Exiting...") + self._exampleStoppedThreadingEvent.set() + + def _handleSessionTerminated(self, *_): + print("Session terminated. Exiting...") + self._exampleStoppedThreadingEvent.set() + + def _handleServiceOpened(self, _1, _2, message: Message): + serviceName = message.getElementAsString(SERVICE_NAME) + if serviceName == self._options.service: + self._subscribe() + else: + print(f"A service was opened: {serviceName}") + + def _stop(self): + # Cancel all the authorized identities + self._session.cancel(list(self._identitiesByCorrelationId.keys())) + + try: + self._session.stopAsync() + except InterruptedError as exc: + print(exc) + + def _handleServiceOpenFailure(self, _1, _2, message: Message): + serviceName = message.getElementAsString(SERVICE_NAME) + if serviceName == self._options.service: + self._stop() + else: + raise Exception( + f"A service which is unknown failed to open: {serviceName}" + ) + + @staticmethod + def _handleEntitlementChanged(_1, _2, message: Message): + # This is just informational. Continue to use existing identity. + correlationId = message.correlationId() + userIdentifier = correlationId.value() + print(f"Entitlements updated for {userIdentifier}") + + def _handleSubscriptionData(self, _, event: Event): + for message in event: + topic = message.correlationId().value() + + service = message.service() + + if message.hasElement(EID, excludeNullElements=True): + entitlements = message.getElement(EID) + + for cid, identity in self._identitiesByCorrelationId.items(): + userIdentifier = cid.value() + ( + isAuthorizedForAllEntitlements, + failedEntitlements, + ) = identity.getFailedEntitlements(service, entitlements) + if isAuthorizedForAllEntitlements: + print( + f"{userIdentifier} is entitled to get data for: {topic}" + ) + + # Now distribute the message to the user. + else: + print( + f"{userIdentifier} is NOT entitled to get data for: " + f"{topic} - Failed eids: {failedEntitlements}" + ) + + else: + print(f"No entitlements are required for: {topic}") + + # Now distribute the message to the authorized users. + + print() + + @staticmethod + def _handleSubscriptionFailure(_1, _2, message: Message): + topic = message.correlationId().value() + print(f"Subscription failed: {topic}") + + @staticmethod + def _handleSubscriptionTerminated(_1, _2, message: Message): + topic = message.correlationId().value() + print(f"Subscription terminated: {topic}") + + def _handleAuthorizationSuccess( + self, session: AbstractSession, _, message: Message + ): + correlationId = message.correlationId() + userIdentifier = correlationId.value() + print(f"Successfully authorized {userIdentifier}") + identity = session.getAuthorizedIdentity(correlationId) + self._identitiesByCorrelationId[correlationId] = identity + + # Deliver init paint to the user. For the purpose of simplicity, + # this example doesn't maintain an init paint cache. + + def _handleAuthorizationFailure(self, _1, _2, message: Message): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Failed to authorize {userIdentifier}") + + def _handleAuthorizationRevoked(self, _1, _2, message: Message): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Authorization revoked for {userIdentifier}: {message}") + + # Remove the identity + del self._identitiesByCorrelationId[correlationId] + + +def main(): + options = parseCmdLine() + + example = EntitlementsVerificationSubscriptionExample(options) + example.run() + + # The main thread is not blocked while the example runs asynchronously. + while not example.stopped: + time.sleep(1) + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/GenerateTokenExample.py b/examples/demoapps/GenerateTokenExample.py new file mode 100644 index 0000000..ec2d143 --- /dev/null +++ b/examples/demoapps/GenerateTokenExample.py @@ -0,0 +1,145 @@ +from argparse import Action, ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi + +AUTH_USER = "AuthenticationType=OS_LOGON" +AUTH_APP_PREFIX = "AuthenticationMode=APPLICATION_ONLY;ApplicationAuthenticationType=APPNAME_AND_KEY;ApplicationName=" +AUTH_USER_APP_PREFIX = "AuthenticationMode=USER_AND_APPLICATION;AuthenticationType=OS_LOGON;ApplicationAuthenticationType=APPNAME_AND_KEY;ApplicationName=" +AUTH_DIR_PREFIX = "AuthenticationType=DIRECTORY_SERVICE;DirSvcPropertyName=" + +AUTH_OPTION_USER = "user" +AUTH_OPTION_APP = "app" +AUTH_OPTION_USER_APP = "userapp" +AUTH_OPTION_DIR = "dir" + +TOKEN = blpapi.Name("token") + + +class AuthOptionsAction(Action): + """The action that parses authorization options from user input""" + + def __call__(self, parser, args, values, option_string=None): + vals = values.split("=", 1) + + authOptions = None + + if vals[0] == AUTH_OPTION_USER: + authOptions = AUTH_USER + elif vals[0] == AUTH_OPTION_APP and len(vals) == 2: + appName = vals[1] + authOptions = f"{AUTH_APP_PREFIX}{appName}" + elif vals[0] == AUTH_OPTION_USER_APP and len(vals) == 2: + appName = vals[1] + authOptions = f"{AUTH_USER_APP_PREFIX}{appName}" + elif vals[0] == AUTH_OPTION_DIR and len(vals) == 2: + dirProperty = vals[1] + authOptions = f"{AUTH_DIR_PREFIX}{dirProperty}" + else: + parser.error(f"Invalid auth option '{values}'") + + setattr(args, self.dest, authOptions) + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + description="Generate a token for a user to be used on the server side", + formatter_class=RawTextHelpFormatter, + ) + parser.add_argument( + "-H", + "--host", + required=True, + dest="ipAndPort", + help="Server name or IP and port separated by ':'", + metavar="host:port", + ) + parser.add_argument( + "-a", + "--auth", + required=True, + dest="authOptions", + help="Authentication option: \n" + " user as a user using OS logon information\n" + " dir= as a user using directory services\n" + " app= as the specified application\n" + " userapp= as user and application using logon information for the user\n", + metavar="option", + action=AuthOptionsAction, + ) + + options = parser.parse_args() + + ipAndPort = options.ipAndPort.split(":") + if len(ipAndPort) != 2: + parser.error(f"Invalid host '{options.ipAndPort}'") + + options.host = ipAndPort[0] + options.port = ipAndPort[1] + + return options + + +def main(): + options = parseCmdLine() + + sessionOptions = blpapi.SessionOptions() + sessionOptions.setServerHost(options.host) + sessionOptions.setServerPort(int(options.port)) + sessionOptions.setAuthenticationOptions(options.authOptions) + sessionOptions.setSessionName("generatetoken") + + print(f"Connecting to {options.host}:{options.port}") + session = blpapi.Session(sessionOptions) + try: + if not session.start(): + print("Failed to start session.") + return + + session.generateToken() + + while True: + event = session.nextEvent() + if event.eventType() != blpapi.Event.TOKEN_STATUS: + continue + + for msg in event: + msgType = msg.messageType() + if msgType == blpapi.Names.TOKEN_GENERATION_SUCCESS: + token = msg.getElementAsString(TOKEN) + print(f"Token is successfully generated: {token}") + elif msgType == blpapi.Names.TOKEN_GENERATION_FAILURE: + print(f"Failed to generate token: {msg}") + + break + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/InteractivePublisherExample.py b/examples/demoapps/InteractivePublisherExample.py new file mode 100644 index 0000000..794adbb --- /dev/null +++ b/examples/demoapps/InteractivePublisherExample.py @@ -0,0 +1,521 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +import threading +import time + +TOPIC_PERMISSIONS = blpapi.Name("topicPermissions") +RESOLVED_TOPIC = blpapi.Name("resolvedTopic") +TOPIC = blpapi.Name("topic") +TOPICS = blpapi.Name("topics") +UUID = blpapi.Name("uuid") +APPLICATION_ID = blpapi.Name("applicationId") +SUBSERVICE_CODE = blpapi.Name("subServiceCode") +RESULT = blpapi.Name("result") +REASON = blpapi.Name("reason") +SOURCE = blpapi.Name("source") +CATEGORY = blpapi.Name("category") +SUBCATEGORY = blpapi.Name("subcategory") +PERMISSIONS = blpapi.Name("permissions") +PERMISSION_SERVICE = blpapi.Name("permissionService") +DESCRIPTION = blpapi.Name("description") +EIDS = blpapi.Name("eids") +NUM_ROWS = blpapi.Name("numRows") +NUM_COLS = blpapi.Name("numCols") +MESSAGE_TYPE_ROW_UPDATE = blpapi.Name("RowUpdate") +ROW_UPDATE = blpapi.Name("rowUpdate") +ROW_NUM = blpapi.Name("rowNum") +SPAN_UPDATE = blpapi.Name("spanUpdate") +START_COL = blpapi.Name("startCol") +LENGTH = blpapi.Name("length") +TEXT = blpapi.Name("text") +OPEN = blpapi.Name("OPEN") +MARKET_DATA_EVENTS = blpapi.Name("MarketDataEvents") +HIGH = blpapi.Name("HIGH") +LOW = blpapi.Name("LOW") + + +class MyEventHandler(object): + def __init__( + self, + serviceName, + eids, + resolveSubServiceCode, + mutex, + stop, + condition, + isPageData, + ): + self.serviceName = serviceName + self.eids = eids + self.resolveSubServiceCode = resolveSubServiceCode + self.mutex = mutex + self.stop = stop + self.condition = condition + self.activeTopics = [] + self.isPageData = isPageData + + def processEvent(self, event, session): + eventType = event.eventType() + if eventType == blpapi.Event.SESSION_STATUS: + for msg in event: + print(msg) + if msg.messageType() == blpapi.Names.SESSION_TERMINATED: + print("Received session terminated, stopping session") + self.stop.set() + break + + elif eventType == blpapi.Event.TOPIC_STATUS: + self.processTopicStatusEvent(session, event) + + elif eventType == blpapi.Event.RESOLUTION_STATUS: + for msg in event: + print(msg) + + if msg.messageType() == blpapi.Names.RESOLUTION_SUCCESS: + resolvedTopic = msg.getElementAsString(RESOLVED_TOPIC) + print(f"ResolvedTopic: {resolvedTopic}") + elif msg.messageType() == blpapi.Names.RESOLUTION_FAILURE: + print( + "Topic resolution failed " + f"(CorrelationId = {msg.correlationId()})" + ) + + elif eventType == blpapi.Event.REQUEST: + for msg in event: + print(msg) + + if msg.messageType() == blpapi.Names.PERMISSION_REQUEST: + self.processPermissionRequest(session, msg) + else: + for msg in event: + print(msg) + + return True + + def processTopicStatusEvent(self, session, event): + topicsToCreate = blpapi.TopicList() + unsubscribedTopics = [] + for msg in event: + print(msg) + msgType = msg.messageType() + topic = session.getTopic(msg) + + if msgType == blpapi.Names.TOPIC_SUBSCRIBED: + if not topic.isValid(): + # Add the topic contained in the message to TopicList + topicsToCreate.add(msg) + + elif msgType == blpapi.Names.TOPIC_UNSUBSCRIBED: + unsubscribedTopics.append(topic) + with self.mutex: + self.activeTopics.remove(topic) + + elif msgType == blpapi.Names.TOPIC_ACTIVATED: + with self.mutex: + self.activeTopics.append(topic) + self.condition.notify_all() + + elif msgType == blpapi.Names.TOPIC_RECAP: + # Here we send a recap in response to a Recap request. + service = topic.service() + correlationId = msg.correlationId() + recapEvent = service.createPublishEvent() + eventFormatter = blpapi.EventFormatter(recapEvent) + eventFormatter.appendRecapMessage(topic, correlationId) + + if self.isPageData: + formatPageRecapEvent(eventFormatter) + else: + formatMarketDataRecapEvent(eventFormatter) + + session.publish(recapEvent) + print("Published recap event:") + for recapMsg in recapEvent: + print(recapMsg) + + if topicsToCreate.size() > 0: + # createTopicsAsync will result in RESOLUTION_SUCCESS and + # TOPIC_CREATED messages. + session.createTopicsAsync(topicsToCreate) + + # Delete all the unsubscribed topics. + if len(unsubscribedTopics) > 0: + session.deleteTopics(unsubscribedTopics) + + def processPermissionRequest(self, session, msg): + service = session.getService(self.serviceName) + + # Similar to createPublishEvent. We assume just one + # service - self.serviceName. A responseEvent can only be + # for single request so we can specify the correlationId - + # which establishes context - when we create the Event. + response = service.createResponseEvent(msg.correlationId()) + permission = 1 # ALLOWED: 0, DENIED: 1 + ef = blpapi.EventFormatter(response) + if msg.hasElement(UUID): + msg.getElementAsInteger(UUID) + permission = 0 + if msg.hasElement(APPLICATION_ID): + msg.getElementAsInteger(APPLICATION_ID) + permission = 0 + + # In appendResponse the string is the name of the + # operation, the correlationId indicates which request we + # are responding to. + ef.appendResponse(blpapi.Names.PERMISSION_RESPONSE) + ef.pushElement(TOPIC_PERMISSIONS) + + # For each of the topics in the request, add an entry to + # the response. + topicsElement = msg.getElement(TOPICS).values() + for topic in topicsElement: + ef.appendElement() + ef.setElement(TOPIC, topic) + if self.resolveSubServiceCode: + try: + ef.setElement(SUBSERVICE_CODE, self.resolveSubServiceCode) + print( + f"Mapping topic {topic} to subServiceCode" + f" {self.resolveSubServiceCode}" + ) + except blpapi.Exception: + print( + "subServiceCode could not be set." + " Resolving without subServiceCode" + ) + ef.setElement(RESULT, permission) + if permission == 1: # DENIED + ef.pushElement(REASON) + ef.setElement(SOURCE, "My Publisher Name") + ef.setElement(CATEGORY, "NOT_AUTHORIZED") + ef.setElement(SUBCATEGORY, "Publisher Controlled") + ef.setElement( + DESCRIPTION, "Permission denied by My Publisher Name" + ) + ef.popElement() + elif self.eids: + ef.pushElement(PERMISSIONS) + ef.appendElement() + ef.setElement(PERMISSION_SERVICE, "//blp/blpperm") + ef.pushElement(EIDS) + for eid in self.eids: + ef.appendValue(eid) + ef.popElement() + ef.popElement() + ef.popElement() + ef.popElement() + ef.popElement() + + # Service is implicit in the Event. sendResponse has a second parameter + # - partialResponse - that defaults to false. + session.sendResponse(response) + + +def formatPageRecapEvent(eventFormatter): + numRows = 5 + eventFormatter.setElement(NUM_ROWS, numRows) + eventFormatter.setElement(NUM_COLS, 80) + eventFormatter.pushElement(ROW_UPDATE) + + for i in range(1, numRows + 1): + eventFormatter.appendElement() + eventFormatter.setElement(ROW_NUM, i) + eventFormatter.pushElement(SPAN_UPDATE) + eventFormatter.appendElement() + eventFormatter.setElement(START_COL, 1) + eventFormatter.setElement(LENGTH, 10) + eventFormatter.setElement(TEXT, "RECAP") + eventFormatter.popElement() + eventFormatter.popElement() + eventFormatter.popElement() + + eventFormatter.popElement() + + +def formatMarketDataRecapEvent(eventFormatter): + eventFormatter.setElement(OPEN, 100.0) + + +def parseCmdLine(): + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Interactive data publisher.", + ) + addConnectionAndAuthOptions(parser) + + publisher_group = parser.add_argument_group("Publisher Options") + publisher_group.add_argument( + "-s", + "--service", + dest="service", + help="the service name", + required=True, + metavar="service", + ) + publisher_group.add_argument( + "-g", + "--group-id", + dest="groupId", + help="the group ID of the service, default to an " + "automatically generated unique value", + metavar="groupId", + ) + publisher_group.add_argument( + "-p", + "--priority", + type=int, + dest="priority", + help="the service priority (default: %(default)s)", + metavar="priority", + default=blpapi.ServiceRegistrationOptions.PRIORITY_HIGH, + ) + publisher_group.add_argument( + "--register-ssc", + dest="ssc", + help="specify active sub-service code range and " + "priority separated by ','", + metavar="begin,end,priority", + ) + publisher_group.add_argument( + "--clear-cache", + type=int, + dest="clearInterval", + help="number of events after which cache will be " + "cleared (default: 0 i.e cache never cleared)", + metavar="eventCount", + default=0, + ) + publisher_group.add_argument( + "--resolve-ssc", + dest="rssc", + type=int, + help="sub-service code to be used in permission response", + metavar="subServiceCode", + ) + publisher_group.add_argument( + "-E", + "--eid", + dest="eids", + type=int, + help="EIDs that are used in permission response. Can be specified multiple times.", + metavar="eid", + action="append", + default=[], + ) + publisher_group.add_argument( + "-P", + "--page", + dest="isPageData", + help="publish as page data", + action="store_true", + default=False, + ) + + options = parser.parse_args() + + # Parse sub-service code range and priority + if options.ssc: + options.sscBegin, options.sscEnd, options.sscPriority = map( + int, options.ssc.split(",") + ) + + return options + + +def activate(options, session): + if options.ssc: + print( + "Activating sub service code range [" + f"{options.sscBegin}, {options.sscEnd}] @ {options.sscPriority}" + ) + session.activateSubServiceCodeRange( + options.service, + options.sscBegin, + options.sscEnd, + options.sscPriority, + ) + + +def deactivate(options, session): + if options.ssc: + print( + "Deactivating sub service code range [" + f"{options.sscBegin}, {options.sscEnd}] @ {options.sscPriority}" + ) + session.deactivateSubServiceCodeRange( + options.service, options.sscBegin, options.sscEnd + ) + + +def main(): + options = parseCmdLine() + + mutex = threading.Lock() + stop = threading.Event() + condition = threading.Condition(mutex) + + myEventHandler = MyEventHandler( + options.service, + options.eids, + options.rssc, + mutex, + stop, + condition, + options.isPageData, + ) + + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("interactivepublisher") + session = blpapi.ProviderSession( + sessionOptions, myEventHandler.processEvent + ) + + if not session.start(): + print("Failed to start session.") + return + + serviceOptions = blpapi.ServiceRegistrationOptions() + if options.groupId is not None: + serviceOptions.setGroupId(options.groupId) + serviceOptions.setServicePriority(options.priority) + + if options.ssc: + print( + "Adding active sub-service code range [" + f"{options.sscBegin}, {options.sscEnd}] @ {options.sscPriority}" + ) + try: + serviceOptions.addActiveSubServiceCodeRange( + options.sscBegin, options.sscEnd, options.sscPriority + ) + except blpapi.Exception as exception: + print( + "FAILED to add active sub-service codes." + f" Exception {exception}" + ) + + try: + if not session.registerService( + options.service, session.getAuthorizedIdentity(), serviceOptions + ): + print(f"Failed to register '{options.service}'") + return + + service = session.getService(options.service) + eventCount = 0 + while not stop.is_set(): + with condition: + if not condition.wait_for( + lambda: len(myEventHandler.activeTopics) > 0, timeout=1 + ): + continue + + publishNull = False + if ( + options.clearInterval > 0 + and eventCount == options.clearInterval + ): + eventCount = 0 + publishNull = True + + event = service.createPublishEvent() + eventFormatter = blpapi.EventFormatter(event) + + with mutex: + for topic in myEventHandler.activeTopics: + if options.isPageData: + formatPageEvent(eventFormatter, topic, publishNull) + else: + formatMarketDataEvent( + eventFormatter, topic, publishNull + ) + + print("Publishing event:") + for msg in event: + print(msg) + + session.publish(event) + time.sleep(10) + eventCount += 1 + if eventCount % 10 == 0: + deactivate(options, session) + time.sleep(30) + activate(options, session) + + finally: + print("Stopping the session") + session.stop() + + +def formatMarketDataEvent(eventFormatter, topic, publishNull): + # NOTE: This function demonstrates how to use the `Element`-based interface + # of `EventFormatter` to format an `Event`. For an example of formatting an + # `Event` using `EventFormatter.fromPy`, see + # `BroadcastPublisherExample.formatMarketData`. + eventFormatter.appendMessage(MARKET_DATA_EVENTS, topic) + if publishNull: + eventFormatter.setElementNull(HIGH) + eventFormatter.setElementNull(LOW) + else: + secondsStr = time.strftime("%S", time.localtime()) + seconds = int(secondsStr) + eventFormatter.setElement(HIGH, seconds * 1.0) + eventFormatter.setElement(LOW, seconds * 0.5) + + +def formatPageEvent(eventFormatter, topic, publishNull): + # NOTE: This function demonstrates how to use `EventFormatter.fromPy` to + # format an `Event`. For an example of formatting an `Event` using the + # `Element`-based` interface of `EventFormatter`, see + # `BroadcastPublisherExample.formatPageData`. + numRows = 5 + for i in range(1, numRows + 1): + eventFormatter.appendMessage(MESSAGE_TYPE_ROW_UPDATE, topic) + + secondsStr = time.strftime("%S", time.localtime()) + messageDict = {ROW_NUM: i} + if publishNull: + messageDict[SPAN_UPDATE] = {} + else: + messageDict[SPAN_UPDATE] = [ + { + START_COL: 1, + LENGTH: len(secondsStr), + TEXT: secondsStr, + } + ] + + eventFormatter.fromPy(messageDict) + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/MultipleRequestsOverrideExample.py b/examples/demoapps/MultipleRequestsOverrideExample.py new file mode 100644 index 0000000..7121168 --- /dev/null +++ b/examples/demoapps/MultipleRequestsOverrideExample.py @@ -0,0 +1,131 @@ +from blpapi_import_helper import blpapi + +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from snippets.requestresponse import ReferenceDataRequests +from util.RequestOptions import Override, REFDATA_SERVICE +from collections import namedtuple +from argparse import ArgumentParser, RawTextHelpFormatter + + +def main(): + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Multiple requests with override example", + ) + addConnectionAndAuthOptions(parser) + cliOptions = parser.parse_args() + + sessionOptions = createSessionOptions(cliOptions) + sessionOptions.setSessionName("multiplerequestsoverride") + session = blpapi.Session(sessionOptions) + + try: + if not session.start(): + print("Failed to connect!") + return + + if not session.openService(REFDATA_SERVICE): + print(f"Failed to open {REFDATA_SERVICE}") + return + + service = session.getService(REFDATA_SERVICE) + + fieldIdVwapStartTime = "VWAP_START_TIME" + fieldIdVwapEndTime = "VWAP_END_TIME" + + Options = namedtuple("Options", ["securities", "fields", "overrides"]) + + # Request 1 + startTime1 = "9:30" + endTime1 = "11:30" + + options = Options( + ["IBM US Equity", "MSFT US Equity"], + ["PX_LAST", "DS002"], + [ + Override(fieldIdVwapStartTime, startTime1), + Override(fieldIdVwapEndTime, endTime1), + ], + ) + + request1 = ReferenceDataRequests.createRequest(service, options) + + print(f"Sending request 1: {request1}") + correlationId1 = blpapi.CorrelationId("request 1") + session.sendRequest(request1, correlationId=correlationId1) + + # Request 2 + startTime2 = "11:30" + endTime2 = "13:30" + + options.overrides.clear() + options.overrides.append(Override(fieldIdVwapStartTime, startTime2)) + options.overrides.append(Override(fieldIdVwapEndTime, endTime2)) + request2 = ReferenceDataRequests.createRequest(service, options) + + print(f"Sending request 2: {request2}") + correlationId2 = blpapi.CorrelationId("request 2") + session.sendRequest(request2, correlationId=correlationId2) + + # Wait for responses for both requests, expect 2 final responses + # either failure or success. + finalResponseCount = 0 + while finalResponseCount < 2: + event = session.nextEvent() + eventType = event.eventType() + for msg in event: + msgCorrelationId = msg.correlationId() + if eventType == blpapi.Event.REQUEST_STATUS: + if msg.messageType() == blpapi.Names.REQUEST_FAILURE: + if correlationId1 == msgCorrelationId: + print("Request 1 failed.") + elif correlationId2 == msgCorrelationId: + print("Request 2 failed.") + + finalResponseCount += 1 + elif eventType in [ + blpapi.Event.RESPONSE, + blpapi.Event.PARTIAL_RESPONSE, + ]: + if correlationId1 == msgCorrelationId: + print("Received response for request 1") + elif correlationId2 == msgCorrelationId: + print("Received response for request 2") + + if eventType == blpapi.Event.RESPONSE: + finalResponseCount += 1 + + print(msg) + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/README.md b/examples/demoapps/README.md new file mode 100644 index 0000000..ed21474 --- /dev/null +++ b/examples/demoapps/README.md @@ -0,0 +1,234 @@ +# BLPAPI Examples +| Example | Keywords | +|---------|----------| +| [ApiFieldsExample](#apifieldsexample) | `apiflds`, `fields`, `request` | +| [BroadcastPublisherExample](#broadcastpublisherexample) | `publisher` | +| [ContributionsExample](#contributionsexample) | `contributions` | +| [EntitlementsVerificationSubscriptionExample](#entitlementsverificationsubscriptionexample) | `asynchronous`, `subscription`, `client-server` | +| [EntitlementsVerificationRequestResponseExample](#entitlementsverificationrequestresponseexample) | `asynchronous`, `request`, `client-server` | +| [GenerateTokenExample](#generatetokenexample) | `token`, `client-server` | +| [InteractivePublisherExample](#interactivepublisherexample) | `publisher` | +| [MultipleRequestsOverrideExample](#multiplerequestsoverrideexample) | `request`, `overrides` | +| [RequestResponseExample](#requestresponseexample) | `request`, `refdata`, `overrides`, `historical`, `intraday` | +| [RequestServiceConsumerExample](#requestserviceconsumerexample) | `request`, `custom service` | +| [RequestServiceProviderExample](#requestserviceproviderexample) | `response`, `custom service` | +| [SecurityLookupExample](#securitylookupexample) | `request`, `instruments` | +| [SnapshotRequestTemplateExample](#snapshotrequesttemplateexample) | `snapshot`, `subscription` | +| [SubscriptionExample](#subscriptionexample) | `asynchronous`, `subscription` | +| [SubscriptionWithEventPollingExample](#subscriptionwitheventpollingexample) | `synchronous`, `subscription` | +| [UserModeExample](#usermodeexample) | `asynchronous`, `request`, `client-server` | + + +## ApiFieldsExample +--- +Sends a request for the fields available for accessing market data and reference data. + +#### Useful for + +- Discovering available fields when subscribing to market data or making requests for reference data. + +#### Sample Arguments + +`-H : --auth --request ` + +There are 4 types of requests: CategorizedFieldSearchRequest, FieldInfoRequest, FieldListRequest, and FieldSearchRequest. + +## BroadcastPublisherExample +--- +Demonstrates a broadcast publisher that publishes data regardless of whether there are active subscriptions or not. By default, market data is published. Page data can be published with the `--page` option. + +#### Useful for + +- Creating services that publish data regardless of whether there are active subscriptions, e.g. alerting + +#### Sample Arguments +`-H : -s --auth ` + +`-H : -s --auth --page --max-events ` + +## ContributionsExample +--- +Demonstrates contributing your own data to Bloomberg. + +#### Sample Arguments +`-H -s --auth ` + +Contribute page data by adding the flag `--page` + +## EntitlementsVerificationSubscriptionExample +--- +Subscribes to data and redistributes it to entitled users, all in an asychronous manner. + +#### Useful for + +- Using the SDK asynchronously (with an Event Handler) +- Creating a client-server setup +- Getting data once and fanning it out to other users + +#### Sample Arguments +`-H --auth -u -u --token= -f BID -f ASK` + +## EntitlementsVerificationRequestResponseExample +--- +An asynchronous redistribution example where an app requests data and redistributes the response to entitled users. + +#### Useful for + +- Using the SDK asynchronously (with an Event Handler) +- Creating a client-server setup +- Getting data once and fanning it out to other users + +#### Sample Arguments +`-H --auth -S -u -S -u -u -T ` + +## GenerateTokenExample +--- +Generates a token for a user. This token can be used for authorization. For example, once generated, the token can be used in the above Entitlements examples. + +#### Useful for + +- Generating a token that can be used to authorize a user on the server side + + +#### Sample Arguments +`--host --auth ` + +## InteractivePublisherExample +--- +Demonstrates a publisher that only publishes data when there are active subscriptions. By default, publishes market data. Pass the `--page` option to publish page data. + + +#### Sample Arguments +`-H -s --auth --register-ssc 0,5,1` + +Publish page data with the `--page` flag + +## MultipleRequestsOverrideExample +--- +Demonstrates how to send requests with different overrides and correlate them to responses using `CorrelationId`. + +#### Useful for + +- Keeping track of multiple requests sent at the same time. + +#### Sample Arguments +Note: Can be run with no arguments + +`-H --auth ` + +## RequestResponseExample +--- +Demonstrates how to make a request and process a response. By default, the service used is `//blp/refdata`, but can be set to any variation of `//blp/refdata`, such as `//blp/staticmktdata`. + + +#### Sample Arguments +Note: Can be run without arguments + +`-r ` + +There are 4 request types: `ReferenceDataRequest`, `ReferenceDataRequestOverride`, `ReferenceDataRequestTableOverride`, and `HistoricalDataRequest`. + +## RequestServiceConsumerExample +--- +Demonstrates the client side of a request/response setup. Works in conjunction with `RequestServiceProviderExample`. + + +#### Sample Arguments +`-H --auth ` + + +## RequestServiceProviderExample +--- +Demonstrates the server side of a request/response setup. A ProviderSession registers as a service and responds to client requests. This is in contrast with a pub-sub model. Works in conjunction with `RequestServiceConsumerExample`. + + +#### Sample Arguments +`-H --auth ` + +## SecurityLookupExample +--- +Demonstrates how to use the Bloomberg Instruments service to look up details about securities. + + +#### Sample Arguments +There are 3 request types: `instrumentListRequest`, `curveListRequest`, `govtListRequest`. For each request type, the user can specify filters i.e., search conditions. + +Instrument List (Default): + +`-S AAPL -F yellowKeyFilter=YK_FILTER_EQTY` + +Curve List: + +`-r curveListRequest -S GOOG -F countryCode=US` + +Govt List: + +`-r govtListRequest -S GOOG -F countryCode=US` + + +## SnapshotRequestTemplateExample +--- +Demonstrates how to make snapshot requests. Snapshots are made by first creating a snapshot template, then sending requests using the template. +This example also batch processes the snapshot templates (batch size is set to 50) because requests are throttled in the infrastructure. + +#### Useful for + +- Getting a "snapshot" of subscription data without having to process real-time ticks + +#### Sample Arguments +`-H -s //blp/mktdata --auth -t "/ticker/SPY US Equity" -f ASK -f BID -f LAST_PRICE -t "/ticker/MSFT US Equity` + +## SubscriptionExample +--- +Demonstrates how to make subscriptions. Handles data asynchronously, using a session with an event handler. Also demonstrates various subscription-related messages, e.g., `SlowConsumerWarning`, `SlowConsumerWarningCleared`, and `DataLoss`. + +Can be used to subscribe to data published by other examples, like `InteractivePublisherExample`. + +#### Useful for +- Using BLPAPI asynchronously, processing events with an event handler (see `SubscriptionWithEventPollingExample` for synchronous usage) + + +#### Sample Arguments +Note: Can be run without arguments + +`-H -a -t "/ticker/IBM US Equity` + +## SubscriptionWithEventPollingExample +--- +Demonstrates how to make subscriptions. Handles data synchronously. + +Can be used to subscribe to data published by other examples, like `InteractivePublisherExample`. + +#### Useful for +- Using the BLPAPI synchronously, processing events with `session.nextEvent()` (see `SubscriptionExample` for the recommended asynchronous usage) + + +#### Sample Arguments +Note: Can be run without arguments + +`-H -s //blp/mktdata -f LAST_PRICE -f BID -t "/ticker/SPY US Equity" -t "/ticker/IBM US Equity" --auth --max-events 2` + +## UserModeExample +--- +An asynchronous identity pass-through example where an app requests data on behalf of users. + +#### Useful for + +- Creating a client-server setup +- Relying on Bloomberg's backend to check entitlements, rather than using an application to check entitlements + +#### Sample Arguments +`-H --auth -u -T -u -u -S "IBM US Equity"` + +## Examples Subdirectories +The above examples have some shared code refactored into the subdirectories `Snippets` and `Util`. These subdirectories contain code with the following functionality: + +#### Snippets +- Creating and sending requests +- Processing responses + +#### Util +- Creating `SessionOptions` +- Creating `SubscriptionList`s +- Creating subscription strings for snapshot request templates +- Handling command-line arguments diff --git a/examples/demoapps/RequestResponseExample.py b/examples/demoapps/RequestResponseExample.py new file mode 100644 index 0000000..daae611 --- /dev/null +++ b/examples/demoapps/RequestResponseExample.py @@ -0,0 +1,234 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi + +from snippets.requestresponse import IntradayTickRequests +from snippets.requestresponse import IntradayBarRequests +from snippets.requestresponse import ReferenceDataRequests +from snippets.requestresponse import HistoricalDataRequest +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from util.RequestOptions import ( + addRequestOptions, + setDefaultValues, + REFERENCE_DATA_REQUEST_TABLE_OVERRIDE, + REFERENCE_DATA_REQUEST_OVERRIDE, + INTRADAY_BAR_REQUEST, + INTRADAY_TICK_REQUEST, + REFERENCE_DATA_REQUEST, + HISTORICAL_DATA_REQUEST, +) + +SERVICE_NAME = blpapi.Name("serviceName") +REASON = blpapi.Name("reason") + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Request/Response Example", + ) + addConnectionAndAuthOptions(parser) + addRequestOptions(parser) + + options = parser.parse_args() + setDefaultValues(options) + + return options + + +def processGenericEvent(event): + """Prints the messages in the event.""" + + # When using a session identity, token generation + # failure, authorization failure or revocation terminates + # the session, in which case, applications only need to + # check session status messages. Applications don't need + # to handle token or authorization messages, which are + # still printed. Will return True if session has failed + # to start or is terminated. False will be returned if otherwise. + + eventType = event.eventType() + for msg in event: + print(msg) + messageType = msg.messageType() + if eventType == blpapi.Event.SESSION_STATUS: + if ( + messageType == blpapi.Names.SESSION_TERMINATED + or messageType == blpapi.Names.SESSION_STARTUP_FAILURE + ): + print("Session failed to start or terminated.") + printContactSupportMessage(msg) + return True + elif eventType == blpapi.Event.SERVICE_STATUS: + if messageType == blpapi.Names.SERVICE_OPEN_FAILURE: + serviceName = msg.getElementAsString(SERVICE_NAME) + print(f"Failed to open {serviceName}") + printContactSupportMessage(msg) + + return False + + +def checkFailures(session): + """Checks failure events published by the session.""" + + # Note that the loop uses `Session.tryNextEvent()` as all events have + # been produced before calling this function, but there could be no events + # at all in the queue if the OS fails to allocate resources. + + while True: + event = session.tryNextEvent() + if event is None: + break + if processGenericEvent(event): + break + + +def printContactSupportMessage(msg): + """Prints RequestId associated with a Message""" + + # Messages can have an associated RequestId + # that is used to identify operations (related to them) + # through the network. + + requestId = msg.getRequestId() + if requestId is not None: + print(f"When contacting support, please provide RequestId {requestId}") + + +def sendRequest(options, session): + """Sends a request based on the request type.""" + service = session.getService(options.service) + requestType = options.requestType + request = None + if requestType == INTRADAY_BAR_REQUEST: + request = IntradayBarRequests.createRequest(service, options) + elif requestType == INTRADAY_TICK_REQUEST: + request = IntradayTickRequests.createRequest(service, options) + elif requestType in [ + REFERENCE_DATA_REQUEST, + REFERENCE_DATA_REQUEST_OVERRIDE, + ]: + request = ReferenceDataRequests.createRequest(service, options) + elif requestType == REFERENCE_DATA_REQUEST_TABLE_OVERRIDE: + request = ReferenceDataRequests.createTableOverrideRequest( + service, options + ) + elif requestType == HISTORICAL_DATA_REQUEST: + request = HistoricalDataRequest.createRequest(service, options) + + # Every request has a RequestId, which is automatically generated, and + # used to identify the operation through the network and also present + # in the response messages. The RequestId should be provided when + # contacting support. + print(f"Sending Request {request.getRequestId()}: {request}") + session.sendRequest(request, None) # correlationId + + +def waitForResponse(session, requestType): + """Waits for response after sending the request""" + + # Success response can come with a number of + # PARTIAL_RESPONSE events followed by a RESPONSE event. + # Failures will be delivered in a REQUEST_STATUS event + # holding a REQUEST_FAILURE message. + + done = False + while not done: + event = session.nextEvent() + eventType = event.eventType() + if eventType == blpapi.Event.PARTIAL_RESPONSE: + print("Processing Partial Response") + processResponseEvent(event, requestType) + elif eventType == blpapi.Event.RESPONSE: + print("Processing Response") + processResponseEvent(event, requestType) + done = True + elif eventType == blpapi.Event.REQUEST_STATUS: + for msg in event: + print(msg) + if msg.messageType == blpapi.Names.REQUEST_FAILURE: + reason = msg.getElement(REASON) + print(f"Request failed: {reason}") + printContactSupportMessage(msg) + done = True + else: + # SESSION_STATUS events can happen at any time and should be + # handled as the session can be terminated, e.g. + # session identity can be revoked at a later time, which + # terminates the session. + done = processGenericEvent(event) + + +def processResponseEvent(event, requestType): + """Processes a response to the request.""" + if requestType == INTRADAY_BAR_REQUEST: + IntradayBarRequests.processResponseEvent(event) + elif requestType == INTRADAY_TICK_REQUEST: + IntradayTickRequests.processResponseEvent(event) + elif requestType in [ + REFERENCE_DATA_REQUEST, + REFERENCE_DATA_REQUEST_OVERRIDE, + REFERENCE_DATA_REQUEST_TABLE_OVERRIDE, + ]: + ReferenceDataRequests.processResponseEvent(event) + elif requestType == HISTORICAL_DATA_REQUEST: + HistoricalDataRequest.processResponseEvent(event) + + +def main(): + """Main function""" + + options = parseCmdLine() + + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("requestresponse") + session = blpapi.Session(sessionOptions) + + try: + if not session.start(): + checkFailures(session) + print("Failed to start session.") + return + + if not session.openService(options.service): + checkFailures(session) + return + + sendRequest(options, session) + waitForResponse(session, options.requestType) + + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/RequestServiceConsumerExample.py b/examples/demoapps/RequestServiceConsumerExample.py new file mode 100644 index 0000000..6ec4898 --- /dev/null +++ b/examples/demoapps/RequestServiceConsumerExample.py @@ -0,0 +1,110 @@ +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from argparse import ArgumentParser, RawTextHelpFormatter +import time + +SERVICE = "//example/refdata" +TIMESTAMP = blpapi.Name("timestamp") +FIELDS = blpapi.Name("fields") +SECURITIES = blpapi.Name("securities") + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Request service consumer example, to be used in " + "conjunction with RequestServiceProviderExample", + ) + addConnectionAndAuthOptions(parser) + options = parser.parse_args() + return options + + +def main(): + options = parseCmdLine() + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("requestserviceconsumer") + session = blpapi.Session(sessionOptions) + + try: + if not session.start(): + print("Failed to start session.") + return + + if not session.openService(SERVICE): + print(f"Failed to open {SERVICE}") + return + + service = session.getService(SERVICE) + request = service.createRequest("ReferenceDataRequest") + + # Add securities to request + securitiesElement = request.getElement(SECURITIES) + securitiesElement.appendValue("IBM US Equity") + securitiesElement.appendValue("MSFT US Equity") + + # Add fields to request + fieldsElement = request.getElement(FIELDS) + fieldsElement.appendValue("PX_LAST") + fieldsElement.appendValue("DS002") + + # Set time stamp + request.set(TIMESTAMP, time.time()) + + print(f"Sending Request: {request}") + + session.sendRequest(request) + + done = True + while done: + event = session.nextEvent() + + for msg in event: + if msg.messageType() == blpapi.Names.REQUEST_FAILURE: + print("Request failed!") + done = False + break + if msg.hasElement(TIMESTAMP): + responseTime = msg.getElementAsFloat(TIMESTAMP) + print(f"Response latency = {time.time() - responseTime}") + print(msg) + + if event.eventType() == blpapi.Event.RESPONSE: + break + + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/RequestServiceProviderExample.py b/examples/demoapps/RequestServiceProviderExample.py new file mode 100644 index 0000000..0b67b0f --- /dev/null +++ b/examples/demoapps/RequestServiceProviderExample.py @@ -0,0 +1,147 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) + +import time + +SERVICE = "//example/refdata" +SESSION_TERMINATED = blpapi.Name("SessionTerminated") +REFERENCE_DATA_REQUEST = blpapi.Name("ReferenceDataRequest") +TIMESTAMP = blpapi.Name("timestamp") +FIELD_DATA = blpapi.Name("fieldData") +FIELD_ID = blpapi.Name("fieldId") +FIELDS = blpapi.Name("fields") +SECURITY = blpapi.Name("security") +SECURITIES = blpapi.Name("securities") +SECURITY_DATA = blpapi.Name("securityData") +DATA = blpapi.Name("data") +DOUBLE_VALUE = blpapi.Name("doubleValue") + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Request service provider example, to be used in " + "conjunction with RequestServiceConsumerExample", + ) + addConnectionAndAuthOptions(parser) + options = parser.parse_args() + return options + + +def processEvent(event, session): + print("Server received an event") + + if event.eventType() == blpapi.Event.REQUEST: + service = session.getService(SERVICE) + for msg in event: + print(msg) + + if msg.messageType() == REFERENCE_DATA_REQUEST: + if msg.hasElement(TIMESTAMP): + requestTime = msg.getElementAsFloat(TIMESTAMP) + latency = time.time() - requestTime + print(f"Request latency = {latency}") + + # A response event must contain only one response + # message and attach the correlation ID of the request + # message. + response = service.createResponseEvent(msg.correlationId()) + ef = blpapi.EventFormatter(response) + + # The parameter of EventFormatter.appendResponse(Name) + # is the name of the operation instead of the response. + ef.appendResponse(REFERENCE_DATA_REQUEST) + securities = msg.getElement(SECURITIES) + fields = msg.getElement(FIELDS) + ef.setElement(TIMESTAMP, time.time()) + ef.pushElement(SECURITY_DATA) + for security in securities.values(): + ef.appendElement() + ef.setElement(SECURITY, security) + ef.pushElement(FIELD_DATA) + + for field in fields.values(): + ef.appendElement() + ef.setElement(FIELD_ID, field) + ef.pushElement(DATA) + ef.setElement(DOUBLE_VALUE, time.time()) + ef.popElement() + ef.popElement() + + ef.popElement() + ef.popElement() + + ef.popElement() + + print("Publishing Response") + for responseMsg in response: + print(responseMsg) + session.sendResponse(response) + + print("Waiting for requests..., Press ENTER to quit") + + else: + for msg in event: + print(msg) + + return True + + +def main(): + options = parseCmdLine() + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("requestserviceprovider") + + providerSession = blpapi.ProviderSession(sessionOptions, processEvent) + + try: + if not providerSession.start(): + print("Failed to start session.") + return + + if not providerSession.registerService(SERVICE): + print(f"Failed to register {SERVICE}") + return + + # wait for enter key to exit application + print("Press ENTER to quit") + input() + + finally: + providerSession.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/SecurityLookupExample.py b/examples/demoapps/SecurityLookupExample.py new file mode 100644 index 0000000..e3b2255 --- /dev/null +++ b/examples/demoapps/SecurityLookupExample.py @@ -0,0 +1,231 @@ +from argparse import Action, ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi + +from snippets.instruments import CurveListRequests +from snippets.instruments import GovtListRequests +from snippets.instruments import InstrumentListRequests +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from collections import namedtuple + +INSTRUMENT_SERVICE = "//blp/instruments" + +INSTRUMENT_LIST_REQUEST = "instrumentListRequest" +CURVE_LIST_REQUEST = "curveListRequest" +GOVT_LIST_REQUEST = "govtListRequest" + +FILTERS_INSTRUMENTS = ["yellowKeyFilter", "languageOverride"] +FILTERS_GOVT = ["ticker", "partialMatch"] +FILTERS_CURVE = [ + "countryCode", + "currencyCode", + "type", + "subtype", + "curveid", + "bbgid", +] + +REQUEST_FAILURE = blpapi.Name("RequestFailure") +SESSION_TERMINATED = blpapi.Name("SessionTerminated") +SESSION_STARTUP_FAILURE = blpapi.Name("SessionStartupFailure") +SERVICE_OPEN_FAILURE = blpapi.Name("ServiceOpenFailure") + +# Defines a filter that is used in a //blp/instruments request. +InstrumentsFilter = namedtuple("InstrumentsFilter", ["name", "value"]) + + +class FilterAction(Action): + """The action that parses filter options from user input""" + + def __call__(self, parser, args, values, option_string=None): + vals = values.split("=", 1) + if len(vals) != 2: + parser.error(f"Invalid filter option '{values}'") + + filters = getattr(args, self.dest) + filters.append(InstrumentsFilter(blpapi.Name(vals[0]), vals[1])) + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Security Lookup Example", + ) + + addConnectionAndAuthOptions(parser) + + lookup_group = parser.add_argument_group("Security Lookup Options") + lookup_group.add_argument( + "-r", + "--request", + dest="requestType", + choices=[ + INSTRUMENT_LIST_REQUEST, + CURVE_LIST_REQUEST, + GOVT_LIST_REQUEST, + ], + help="specify the request type (default: %(default)s)", + metavar="requestType", + default=INSTRUMENT_LIST_REQUEST, + ) + lookup_group.add_argument( + "-S", + "--security", + dest="query", + help="security query string", + metavar="security", + ) + lookup_group.add_argument( + "--max-results", + dest="maxResults", + help="max results returned in the response (default: %(default)d)", + metavar="maxResults", + type=int, + default=10, + ) + lookup_group.add_argument( + "-F", + "--filter", + dest="filters", + help=f"""filter and value separated by '=', e.g., countryCode=US. Can be specified multiple times. +The applicable filters for each request: +{INSTRUMENT_LIST_REQUEST}: {FILTERS_INSTRUMENTS} +{CURVE_LIST_REQUEST} : {FILTERS_CURVE} +{GOVT_LIST_REQUEST} : {FILTERS_GOVT}""", + metavar="=", + action=FilterAction, + default=[], + ) + + options = parser.parse_args() + + return options + + +def sendRequest(options, session): + """Sends a request based on the request type.""" + instrumentsService = session.getService(INSTRUMENT_SERVICE) + requestType = options.requestType + request = None + if requestType == CURVE_LIST_REQUEST: + request = CurveListRequests.createRequest( + instrumentsService, + options.query, + options.maxResults, + options.filters, + ) + elif requestType == GOVT_LIST_REQUEST: + request = GovtListRequests.createRequest( + instrumentsService, + options.query, + options.maxResults, + options.filters, + ) + elif requestType == INSTRUMENT_LIST_REQUEST: + request = InstrumentListRequests.createRequest( + instrumentsService, + options.query, + options.maxResults, + options.filters, + ) + + print(f"Sending Request {request}") + session.sendRequest(request) + + +def waitForResponse(session, requestType): + """Waits for response after sending the request""" + + # Success response can come with a number of PARTIAL_RESPONSE events + # followed by a RESPONSE event. + # Failures will be delivered in a REQUEST_STATUS event holding a + # REQUEST_FAILURE message. + + done = False + while not done: + event = session.nextEvent() + eventType = event.eventType() + if eventType == blpapi.Event.PARTIAL_RESPONSE: + print("Processing Partial Response") + processResponseEvent(event, requestType) + elif eventType == blpapi.Event.RESPONSE: + print("Processing Response") + processResponseEvent(event, requestType) + done = True + elif eventType == blpapi.Event.REQUEST_STATUS: + for msg in event: + if msg.messageType() == REQUEST_FAILURE: + print(f"Request failed: {msg}") + done = True + else: + for msg in event: + print(msg) + if eventType == blpapi.Event.SESSION_STATUS: + if msg.messageType() == SESSION_TERMINATED: + done = True + + +def processResponseEvent(event, requestType): + """Processes a response to the request.""" + if requestType == CURVE_LIST_REQUEST: + CurveListRequests.processResponse(event) + elif requestType == GOVT_LIST_REQUEST: + GovtListRequests.processResponse(event) + elif requestType == INSTRUMENT_LIST_REQUEST: + InstrumentListRequests.processResponse(event) + + +def main(): + """Main function""" + + options = parseCmdLine() + sessionOptions = createSessionOptions(options) + sessionOptions.setSessionName("securitylookupexample") + + session = blpapi.Session(sessionOptions) + try: + if not session.start(): + print("Failed to start session.") + return + + if not session.openService(INSTRUMENT_SERVICE): + print(f"Failed to open {INSTRUMENT_SERVICE}") + return + + sendRequest(options, session) + waitForResponse(session, options.requestType) + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/SnapshotRequestTemplateExample.py b/examples/demoapps/SnapshotRequestTemplateExample.py new file mode 100644 index 0000000..f2fb1ed --- /dev/null +++ b/examples/demoapps/SnapshotRequestTemplateExample.py @@ -0,0 +1,256 @@ +from argparse import ArgumentParser, RawTextHelpFormatter +from threading import Condition, Lock +from blpapi_import_helper import blpapi +from blpapi import Names +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from util.SubscriptionOptions import ( + addSubscriptionOptionsForSnapshot, + setSubscriptionSessionOptions, + createSubscriptionStrings, +) +import time + +# Requests are throttled in the infrastructure. Snapshot request templates send +# one resolution request per topic (unlike normal subscriptions where multiple +# topics are resolved at once), which is likely to cause request throttling. +# It is therefore recommended to create request templates in batches. +TEMPLATE_BATCH_SIZE = 50 + + +class MyCorrelation: + """The object that stores the topic of a snapshot. + Used to avoid duplicate correlation id exception. + """ + + # To be able to retrieve the topic associated with a + # response message, the correlationId of the request + # is created with the topic string. This will eventually + # lead to `DuplicateCorrelationIdException` for requests + # having the same topic strings. + # + # This class therefore encapsulates the topic string inside + # an object which will be different (by reference) each time + # it is instantiated, regardless of the topic string saved + # within it. When the response is received, the topic string + # is extracted from it. + + def __init__(self, topic): + self.topic = topic + + def __str__(self): + return self.topic + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, description="Retrieve Snapshots" + ) + addConnectionAndAuthOptions(parser) + addSubscriptionOptionsForSnapshot(parser) + + options = parser.parse_args() + + return options + + +class SnapshotRequestTemplateExample: + def __init__(self): + self._snapshots = {} + + # Lock and conditions are used to synchronize requests and responses, + # i.e., the next requests are only sent after all the responses + # of the current requests have been received. + self._lock = Lock() + self._responseCount = 0 + self._responseCondition = Condition(self._lock) + + self._templateCount = 0 + self.d_templateBatchingCondition = Condition(self._lock) + + self._running = True + + def _createTemplates(self, session, options): + # NOTE: resources used by a snapshot request template are released + # only when a 'RequestTemplateTerminated' message is received or when + # the session is destroyed. In order to release resources when a + # request template is not needed anymore, the user should call + # 'Session.cancel' and pass the correlation id used when creating the + # request template, or call 'RequestTemplate.close'. If 'Session.cancel' + # is used, all outstanding requests are canceled and the underlying + # subscription is closed immediately. If the handle is closed with + # 'RequestTemplate.close', the underlying subscription is closed + # only when all outstanding requests are served. + + subscriptionStrings = createSubscriptionStrings(options) + with self._lock: + self._responseCount = len(subscriptionStrings) + for userTopic, subscriptionString in subscriptionStrings.items(): + self.d_templateBatchingCondition.wait_for( + lambda: not self._running + or self._templateCount < TEMPLATE_BATCH_SIZE + ) + + if not self._running: + break + + # Create the template + print(f"Creating snapshot request template for {userTopic}") + + statusCid = blpapi.CorrelationId(MyCorrelation(userTopic)) + requestTemplate = session.createSnapshotRequestTemplate( + subscriptionString, statusCid + ) + self._snapshots[statusCid] = requestTemplate + + # Wait until all the request templates have finished, either + # success or failure. + self._responseCondition.wait_for( + lambda: not self._running or self._responseCount == 0 + ) + + def _sendRequests(self, session): + while True: + print("Sending requests using the request templates") + + with self._lock: + if not self._running: + break + + self._responseCount = len(self._snapshots) + for cid, template in self._snapshots.items(): + userTopic = cid.value().topic + print(f"Sending request for {userTopic}") + session.sendRequestTemplate( + template, + blpapi.CorrelationId(MyCorrelation(userTopic)), + ) + + print("Waiting for the responses..., Press [Ctrl-C] to exit\n") + self._responseCondition.wait_for( + lambda: not self._running or self._responseCount == 0 + ) + + print( + "Received all the responses, will send next request in 5 seconds\n" + ) + time.sleep(5) + + def run(self): + """main entry point""" + options = parseCmdLine() + + sessionOptions = createSessionOptions(options) + setSubscriptionSessionOptions(sessionOptions, options) + sessionOptions.setSessionName("snapshotrequesttemplateexample") + session = blpapi.Session(sessionOptions, self.processEvent) + + try: + if not session.start(): + print("Failed to start session.") + return + + if not session.openService(options.service): + print(f"Failed to open service '{options.service}'.") + return + + self._createTemplates(session, options) + + if self._snapshots: + self._sendRequests(session) + else: + print( + "Failed to create all the request templates, stopping..." + ) + finally: + session.stop() + + def processEvent(self, event, _): + """Process session event""" + + eventType = event.eventType() + + for msg in event: + messageType = msg.messageType() + cid = msg.correlationId() + myCorrelation = cid.value() + if messageType == Names.REQUEST_TEMPLATE_AVAILABLE: + print( + "Request template is successfully created for topic" + f" {myCorrelation}" + ) + print(msg) + + with self._lock: + # Decrease template count + self._templateCount -= 1 + self.d_templateBatchingCondition.notify_all() + + # Decrease response count + self._responseCount -= 1 + self._responseCondition.notify_all() + elif messageType == Names.REQUEST_TEMPLATE_TERMINATED: + # Will also receive a 'RequestFailure' message preceding + # 'RequestTemplateTerminated' for every pending request. + print(f"Request template terminated for topic {myCorrelation}") + print(msg) + + with self._lock: + # Remove the template + del self._snapshots[myCorrelation] + + # Decrease template count + self._templateCount -= 1 + self.d_templateBatchingCondition.notify_all() + + # Decrease response count + self._responseCount -= 1 + self._responseCondition.notify_all() + elif eventType == blpapi.Event.PARTIAL_RESPONSE: + print(f"Received partial response for topic {myCorrelation}") + print(msg) + elif eventType == blpapi.Event.RESPONSE: + print(f"Received response for topic {myCorrelation}") + print(msg) + + with self._lock: + self._responseCount -= 1 + self._responseCondition.notify_all() + elif msg.messageType() == Names.SESSION_TERMINATED: + with self._lock: + self._running = False + self.d_templateBatchingCondition.notify_all() + self._responseCondition.notify_all() + + +if __name__ == "__main__": + try: + example = SnapshotRequestTemplateExample() + example.run() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/SubscriptionExample.py b/examples/demoapps/SubscriptionExample.py new file mode 100644 index 0000000..12e0833 --- /dev/null +++ b/examples/demoapps/SubscriptionExample.py @@ -0,0 +1,175 @@ +import time + +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi + +from util.SubscriptionOptions import ( + addSubscriptionOptions, + setSubscriptionSessionOptions, + createSubscriptionList, +) +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) + +DEFAULT_QUEUE_SIZE = 10000 + + +class SubscriptionEventHandler(object): + def getTimeStamp(self): + return time.strftime("%Y/%m/%d %X") + + def processSubscriptionStatus(self, event): + timeStamp = self.getTimeStamp() + for msg in event: + topic = msg.correlationId().value() + print(f"{timeStamp}: {topic}") + print(msg) + if msg.messageType() == blpapi.Names.SUBSCRIPTION_FAILURE: + print(f"Subscription for {topic} failed") + elif msg.messageType() == blpapi.Names.SUBSCRIPTION_TERMINATED: + # Subscription can be terminated if the session identity + # is revoked. + print(f"Subscription for {topic} TERMINATED") + + def processSubscriptionDataEvent(self, event): + timeStamp = self.getTimeStamp() + for msg in event: + topic = msg.correlationId().value() + print(f"{timeStamp}: {topic}") + print(msg) + + def processMiscEvents(self, event): + for msg in event: + if msg.messageType() == blpapi.Names.SLOW_CONSUMER_WARNING: + print( + f"{blpapi.Names.SLOW_CONSUMER_WARNING} - The event queue is " + + "beginning to approach its maximum capacity and " + + "the application is not processing the data fast " + + "enough. This could lead to ticks being dropped" + + " (DataLoss).\n" + ) + elif ( + msg.messageType() == blpapi.Names.SLOW_CONSUMER_WARNING_CLEARED + ): + print( + f"{blpapi.Names.SLOW_CONSUMER_WARNING_CLEARED} - the event " + + "queue has shrunk enough that there is no " + + "longer any immediate danger of overflowing the " + + "queue. If any precautionary actions were taken " + + "when SlowConsumerWarning message was delivered, " + + "it is now safe to continue as normal.\n" + ) + else: + print(msg) + if msg.messageType() == blpapi.Names.DATA_LOSS: + topic = msg.correlationId().value() + print( + f"{blpapi.Names.DATA_LOSS} - The application is too slow to " + + "process events and the event queue is overflowing. " + + f"Data is lost for topic {topic}.\n" + ) + elif event.eventType() == blpapi.Event.SESSION_STATUS: + # SESSION_STATUS events can happen at any time and + # should be handled as the session can be terminated, + # e.g. session identity can be revoked at a later + # time, which terminates the session. + if msg.messageType() == blpapi.Names.SESSION_TERMINATED: + print("Session terminated") + return + + def processEvent(self, event, _session): + try: + if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: + self.processSubscriptionDataEvent(event) + elif event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS: + self.processSubscriptionStatus(event) + else: + self.processMiscEvents(event) + except blpapi.Exception as exception: + print(f"Failed to process event {event}: {exception}") + return False + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Asynchronous subscription with event handler", + ) + addConnectionAndAuthOptions(parser) + addSubscriptionOptions(parser) + + parser.add_argument( + "-q", + "--event-queue-size", + dest="eventQueueSize", + help="The maximum number of events that is buffered by the session (default: %(default)d)", + type=int, + metavar="eventQueueSize", + default=DEFAULT_QUEUE_SIZE, + ) + + options = parser.parse_args() + + return options + + +def main(): + options = parseCmdLine() + + sessionOptions = createSessionOptions(options) + setSubscriptionSessionOptions(sessionOptions, options) + sessionOptions.setMaxEventQueueSize(options.eventQueueSize) + sessionOptions.setSessionName("subscription") + handler = SubscriptionEventHandler() + session = blpapi.Session(sessionOptions, handler.processEvent) + + try: + if not session.start(): + print("Failed to start session.") + return + + if not session.openService(options.service): + print("Failed to open service.") + return + + subscriptions = createSubscriptionList(options) + session.subscribe(subscriptions) + + print("Press ENTER to quit") + input() + + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/SubscriptionWithEventPollingExample.py b/examples/demoapps/SubscriptionWithEventPollingExample.py new file mode 100644 index 0000000..23b97d0 --- /dev/null +++ b/examples/demoapps/SubscriptionWithEventPollingExample.py @@ -0,0 +1,191 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from blpapi import Names + +from util.SubscriptionOptions import ( + addSubscriptionOptions, + setSubscriptionSessionOptions, + createSubscriptionList, +) +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createSessionOptions, +) +from util.MaxEventsOption import addMaxEventsOption + +SERVICE_NAME = blpapi.Name("serviceName") + + +def parseCmdLine(): + """Parse command line arguments""" + + parser = ArgumentParser( + formatter_class=RawTextHelpFormatter, + description="Subscription example with event polling", + ) + addSubscriptionOptions(parser) + addConnectionAndAuthOptions(parser) + addMaxEventsOption(parser) + + options = parser.parse_args() + + return options + + +def checkFailures(session): + """Checks failure events published by the session.""" + + # Note that the loop uses 'session.tryNextEvent' as all events have + # been produced before calling this function, but there could be no events + # at all in the queue if the OS fails to allocate resources. + while True: + event = session.tryNextEvent() + if event is None: + return + + eventType = event.eventType() + for msg in event: + print(msg) + if processGenericMessage(eventType, msg): + return + + +def processSubscriptionEvents(session, maxEvents): + eventCount = 0 + while True: + # Specify timeout to give a chance for Ctrl-C + event = session.nextEvent(1000) + eventType = event.eventType() + for msg in event: + print(msg) + messageType = msg.messageType() + messageCorrelationId = msg.correlationId() + if eventType == blpapi.Event.SUBSCRIPTION_STATUS: + if ( + messageType == Names.SUBSCRIPTION_FAILURE + or messageType == Names.SUBSCRIPTION_TERMINATED + ): + topic = messageCorrelationId.value() + print(f"Subscription failed for topic {topic}") + printContactSupportMessage(msg) + elif eventType == blpapi.Event.SUBSCRIPTION_DATA: + topic = messageCorrelationId.value() + print(f"Received subscription data for topic {topic}") + + if msg.recapType() == blpapi.Message.RECAPTYPE_SOLICITED: + if msg.getRequestId() is not None: + # An init paint tick can have an associated + # RequestId that is used to identify the + # source of the data and can be used when + # contacting support + print( + f"Received init paint with RequestId {msg.getRequestId()}" + ) + else: + # SESSION_STATUS events can happen at any time and + # should be handled as the session can be terminated, + # e.g. session identity can be revoked at a later + # time, which terminates the session. + if processGenericMessage(eventType, msg): + return + + if event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: + eventCount += 1 + if eventCount >= maxEvents: + break + + +def processGenericMessage(eventType, message): + """Prints error information if the 'message' is a failure message.""" + + messageType = message.messageType() + + # When using a session identity, i.e. + # 'SessionOptions.setSessionIdentityOptions(AuthOptions)', token + # generation failure, authorization failure or revocation terminates the + # session, in which case, applications only need to check session status + # messages. Applications don't need to handle token or authorization messages + if eventType == blpapi.Event.SESSION_STATUS: + if ( + messageType == Names.SESSION_TERMINATED + or messageType == Names.SESSION_STARTUP_FAILURE + ): + print("Session failed to start or terminated") + printContactSupportMessage(message) + # Session failed to start/terminated + return True + elif eventType == blpapi.Event.SERVICE_STATUS: + if messageType == Names.SERVICE_OPEN_FAILURE: + serviceName = message.getElementAsString(SERVICE_NAME) + print(f"Failed to open {serviceName}") + printContactSupportMessage(message) + + # Session OK + return False + + +def printContactSupportMessage(msg): + """Prints contact support message.""" + + # Messages can have associated RequestIds which + # identify operations (related to them) through the network. + requestId = msg.getRequestId() + if requestId is not None: + print(f"When contacting support, please provide RequestId {requestId}") + + +def main(): + """Main function""" + + options = parseCmdLine() + + sessionOptions = createSessionOptions(options) + setSubscriptionSessionOptions(sessionOptions, options) + sessionOptions.setSessionName("subscriptionwitheventpolling") + session = blpapi.Session(sessionOptions) + + try: + if not session.start(): + checkFailures(session) + print("Failed to start session.") + return + + if not session.openService(options.service): + checkFailures(session) + return + + subscriptions = createSubscriptionList(options) + session.subscribe(subscriptions) + + processSubscriptionEvents(session, options.maxEvents) + finally: + session.stop() + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/UserModeExample.py b/examples/demoapps/UserModeExample.py new file mode 100644 index 0000000..5ef50b4 --- /dev/null +++ b/examples/demoapps/UserModeExample.py @@ -0,0 +1,311 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + +from blpapi_import_helper import blpapi +from blpapi import Session, Names, CorrelationId +from util.ConnectionAndAuthOptions import ( + addConnectionAndAuthOptions, + createClientServerSetupAuthOptions, + createSessionOptions, +) +from util.events.SessionRouter import SessionRouter + +from functools import partial +from threading import Event as ThreadingEvent +from time import sleep + +REFDATA_SVC_NAME = "//blp/refdata" +SECURITIES = blpapi.Name("securities") +FIELDS = blpapi.Name("fields") +RETURN_EIDS = blpapi.Name("returnEids") +SERVICE_NAME = blpapi.Name("serviceName") + + +class UserModeExample: + """User Mode Example""" + + def __init__(self, options): + self._sessionTerminatedSignal = ThreadingEvent() + self._router = SessionRouter() + self._session = None + self._options = options + self._refDataService = None + self._identitiesByCorrelationId = {} + + self._router.addExceptionHandler(self._handleException) + + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTED, self._handleSessionStarted + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_STARTUP_FAILURE, self._handleSessionStartupFailure + ) + self._router.addMessageHandlerByMessageType( + Names.SESSION_TERMINATED, self._handleSessionTerminated + ) + + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPENED, self._handleServiceOpened + ) + self._router.addMessageHandlerByMessageType( + Names.SERVICE_OPEN_FAILURE, self._handleServiceOpenFailure + ) + + @property + def stopped(self): + return self._sessionTerminatedSignal.is_set() + + def createAndStartSession(self): + # Use the specified application as the session identity to + # authorize. This may cause the session to stop and the example + # to terminate, if the identity is revoked. + sessionOptions = createSessionOptions(self._options) + sessionOptions.setSessionName("usermode") + self._session = Session(sessionOptions, self._router.processEvent) + self._session.startAsync() + + def _stop(self): + # Cancel all the authorized identities + self._session.cancel(self._identitiesByCorrelationId.keys()) + self._session.stopAsync() + + def _handleException(self, _session, _event, exception): + print(exception) + self._stop() + + def _handleSessionStarted( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + _msg: blpapi.Message, + ): + # Add the authorization messages handlers after the session + # started to only react to the authorization messages of users, + # i.e., avoid those of the session identity. + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_SUCCESS, self._handleAuthorizationSuccess + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_FAILURE, self._handleAuthorizationFailure + ) + self._router.addMessageHandlerByMessageType( + Names.AUTHORIZATION_REVOKED, self._handleAuthorizationRevoked + ) + + # both actions will run concurrently + self._openServices() + self._authorizeUsers() + + def _handleSessionStartupFailure( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + _msg: blpapi.Message, + ): + print("Failed to start session. Exiting...") + self._sessionTerminatedSignal.set() + + def _handleSessionTerminated( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + _msg: blpapi.Message, + ): + print("Session terminated. Exiting...") + self._sessionTerminatedSignal.set() + + def _handleServiceOpened( + self, + session: blpapi.AbstractSession, + _event: blpapi.Event, + message: blpapi.Message, + ): + serviceName = message[SERVICE_NAME] + self._refDataService = session.getService(serviceName) + + if serviceName == REFDATA_SVC_NAME: + # it is possible that by now some identities are already authorised + # we are sending a request on their behalf here + for cid, identity in self._identitiesByCorrelationId.items(): + userIdentifier = cid.value() + self._sendRefDataRequest(identity, userIdentifier) + print(f"A service was opened: {serviceName}") + + def _handleServiceOpenFailure( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + message: blpapi.Message, + ): + serviceName = message[SERVICE_NAME] + if serviceName == REFDATA_SVC_NAME: + print(f"Failed to open service '{serviceName}', stopping...") + self._stop() + return + + raise RuntimeError(f"An unknown service failed to open: {serviceName}") + + def _handleAuthorizationSuccess( + self, + session: blpapi.AbstractSession, + _event: blpapi.Event, + message: blpapi.Message, + ): + correlationId = message.correlationId() + userIdentifier = correlationId.value() + print(f"Successfully authorized {userIdentifier}") + + identity = session.getAuthorizedIdentity(correlationId) + self._identitiesByCorrelationId[correlationId] = identity + + if self._refDataService: + # it is possible that the service is already open by now + # in this case we must send the request on behalf of the identity + userIdentifier = correlationId.value() + self._sendRefDataRequest(identity, userIdentifier) + else: + pass # the request will be sent by open service handler + + def _handleAuthorizationFailure( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + message: blpapi.Message, + ): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Failed to authorize {userIdentifier}") + + def _handleAuthorizationRevoked( + self, + _session: blpapi.AbstractSession, + _event: blpapi.Event, + message: blpapi.Message, + ): + correlationId = message.correlationId() + self._router.removeMessageHandlerByCorrelationId(correlationId) + + userIdentifier = correlationId.value() + print(f"Authorization revoked for {userIdentifier}") + + # Remove the identity + self._identitiesByCorrelationId.pop(correlationId, None) + + def _authorizeUsers(self): + # Authorize each of the users + authOptionsByIdentifier = createClientServerSetupAuthOptions( + self._options + ) + for userIdentifier, authOptions in authOptionsByIdentifier.items(): + correlationId = blpapi.CorrelationId(userIdentifier) + self._session.generateAuthorizedIdentity( + authOptions, correlationId + ) + + def _openServices(self): + self._session.openServiceAsync(REFDATA_SVC_NAME) + + def _sendRefDataRequest(self, identity, userId): + # To send a reference data request on behalf of a user + # we need 1) the identity to be authorised 2) the service be opened. + # Due to asynchronous nature of this example the messages + # for successful service opening and successful authorization + # may arrive in any possible order. + # Hence, we call this method in both handlers. + # For open service handler to cover the identities authorised (before), + # and in authorization handler if the service is open (after). + request = self._refDataService.createRequest("ReferenceDataRequest") + requestDict = { + SECURITIES: self._options.securities, + FIELDS: ["PX_LAST", "DS002"], + RETURN_EIDS: True, + } + + request.fromPy(requestDict) + + print(f"Sending RefDataRequest on behalf of {userId}:\n{request}") + correlationId = CorrelationId("example") + self._router.addMessageHandlerByCorrelationId( + correlationId, + partial(UserModeExample._processResponseMessage, userId), + ) + self._session.sendRequest(request, identity, correlationId) + + @staticmethod + def _processResponseMessage( + userId, + _session: blpapi.Session, + _event: blpapi.Event, + message: blpapi.Message, + ): + if message.messageType() == Names.REQUEST_FAILURE: + print(f"Request failed for {userId}.") + else: + print(f"Received response for {userId}.") + + +def parseCmdLine(): + """Parse command line arguments""" + parser = ArgumentParser( + description="User Mode Example", formatter_class=RawTextHelpFormatter + ) + addConnectionAndAuthOptions(parser, forClientServerSetup=True) + + parser.add_argument( + "-S", + "--security", + dest="securities", + help="security used in ReferenceDataRequest (default:" + " IBM US Equity). Can be specified multiple times", + metavar="security", + action="append", + default=[], + ) + + options = parser.parse_args() + + if not options.securities: + options.securities.append("IBM US Equity") + + if not options.userIdAndIps and not options.tokens: + parser.error("No userId:IP or token specified") + + return options + + +def main(): + options = parseCmdLine() + + example = UserModeExample(options) + example.createAndStartSession() + + # The main thread is not blocked and the example is running asynchronously. + while not example.stopped: + sleep(0.1) + + +if __name__ == "__main__": + try: + main() + except Exception as e: # pylint: disable=broad-except + print(e) + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/blpapi_import_helper/__init__.py b/examples/demoapps/blpapi_import_helper/__init__.py new file mode 100644 index 0000000..e6d0fae --- /dev/null +++ b/examples/demoapps/blpapi_import_helper/__init__.py @@ -0,0 +1,45 @@ +# __init__.py + +# pylint: disable=no-member + +import os +import platform as plat +import sys +import contextlib + + +@contextlib.contextmanager +def _libdir(): + if ( + sys.version_info >= (3, 8) + and plat.system().lower() == "windows" + and os.getenv("BLPAPI_LIBDIR") is not None + ): + yield os.add_dll_directory(os.getenv("BLPAPI_LIBDIR")) + else: + yield None + + +with _libdir(): + import blpapi + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/apiflds/ApiFieldsRequestUtils.py b/examples/demoapps/snippets/apiflds/ApiFieldsRequestUtils.py new file mode 100644 index 0000000..6cae18a --- /dev/null +++ b/examples/demoapps/snippets/apiflds/ApiFieldsRequestUtils.py @@ -0,0 +1,67 @@ +from blpapi import Name + +ID = Name("id") +FIELD_INFO = Name("fieldInfo") +MNEMONIC = Name("mnemonic") +DESCRIPTION = Name("description") +FIELD_ERROR = Name("fieldError") +MESSAGE = Name("message") + +ID_LEN = 13 +MNEMONIC_LEN = 36 +DESC_LEN = 40 +CAT_NAME_LEN = 40 + + +def printHeader(): + print( + f'{"FIELD ID".ljust(ID_LEN)}' + f'{"MNEMONIC".ljust(MNEMONIC_LEN)}' + f'{"DESCRIPTION".ljust(DESC_LEN)}' + ) + print( + f'{"-----------".ljust(ID_LEN)}' + f'{"-----------".ljust(MNEMONIC_LEN)}' + f'{"-----------".ljust(DESC_LEN)}' + ) + + +def printField(field): + fieldId = field[ID] + if FIELD_INFO in field: + fieldInfo = field[FIELD_INFO] + fieldMnemonic = fieldInfo[MNEMONIC] + fieldDesc = fieldInfo[DESCRIPTION] + + print( + f"{fieldId.ljust(ID_LEN)}" + f"{fieldMnemonic.ljust(MNEMONIC_LEN)}" + f"{fieldDesc.ljust(DESC_LEN)}" + ) + else: + errorMsg = field[FIELD_ERROR][MESSAGE] + + print() + print(f" ERROR: {fieldId} - {errorMsg}") + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/apiflds/CategorizedFieldSearchRequests.py b/examples/demoapps/snippets/apiflds/CategorizedFieldSearchRequests.py new file mode 100644 index 0000000..192d038 --- /dev/null +++ b/examples/demoapps/snippets/apiflds/CategorizedFieldSearchRequests.py @@ -0,0 +1,71 @@ +from snippets.apiflds import ApiFieldsRequestUtils + +from blpapi import Name + +EXCLUDE = Name("exclude") +FIELD_TYPE = Name("fieldType") +FIELD_DATA = Name("fieldData") +SEARCH_SPEC = Name("searchSpec") +RETURN_FIELD_DOC = Name("returnFieldDocumentation") +CATEGORY = Name("category") +CATEGORY_NAME = Name("categoryName") +CATEGORY_ID = Name("categoryId") +FIELD_SEARCH_ERROR = Name("fieldSearchError") + + +def createRequest(apifldsService): + request = apifldsService.createRequest("CategorizedFieldSearchRequest") + request.set(SEARCH_SPEC, "last price") + + exclude = request.getElement(EXCLUDE) + exclude.setElement(FIELD_TYPE, "Static") + + request.set(RETURN_FIELD_DOC, False) + + return request + + +def processResponse(event): + for msg in event: + if FIELD_SEARCH_ERROR in msg: + print(msg) + continue + + categories = msg[CATEGORY] + for category in categories: + category_name = category[CATEGORY_NAME] + category_id = category[CATEGORY_ID] + print( + f"\nCategory Name: {category_name.ljust(ApiFieldsRequestUtils.CAT_NAME_LEN)}" + f"\tId: {category_id}" + ) + + ApiFieldsRequestUtils.printHeader() + + fields = category[FIELD_DATA] + for field in fields: + ApiFieldsRequestUtils.printField(field) + + print() + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/apiflds/FieldInfoRequests.py b/examples/demoapps/snippets/apiflds/FieldInfoRequests.py new file mode 100644 index 0000000..db8d78f --- /dev/null +++ b/examples/demoapps/snippets/apiflds/FieldInfoRequests.py @@ -0,0 +1,56 @@ +from snippets.apiflds import ApiFieldsRequestUtils + +from blpapi import Name + +ID = Name("id") +FIELD_DATA = Name("fieldData") +RETURN_FIELD_DOC = Name("returnFieldDocumentation") + + +def createRequest(apifldsService): + request = apifldsService.createRequest("FieldInfoRequest") + + idElement = request.getElement(ID) + idElement.appendValue("LAST_PRICE") + idElement.appendValue("pq005") + idElement.appendValue("zz0002") + + request.set(RETURN_FIELD_DOC, True) + + return request + + +def processResponse(event): + # NOTE: this function uses the dictionary-like interface to read a + # `Message`. See `FieldListRequests.processResponse` for the method-based + # interface. + for msg in event: + ApiFieldsRequestUtils.printHeader() + + fields = msg[FIELD_DATA] + for field in fields: + ApiFieldsRequestUtils.printField(field) + + print() + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/apiflds/FieldListRequests.py b/examples/demoapps/snippets/apiflds/FieldListRequests.py new file mode 100644 index 0000000..8fb3f21 --- /dev/null +++ b/examples/demoapps/snippets/apiflds/FieldListRequests.py @@ -0,0 +1,51 @@ +from snippets.apiflds import ApiFieldsRequestUtils + +from blpapi import Name + +FIELD_DATA = Name("fieldData") +FIELD_TYPE = Name("fieldType") +RETURN_FIELD_DOC = Name("returnFieldDocumentation") + + +def createRequest(apifldsService): + request = apifldsService.createRequest("FieldListRequest") + request[FIELD_TYPE] = "Static" + request[RETURN_FIELD_DOC] = False + + return request + + +def processResponse(event): + # NOTE: this function uses the method-based interface to read a + # `Message`. See `FieldInfoRequests.processResponse` for the + # dictionary-like interface. + for msg in event: + ApiFieldsRequestUtils.printHeader() + + fields = msg.getElement(FIELD_DATA) + for i in range(fields.numValues()): + ApiFieldsRequestUtils.printField(fields.getValueAsElement(i)) + + print() + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/apiflds/FieldSearchRequests.py b/examples/demoapps/snippets/apiflds/FieldSearchRequests.py new file mode 100644 index 0000000..ba6394a --- /dev/null +++ b/examples/demoapps/snippets/apiflds/FieldSearchRequests.py @@ -0,0 +1,54 @@ +from snippets.apiflds import ApiFieldsRequestUtils + +from blpapi import Name + +EXCLUDE = Name("exclude") +FIELD_TYPE = Name("fieldType") +FIELD_DATA = Name("fieldData") +SEARCH_SPEC = Name("searchSpec") +RETURN_FIELD_DOC = Name("returnFieldDocumentation") + + +def createRequest(apifldsService): + request = apifldsService.createRequest("FieldSearchRequest") + request.set(SEARCH_SPEC, "last price") + + exclude = request.getElement(EXCLUDE) + exclude.setElement(FIELD_TYPE, "Static") + + request.set(RETURN_FIELD_DOC, False) + + return request + + +def processResponse(event): + for msg in event: + ApiFieldsRequestUtils.printHeader() + + fields = msg[FIELD_DATA] + for field in fields: + ApiFieldsRequestUtils.printField(field) + + print() + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/instruments/CurveListRequests.py b/examples/demoapps/snippets/instruments/CurveListRequests.py new file mode 100644 index 0000000..9394a22 --- /dev/null +++ b/examples/demoapps/snippets/instruments/CurveListRequests.py @@ -0,0 +1,72 @@ +from blpapi import Name + +NAME_DESCRIPTION = Name("description") +NAME_QUERY = Name("query") +NAME_RESULTS = Name("results") +NAME_MAX_RESULTS = Name("maxResults") +NAME_CURVE = Name("curve") +ERROR_RESPONSE = Name("ErrorResponse") + +CURVE_RESPONSE_ELEMENTS = [ + Name("country"), + Name("currency"), + Name("curveid"), + Name("type"), + Name("subtype"), + Name("publisher"), + Name("bbgid"), +] + + +def createRequest(instrumentsService, query, maxResults, filters): + request = instrumentsService.createRequest("curveListRequest") + request[NAME_QUERY] = query + request[NAME_MAX_RESULTS] = maxResults + + for f in filters: + request[f.name] = f.value + + return request + + +def processResponse(event): + for msg in event: + if msg.messageType() == ERROR_RESPONSE: + print(f"Received error: {msg}") + continue + + results = msg[NAME_RESULTS] + print(f"Processing {len(results)} results:") + + for i, result in enumerate(results): + elements_values = [ + f"{n}={result[n]}" for n in CURVE_RESPONSE_ELEMENTS + ] + + curve = result[NAME_CURVE] + description = result[NAME_DESCRIPTION] + print( + f" {i + 1} {curve} - {description}, {' '.join(elements_values)}" + ) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/instruments/GovtListRequests.py b/examples/demoapps/snippets/instruments/GovtListRequests.py new file mode 100644 index 0000000..8cbd01f --- /dev/null +++ b/examples/demoapps/snippets/instruments/GovtListRequests.py @@ -0,0 +1,59 @@ +from blpapi import Name + +NAME_QUERY = Name("query") +NAME_RESULTS = Name("results") +NAME_MAX_RESULTS = Name("maxResults") + +NAME_PARSEKY = Name("parseky") +NAME_NAME = Name("name") +NAME_TICKER = Name("ticker") +ERROR_RESPONSE = Name("ErrorResponse") + + +def createRequest(instrumentsService, query, maxResults, filters): + request = instrumentsService.createRequest("govtListRequest") + request[NAME_QUERY] = query + request[NAME_MAX_RESULTS] = maxResults + + for f in filters: + request[f.name] = f.value + + return request + + +def processResponse(event): + for msg in event: + if msg.messageType() == ERROR_RESPONSE: + print(f"Received error: {msg}") + continue + + results = msg.getElement(NAME_RESULTS) + print(f"Processing {len(results)} results:") + + for i, result in enumerate(results): + parsekey = result[NAME_PARSEKY] + name = result[NAME_NAME] + ticker = result[NAME_TICKER] + print(f" {i + 1} {parsekey}, {name} - {ticker}") + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/instruments/InstrumentListRequests.py b/examples/demoapps/snippets/instruments/InstrumentListRequests.py new file mode 100644 index 0000000..bd9cccd --- /dev/null +++ b/examples/demoapps/snippets/instruments/InstrumentListRequests.py @@ -0,0 +1,57 @@ +from blpapi import Name + +NAME_DESCRIPTION = Name("description") +NAME_QUERY = Name("query") +NAME_RESULTS = Name("results") +NAME_MAX_RESULTS = Name("maxResults") + +NAME_SECURITY = Name("security") +ERROR_RESPONSE = Name("ErrorResponse") + + +def createRequest(instrumentsService, query, maxResults, filters): + request = instrumentsService.createRequest("instrumentListRequest") + request[NAME_QUERY] = query + request[NAME_MAX_RESULTS] = maxResults + + for f in filters: + request[f.name] = f.value + + return request + + +def processResponse(event): + for msg in event: + if msg.messageType() == ERROR_RESPONSE: + print(f"Received error: {msg}") + continue + + results = msg[NAME_RESULTS] + print(f"Processing {len(results)} results:") + + for i, result in enumerate(results): + security = result[NAME_SECURITY] + description = result[NAME_DESCRIPTION] + print(f" {i + 1} {security} - {description}") + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/requestresponse/HistoricalDataRequest.py b/examples/demoapps/snippets/requestresponse/HistoricalDataRequest.py new file mode 100644 index 0000000..2bc21c6 --- /dev/null +++ b/examples/demoapps/snippets/requestresponse/HistoricalDataRequest.py @@ -0,0 +1,59 @@ +# HistoricalDataRequest.py + +from blpapi import Name + +SECURITIES = Name("securities") +PERIODICITY_ADJUSTMENT = Name("periodicityAdjustment") +PERIODICITY_SELECTION = Name("periodicitySelection") +START_DATE = Name("startDate") +END_DATE = Name("endDate") +MAX_DATA_POINTS = Name("maxDataPoints") +RETURN_EIDS = Name("returnEids") +FIELDS = Name("fields") + + +def createRequest(service, options): + # NOTE: this function uses `Request.__setitem__` to format a `Request`. See + # the other `createRequest` functions in this `requestresponse` directory + # for examples of alternative interfaces for formatting a `Request`. + request = service.createRequest("HistoricalDataRequest") + + request[SECURITIES] = options.securities + request[FIELDS] = options.fields + + request[PERIODICITY_ADJUSTMENT] = "ACTUAL" + request[PERIODICITY_SELECTION] = "MONTHLY" + request[START_DATE] = "20200101" + request[END_DATE] = "20201231" + request[MAX_DATA_POINTS] = 100 + request[RETURN_EIDS] = True + + return request + + +def processResponseEvent(event): + for msg in event: + print(f"Received response to request {msg.getRequestId()}") + print(msg) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/requestresponse/IntradayBarRequests.py b/examples/demoapps/snippets/requestresponse/IntradayBarRequests.py new file mode 100644 index 0000000..8c26fea --- /dev/null +++ b/examples/demoapps/snippets/requestresponse/IntradayBarRequests.py @@ -0,0 +1,105 @@ +# IntradayBarRequests.py + +from blpapi import Name + +# Used with `Message.toPy`, meaning they should use strings rather than `Name` +BAR_DATA = "barData" +BAR_TICK_DATA = "barTickData" +OPEN = "open" +HIGH = "high" +LOW = "low" +CLOSE = "close" +VOLUME = "volume" +NUM_EVENTS = "numEvents" +TIME = "time" +RESPONSE_ERROR = "responseError" + +SECURITY = Name("security") +EVENT_TYPE = Name("eventType") +INTERVAL = Name("interval") +START_DATE_TIME = Name("startDateTime") +END_DATE_TIME = Name("endDateTime") +GAP_FILL_INITIAL_BAR = Name("gapFillInitialBar") + +DATETIME_FORMAT = "%m/%d/%Y %H:%M" + + +def createRequest(service, options): + # NOTE: this function uses `Request.set` to format a `Request`. See + # the other `createRequest` functions in this `requestresponse` directory + # for examples of alternative interfaces for formatting a `Request`. + request = service.createRequest("IntradayBarRequest") + + # Only one security / eventType per request + request.set(SECURITY, options.securities[0]) + request.set(EVENT_TYPE, options.eventTypes[0]) + request.set(INTERVAL, options.barInterval) + + request.set(START_DATE_TIME, options.startDateTime) + request.set(END_DATE_TIME, options.endDateTime) + + if options.gapFillInitialBar: + request.set(GAP_FILL_INITIAL_BAR, options.gapFillInitialBar) + + return request + + +def processResponseEvent(response): + # NOTE: This function demonstrates the use of `Message.toPy` for accessing + # the contents of a `Message`. Here, the contents of the `Message` get + # converted to a `dict`. See `IntradayTickRequests.processResponseEvent` + # for an example of accessing the contents of a `Message` using + # `Message.__getitem__`, without having to convert to a `dict`. + + for msg in response: + print(f"Received response to request {msg.getRequestId()}") + + msgDict = msg.toPy() + + if RESPONSE_ERROR in msgDict: + responseError = msg[RESPONSE_ERROR] + print(f"REQUEST FAILED: {responseError}") + continue + + data = msgDict[BAR_DATA][BAR_TICK_DATA] + print(f"Response contains {len(data)} bar(s)") + spaces = "\t\t\t\t" + print( + f"Datetime{spaces}Open{spaces}High{spaces}Low{spaces}Close{spaces}NumEvents{spaces}Volume" + ) + for bar in data: + barTime = bar[TIME] + barOpen = bar[OPEN] + barHigh = bar[HIGH] + barLow = bar[LOW] + barClose = bar[CLOSE] + barNumEvents = bar[NUM_EVENTS] + barVolume = bar[VOLUME] + + print( + f"{barTime.strftime(DATETIME_FORMAT)}{spaces}{barOpen:.2f}" + f"{spaces}{barHigh:.2f}{spaces}{barLow:.2f}{spaces}" + f"{barClose:.2f}{spaces}{barNumEvents}{spaces}{barVolume}" + ) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/requestresponse/IntradayTickRequests.py b/examples/demoapps/snippets/requestresponse/IntradayTickRequests.py new file mode 100644 index 0000000..4d4a9d9 --- /dev/null +++ b/examples/demoapps/snippets/requestresponse/IntradayTickRequests.py @@ -0,0 +1,93 @@ +# IntradayTickRequests.py + +from blpapi import Name + +TICK_DATA = Name("tickData") +CONDITION_CODES = Name("conditionCodes") +SIZE = Name("size") +TIME = Name("time") +TYPE = Name("type") +VALUE = Name("value") +RESPONSE_ERROR = Name("responseError") +SECURITY = Name("security") +EVENT_TYPES = Name("eventTypes") +START_DATE_TIME = Name("startDateTime") +END_DATE_TIME = Name("endDateTime") +INCLUDE_CONDITION_CODES = Name("includeConditionCodes") + +DATETIME_FORMAT = "%m/%d/%Y %H:%M" + + +def createRequest(service, options): + # NOTE: this function uses `Request.fromPy` to format a `Request`. See + # the other `createRequest` functions in this `requestresponse` directory + # for examples of alternative interfaces for formatting a `Request`. + request = service.createRequest("IntradayTickRequest") + + requestDict = { + SECURITY: options.securities[0], + EVENT_TYPES: options.eventTypes, + # All times are in GMT + START_DATE_TIME: options.startDateTime, + END_DATE_TIME: options.endDateTime, + } + if options.conditionCodes: + requestDict[INCLUDE_CONDITION_CODES] = True + + request.fromPy(requestDict) + + return request + + +def processResponseEvent(response): + # NOTE: This function demonstrates the `dict`-like interface for accessing + # the contents of a `Message`. For an example of explicitly converting a + # `Message` to a `dict`, see the use of `Message.toPy` in + # `IntradayBarRequests.processResponseEvent`. + + for msg in response: + print(f"Received response to request {msg.getRequestId()}") + + if RESPONSE_ERROR in msg: + responseError = msg[RESPONSE_ERROR] + print(f"REQUEST FAILED: {responseError}") + continue + + data = msg[TICK_DATA][TICK_DATA] + print("TIME\t\t\tTYPE\t\tVALUE\t\tSIZE\tCONDITION_CODES") + print("----\t\t\t----\t\t-----\t\t----\t----") + for item in data: + itemTime = item[TIME] + itemType = item[TYPE] + itemValue = item[VALUE] + itemSize = item[SIZE] + itemConditionCodes = "" + if CONDITION_CODES in item: + itemConditionCodes = item[CONDITION_CODES] + + print( + f"{itemTime.strftime(DATETIME_FORMAT)}\t{itemType}\t" + f"{itemValue:.2f}\t\t{itemSize}\t{itemConditionCodes}" + ) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/snippets/requestresponse/ReferenceDataRequests.py b/examples/demoapps/snippets/requestresponse/ReferenceDataRequests.py new file mode 100644 index 0000000..ebca905 --- /dev/null +++ b/examples/demoapps/snippets/requestresponse/ReferenceDataRequests.py @@ -0,0 +1,153 @@ +# ReferenceDataRequests.py + +import blpapi + +SECURITY_DATA = blpapi.Name("securityData") +SECURITY = blpapi.Name("security") +FIELD_DATA = blpapi.Name("fieldData") +RESPONSE_ERROR = blpapi.Name("responseError") +SECURITY_ERROR = blpapi.Name("securityError") +FIELD_EXCEPTIONS = blpapi.Name("fieldExceptions") +FIELD_ID = blpapi.Name("fieldId") +ERROR_INFO = blpapi.Name("errorInfo") +SECURITIES = blpapi.Name("securities") +FIELDS = blpapi.Name("fields") +OVERRIDES = blpapi.Name("overrides") +VALUE = blpapi.Name("value") +ROW = blpapi.Name("row") +TABLE_OVERRIDES = blpapi.Name("tableOverrides") + + +def createRequest(service, options): + # NOTE: This function shows the `Element`-based interface of formatting + # a `Request`. See `createTableOverrideRequest` for an example of + # formatting a `Request` using `Request.fromPy`. See the other + # `createRequest` functions in this `requestresponse` directory for + # examples of alternative interfaces for formatting a `Request`. + + request = service.createRequest("ReferenceDataRequest") + securitiesElement = request.getElement(SECURITIES) + + for security in options.securities: + securitiesElement.appendValue(security) + + fieldsElement = request.getElement(FIELDS) + for field in options.fields: + fieldsElement.appendValue(field) + + if options.overrides: + # Add overrides + overridesElement = request.getElement(OVERRIDES) + for override in options.overrides: + overrideElement = overridesElement.appendElement() + overrideElement.setElement(FIELD_ID, override.fieldId) + overrideElement.setElement(VALUE, override.value) + + return request + + +def createTableOverrideRequest(service, options): + # NOTE: This function shows how to format a `Request` using + # `Request.fromPy`. See `createRequest` for an example of formatting a + # `Request` using the `Element`-based interface. + + request = service.createRequest("ReferenceDataRequest") + + # (rate, duration, transition) + rate1 = (1.0, 12, "S") # S = Step + rate2 = (2.0, 12, "R") # R = Ramp + + requestDict = { + SECURITIES: options.securities, + FIELDS: options.fields, + OVERRIDES: [ + {FIELD_ID: "ALLOW_DYNAMIC_CASHFLOW_CALCS", VALUE: "Y"}, + {FIELD_ID: "LOSS_SEVERITY", VALUE: 31}, + ], + TABLE_OVERRIDES: [ + { + FIELD_ID: "DEFAULT_VECTOR", + ROW: [ + {VALUE: ["Anchor", "PROJ"]}, + {VALUE: ["Type", "CDR"]}, + {VALUE: rate1}, + {VALUE: rate2}, + ], + } + ], + } + request.fromPy(requestDict) + + return request + + +def processResponseEvent(event): + # NOTE: This function shows the `Element` method interface for accessing + # the contents of a `Message`. For examples of the `dict`-like interface, + # see `IntradayTickRequests.processResponseEvent` and + # `IntradayBarRequests.processResponseEvent` + + for msg in event: + print(f"Received response to request {msg.getRequestId()}") + + if msg.hasElement(RESPONSE_ERROR): + print(f"REQUEST FAILED: {msg.getElement(RESPONSE_ERROR)}") + continue + + securities = msg.getElement(SECURITY_DATA) + numSecurities = securities.numValues() + print(f"Processing {numSecurities} securities:") + + for i in range(numSecurities): + security = securities.getValueAsElement(i) + ticker = security.getElementAsString(SECURITY) + print(f"\nTicker: {ticker}") + + if security.hasElement(SECURITY_ERROR): + print( + f"SECURITY FAILED: {security.getElement(SECURITY_ERROR)}" + ) + continue + + if security.hasElement(FIELD_DATA): + fields = security.getElement(FIELD_DATA) + if fields.numElements() > 0: + print("FIELD\t\tVALUE") + print("-----\t\t-----") + numElements = fields.numElements() + for j in range(numElements): + field = fields.getElement(j) + print(f"{field.name()} \t\t {field} ") + + fieldExceptions = security.getElement(FIELD_EXCEPTIONS) + if fieldExceptions.numValues() > 0: + print("FIELD\t\tEXCEPTION") + print("-----\t\t---------") + for k in range(fieldExceptions.numValues()): + fieldException = fieldExceptions.getValueAsElement(k) + print( + f"{fieldException.getElementAsString(FIELD_ID)} " + f"\t\t {fieldException.getElement(ERROR_INFO)}" + ) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/util/ConnectionAndAuthOptions.py b/examples/demoapps/util/ConnectionAndAuthOptions.py new file mode 100644 index 0000000..cb1b953 --- /dev/null +++ b/examples/demoapps/util/ConnectionAndAuthOptions.py @@ -0,0 +1,375 @@ +from blpapi_import_helper import blpapi +from argparse import Action +from collections import namedtuple + + +_SESSION_IDENTITY_AUTH_OPTIONS = "sessionIdentityAuthOptions" + + +class AuthOptionsAction(Action): + """The action that parses authorization options from user input""" + + def __call__(self, parser, args, values, option_string=None): + vals = values.split("=", 1) + + authOptions = None + + auth_type = vals[0] + if auth_type == "user": + authUser = blpapi.AuthUser.createWithLogonName() + authOptions = blpapi.AuthOptions.createWithUser(authUser) + elif auth_type == "none": + authOptions = None + else: + if len(vals) != 2: + parser.error(f"Invalid auth option '{values}'") + + if auth_type == "app": + appName = vals[1] + authOptions = blpapi.AuthOptions.createWithApp(appName) + elif auth_type == "userapp": + appName = vals[1] + authUser = blpapi.AuthUser.createWithLogonName() + authOptions = blpapi.AuthOptions.createWithUserAndApp( + authUser, appName + ) + elif auth_type == "dir": + dirProperty = vals[1] + authUser = blpapi.AuthUser.createWithActiveDirectoryProperty( + dirProperty + ) + authOptions = blpapi.AuthOptions.createWithUser(authUser) + elif auth_type == "manual": + parts = vals[1].split(",") + if len(parts) != 3: + parser.error(f"Invalid auth option '{values}'") + + appName, ip, userId = parts + authUser = blpapi.AuthUser.createWithManualOptions(userId, ip) + authOptions = blpapi.AuthOptions.createWithUserAndApp( + authUser, appName + ) + else: + parser.error(f"Invalid auth option '{values}'") + + setattr(args, self.dest, authOptions) + + +class AppAuthAction(Action): + """The action that parses app authorization options from user input""" + + def __call__(self, parser, args, values, option_string=None): + vals = values.split("=", 1) + if len(vals) != 2: + parser.error(f"Invalid auth option '{values}'") + + authType, appName = vals + if authType != "app": + parser.error(f"Invalid auth option '{values}'") + + setattr(args, self.dest, appName) + authOptions = blpapi.AuthOptions.createWithApp(appName) + setattr(args, _SESSION_IDENTITY_AUTH_OPTIONS, authOptions) + + +HostPort = namedtuple("HostPort", ["host", "port"]) +ServerAddress = namedtuple("ServerAddress", ["endpoint", "socks5"]) + + +class HostAction(Action): + """The action that parses host options from user input""" + + @staticmethod + def _parseHostPort(parser, value): + vals = value.split(":", 1) + if len(vals) != 2: + parser.error(f"Invalid host option '{value}'") + + maxPortValue = 65535 + if int(vals[1]) <= 0 or int(vals[1]) > maxPortValue: + parser.error( + f"Invalid port '{value}', value must be 1 through {maxPortValue}" + ) + return HostPort(vals[0], vals[1]) + + def __call__(self, parser, args, values, option_string=None): + endpointSocks5 = values.split("/", 1) + if len(endpointSocks5) == 0 or len(endpointSocks5) > 2: + parser.error(f"Invalid host option '{values}'") + + endpoint = HostAction._parseHostPort(parser, endpointSocks5[0]) + socks5 = None + if len(endpointSocks5) == 2: + socks5 = HostAction._parseHostPort(parser, endpointSocks5[1]) + + hosts = getattr(args, self.dest) + hosts.append(ServerAddress(endpoint, socks5)) + + +class UserIdIpAction(Action): + """The action that parses userId and IP authorization options from user + input + """ + + def __call__(self, parser, args, values, option_string=None): + vals = values.split(":") + if len(vals) != 2: + parser.error(f"Invalid auth option '{values}'") + + userId, ip = vals + getattr(args, self.dest).append((userId, ip)) + + +def addConnectionAndAuthOptions(parser, forClientServerSetup=False): + """ + Helper function that adds the options for connection and authorization to + the argument parser. + """ + # Server options + server_group = parser.add_argument_group("Connections") + server_group.add_argument( + "-H", + "--host", + dest="hosts", + help="Endpoint host:port and optional SOCKS5 host:port to use to connect" + " (default: localhost:8194). Can be specified multiple times.", + metavar="host:port[/socks5Host:socks5Port]", + action=HostAction, + default=[], + ) + + # Auth options + if forClientServerSetup: + _addArgGroupsAuthAndEntitlementsClientServerSetup(parser) + else: + _addArgGroupAuth(parser) + + # TLS Options + tls_group = parser.add_argument_group("TLS (specify all or none)") + tls_group.add_argument( + "--tls-client-credentials", + dest="tls_client_credentials", + help="name a PKCS#12 file to use as a source of " "client credentials", + metavar="file", + ) + tls_group.add_argument( + "--tls-client-credentials-password", + dest="tls_client_credentials_password", + help="specify password for accessing client credentials", + metavar="password", + default="", + ) + tls_group.add_argument( + "--tls-trust-material", + dest="tls_trust_material", + help="name a PKCS#7 file to use as a source of " + "trusted certificates", + metavar="file", + ) + tls_group.add_argument( + "--read-certificate-files", + dest="read_certificate_files", + help="Enable reading the TLS files and pass the blobs", + action="store_true", + ) + + # ZFP Options + zfp_group = parser.add_argument_group( + "ZFP connections over leased lines (requires TLS)" + ) + zfp_group.add_argument( + "-z", + "--zfp-over-leased-line", + dest="remote", + help="enable ZFP connections over leased lines on the " + "specified port (8194 or 8196)" + "\n(When this option is enabled, option -H/--host is ignored.)", + metavar="port", + type=int, + ) + + +def _addArgGroupAuth(parser): + auth_group = parser.add_argument_group("Authorization") + auth_group.add_argument( + "-a", + "--auth", + dest=_SESSION_IDENTITY_AUTH_OPTIONS, + help="""authorization option (default: none) +none applicable to Desktop API product that requires + Bloomberg Professional service to be installed locally +user as a user using OS logon information +dir= as a user using directory services +app= as the specified application +userapp= as user and application using logon information for the user +manual= as user and application, with manually provided + IP address and EMRS user""", + metavar="option", + action=AuthOptionsAction, + ) + + +def _addArgGroupsAuthAndEntitlementsClientServerSetup(parser): + """Adds the auth and entitlements options for the entitlement examples to + the argument parser. + """ + auth_group = parser.add_argument_group("Authorization") + auth_group.add_argument( + "-a", + "--auth", + dest="authAppName", + required=True, + help="authorize this application using the specified application", + metavar="app=", + action=AppAuthAction, + ) + + entitlements_group = parser.add_argument_group( + "User Authorization/Entitlements" + ) + entitlements_group.add_argument( + "-u", + "--userid-ip", + dest="userIdAndIps", + help="authorize a user using userId and IP separated by ':'. Can be specified multiple times.", + metavar="userId:IP", + action=UserIdIpAction, + default=[], + ) + + entitlements_group.add_argument( + "-T", + "--token", + dest="tokens", + help="authorize a user using the specified token. Can be specified multiple times.\n" + "If the token starts with '-', use " + "either -T or --token=.", + metavar="token", + action="append", + default=[], + ) + + +def _getTlsOptions(options): + """Parse TlsOptions from user input""" + + if ( + options.tls_client_credentials is None + or options.tls_trust_material is None + ): + return None + + print("TlsOptions enabled") + if options.read_certificate_files: + with open(options.tls_client_credentials, "rb") as credentialfile: + credential_blob = credentialfile.read() + with open(options.tls_trust_material, "rb") as trustfile: + trust_blob = trustfile.read() + return blpapi.TlsOptions.createFromBlobs( + credential_blob, + options.tls_client_credentials_password, + trust_blob, + ) + + return blpapi.TlsOptions.createFromFiles( + options.tls_client_credentials, + options.tls_client_credentials_password, + options.tls_trust_material, + ) + + +def createClientServerSetupAuthOptions(options): + """Creates a dictionary whose keys are the identifier representing a user, + either userId:IP or token, and whose values are the AuthOptions, either + manual option (userId + IP + App) or token. + """ + authOptionsByIdentifier = {} + for userId, ip in options.userIdAndIps: + authUser = blpapi.AuthUser.createWithManualOptions(userId, ip) + authOptions = blpapi.AuthOptions.createWithUserAndApp( + authUser, options.authAppName + ) + authOptionsByIdentifier[f"{userId}:{ip}"] = authOptions + + for i, token in enumerate(options.tokens): + authOptions = blpapi.AuthOptions.createWithToken(token) + authOptionsByIdentifier[f"token #{i + 1}"] = authOptions + + return authOptionsByIdentifier + + +def createSessionOptions(options): + """ + Creates SessionOptions from the following command line arguments: + - connections where servers, TLS and ZFP over Leased lines are specified. + - TLS options + - authorization options that are used as session identity options. + """ + + tlsOptions = _getTlsOptions(options) + if options.remote: + if tlsOptions is None: + raise RuntimeError("ZFP connections require TLS parameters") + + print("Creating a ZFP connection for leased lines.") + sessionOptions = blpapi.ZfpUtil.getZfpOptionsForLeasedLines( + options.remote, tlsOptions + ) + else: + sessionOptions = blpapi.SessionOptions() + for idx, serverAddress in enumerate(options.hosts): + socks5Config = ( + blpapi.Socks5Config( + serverAddress.socks5.host, int(serverAddress.socks5.port) + ) + if serverAddress.socks5 + else None + ) + sessionOptions.setServerAddress( + serverAddress.endpoint.host, + int(serverAddress.endpoint.port), + idx, + socks5Config, + ) + + if tlsOptions: + sessionOptions.setTlsOptions(tlsOptions) + + sessionOptions.setSessionIdentityOptions( + options.sessionIdentityAuthOptions + ) + + def serverAddressToString(server: ServerAddress): + tostr = ":".join(server.endpoint) + if server.socks5: + tostr = f"{tostr}/{':'.join(server.socks5)}" + return tostr + + print( + f"Connecting to " + f"{', '.join([serverAddressToString(h) for h in options.hosts])}" + ) + + return sessionOptions + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/util/MaxEventsOption.py b/examples/demoapps/util/MaxEventsOption.py new file mode 100644 index 0000000..d437314 --- /dev/null +++ b/examples/demoapps/util/MaxEventsOption.py @@ -0,0 +1,39 @@ +import sys + + +def addMaxEventsOption(argparser): + """ + Helper function that adds the option for the maximum number of events + before stopping to the argument parser and parses the command line + argument to an integer as the maximum number of events. + """ + argparser.add_argument( + "--max-events", + dest="maxEvents", + help="number of events to process before stopping (default: %(default)d).", + metavar="maxEvents", + type=int, + default=sys.maxsize, + ) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/util/RequestOptions.py b/examples/demoapps/util/RequestOptions.py new file mode 100644 index 0000000..66baa53 --- /dev/null +++ b/examples/demoapps/util/RequestOptions.py @@ -0,0 +1,277 @@ +from argparse import Action +from collections import namedtuple +import datetime + +REFDATA_SERVICE = "//blp/refdata" +INTRADAY_BAR_REQUEST = "IntradayBarRequest" +INTRADAY_TICK_REQUEST = "IntradayTickRequest" +REFERENCE_DATA_REQUEST = "ReferenceDataRequest" +REFERENCE_DATA_REQUEST_OVERRIDE = "ReferenceDataRequestOverride" +REFERENCE_DATA_REQUEST_TABLE_OVERRIDE = "ReferenceDataRequestTableOverride" +HISTORICAL_DATA_REQUEST = "HistoricalDataRequest" + +# Defines a parameter override in a reference data request. +Override = namedtuple("Override", ["fieldId", "value"]) + + +class OverridesAction(Action): + """The action that parses overrides options from user input""" + + def __call__(self, parser, args, values, option_string=None): + vals = values.split("=", 1) + overrides = getattr(args, self.dest) + overrides.append(Override(vals[0], vals[1])) + + +def parseDatetime(value): + return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S") + + +def addRequestOptions(parser): + """ + Helper function that adds the options that are used to + create a blpapi request to the argument parser. + """ + + # Compute default start/end datetime + ( + defaultStartDateTime, + defaultIntradayBarEndDateTime, + defaultIntradayTickEndDateTime, + ) = computeDefaultStartAndEndDateTime() + formattedDefaultStartDateTime = defaultStartDateTime.isoformat( + timespec="seconds" + ) + formattedDefaultIntradayBarEndDateTime = ( + defaultIntradayBarEndDateTime.isoformat(timespec="seconds") + ) + formattedDefaultIntradayTickEndDateTime = ( + defaultIntradayTickEndDateTime.isoformat(timespec="seconds") + ) + + isoDatetimeFormat = "YYYY-MM-DDTHH:MM:SS" + + # Request options + defaultBarInterval = 5 + argGroupRequest = parser.add_argument_group("Request Options") + argGroupRequest.add_argument( + "-s", + "--service", + dest="service", + help="The service name (default: %(default)s)", + metavar="service", + default=REFDATA_SERVICE, + ) + argGroupRequest.add_argument( + "-S", + "--security", + dest="securities", + help="Security to request. Can be specified multiple times.", + metavar="security", + action="append", + default=[], + ) + argGroupRequest.add_argument( + "-f", + "--field", + dest="fields", + help="Field to request. Can be specified multiple times.", + metavar="field", + action="append", + default=[], + ) + argGroupRequest.add_argument( + "-e", + "--event", + dest="eventTypes", + help="Event Type (default: ['TRADE']). Can be specified multiple times.", + metavar="eventType", + action="append", + default=[], + ) + argGroupRequest.add_argument( + "-i", + "--interval", + dest="barInterval", + type=int, + help="Bar interval in minutes (default: %(default)d)", + metavar="barInterval", + default=defaultBarInterval, + ) + argGroupRequest.add_argument( + "-I", + "--include-condition-codes", + dest="conditionCodes", + help="Include condition codes", + action="store_true", + default=False, + ) + argGroupRequest.add_argument( + "-G", + "--gap-fill-initial-bar", + dest="gapFillInitialBar", + help="Gap fill initial bar", + action="store_true", + default=False, + ) + argGroupRequest.add_argument( + "--start-date", + dest="startDateTime", + help="Start datetime in the format of " f"{isoDatetimeFormat}", + metavar="startDateTime", + type=parseDatetime, + ) + argGroupRequest.add_argument( + "--end-date", + dest="endDateTime", + help="End datetime in the format of " f"{isoDatetimeFormat}", + metavar="endDateTime", + type=parseDatetime, + ) + argGroupRequest.add_argument( + "-O", + "--override", + dest="overrides", + help="Field to override. Can be specified multiple times.", + metavar="=", + action=OverridesAction, + default=[], + ) + argGroupRequest.add_argument( + "-r", + "--request", + dest="requestType", + choices=[ + REFERENCE_DATA_REQUEST, + REFERENCE_DATA_REQUEST_OVERRIDE, + REFERENCE_DATA_REQUEST_TABLE_OVERRIDE, + INTRADAY_BAR_REQUEST, + INTRADAY_TICK_REQUEST, + HISTORICAL_DATA_REQUEST, + ], + help=f"""Request Type (default: %(default)s) +To retrieve reference data: + -r, --request {REFERENCE_DATA_REQUEST} + [-S, --security ] + [-f, --field ] +To retrieve reference data with overrides: + -r, --request {REFERENCE_DATA_REQUEST_OVERRIDE} + [-S, --security ] + [-f, --field ] + [-O, --override <= = {{VWAP_START_TIME=9:30, VWAP_END_TIME=11:30}}] +To retrieve reference data with table overrides: + -r, --request {REFERENCE_DATA_REQUEST_TABLE_OVERRIDE} + [-S, --security ] + [-f, --field ] +To retrieve intraday bars: + -r, --request {INTRADAY_BAR_REQUEST} + [-S, --security ] + [-e, --event ] + [-i, --interval ] + [--start-date ] + [--end-date ] + [-G, --gap-fill-initial-bar] + 1) All times are in GMT. + 2) Only one security can be specified. + 3) Only one event can be specified. +To retrieve intraday raw ticks: + -r, --request {INTRADAY_TICK_REQUEST} + [-S, --security ] + [-e, --event ] + [--start-date ] + [--end-date ] + [--include-condition-codes ] + 1) All times are in GMT. + 2) Only one security can be specified. +To retrieve historical data: + -r, --request {HISTORICAL_DATA_REQUEST} + [-S, --security ] + [-f, --field ]""", + metavar="requestType", + default=REFERENCE_DATA_REQUEST, + ) + + +def setDefaultValues(options): + if not options.eventTypes: + options.eventTypes = ["TRADE"] + + if not options.securities: + if options.requestType == REFERENCE_DATA_REQUEST_TABLE_OVERRIDE: + options.securities = ["FHR 3709 FA Mtge"] + else: + options.securities = ["IBM US Equity", "MSFT US Equity"] + + if not options.fields: + if options.requestType == REFERENCE_DATA_REQUEST_TABLE_OVERRIDE: + options.fields = ["MTG_CASH_FLOW", "SETTLE_DT"] + else: + options.fields = ["PX_LAST"] + if options.requestType == REFERENCE_DATA_REQUEST_OVERRIDE: + options.fields += ["DS002", "EQY_WEIGHTED_AVG_PX"] + + if ( + not options.overrides + and options.requestType == REFERENCE_DATA_REQUEST_OVERRIDE + ): + options.overrides = [ + Override("VWAP_START_TIME", "9:30"), + Override("VWAP_END_TIME", "11:30"), + ] + + # Compute default start/end datetime + if not options.startDateTime or not options.endDateTime: + ( + defaultStartDateTime, + defaultIntradayBarEndDateTime, + defaultIntradayTickEndDateTime, + ) = computeDefaultStartAndEndDateTime() + if not options.startDateTime: + options.startDateTime = defaultStartDateTime + + if not options.endDateTime: + options.endDateTime = ( + defaultIntradayBarEndDateTime + if options.requestType == INTRADAY_BAR_REQUEST + else defaultIntradayTickEndDateTime + ) + + +def computeDefaultStartAndEndDateTime(): + today = datetime.datetime.today() + previousTradingDate = today - datetime.timedelta(days=1) + if datetime.date.weekday(previousTradingDate.date()) == 5: # if Saturday + previousTradingDate = previousTradingDate - datetime.timedelta(days=1) + elif datetime.date.weekday(previousTradingDate.date()) == 6: # if Sunday + previousTradingDate = previousTradingDate - datetime.timedelta(days=2) + + # Start on the market open time (GMT) on previous trading day. + startDateTime = previousTradingDate.replace(hour=14, minute=30, second=0) + + # The default bar interval is 5 minute, by default there are 12 bars + intradayBarEndDateTime = startDateTime + datetime.timedelta(minutes=60) + intradayTickEndDateTime = startDateTime + datetime.timedelta(minutes=5) + + return startDateTime, intradayBarEndDateTime, intradayTickEndDateTime + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/util/SubscriptionOptions.py b/examples/demoapps/util/SubscriptionOptions.py new file mode 100644 index 0000000..b836197 --- /dev/null +++ b/examples/demoapps/util/SubscriptionOptions.py @@ -0,0 +1,153 @@ +from blpapi_import_helper import blpapi + +DEFAULT_SERVICE = "//blp/mktdata" +DEFAULT_TOPIC_PREFIX = "/ticker/" +DEFAULT_TOPIC = "IBM US Equity" + + +def addSubscriptionOptionsForSnapshot(parser): + """ + Creates an instance for snapshot requests, which + does not include interval option. + """ + addSubscriptionOptions(parser, True) + + +def addSubscriptionOptions(parser, isSnapshot=False): + """ + Helper function that adds the options for subscriptions to the argument + parser. + """ + subscription_group = parser.add_argument_group("Subscription Options") + subscription_group.add_argument( + "-s", + "--service", + dest="service", + help="service name (default: %(default)s)", + metavar="service", + default=DEFAULT_SERVICE, + ) + subscription_group.add_argument( + "-t", + "--topic", + dest="topics", + help=f"""topic name (default: {DEFAULT_TOPIC}). Can be specified multiple times. +Can be one of the following: +* Instrument +* Instrument qualified with a prefix +* Instrument qualified with a service and a prefix + """, + metavar="topic", + action="append", + default=[], + ) + subscription_group.add_argument( + "-f", + "--field", + dest="fields", + help="field to subscribe. Can be specified multiple times.", + metavar="field", + action="append", + default=[], + ) + subscription_group.add_argument( + "-o", + "--option", + dest="options", + help="subscription options. Can be specified multiple times.", + metavar="option", + action="append", + default=[], + ) + subscription_group.add_argument( + "-x", + "--topic-prefix", + dest="topicPrefix", + help="The topic prefix to be used for subscriptions (default: %(default)s)", + metavar="prefix", + default=DEFAULT_TOPIC_PREFIX, + ) + + if not isSnapshot: + subscription_group.add_argument( + "-i", + "--interval", + dest="interval", + type=float, + help="subscription option that specifies a time in seconds to " + "intervalize the subscriptions", + metavar="interval", + ) + + +def setSubscriptionSessionOptions(sessionOptions, options): + sessionOptions.setDefaultSubscriptionService(options.service) + sessionOptions.setDefaultTopicPrefix(options.topicPrefix) + + +def createSubscriptionList(options): + """ + Creates a SubscriptionList from the following command line arguments: + - topic names + - service name + - fields to subscribe to + - subscription options + - subscription interval + """ + if not options.topics: + options.topics = [DEFAULT_TOPIC] + + if options.interval: + options.options.append(f"interval={options.interval}") + + subscriptions = blpapi.SubscriptionList() + for topic in options.topics: + subscriptions.add( + topic, options.fields, options.options, blpapi.CorrelationId(topic) + ) + return subscriptions + + +def createSubscriptionStrings(options): + """ + Creates a dict from the topics provided on the command line to their + corresponding subscription strings. + """ + if not options.topics: + options.topics = [DEFAULT_TOPIC] + + subscriptionStrings = {} + + # Use SubscriptionList to help construct the subscription string + subscriptionList = blpapi.SubscriptionList() + for i, userTopic in enumerate(options.topics): + subscriptionList.add(userTopic, options.fields, options.options) + subscriptionStrings[userTopic] = subscriptionList.topicStringAt(i) + print( + f"topic: {userTopic} -> subscription string: " + f"{subscriptionStrings[userTopic]}" + ) + + return subscriptionStrings + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/demoapps/util/events/SessionRouter.py b/examples/demoapps/util/events/SessionRouter.py new file mode 100644 index 0000000..44cf6b1 --- /dev/null +++ b/examples/demoapps/util/events/SessionRouter.py @@ -0,0 +1,118 @@ +from typing import Callable +from blpapi_import_helper import blpapi + + +def printEvent(event: blpapi.Event): + for message in event: + service = message.service() + if service: + print(f"Service: {service.name()}") + print(message) + + +class SessionRouter: + EventHandler = Callable[[blpapi.AbstractSession, blpapi.Event], None] + MessageHandler = Callable[ + [blpapi.AbstractSession, blpapi.Event, blpapi.Message], None + ] + ExceptionHandler = Callable[ + [blpapi.AbstractSession, blpapi.Event, Exception], None + ] + + def __init__(self): + super(SessionRouter, self).__init__() + self._eventHandlersByEventType = {} + self._messageHandlersByEventType = {} + self._messageHandlersByMessageType = {} + self._messageHandlersByCorrelationId = {} + self._exceptionHandlers = [] + + def processEvent( + self, event: blpapi.Event, session: blpapi.AbstractSession + ): + try: + printEvent(event) + + eventHandler = self._eventHandlersByEventType.get( + event.eventType() + ) + if eventHandler is not None: + eventHandler(session, event) + + eventTypeMessageHandler = self._messageHandlersByEventType.get( + event.eventType() + ) + + for message in event: + for cid in message.correlationIds(): + cidMessageHandler = ( + self._messageHandlersByCorrelationId.get(cid) + ) + if cidMessageHandler is not None: + cidMessageHandler(session, event, message) + + if eventTypeMessageHandler is not None: + eventTypeMessageHandler(session, event, message) + + messageTypeMessageHandler = ( + self._messageHandlersByMessageType.get( + message.messageType() + ) + ) + if messageTypeMessageHandler is not None: + messageTypeMessageHandler(session, event, message) + except Exception as exception: # pylint: disable=broad-except + for exceptionHandler in self._exceptionHandlers: + exceptionHandler(session, event, exception) + + def addEventHandlerByEventType( + self, eventType: int, eventHandler: EventHandler + ): + self._eventHandlersByEventType[eventType] = eventHandler + + def addMessageHandlerByEventType( + self, eventType: int, messageHandler: MessageHandler + ): + self._messageHandlersByEventType[eventType] = messageHandler + + def addMessageHandlerByMessageType( + self, messageType: blpapi.Name, messageHandler: MessageHandler + ): + self._messageHandlersByMessageType[messageType] = messageHandler + + def addMessageHandlerByCorrelationId( + self, + correlationId: blpapi.CorrelationId, + messageHandler: MessageHandler, + ): + self._messageHandlersByCorrelationId[correlationId] = messageHandler + + def addExceptionHandler(self, exceptionHandler: ExceptionHandler): + self._exceptionHandlers.append(exceptionHandler) + + def removeMessageHandlerByCorrelationId( + self, correlationId: blpapi.CorrelationId + ): + self._messageHandlersByCorrelationId.pop(correlationId, None) + + +__copyright__ = """ +Copyright 2021, Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright +notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/README.md b/examples/unittests/market-data-notifier/README.md new file mode 100644 index 0000000..b5222ca --- /dev/null +++ b/examples/unittests/market-data-notifier/README.md @@ -0,0 +1,43 @@ +# MarketDataNotifier + +This example includes an application and the unit tests for the application. + +The MarketDataNotifier is an example of how a BLPAPI application can be +structured and unit tested. + +The application source code is in `src/` and unit tests in `tests/`. + +## Description of the example + +The example provided will test the application by mocking the essential objects. + +The interfaces in the diagram give us the ability to create mock objects by +implementing these interfaces. + +![](./diagram.png) + +The Authorizer is responsible for setting up the authorization of the +application. This includes creating and sending the auth request and awaiting a +successful reply. + +The Subscriber is responsible for setting up the subscriptions for given +topics. + +The EventProcessor handles all the incoming events and triggers business logic +(ComputeEngine or Notifier). + +The Notifier fires notifications within the system such as sending alerts to +the terminal. + +The ComputeEngine does complex computations on incoming data and passes it off +to the Notifier. + +The actual application does the following: + + * Sets up the necessary objects (Notifier, ComputeEngine, Session, + TokenGenerator, Authorizer, Subscriber) + * Starts the session + * Authorizes the application + * Subscribes to topics + * Allows the EventProcessor to process the incoming events + * Calls either methods from Notifier or ComputeEngine diff --git a/examples/unittests/market-data-notifier/diagram.png b/examples/unittests/market-data-notifier/diagram.png new file mode 100644 index 0000000..6a9f703 Binary files /dev/null and b/examples/unittests/market-data-notifier/diagram.png differ diff --git a/examples/unittests/market-data-notifier/src/__init__.py b/examples/unittests/market-data-notifier/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/unittests/market-data-notifier/src/appconfig.py b/examples/unittests/market-data-notifier/src/appconfig.py new file mode 100644 index 0000000..222c3de --- /dev/null +++ b/examples/unittests/market-data-notifier/src/appconfig.py @@ -0,0 +1,148 @@ +"""Sample command line parser.""" + +from argparse import ArgumentParser, Action + + +class AuthOptionsAction(Action): # pylint: disable=too-few-public-methods + """Parse authorization args from user input.""" + + def __call__(self, parser, args, values, option_string=None): + value = values + vals = value.split("=", 1) + + auth = None + if value == "user": + auth = {"option": "AuthenticationType=OS_LOGON"} + elif value == "none": + auth = {"option": None} + elif vals[0] == "app" and len(vals) == 2: + auth = { + "option": "AuthenticationMode=APPLICATION_ONLY;" + "ApplicationAuthenticationType=APPNAME_AND_KEY;" + "ApplicationName=" + vals[1] + } + elif vals[0] == "userapp" and len(vals) == 2: + auth = { + "option": "AuthenticationMode" + "=USER_AND_APPLICATION;AuthenticationType=OS_LOGON;" + "ApplicationAuthenticationType=APPNAME_AND_KEY;" + "ApplicationName=" + vals[1] + } + elif vals[0] == "dir" and len(vals) == 2: + auth = { + "option": "AuthenticationType=DIRECTORY_SERVICE;" + "DirSvcPropertyName=" + vals[1] + } + elif vals[0] == "manual": + parts = [] + if len(vals) == 2: + parts = vals[1].split(",") + + if len(parts) != 3: + raise ValueError("Invalid auth option '%s'" % value) + + option = ( + "AuthenticationMode=USER_AND_APPLICATION;" + "AuthenticationType=MANUAL;" + "ApplicationAuthenticationType=APPNAME_AND_KEY;" + "ApplicationName=" + ) + parts[0] + + auth = { + "option": option, + "manual": {"ip": parts[1], "user": parts[2]}, + } + else: + raise ValueError("Invalid auth option '%s'" % value) + + setattr(args, self.dest, auth) + + +def parseCmdLine(): + """Parse command line arguments.""" + + parser = ArgumentParser(description="Retrieve realtime data.") + parser.add_argument( + "-a", + "--ip", + dest="hosts", + help="server name or IP (default: localhost)", + metavar="ipAddress", + action="append", + default=[], + ) + parser.add_argument( + "-p", + dest="port", + type=int, + help="server port (default: %default)", + metavar="tcpPort", + default=8194, + ) + parser.add_argument( + "-s", + dest="service", + help="service name (default: %default)", + metavar="service", + default="//viper/mktdata", + ) + parser.add_argument( + "-t", + dest="topics", + help="topic name (default: //blp/mktdata/ticker/IBM Equity)", + metavar="topic", + action="append", + default=["//blp/mktdata/ticker/IBM Equity"], + ) + parser.add_argument( + "-f", + dest="fields", + help="field to subscribe to (default: LAST_PRICE)", + metavar="field", + action="append", + default=["LAST_PRICE"], + ) + parser.add_argument( + "-o", + dest="options", + help="subscription options (default: empty)", + metavar="option", + action="append", + default=[], + ) + parser.add_argument( + "--auth", + dest="auth", + help="authentication option: " + "user|none|app=|userapp=|dir=|" + "manual=" + " (default: none)", + metavar="option", + action=AuthOptionsAction, + default={"option": None}, + ) + + args = parser.parse_args() + return args + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/application.py b/examples/unittests/market-data-notifier/src/application.py new file mode 100644 index 0000000..d09f9b0 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/application.py @@ -0,0 +1,54 @@ +"""Sample application.""" + +from __future__ import print_function + + +# pylint: disable=too-few-public-methods +class Application: + """Custom application for demonstration purposes.""" + + def __init__(self, session, authorizer, subscriber, options): + self._session = session + self._authorizer = authorizer + self._subscriber = subscriber + self._options = options + + def run(self): + """Start the application.""" + if not self._session.start(): + print("Failed to start session") + return + + identity = self._session.createIdentity() + if not self._authorizer.authorize(identity): + print("No authorization") + return + + self._subscriber.subscribe( + self._options.topics, + self._options.fields, + self._options.options, + identity, + ) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/authorizer.py b/examples/unittests/market-data-notifier/src/authorizer.py new file mode 100644 index 0000000..faaf1d9 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/authorizer.py @@ -0,0 +1,94 @@ +"""Sample authorization related component.""" + +from __future__ import print_function + +import datetime + +import blpapi + +TOKEN = blpapi.Name("token") + + +# pylint: disable=too-few-public-methods, too-many-branches +class Authorizer: + """Helper for authorization.""" + + def __init__(self, session, token_generator): + self._session = session + self._token_generator = token_generator + + def _authorize(self, auth_service, identity, cid, event_queue=None): + """Authorize the identity.""" + + token = self._token_generator.generate() + + if token is None: + print("Failed to get token") + return False + + # Create and fill the authorization request + auth_request = auth_service.createAuthorizationRequest() + auth_request.set(TOKEN, token) + + if event_queue is None: + event_queue = blpapi.EventQueue() + + # Send authorization request to "fill" the Identity + self._session.sendAuthorizationRequest( + auth_request, identity, cid, event_queue + ) + + # Process related responses + start_time = datetime.datetime.today() + WAIT_TIME_SECONDS = 10 + while True: + event = event_queue.nextEvent(WAIT_TIME_SECONDS * 1000) + if ( + event.eventType() == blpapi.Event.RESPONSE + or event.eventType() == blpapi.Event.REQUEST_STATUS + or event.eventType() == blpapi.Event.PARTIAL_RESPONSE + ): + for msg in event: + print(msg) + if msg.messageType() == blpapi.Names.AUTHORIZATION_SUCCESS: + return True + print("Authorization failed") + return False + + end_time = datetime.datetime.today() + max_time_diff = datetime.timedelta(seconds=WAIT_TIME_SECONDS) + if end_time - start_time > max_time_diff: + return False + + def authorize(self, identity, queue=None): + """Authorize the provided identity. + + Return True on success and False on failure. + """ + if self._session.openService("//blp/apiauth"): + service = self._session.getService("//blp/apiauth") + cid = blpapi.CorrelationId("auth") + return self._authorize(service, identity, cid, queue) + return False + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/compute_engine.py b/examples/unittests/market-data-notifier/src/compute_engine.py new file mode 100644 index 0000000..9aaa203 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/compute_engine.py @@ -0,0 +1,32 @@ +"""Dummy 'compute engine' for testing purposes""" + + +# pylint: disable=too-few-public-methods, no-init, no-self-use +class ComputeEngine: + """A class that does some 'financial computation'.""" + + def someVeryComplexComputation(self, value): + """Computation to be tested.""" + return value * 2 + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/event_processor.py b/examples/unittests/market-data-notifier/src/event_processor.py new file mode 100644 index 0000000..9a849e6 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/event_processor.py @@ -0,0 +1,53 @@ +"""Simple class for handling incoming events from a session""" + +import blpapi + +TOKEN_SUCCESS = blpapi.Name("TokenSuccess") +TOKEN_FAILURE = blpapi.Name("TokenFailure") +TOKEN = blpapi.Name("token") +LAST_PRICE = blpapi.Name("LAST_PRICE") + + +# pylint: disable=too-few-public-methods +class EventProcessor: + """Custom EventHandler implementation for demonstration purposes.""" + + def __init__(self, notifier, compute_engine): + self._notifier = notifier + self._compute_engine = compute_engine + + def processEvent(self, event, _): + """Action for each event from the session.""" + for msg in event: + if event.eventType() == blpapi.Event.SESSION_STATUS: + self._notifier.log_session_state(msg) + elif event.eventType() == blpapi.Event.SUBSCRIPTION_STATUS: + self._notifier.log_subscription_state(msg) + elif event.eventType() == blpapi.Event.SUBSCRIPTION_DATA: + last_price = msg.getElementAsFloat(LAST_PRICE) + result = self._compute_engine.someVeryComplexComputation( + last_price + ) + self._notifier.send_to_terminal(result) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/main.py b/examples/unittests/market-data-notifier/src/main.py new file mode 100644 index 0000000..4860419 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/main.py @@ -0,0 +1,59 @@ +"""Sample script for subscribing to a security.""" + +import blpapi + +import appconfig +from compute_engine import ComputeEngine +from notifier import Notifier +from event_processor import EventProcessor +from token_generator import TokenGenerator +from authorizer import Authorizer +from subscriber import Subscriber +from application import Application + +if __name__ == "__main__": + options = appconfig.parseCmdLine() + compute_engine = ComputeEngine() + notifier = Notifier() + event_processor = EventProcessor(notifier, compute_engine) + + so = blpapi.SessionOptions() + for i, host in enumerate(options.hosts): + so.setServerAddress(host, options.port, i) + + so.setAuthenticationOptions(options.auth["option"]) + + session = blpapi.Session(so, event_processor.processEvent) + + token_generator = TokenGenerator(session) + authorizer = Authorizer(session, token_generator) + + subscriber = Subscriber(session) + + application = Application(session, authorizer, subscriber, options) + + application.run() + + input("Press Enter to continue...\n") + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/notifier.py b/examples/unittests/market-data-notifier/src/notifier.py new file mode 100644 index 0000000..e459c50 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/notifier.py @@ -0,0 +1,47 @@ +"""Sample class for testing purposes.""" + +from __future__ import print_function + + +# pylint: disable=no-init,no-self-use +class Notifier: + """ + Notifier is an approximation of a class that attempts to: + 1. Log all session events (for example SessionStartupFailure). + 2. Log all subscription events (for example SubscriptionStarted). + 3. Deliver subscription data to terminal ("Bloomberg terminal"). + """ + + def log_session_state(self, msg): + """Print the provided message.""" + print("Logging Session state with " + str(msg)) + + def log_subscription_state(self, msg): + """Print the provided message.""" + print("Logging Subscription state with " + str(msg)) + + def send_to_terminal(self, value): + """Print the provided value.""" + print("VALUE = " + str(value)) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/subscriber.py b/examples/unittests/market-data-notifier/src/subscriber.py new file mode 100644 index 0000000..fdf49e4 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/subscriber.py @@ -0,0 +1,43 @@ +"""Sample subscriber for testing.""" + +import blpapi + + +# pylint: disable=too-few-public-methods,too-many-arguments +class Subscriber: + """Custom Subscriber implementation for demonstration purposes.""" + + def __init__(self, session): + self._session = session + + def subscribe(self, topics, fields, options, identity): + """Subscribes to the provided service/topics.""" + + subscription_list = blpapi.SubscriptionList() + for topic in topics: + subscription_list.add( + topic, fields, options, blpapi.CorrelationId(topic) + ) + self._session.subscribe(subscription_list, identity) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/src/token_generator.py b/examples/unittests/market-data-notifier/src/token_generator.py new file mode 100644 index 0000000..6c01700 --- /dev/null +++ b/examples/unittests/market-data-notifier/src/token_generator.py @@ -0,0 +1,59 @@ +"""Sample token generator for testing.""" + +import blpapi + +TOKEN_SUCCESS = blpapi.Names.TOKEN_GENERATION_SUCCESS +TOKEN_FAILURE = blpapi.Names.TOKEN_GENERATION_FAILURE +TOKEN = blpapi.Name("token") + + +# pylint: disable=too-few-public-methods +class TokenGenerator: + """Generates a token for later authorization.""" + + def __init__(self, session): + self._session = session + + def generate(self, event_queue=None): + """Generate a token.""" + + token = None + if event_queue is None: + event_queue = blpapi.EventQueue() + + self._session.generateToken(blpapi.CorrelationId(), event_queue) + + event = event_queue.nextEvent() + if ( + event.eventType() == blpapi.Event.REQUEST_STATUS + or event.eventType() == blpapi.Event.TOKEN_STATUS + ): + for msg in event: + if msg.messageType() == TOKEN_SUCCESS: + token = msg.getElementAsString(TOKEN) + return token + if msg.messageType() == TOKEN_FAILURE: + return None + return None + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/tests/test_application.py b/examples/unittests/market-data-notifier/tests/test_application.py new file mode 100644 index 0000000..24f6230 --- /dev/null +++ b/examples/unittests/market-data-notifier/tests/test_application.py @@ -0,0 +1,144 @@ +""" Test suite for Application. """ + +import unittest + +try: + from unittest.mock import Mock +except ImportError: + from mock import Mock + +import os +import sys + +# pylint: disable=line-too-long,wrong-import-position +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")) +) +from application import Application + + +class TestApplication(unittest.TestCase): + """Test cases for Application.""" + + def setUp(self): + self.mock_session = Mock() + self.mock_authorizer = Mock() + self.mock_subscriber = Mock() + self.mock_options = Mock() + + def testSessionStartFail(self): + """Verify that if the session fails to start, no authorization or + subscriptions are made. + + Plan: + Set up and verify the following mocks: + a. start() returns False. + b. authorize() is not called. + c. subscribe() is not called. + """ + application = Application( + self.mock_session, + self.mock_authorizer, + self.mock_subscriber, + self.mock_options, + ) + + self.mock_session.start.return_value = False + application.run() + + self.mock_session.start.assert_called_once() + self.mock_authorizer.authorize.assert_not_called() + self.mock_subscriber.subscribe.assert_not_called() + + def testSessionAuthorizeFail(self): + """Verify that if authorization fails, no subscriptions are made. + + Plan: + Set up and verify the following mocks: + a. start() returns True. + b. authorize() fails and returns False. + c. subscribe() is not called. + """ + application = Application( + self.mock_session, + self.mock_authorizer, + self.mock_subscriber, + self.mock_options, + ) + + self.mock_session.start.return_value = True + self.mock_authorizer.authorize.return_value = False + + application.run() + + self.mock_session.start.assert_called_once() + self.mock_authorizer.authorize.assert_called_once() + self.mock_subscriber.subscribe.assert_not_called() + + def testSubscribeWithConfig(self): + """Verify the correct topics and fields are used when subscribing on + the session. + + Plan: + Set up and verify the following mocks: + a. start() returns True. + b. authorize() succeeds and returns True. + c. subscribe() is called with the same topics and fields configured in + the options. + """ + expected_topics = ["IBM US Equity", "MSFT US Equity"] + expected_fields = ["LAST_PRICE", "BID", "ASK"] + service_name = "//blp/mktdata" + + self.mock_options.configure_mock( + **{ + "service": service_name, + "topics": expected_topics, + "fields": expected_fields, + } + ) + + application = Application( + self.mock_session, + self.mock_authorizer, + self.mock_subscriber, + self.mock_options, + ) + + self.mock_session.start.return_value = True + self.mock_authorizer.authorize.return_value = True + + application.run() + + self.mock_session.start.assert_called_once() + self.mock_authorizer.authorize.assert_called_once() + + actual_topics = self.mock_subscriber.subscribe.call_args[0][0] + actual_fields = self.mock_subscriber.subscribe.call_args[0][1] + self.assertEqual(expected_topics, actual_topics) + self.assertEqual(expected_fields, actual_fields) + + +if __name__ == "__main__": + unittest.main() + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/tests/test_authorizer.py b/examples/unittests/market-data-notifier/tests/test_authorizer.py new file mode 100644 index 0000000..e4b022d --- /dev/null +++ b/examples/unittests/market-data-notifier/tests/test_authorizer.py @@ -0,0 +1,306 @@ +""" Test suite for Authorizer. """ + +import unittest + +try: + from unittest.mock import Mock +except ImportError: + from mock import Mock + +import os +import sys + +# pylint: disable=line-too-long,wrong-import-position +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")) +) +from authorizer import Authorizer + +import blpapi + + +APIAUTH_SCHEMA = """ + + + + Request + AuthorizationRequest + Response + AuthorizationSuccess + AuthorizationFailure + true + + + Request + TokenRequest + Response + TokenResponse + + false + false + false + false + false + + + + seqAuthorizationRequest + + + true + false + + + + true + false + + + + seqTokenRequest + + + true + false + + + + true + false + + + + seqErrorInfo + + + true + false + + + + true + false + + + + true + false + + + + true + false + + + + true + false + + + + seqAuthorizationSuccess + + + seqAuthorizationFailure + + + true + false + + + + seqAuthorizationTokenResponse + + + seqTokenResponse + + + true + false + + + + true + false + + + + choiceRequest + + + true + false + + + + true + false + + + + choiceResponse + + + true + false + + + + true + false + + + + true + false + + + + +""" + + +class TestAuthorizer(unittest.TestCase): + """Test cases for Authorizer.""" + + def setUp(self): + self.mock_session = Mock() + self.mock_token_generator = Mock() + self.authorizer = Authorizer( + self.mock_session, self.mock_token_generator + ) + self.mock_event_queue = Mock() + + def testAuthorizationSuccess(self): + """Verify that for a valid identity the authorization returns True. + + Plan: + 1. Create a service instance from the apiauth schema. + 2. Set the following expectations: + b. Verify that service is opened and successfully retrieved. + 3. Create an admin event to represent the authorization success. + 4. Call authorize() + 4. Verify the following: + a. The service is opened and retrieved. + b. A token is generated. + c. An authorization request is sent. + d. authorize() returns True. + """ + self.mock_session.openService.return_value = True + + service = blpapi.test.deserializeService(APIAUTH_SCHEMA) + self.mock_session.getService.return_value = service + + token = "abcdefg" + self.mock_token_generator.generate.return_value = token + + event = blpapi.test.createEvent(blpapi.Event.RESPONSE) + authorization_success = blpapi.Names.AUTHORIZATION_SUCCESS + schema_def = blpapi.test.getAdminMessageDefinition( + authorization_success + ) + + blpapi.test.appendMessage(event, schema_def) + + # The AuthorizationSuccess message does not have any fields, therefore + # no formatting is required. + + self.mock_event_queue.nextEvent.return_value = event + + identity = Mock() + authorization_result = self.authorizer.authorize( + identity, self.mock_event_queue + ) + + self.mock_session.openService.assert_called_once() + self.mock_session.getService.assert_called_once() + self.mock_session.sendAuthorizationRequest.assert_called_once() + + self.mock_token_generator.generate.assert_called_once() + self.mock_event_queue.nextEvent.assert_called_once() + + self.assertTrue(authorization_result) + + def testAuthorizationFailure(self): + """Verify that for a invalid identity the authorization returns False. + + Plan: + 1. Create a service instance from the apiauth schema. + 2. Create and format an event to represent the authorization failure. + 3. Call authorize() + 4. Verify the following: + a. The service is opened and retrieved. + b. A token is generated. + c. An authorization request is sent. + d. authorize() returns False. + """ + self.mock_session.openService.return_value = True + + service = blpapi.test.deserializeService(APIAUTH_SCHEMA) + self.mock_session.getService.return_value = service + + token = "abcdefg" + self.mock_token_generator.generate.return_value = token + + event = blpapi.test.createEvent(blpapi.Event.RESPONSE) + authorization_request = blpapi.Name("AuthorizationRequest") + authorization_failure_index = 1 + schema_def = service.getOperation( + authorization_request + ).getResponseDefinitionAt(authorization_failure_index) + + formatter = blpapi.test.appendMessage(event, schema_def) + + message_content = { + "reason": { + "code": 101, + "message": "Invalid user", + "category": "BAD_ARGS", + "subcategory": "INVALID_USER", + "source": "test-source", + } + } + + formatter.formatMessageDict(message_content) + + self.mock_event_queue.nextEvent.return_value = event + + identity = Mock() + authorization_result = self.authorizer.authorize( + identity, self.mock_event_queue + ) + + self.mock_session.openService.assert_called_once() + self.mock_session.getService.assert_called_once() + self.mock_session.sendAuthorizationRequest.assert_called_once() + + self.mock_token_generator.generate.assert_called_once() + self.mock_event_queue.nextEvent.assert_called_once() + + self.assertFalse(authorization_result) + + +if __name__ == "__main__": + unittest.main() + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/tests/test_eventprocessor.py b/examples/unittests/market-data-notifier/tests/test_eventprocessor.py new file mode 100644 index 0000000..8adf3e6 --- /dev/null +++ b/examples/unittests/market-data-notifier/tests/test_eventprocessor.py @@ -0,0 +1,194 @@ +""" Test suite for EventProcessor. """ + +import unittest + +try: + from unittest.mock import Mock +except ImportError: + from mock import Mock + +import os +import sys + +# pylint: disable=line-too-long,wrong-import-position +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")) +) +from event_processor import EventProcessor + +import blpapi + + +MKTDATA_SCHEMA = """ + + + + 0 + 1 + 2 + 3 + 4 + 9999 + + 134217729 + + 9999 + + + + fields in subscription + + Last Trade/Last Price + 65536 + + + Bid Price + 131072 + + + Ask Price + 196608 + + + Volume + 458753 + + + + +""" + + +class TestEventProcessor(unittest.TestCase): + """Test cases for EventProcessor.""" + + def setUp(self): + self.mock_session = Mock() + self.mock_notifier = Mock() + self.mock_compute_engine = Mock() + self.event_processor = EventProcessor( + self.mock_notifier, self.mock_compute_engine + ) + + def testNotifierReceivesSessionStarted(self): + """Verify that notifier receives a `SessionStarted' message. + + Plan: + 1. Create a SessionStatus admin event using blpapi.test.createEvent(). + 2. Obtain the message schema using + blpapi.test.getAdminMessageDefinition(). + 3. Append a message of type SessionStarted using + blpapi.test.appendMessage(). + 4. Verify that the expected message is passed to + notifier.log_session_state(). + """ + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + session_started = blpapi.Names.SESSION_STARTED + schema_def = blpapi.test.getAdminMessageDefinition(session_started) + + blpapi.test.appendMessage(event, schema_def) + + self.event_processor.processEvent(event, self.mock_session) + + self.mock_notifier.log_session_state.assert_called_once() + actual_message = self.mock_notifier.log_session_state.call_args[0][0] + self.assertEqual(session_started, actual_message.messageType()) + + def testNotifierReceivesSubscriptionStarted(self): + """Verify that notifier receives a `SubscriptionStarted` message. + + Plan: + 1. Create a SubscriptionStatus admin event using + blpapi.test.createEvent(). + 2. Obtain the schema for SubscriptionStarted message using + blpapi.test.getAdminMessageDefinition(). + 3. Append a message of type `SubscriptionStarted` using + blpapi.test.appendMessage(). + 4. Verify that the expected message is passed to + notifier.log_subscription_state(). + """ + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + subscription_started = blpapi.Names.SUBSCRIPTION_STARTED + schema_def = blpapi.test.getAdminMessageDefinition( + subscription_started + ) + + blpapi.test.appendMessage(event, schema_def) + + self.event_processor.processEvent(event, self.mock_session) + + self.mock_notifier.log_subscription_state.assert_called_once() + actual_message = self.mock_notifier.log_subscription_state.call_args[ + 0 + ][0] + self.assertEqual(subscription_started, actual_message.messageType()) + + def testNotifierReceivesSubscriptionData(self): + """Verify that: + 1. Compute engine receives the correct LAST_PRICE. + 2. Compute engine performs the correct computation and returns the + correct value. + 3. The correct value is sent to the terminal. + + Plan: + 1. Obtain the service by deserializing its schema. + 2. Create a SubscriptionEvent using blpapi.test.createEvent(). + 3. Obtain the element schema definition from the service. + 4. Append a message of type `MarketDataEvents' using + blpapi.test.appendMessage(). + 5. Format the message using the formatter returned by appendMessage(). + In this example the message's body is represented by + { LAST_PRICE: 142.80 }. + 6. Verify that the expected and actual values are the same. + """ + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_DATA) + + service = blpapi.test.deserializeService(MKTDATA_SCHEMA) + mktdata_events = blpapi.Name("MarketDataEvents") + schema_def = service.getEventDefinition(mktdata_events) + + formatter = blpapi.test.appendMessage(event, schema_def) + + expected_last_price = 142.80 + message_content = {"LAST_PRICE": expected_last_price} + formatter.formatMessageDict(message_content) + + expected_compute_result = 200.00 + + self.mock_compute_engine.someVeryComplexComputation.return_value = ( + expected_compute_result + ) + + self.event_processor.processEvent(event, self.mock_session) + + self.mock_compute_engine.someVeryComplexComputation.assert_called_once_with( + expected_last_price + ) + self.mock_notifier.send_to_terminal.assert_called_once_with( + expected_compute_result + ) + + +if __name__ == "__main__": + unittest.main() + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/market-data-notifier/tests/test_tokengenerator.py b/examples/unittests/market-data-notifier/tests/test_tokengenerator.py new file mode 100644 index 0000000..57a8047 --- /dev/null +++ b/examples/unittests/market-data-notifier/tests/test_tokengenerator.py @@ -0,0 +1,131 @@ +""" Test suite for TokenGenerator. """ + +import unittest + +try: + from unittest.mock import Mock +except ImportError: + from mock import Mock + +import os +import sys + +# pylint: disable=line-too-long,wrong-import-position +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")) +) +from token_generator import TokenGenerator + +import blpapi + + +class TestTokenGenerator(unittest.TestCase): + """Test cases for TokenGenerator.""" + + def setUp(self): + self.mock_session = Mock() + self.mock_event_queue = Mock() + self.token_generator = TokenGenerator(self.mock_session) + + def testTokenGenerationSuccess(self): + """Verify that on token generation success, the application receives + a valid token. + + Plan: + 1. Create a TokenStatus admin event using blpapi.test.createEvent(). + 2. Obtain the schema for TokenGenerationSuccess using + blpapi.test.getAdminMessageDefinition(). + 3. Append a message of type TokenGenerationSuccess using + blpapi.test.appendMessage(). + 4. Using the returned formatter, format the message. In this example + the message has body { "token": "dummy_token" }. + `token` is the element name, and `dummy_token` is the token value + which will be delivered to the client application. + 5. Setup the event queue to return the appropriate event. + 6. Verify that the expected token value is generated. + """ + event = blpapi.test.createEvent(blpapi.Event.TOKEN_STATUS) + token_success = blpapi.Names.TOKEN_GENERATION_SUCCESS + schema_def = blpapi.test.getAdminMessageDefinition(token_success) + + formatter = blpapi.test.appendMessage(event, schema_def) + + expected_token = "dummy_token" + message_content = {"token": expected_token} + + formatter.formatMessageDict(message_content) + + self.mock_event_queue.nextEvent.return_value = event + + actual_token = self.token_generator.generate(self.mock_event_queue) + + self.mock_session.generateToken.assert_called_once() + self.mock_event_queue.nextEvent.assert_called_once() + self.assertEqual(expected_token, actual_token) + + def testTokenGenerationFailure(self): + """Verify that on token generation failure, the application receives an + empty token. + + Plan: + 1. Create a TokenStatus admin event using blpapi.test.createEvent(). + 2. Obtain schema for TokenGenerationFailure using + blpapi.test.getAdminMessageDefinition(). + 3. Append a message of type TokenGenerationFailure using + blpapi.test.appendMessage(). + 4. Using the returned formatter, format the message. In this example, + the message body contains the reason for failure. + The reason is delivered to the user application. + 5. Setup the event queue to return the appropriate event. + 6. Verify that the actual token is None. + """ + message_content = { + "reason": { + "source": "apitkns (apiauth) on n795", + "category": "NO_AUTH", + "errorCode": 3, + "description": "App not in emrs ...", + "subcategory": "INVALID_APP", + } + } + event = blpapi.test.createEvent(blpapi.Event.TOKEN_STATUS) + + token_failure = blpapi.Names.TOKEN_GENERATION_FAILURE + schema_def = blpapi.test.getAdminMessageDefinition(token_failure) + + formatter = blpapi.test.appendMessage(event, schema_def) + + formatter.formatMessageDict(message_content) + + self.mock_event_queue.nextEvent.return_value = event + + actual_token = self.token_generator.generate(self.mock_event_queue) + + self.mock_session.generateToken.assert_called_once() + self.mock_event_queue.nextEvent.assert_called_once() + self.assertIsNone(actual_token) + + +if __name__ == "__main__": + unittest.main() + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/snippets/resolver/resolverutils.py b/examples/unittests/snippets/resolver/resolverutils.py new file mode 100644 index 0000000..bec31ef --- /dev/null +++ b/examples/unittests/snippets/resolver/resolverutils.py @@ -0,0 +1,122 @@ +""" Sample utility functions for registering a service and handling permission +requests. """ + +import blpapi + +# 'blpapi.Name' objects are more expensive to construct than `str`, but +# are more efficient on use through the interface. By creating the +# 'blpapi.Name' objects in advance we can take advantage of the efficiency +# without paying the cost of constructing them when needed. +TOPIC = blpapi.Name("topic") +TOPICS = blpapi.Name("topics") +TOPIC_PERMISSION = blpapi.Name("topicPermissions") +RESULT = blpapi.Name("result") +REASON = blpapi.Name("reason") +SOURCE = blpapi.Name("source") +CATEGORY = blpapi.Name("category") +SUBCATEGORY = blpapi.Name("subcategory") +DESCRIPTION = blpapi.Name("description") + +ALLOWED_APP_ID = 1234 +RESOLVER_ID = "service:hostname" +# This can be any string, but it's helpful to provide information on the +# instance of the resolver that responded to debug failures in production. + + +def resolutionServiceRegistration( + providerSession, providerIdentity, serviceName +): + """This helper demonstrates how to register a service. + + This helper assumes the following: + * Specified `providerSession` is already started + * Specified `providerIdentity` is already authorized if auth is needed or + default-constructed if authorization is not required. + + Args: + providerSession (ProviderSession): The session to register services. + providerIdentity (Identity): Identity used to verify permissions to + provide the service being registered. + serviceName (str): Name of the service. + + Returns: + bool: True if service registration succeeds; False otherwise. + """ + serviceOptions = blpapi.ServiceRegistrationOptions() + + dummyPriority = 123 + serviceOptions.setServicePriority(dummyPriority) + + serviceOptions.setPartsToRegister( + blpapi.ServiceRegistrationOptions.PART_PUBLISHER_RESOLUTION + ) + + if not providerSession.registerService( + serviceName, providerIdentity, serviceOptions + ): + print("Failed to register {}".format(serviceName)) + return False + + return True + + +def handlePermissionRequest(providerSession, service, request): + """Respond to a PermissionRequest. + + Only accept requests with applicationId `ALLOWED_APP_ID`. + """ + assert request.messageType() == blpapi.Names.PERMISSION_REQUEST + + disallowed = 1 + if ( + request.hasElement("applicationId") + and request.getElementAsInteger("applicationId") == ALLOWED_APP_ID + ): + disallowed = 0 + + response = service.createResponseEvent(request.correlationIds()[0]) + formatter = blpapi.EventFormatter(response) + formatter.appendResponse(blpapi.Names.PERMISSION_RESPONSE) + + topics = request.getElement(TOPICS) + formatter.pushElement(TOPIC_PERMISSION) + + for i in range(topics.numValues()): + formatter.appendElement() + formatter.setElement(TOPIC, topics.getValueAsString(i)) + formatter.setElement(RESULT, disallowed) + if disallowed: + formatter.pushElement(REASON) + formatter.setElement(SOURCE, RESOLVER_ID) + formatter.setElement(CATEGORY, "NOT_AUTHORIZED") + formatter.setElement(SUBCATEGORY, "") + formatter.setElement(DESCRIPTION, "Only app 1234 allowed") + formatter.popElement() + formatter.popElement() + + formatter.popElement() + + providerSession.sendResponse(response) + return True + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/snippets/resolver/test_resolverutils.py b/examples/unittests/snippets/resolver/test_resolverutils.py new file mode 100644 index 0000000..a0fa88e --- /dev/null +++ b/examples/unittests/snippets/resolver/test_resolverutils.py @@ -0,0 +1,221 @@ +""" Sample test cases for mocking `blpapi` objects and using the `blpapi.test` +submodule in the context of resolvers. +""" + +import unittest + + +try: + from unittest.mock import ANY, Mock +except ImportError: + from mock import ANY, Mock + +import blpapi + +from resolverutils import ( + resolutionServiceRegistration, + handlePermissionRequest, +) + + +RESULT = blpapi.Name("result") +REASON = blpapi.Name("reason") +CATEGORY = blpapi.Name("category") +NOT_AUTHORIZED = blpapi.Name("NOT_AUTHORIZED") +TOPIC_PERMISSIONS = blpapi.Name("topicPermissions") +PERMISSION_REQUEST = blpapi.Names.PERMISSION_REQUEST +PERMISSION_RESPONSE = blpapi.Names.PERMISSION_RESPONSE +TOPICS = blpapi.Name("topics") +SERVICE_NAME = blpapi.Name("serviceName") +APPLICATION_ID = blpapi.Name("applicationId") + +ALLOWED_APP_ID = 1234 +INVALID_APP_ID = 4321 + + +def createPermissionEvent(cid, applicationId): + """Create a mock PermissionRequest `event`.""" + props = blpapi.test.MessageProperties() + props.setCorrelationIds([cid]) + + request = blpapi.test.createEvent(blpapi.Event.REQUEST) + + schemaDef = blpapi.test.getAdminMessageDefinition(PERMISSION_REQUEST) + + # this goes through Json converter for demonstration purposes + # and Json doesn't support Names as keys -- hence, strings. + content = { + "topics": ["topic1", "topic2"], + "serviceName": "//blp/mytestservice", + "applicationId": applicationId, + } + + formatter = blpapi.test.appendMessage(request, schemaDef, props) + + formatter.formatMessageDict(content) + + return request + + +def getFirstMessage(event): + """Retrieve the first `Message` from the provided `event`.""" + for msg in event: + return msg + raise Exception("No messages in event") + + +# pylint: disable=line-too-long +def getService(): + """Create a basic `Service` instance by deserializing a schema string.""" + schema = """ + + + + 12345 + false + false + 12346 + + + + + + + + """ + return blpapi.test.deserializeService(schema) + + +class TestResolverUtils(unittest.TestCase): + """Test suite for resolverutils.""" + + def testResolutionServiceRegistration(self): + """This test demonstrates how to mock interactions on objects of type + `ProviderSession`. + In this test, we are setting the return value of the function, and + verifying our input parameters. + """ + mockSession = Mock() + mockIdentity = Mock() + + serviceName = "//blp/mytestservice" + + mockSession.registerService.return_value = True + + registrationResult = resolutionServiceRegistration( + mockSession, mockIdentity, serviceName + ) + serviceRegistrationOptions = mockSession.registerService.call_args[0][ + 2 + ] + + self.assertTrue(registrationResult) + + mockSession.registerService.assert_called_once_with( + serviceName, mockIdentity, ANY + ) + expectedPriority = 123 + self.assertEqual( + expectedPriority, serviceRegistrationOptions.getServicePriority() + ) + self.assertTrue( + serviceRegistrationOptions.getPartsToRegister() + & blpapi.ServiceRegistrationOptions.PART_PUBLISHER_RESOLUTION + ) + + def testSuccessfulResolution(self): + """Test the creation of a successful permission response.""" + mockSession = Mock() + service = getService() + + cid = blpapi.CorrelationId(1) + permissionEvent = createPermissionEvent(cid, ALLOWED_APP_ID) + permissionRequest = getFirstMessage(permissionEvent) + + handlePermissionRequest(mockSession, service, permissionRequest) + + mockSession.sendResponse.assert_called_once() + response = mockSession.sendResponse.call_args[0][0] + self.assertEqual(blpapi.Event.RESPONSE, response.eventType()) + + permissionResponse = getFirstMessage(response) + self.assertEqual(cid, permissionResponse.correlationIds()[0]) + self.assertEqual(PERMISSION_RESPONSE, permissionResponse.messageType()) + self.assertTrue(permissionResponse.hasElement(TOPIC_PERMISSIONS)) + + topicPermissions = permissionResponse.getElement(TOPIC_PERMISSIONS) + + topicCount = 2 + self.assertEqual(topicCount, topicPermissions.numValues()) + + for i in range(topicCount): + topicPermission = topicPermissions.getValueAsElement(i) + self.assertTrue(topicPermission.hasElement(RESULT)) + self.assertEqual(0, topicPermission.getElementAsInteger(RESULT)) + + def testFailedResolution(self): + """Test the creation of a failed permission response.""" + mockSession = Mock() + service = getService() + + cid = blpapi.CorrelationId(1) + permissionEvent = createPermissionEvent(cid, INVALID_APP_ID) + permissionRequest = getFirstMessage(permissionEvent) + + handlePermissionRequest(mockSession, service, permissionRequest) + + mockSession.sendResponse.assert_called_once() + response = mockSession.sendResponse.call_args[0][0] + self.assertEqual(blpapi.Event.RESPONSE, response.eventType()) + + permissionResponse = getFirstMessage(response) + self.assertEqual(cid, permissionResponse.correlationIds()[0]) + self.assertEqual(PERMISSION_RESPONSE, permissionResponse.messageType()) + self.assertTrue(permissionResponse.hasElement(TOPIC_PERMISSIONS)) + + topicPermissions = permissionResponse.getElement(TOPIC_PERMISSIONS) + + topicCount = 2 + self.assertEqual(topicCount, topicPermissions.numValues()) + + for i in range(topicCount): + topicPermission = topicPermissions.getValueAsElement(i) + self.assertTrue(topicPermission.hasElement(RESULT)) + self.assertEqual(1, topicPermission.getElementAsInteger(RESULT)) + + self.assertTrue(topicPermission.hasElement(REASON)) + reason = topicPermission.getElement(REASON) + + self.assertTrue(reason.hasElement(CATEGORY)) + self.assertEqual( + NOT_AUTHORIZED, reason.getElementAsString(CATEGORY) + ) + + +if __name__ == "__main__": + unittest.main() + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/snippets/test_events.py b/examples/unittests/snippets/test_events.py new file mode 100644 index 0000000..886db6e --- /dev/null +++ b/examples/unittests/snippets/test_events.py @@ -0,0 +1,851 @@ +"""Sample unit test cases""" + +import unittest + +import blpapi + +# pylint: disable=no-self-use +# unlike "proper" unit tests, the provided samples do not include any +# assertions, so there is no 'self' use in the tests. + +# pylint: disable=too-many-public-methods + + +class TestEvents(unittest.TestCase): + """The following test cases provide an example of how to mock different + events supported by the blpapi-sdk. The code to set up the expectation and + verification of values is omitted from example tests.""" + + # ===================== + # SESSION STATUS EVENTS + # ===================== + + def testSessionStarted(self): + """Sample SessionStarted message""" + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SESSION_STARTED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "initialEndpoints": [ + {"address": "12.34.56.78:8194"}, + {"address": "98.76.54.32:8194"}, + ] + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSessionStartupFailure(self): + """Sample SessionStartupFailure message""" + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SESSION_STARTUP_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSessionTerminated(self): + """Sample SessionTerminated message""" + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SESSION_TERMINATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSessionConnectionUp(self): + """Sample SessionConnectionUp message""" + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SESSION_CONNECTION_UP + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "server": "12.34.56.78:8194", + "serverId": "ny-hostname", + "encryptionStatus": "Clear", + "compressionStatus": "Uncompressed", + "socks5Proxy": "socks5Host:1080", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSessionConnectionDown(self): + """Sample SessionConnectionDown message""" + event = blpapi.test.createEvent(blpapi.Event.SESSION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SESSION_CONNECTION_DOWN + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "server": "12.34.56.78:8194", + "serverId": "ny-hostname", + "socks5Proxy": "socks5Host:1080", + "description": "Connection down description", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ============ + # ADMIN EVENTS + # ============ + + def testSlowConsumerWarning(self): + """Sample SlowConsumerWarning message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SLOW_CONSUMER_WARNING + ) + blpapi.test.appendMessage(event, schema) + + def testSlowConsumerWarningCleared(self): + """Sample SlowConsumerWarningCleared message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SLOW_CONSUMER_WARNING_CLEARED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"eventsDropped": 123} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testDataLoss(self): + """Sample DataLoss message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition(blpapi.Name("DataLoss")) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"id": "id", "source": "Test", "numMessagesDropped": 123} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testRequestTemplateAvailable(self): + """Sample RequestTemplateAvailable message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.REQUEST_TEMPLATE_AVAILABLE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "boundTo": {"dataConnection": [{"address": "12.34.56.78:8194"}]} + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testRequestTemplatePending(self): + """Sample RequestTemplatePending message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.REQUEST_TEMPLATE_PENDING + ) + + blpapi.test.appendMessage(event, schema) + + def testRequestTemplateTerminated(self): + """Sample RequestTemplateTerminated message""" + event = blpapi.test.createEvent(blpapi.Event.ADMIN) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.REQUEST_TEMPLATE_TERMINATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ===================== + # SERVICE STATUS EVENTS + # ===================== + + def testServiceOpened(self): + """Sample ServiceOpened message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_OPENED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"serviceName": "//blp/myservice"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testServiceOpenFailure(self): + """Sample ServiceOpenFailure message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_OPEN_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testServiceRegistered(self): + """Sample ServiceRegistered message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_REGISTERED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"serviceName": "//blp/myservice"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testServiceRegisterFailure(self): + """Sample ServiceRegisterFailure message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_REGISTER_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testServiceDeregistered(self): + """Sample ServiceDeregistered message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_DEREGISTERED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"serviceName": "//blp/myservice"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testServiceDown(self): + """Sample ServiceDown message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_DOWN + ) + + formatter = blpapi.test.appendMessage(event, schema) + + # content = { + # "serviceName": "//blp/myservice", + # "servicePart": { + # "publishing": { } + # }, + # "endpoint": "12.34.56.78" + # } + # formatter.formatMessageDict(content) + + # Existence of void types (e.g. "servicePart" elements") are not + # well-supported by the JSON/XML interface. Instead, use the + # `EventFormatter`-like interface provided by `MessageFormatter`. + formatter.setElement(blpapi.Name("serviceName"), "//blp/myservice") + formatter.pushElement(blpapi.Name("servicePart")) + formatter.setElement(blpapi.Name("publishing"), None) + formatter.popElement() + formatter.setElement(blpapi.Name("endpoint"), "12.34.56.78") + + def testServiceUp(self): + """Sample ServiceUp message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition(blpapi.Names.SERVICE_UP) + + formatter = blpapi.test.appendMessage(event, schema) + + # content = { + # "serviceName": "//blp/myservice", + # "servicePart": { + # "publishing": { } + # }, + # "endpoint": "12.34.56.78" + # } + # formatter.formatMessageDict(content) + + # Existence of void types (e.g. "servicePart" elements") are not + # well-supported by the JSON/XML interface. Instead, use the + # `EventFormatter`-like interface provided by `MessageFormatter`. + formatter.setElement(blpapi.Name("serviceName"), "//blp/myservice") + formatter.pushElement(blpapi.Name("servicePart")) + formatter.setElement(blpapi.Name("publishing"), None) + formatter.popElement() + formatter.setElement(blpapi.Name("endpoint"), "12.34.56.78") + + def testServiceAvailabilityInfo(self): + """Sample ServiceAvailabilityInfo message""" + event = blpapi.test.createEvent(blpapi.Event.SERVICE_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SERVICE_AVAILABILITY_INFO + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "serviceName": "//blp/myservice", + "serverAdded": {"address": "12.34.56.78"}, + "serverRemoved": {"address": "12.34.56.78"}, + "servers": ["12.34.56.78", "12.34.56.78"], + } + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # =================== + # TOKEN STATUS EVENTS + # =================== + + def testTokenGenerationSuccess(self): + """Sample TokenGenerationSuccess message""" + event = blpapi.test.createEvent(blpapi.Event.TOKEN_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOKEN_GENERATION_SUCCESS + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"token": "mytoken"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTokenGenerationFailure(self): + """Sample TokenGenerationFailure message""" + event = blpapi.test.createEvent(blpapi.Event.TOKEN_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOKEN_GENERATION_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ========================== + # SUBSCRIPTION STATUS EVENTS + # ========================== + + def testSubscriptionStarted(self): + """Sample SubscriptionStarted message""" + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SUBSCRIPTION_STARTED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "exceptions": [ + { + "fieldId": "field", + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + }, + } + ], + "resubscriptionId": 123, + "streamIds": ["123", "456"], + "receivedFrom": {"address": "12.34.56.78:81964"}, + "reason": "TestUtil", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSubscriptionFailure(self): + """Sample SubscriptionFailure message""" + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SUBSCRIPTION_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + }, + "failureDetails": [ + { + "fieldId": "field", + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + }, + } + ], + "resubscriptionId": 123, + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSubscriptionStreamsActivated(self): + """Sample SubscriptionStreamsActivated message""" + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SUBSCRIPTION_STREAMS_ACTIVATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "streams": [ + {"id": "streamId", "endpoint": {"address": "12.34.56.78:8194"}} + ], + "reason": "TestUtil", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSubscriptionStreamsDeactivated(self): + """Sample SubscriptionStreamsDeactivated message""" + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SUBSCRIPTION_STREAMS_DEACTIVATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "streams": [ + {"id": "streamId", "endpoint": {"address": "12.34.56.78:8194"}} + ], + "reason": "TestUtil", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testSubscriptionTerminated(self): + """Sample SubscriptionTerminated message""" + event = blpapi.test.createEvent(blpapi.Event.SUBSCRIPTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.SUBSCRIPTION_TERMINATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ===================== + # REQUEST STATUS EVENTS + # ===================== + + def testRequestFailure(self): + """Sample RequestFailure message""" + event = blpapi.test.createEvent(blpapi.Event.REQUEST_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.REQUEST_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ======================== + # RESOLUTION STATUS EVENTS + # ======================== + + def testResolutionSuccess(self): + """Sample ResolutionSuccess message""" + event = blpapi.test.createEvent(blpapi.Event.RESOLUTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.RESOLUTION_SUCCESS + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"resolvedTopic": "//blp/myservice/rtopic"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testResolutionFailure(self): + """Sample ResolutionFailure message""" + event = blpapi.test.createEvent(blpapi.Event.RESOLUTION_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.RESOLUTION_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + } + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + # ============================ + # PERMISSION STATUS OPERATIONS + # ============================ + + def testPermissionRequest(self): + """Sample PermissionRequest message""" + event = blpapi.test.createEvent(blpapi.Event.REQUEST) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.PERMISSION_REQUEST + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "topics": ["topic1", "topic2"], + "serviceName": "//blp/mytestservice", + "uuid": 1234, + "seatType": 1234, + "applicationId": 1234, + "userName": "someName", + "appName": "myAppName", + "deviceAddress": "myDevice", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testPermissionResponse(self): + """Sample PermissionResponse message""" + # Unlike the other admin messages, 'PermissionResponse' is not + # delivered to applications by the SDK. It is used by resolvers to + # respond to incoming 'PermissionRequest' messages. BLPAPI applications + # are not expected to handle these messages. + # + # For testing if an application is publishing 'PermissionResponse' + # messages with correct values, it is recommended to mock the related + # `ProviderSession::publish()` method to capture the published events. + # See the provided testing examples for more detail. + + # =================== + # TOPIC STATUS EVENTS + # =================== + + def testTopicCreated(self): + """Sample TopicCreated message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_CREATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicCreateFailure(self): + """Sample TopicCreateFailure message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_CREATE_FAILURE + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "topic": "mytopic", + "reason": { + "source": "TestUtil", + "errorCode": -1, + "category": "CATEGORY", + "description": "for testing", + "subcategory": "SUBCATEGORY", + }, + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicDeleted(self): + """Sample TopicDeleted message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_DELETED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic", "reason": "TestUtil"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicSubscribed(self): + """Sample TopicSubscribed message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_SUBSCRIBED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic", "topicWithOptions": "topicwithopts"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicResubscribed(self): + """Sample TopicResubscribed message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_RESUBSCRIBED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "topic": "mytopic", + "topicWithOptions": "topicwithopts", + "reason": "TestUtil", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicUnsubscribed(self): + """Sample TopicUnsubscribed message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_UNSUBSCRIBED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic", "reason": "TestUtil"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicActivated(self): + """Sample TopicActivated message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_ACTIVATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicDeactivated(self): + """Sample TopicDeactivated message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_DEACTIVATED + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = {"topic": "mytopic", "reason": "TestUtil"} + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + def testTopicRecap(self): + """Sample TopicRecap message""" + event = blpapi.test.createEvent(blpapi.Event.TOPIC_STATUS) + schema = blpapi.test.getAdminMessageDefinition( + blpapi.Names.TOPIC_RECAP + ) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "topic": "mytopic", + "isSolicited": True, + "topicWithOptions": "topicwithopts", + } + + formatter.formatMessageDict(content) + for msg in event: + self.assertEqual(content, msg.toPy()) + + +if __name__ == "__main__": + unittest.main() + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/examples/unittests/snippets/test_refdata.py b/examples/unittests/snippets/test_refdata.py new file mode 100644 index 0000000..9c18204 --- /dev/null +++ b/examples/unittests/snippets/test_refdata.py @@ -0,0 +1,171 @@ +""" Sample unit test cases. """ + +import unittest + +import blpapi + +# pylint: disable=line-too-long +REF_DATA_SCHEMA = '\ +\ + \ + \ + ReferenceDataRequest\ + Response\ + ReferenceDataResponse\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + true\ + false\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + The contents of this type depends on the response\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +' + + +class TestRefdata(unittest.TestCase): + """Responses in `//blp/refdata` use a different dynamic schema for each + response, depending on the fields requested. This makes it is necessary to + create an ad-hoc schema for the test cases. + + The example in this repository provides an example schema that supports + successful and unsuccessful `ReferenceDataResponse` types. The provided + schema can be modified to handle additional fields as needed. + """ + + def setUp(self): + self.refdataService = blpapi.test.deserializeService(REF_DATA_SCHEMA) + self.requestName = blpapi.Name("ReferenceDataRequest") + + def testRefdataResponseSuccess(self): + """Verify that a successful `ReferenceDataResponse` can be created + with the provided sample schema. Note that some of the fields are not + filled in this example. + """ + event = blpapi.test.createEvent(blpapi.Event.RESPONSE) + + schema = self.refdataService.getOperation( + self.requestName + ).getResponseDefinitionAt(0) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "securityData": [ + { + "security": "IBM US Equity", + "fieldData": {"LAST_PRICE": 138.533300}, + "sequenceNumber": 0, + } + ] + } + + formatter.formatMessageDict(content) + + def testRefdataResponseFailure(self): + """Verify that an unsuccessful `ReferenceDataResponse` can be created + with the provided sample schema. Note that some of the fields are not + filled in this example. + """ + event = blpapi.test.createEvent(blpapi.Event.RESPONSE) + + schema = self.refdataService.getOperation( + self.requestName + ).getResponseDefinitionAt(0) + + formatter = blpapi.test.appendMessage(event, schema) + + content = { + "securityData": [ + { + "security": "IBM US Equity", + "fieldData": {}, + "fieldExceptions": [ + { + "fieldId": "PX_LAST", + "errorInfo": { + "source": "src", + "code": 5, + "category": "NO_AUTH", + "message": "Field..", + "subcategory": "FIELD..", + }, + } + ], + "sequenceNumber": 0, + } + ] + } + + formatter.formatMessageDict(content) + + +if __name__ == "__main__": + unittest.main() + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/setup.cfg b/setup.cfg index 18cf3ff..8587248 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,17 @@ [bdist_rpm] -doc_files = README examples changelog.txt NOTES +doc_files = + README.md + examples + changelog.txt + +[metadata] +license_files = + License.txt + cpp-licenses/LICENSE.openssl + cpp-licenses/License.inteldfp + cpp-licenses/License.blpapi-cpp [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff --git a/setup.py b/setup.py index ca04cd6..c72cc91 100644 --- a/setup.py +++ b/setup.py @@ -4,77 +4,147 @@ setup.py file for Bloomberg Python SDK """ -from setuptools import setup, Extension import os import platform as plat -from sys import version +import re +import codecs +from sys import argv +from shutil import copyfile +from setuptools import setup, Extension + + +def override_get_tag(): + from wheel.bdist_wheel import bdist_wheel + + # bdist_wheel upon seeing an extension module will (wrongly) assume + # that not only platform needs to be fixed, but also interpreter. + # This makes sure we create no-py-specific wheel + class BDistWheel(bdist_wheel): + def get_tag(self): + return (self.python_tag, "none", self.plat_name.replace("-", "_")) + + return {"bdist_wheel": BDistWheel} + +os.chdir(os.path.dirname(os.path.realpath(__file__))) platform = plat.system().lower() -versionString = '3.9.2' -if version < '2.6': - raise Exception( - "Python versions before 2.6 are not supported (current version is " + - version + ")") -blpapiRoot = os.environ.get('BLPAPI_ROOT') -blpapiIncludesVar = os.environ.get('BLPAPI_INCDIR') -blpapiLibVar = os.environ.get('BLPAPI_LIBDIR') +def find_version_number(): + """Load the version number from blpapi/version.py""" + version_path = os.path.abspath(os.path.join("src", "blpapi", "version.py")) + version_file = None + with codecs.open(version_path, "r") as fp: + version_file = fp.read() -assert blpapiRoot or (blpapiIncludesVar and blpapiLibVar), \ - "BLPAPI_ROOT environment variable isn't defined" + version_match = re.search( + r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M + ) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") -is64bit = plat.architecture()[0] == '64bit' -if is64bit: - blpapiLibraryName = 'blpapi3_64' -else: - blpapiLibraryName = 'blpapi3_32' - -if platform == 'windows': - blpapiLibraryPath = os.path.join(blpapiRoot, 'lib') - extraLinkArgs = ['/MANIFEST'] - - # Handle the very frequent case when user need to use Visual C++ 2010 - # with Python that wants to use Visual C++ 2008. - if plat.python_compiler().startswith('MSC v.1500'): - if (not ('VS90COMNTOOLS' in os.environ)) and \ - ('VS100COMNTOOLS' in os.environ): - os.environ['VS90COMNTOOLS'] = os.environ['VS100COMNTOOLS'] -elif platform == 'linux': - blpapiLibraryPath = os.path.join(blpapiRoot, 'Linux') - extraLinkArgs = [] -elif platform == 'darwin': - blpapiLibraryPath = os.path.join(blpapiRoot, 'Darwin') - extraLinkArgs = [] -else: + +package_data = {} +cmdclass = {} +if "bdist_wheel" in argv: + libpath = os.getenv("BLPAPI_DEPENDENCY") + if libpath: + libname = os.path.basename(libpath) + assert os.path.exists( + libpath + ), f"Could not find blpapi library at {libpath}" + # copy, as package_data only supports local files + copyfile(libpath, f"./src/blpapi/{libname}") + package_data = {"blpapi": [libname, "py.typed"]} + else: + print("BLPAPI_DEPENDENCY environment variable isn't defined") + cmdclass = override_get_tag() + +packages = ["blpapi", "blpapi.test"] + +# INTERNAL ONLY START +# see automation/prepare_release.py +internal_build = os.environ.get("BLPAPI_PY_INTERNAL_BUILD", False) +if internal_build: + internalutils_path = "src/blpapi/internalutils" + if not ( + os.path.exists(internalutils_path) + and os.path.isdir(internalutils_path) + ): + error_msg = """Tried to build the internal Bloomberg build of the +BLPAPI Python SDK, but failed to find the internalutils subdirectory. + +If you are not a Bloomberg developer, this will not work, and you should unset +the BLPAPI_PY_INTERNAL_BUILD environment variable to continue. internalutils +provide some default configurations for use only within Bloomberg networks. + +If you are a Bloomberg developer, either unset the BLPAPI_PY_INTERNAL_BUILD +environment variable to build the public release, or ensure the internalutils +subdirectory is present. +""" + raise ImportError(error_msg) + + packages.append("blpapi.internalutils") +# INTERNAL ONLY END + + +def lib_in_release(): + """Returns the right library folder name for each platform""" + if platform == "windows": + return "lib" + if platform == "linux": + return "Linux" + if platform == "darwin": + return "Darwin" raise Exception("Platform '" + platform + "' isn't supported") -blpapiLibraryPath = blpapiLibVar or blpapiLibraryPath -blpapiIncludes = blpapiIncludesVar or os.path.join(blpapiRoot, 'include') +blpapiRoot = os.environ.get("BLPAPI_ROOT", ".") +blpapiIncludesVar = os.environ.get("BLPAPI_INCDIR") +blpapiLibVar = os.environ.get("BLPAPI_LIBDIR") + +assert blpapiRoot or (blpapiIncludesVar and blpapiLibVar), ( + "BLPAPI_ROOT (or BLPAPI_INCDIR/BLPAPI_LIBDIR) " + + "environment variable isn't defined" +) +blpapiLibraryPath = blpapiLibVar or os.path.join(blpapiRoot, lib_in_release()) +blpapiIncludes = blpapiIncludesVar or os.path.join(blpapiRoot, "include") +is64bit = plat.architecture()[0] == "64bit" +if is64bit: + blpapiLibraryName = "blpapi3_64" +else: + blpapiLibraryName = "blpapi3_32" +extraLinkArgs = ["/MANIFEST"] if platform == "windows" else [] blpapi_wrap = Extension( - 'blpapi._internals', - sources=['blpapi/internals_wrap.cxx'], + "blpapi.ffiutils", + sources=["src/blpapi/ffi_utils.c"], include_dirs=[blpapiIncludes], library_dirs=[blpapiLibraryPath], libraries=[blpapiLibraryName], - extra_link_args=extraLinkArgs + extra_compile_args=[], + extra_link_args=extraLinkArgs, ) +extensions = [blpapi_wrap] setup( - name='blpapi', - version=versionString, - author='Bloomberg L.P.', - author_email='open-tech@bloomberg.net', - description='Python SDK for Bloomberg BLPAPI (<=3.9)', - ext_modules=[blpapi_wrap], - url='http://www.bloomberglabs.com/api/', - packages=["blpapi"], + name="blpapi", + version=find_version_number(), + author="Bloomberg L.P.", + author_email="open-tech@bloomberg.net", + cmdclass=cmdclass, + description="Python SDK for Bloomberg BLPAPI", + ext_modules=extensions, + url="http://www.bloomberglabs.com/api/", + packages=packages, + package_dir={"": "src"}, + package_data=package_data, + python_requires=">=3.8", classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Financial and Insurance Industry', - 'License :: Other/Proprietary License', - 'Topic :: Office/Business :: Financial', + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Financial and Insurance Industry", + "License :: Other/Proprietary License", + "Topic :: Office/Business :: Financial", ], ) diff --git a/src/blpapi.egg-info/PKG-INFO b/src/blpapi.egg-info/PKG-INFO new file mode 100644 index 0000000..ed6ac7c --- /dev/null +++ b/src/blpapi.egg-info/PKG-INFO @@ -0,0 +1,14 @@ +Metadata-Version: 2.1 +Name: blpapi +Version: 3.24.11 +Summary: Python SDK for Bloomberg BLPAPI +Home-page: http://www.bloomberglabs.com/api/ +Author: Bloomberg L.P. +Author-email: open-tech@bloomberg.net +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Financial and Insurance Industry +Classifier: License :: Other/Proprietary License +Classifier: Topic :: Office/Business :: Financial +Requires-Python: >=3.8 +License-File: License.txt diff --git a/src/blpapi.egg-info/SOURCES.txt b/src/blpapi.egg-info/SOURCES.txt new file mode 100644 index 0000000..53b6fb2 --- /dev/null +++ b/src/blpapi.egg-info/SOURCES.txt @@ -0,0 +1,111 @@ +License.txt +MANIFEST.in +README.md +changelog.txt +setup.cfg +setup.py +examples/demoapps/ApiFieldsExample.py +examples/demoapps/BroadcastPublisherExample.py +examples/demoapps/ContributionsExample.py +examples/demoapps/EntitlementsVerificationRequestResponseExample.py +examples/demoapps/EntitlementsVerificationSubscriptionExample.py +examples/demoapps/GenerateTokenExample.py +examples/demoapps/InteractivePublisherExample.py +examples/demoapps/MultipleRequestsOverrideExample.py +examples/demoapps/README.md +examples/demoapps/RequestResponseExample.py +examples/demoapps/RequestServiceConsumerExample.py +examples/demoapps/RequestServiceProviderExample.py +examples/demoapps/SecurityLookupExample.py +examples/demoapps/SnapshotRequestTemplateExample.py +examples/demoapps/SubscriptionExample.py +examples/demoapps/SubscriptionWithEventPollingExample.py +examples/demoapps/UserModeExample.py +examples/demoapps/blpapi_import_helper/__init__.py +examples/demoapps/snippets/apiflds/ApiFieldsRequestUtils.py +examples/demoapps/snippets/apiflds/CategorizedFieldSearchRequests.py +examples/demoapps/snippets/apiflds/FieldInfoRequests.py +examples/demoapps/snippets/apiflds/FieldListRequests.py +examples/demoapps/snippets/apiflds/FieldSearchRequests.py +examples/demoapps/snippets/instruments/CurveListRequests.py +examples/demoapps/snippets/instruments/GovtListRequests.py +examples/demoapps/snippets/instruments/InstrumentListRequests.py +examples/demoapps/snippets/requestresponse/HistoricalDataRequest.py +examples/demoapps/snippets/requestresponse/IntradayBarRequests.py +examples/demoapps/snippets/requestresponse/IntradayTickRequests.py +examples/demoapps/snippets/requestresponse/ReferenceDataRequests.py +examples/demoapps/util/ConnectionAndAuthOptions.py +examples/demoapps/util/MaxEventsOption.py +examples/demoapps/util/RequestOptions.py +examples/demoapps/util/SubscriptionOptions.py +examples/demoapps/util/events/SessionRouter.py +examples/unittests/market-data-notifier/README.md +examples/unittests/market-data-notifier/diagram.png +examples/unittests/market-data-notifier/src/__init__.py +examples/unittests/market-data-notifier/src/appconfig.py +examples/unittests/market-data-notifier/src/application.py +examples/unittests/market-data-notifier/src/authorizer.py +examples/unittests/market-data-notifier/src/compute_engine.py +examples/unittests/market-data-notifier/src/event_processor.py +examples/unittests/market-data-notifier/src/main.py +examples/unittests/market-data-notifier/src/notifier.py +examples/unittests/market-data-notifier/src/subscriber.py +examples/unittests/market-data-notifier/src/token_generator.py +examples/unittests/market-data-notifier/tests/test_application.py +examples/unittests/market-data-notifier/tests/test_authorizer.py +examples/unittests/market-data-notifier/tests/test_eventprocessor.py +examples/unittests/market-data-notifier/tests/test_tokengenerator.py +examples/unittests/snippets/test_events.py +examples/unittests/snippets/test_refdata.py +examples/unittests/snippets/resolver/resolverutils.py +examples/unittests/snippets/resolver/test_resolverutils.py +src/blpapi/__init__.py +src/blpapi/abstractsession.py +src/blpapi/auth.py +src/blpapi/chandle.py +src/blpapi/constant.py +src/blpapi/correlationid.py +src/blpapi/ctypesutils.py +src/blpapi/datatype.py +src/blpapi/datetime.py +src/blpapi/debug.py +src/blpapi/debug_environment.py +src/blpapi/diagnosticsutil.py +src/blpapi/element.py +src/blpapi/event.py +src/blpapi/eventdispatcher.py +src/blpapi/eventformatter.py +src/blpapi/exception.py +src/blpapi/ffi_utils.c +src/blpapi/highresclock.py +src/blpapi/identity.py +src/blpapi/internals.py +src/blpapi/logging.py +src/blpapi/message.py +src/blpapi/name.py +src/blpapi/names.py +src/blpapi/providersession.py +src/blpapi/py.typed +src/blpapi/pycbhelpers.py +src/blpapi/request.py +src/blpapi/requesttemplate.py +src/blpapi/resolutionlist.py +src/blpapi/schema.py +src/blpapi/service.py +src/blpapi/session.py +src/blpapi/sessionoptions.py +src/blpapi/subscriptionlist.py +src/blpapi/topic.py +src/blpapi/topiclist.py +src/blpapi/typehints.py +src/blpapi/utils.py +src/blpapi/version.py +src/blpapi/zfputil.py +src/blpapi.egg-info/PKG-INFO +src/blpapi.egg-info/SOURCES.txt +src/blpapi.egg-info/dependency_links.txt +src/blpapi.egg-info/top_level.txt +src/blpapi/test/__init__.py +src/blpapi/test/messageformatter.py +src/blpapi/test/messageproperties.py +src/blpapi/test/testutil.py \ No newline at end of file diff --git a/src/blpapi.egg-info/dependency_links.txt b/src/blpapi.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/blpapi.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/src/blpapi.egg-info/top_level.txt b/src/blpapi.egg-info/top_level.txt new file mode 100644 index 0000000..6205a9d --- /dev/null +++ b/src/blpapi.egg-info/top_level.txt @@ -0,0 +1 @@ +blpapi diff --git a/blpapi/__init__.py b/src/blpapi/__init__.py similarity index 60% rename from blpapi/__init__.py rename to src/blpapi/__init__.py index bdb6e92..4bb8b78 100644 --- a/blpapi/__init__.py +++ b/src/blpapi/__init__.py @@ -1,56 +1,82 @@ # __init__.py +# pylint: disable=missing-docstring,redefined-builtin,wildcard-import +# pylint: disable=raise-missing-from + +# pylint: disable=no-member + try: - from .internals import CorrelationId + from .internals import BDatetime except ImportError as error: # The most likely reason for a failure here is a failure to locate the # shared object for the C++ library. Provide a meaningful error message. - import platform - s = platform.system() - if s == 'Windows': - env = 'PATH' - elif s == 'Darwin': - env = 'DYLD_LIBRARY_PATH' - else: - env = 'LD_LIBRARY_PATH' - - msg = """%s - -Could not open the C++ SDK library. - -Download and install the latest C++ SDK from: - - http://www.bloomberg.com/professional/api-library - -If the C++ SDK is already installed, please ensure that the path to the library -was added to %s before entering the interpreter. + from .debug import debug_load_error -""" % (str(error), env) - raise ImportError(msg) + raise debug_load_error(error) from .abstractsession import AbstractSession +from .auth import AuthOptions, AuthUser from .constant import Constant, ConstantList -from .datetime import FixedOffset +from .correlationid import CorrelationId from .datatype import DataType +from .datetime import FixedOffset from .element import Element from .event import Event, EventQueue from .eventdispatcher import EventDispatcher from .eventformatter import EventFormatter from .exception import * from .identity import Identity +from .logging import Logger from .message import Message from .name import Name +from .names import Names from .providersession import ProviderSession, ServiceRegistrationOptions from .request import Request +from .requesttemplate import RequestTemplate from .resolutionlist import ResolutionList from .schema import SchemaElementDefinition, SchemaStatus, SchemaTypeDefinition -from .service import Service -from .session import Session -from .sessionoptions import SessionOptions +from .service import Service, Operation +from .session import ( + Session, + SubscriptionPreprocessError, + SubscriptionPreprocessMode, +) +from .sessionoptions import SessionOptions, TlsOptions, Socks5Config from .subscriptionlist import SubscriptionList from .topic import Topic from .topiclist import TopicList +from .zfputil import ZfpUtil +from .version import ( + __version__, + version, + cpp_sdk_version, + expected_cpp_sdk_version, + print_version, +) + +from .pycbhelpers import ( + voidFromPyObject, + pyObjectFromVoid, +) +from .internals import ( + libblpapict, + charPtrWithSizeFromPyStr, + charPtrFromPyStr, + getPODFromOutput, +) + +# INTERNAL ONLY START +# see automation/prepare_release.py +try: + from . import internalutils # blpapi.internalutils submodule +except ImportError as error: + # internalutils is not available, most likely because this is a public release + # simply continue silently + pass +# INTERNAL ONLY END +# blpapi.test module +from .test import * __copyright__ = """ Copyright 2012. Bloomberg Finance L.P. diff --git a/src/blpapi/abstractsession.py b/src/blpapi/abstractsession.py new file mode 100644 index 0000000..1dfbfa8 --- /dev/null +++ b/src/blpapi/abstractsession.py @@ -0,0 +1,470 @@ +# abstractsession.py + +"""A common interface shared between publish and consumer sessions. + +This file defines a class 'AbstractSession' - an interface which is shared +between its concrete implementations 'Session' and 'ProviderSession'. + +SERVICE IDENTIFIER +------------------ +A service identifier is the fully qualified service name which uniquely +identifies the service in the API infrastructure. A service must be of the +form "///" where '' and '' are +non-empty strings of characters from the set '[-_.a-zA-Z0-9]'. Service +identifiers are case-insensitive, but clients are encouraged to prefer +identifiers without upper-case characters. Note that the and + cannot contain the character '/'. +""" + +# pylint: disable=protected-access +from typing import Callable, Union, Sequence, Optional +from . import typehints # pylint: disable=unused-import +from .typehints import ( + BlpapiAbstractSessionHandle, + BlpapiSessionHandle, + BlpapiProviderSessionHandle, +) +from . import exception +from .exception import _ExceptionUtil +from .identity import Identity +from .service import Service +from . import internals +from .correlationid import CorrelationId +from .utils import get_handle +from .chandle import CHandle + + +class AbstractSession(CHandle): + r"""A common interface shared between publish and consumer sessions. + + This class provides an abstract session which defines shared interface + between publish and consumer requests for Bloomberg. + + Sessions manage access to services either by requests and responses or + subscriptions. A Session can dispatch events and replies in either a + synchronous or asynchronous mode. The mode of a Session is determined when + it is constructed and cannot be changed subsequently. + + A Session is asynchronous if an ``eventHandler`` argument is supplied when + it is constructed. The ``nextEvent()`` method may not be called. All + incoming events are delivered to the ``eventHandler`` supplied on + construction. + + If supplied, ``eventHandler`` must be a callable object that takes two + arguments: received :class:`Event` and related session. + + A Session is synchronous if an ``eventHandler`` argument is not supplied + when it is constructed. The ``nextEvent()`` method must be called to read + incoming events. + + Several methods in Session take a :class:`CorrelationId` parameter. The + application may choose to supply its own :class:`CorrelationId` values or + allow the Session to create values. If the application supplies its own + :class:`CorrelationId` values it must manage their lifetime such that the + same value is not reused for more than one operation at a time. The + lifetime of a :class:`CorrelationId` begins when it is supplied in a method + invoked on a Session and ends either when it is explicitly cancelled using + :meth:`cancel()` or ``unsubscribe()``, when a :attr:`~Event.RESPONSE` + :class:`Event` (not a :attr:`~Event.PARTIAL_RESPONSE`) containing it is + received or when a :attr:`~Event.SUBSCRIPTION_STATUS` :class:`Event` which + indicates that the subscription it refers to has been terminated is + received. + + When using an asynchronous Session, the application must be aware that + because the callbacks are generated from another thread, they may be + processed before the call which generates them has returned. For example, + the :attr:`~Event.SESSION_STATUS` :class:`Event` generated by a + ``startAsync()`` may be processed before ``startAsync()`` has returned + (even though ``startAsync()`` itself will not block). + + This becomes more significant when Session generated + :class:`CorrelationId`\s are in use. For example, if a call to + ``subscribe()`` which returns a Session generated :class:`CorrelationId` + has not completed before the first :class:`Event`\s which contain that + :class:`CorrelationId` arrive the application may not be able to interpret + those events correctly. For this reason, it is preferable to use user + generated :class:`CorrelationId`\s when using asynchronous Sessions. This + issue does not arise when using a synchronous Session as long as the calls + to ``subscribe()`` etc are made on the same thread as the calls to + ``nextEvent()``. + """ + + def __init__( + self, + sessionHandle: Union[BlpapiSessionHandle, BlpapiProviderSessionHandle], + abstractSessionHandle: BlpapiAbstractSessionHandle, + dtor: Callable, + ) -> None: + """Instantiate an :class:`AbstractSession` with the specified handle. + + Args: + sessionHandle: Handle to the underlying session + abstractSessionHandle: Handle to the underlying abstract session + + Raises: + NotImplementedError: If this class is instantiated directly + + This function is for internal use only. Clients should create sessions + using one of the concrete subclasses of :class:`AbstractSession`. + + """ + + if self.__class__ is AbstractSession: + raise NotImplementedError( + "Don't instantiate this class directly." + "Create sessions using one of the concrete subclasses of this class." + ) + super(AbstractSession, self).__init__(sessionHandle, dtor) + self.__handle = abstractSessionHandle + + def openService(self, serviceName: str) -> bool: + """Open the service identified by the specified ``serviceName``. + + Args: + serviceName: Name of the service + + Returns: + ``True`` if the service is opened successfully, ``False`` + otherwise. + + Attempt to open the service identified by the specified ``serviceName`` + and block until the service is either opened successfully or has failed + to be opened. Return ``True`` if the service is opened successfully and + ``False`` if the service cannot be successfully opened. + + The ``serviceName`` must contain a fully qualified service name. That + is, it must be of the form ``///``. + + Before :meth:`openService()` returns a :attr:`~Event.SERVICE_STATUS` + :class:`Event` is generated. If this is an asynchronous Session then + this :class:`Event` may be processed by the registered ``eventHandler`` + before :meth:`openService()` has returned. + """ + return ( + internals.blpapi_AbstractSession_openService( + self.__handle, serviceName + ) + == 0 + ) + + def openServiceAsync( + self, serviceName: str, correlationId: Optional[CorrelationId] = None + ) -> CorrelationId: + r"""Begin the process to open the service and return immediately. + + Args: + serviceName: Name of the service + correlationId: Correlation id to associate with + events generated as a result of this call + + Returns: + CorrelationId: The correlation id used to identify the Events + generated as a result of this call + + Begin the process to open the service identified by the specified + ``serviceName`` and return immediately. The optional specified + ``correlationId`` is used to track :class:`Event`\s generated as a + result of this call. + + The ``serviceName`` must contain a fully qualified service name. That + is, it must be of the form ``///``. + + The application must monitor events for a :attr:`~Event.SERVICE_STATUS` + :class:`Event` which will be generated once the service has been + successfully opened or the opening has failed. + """ + if correlationId is None: + correlationId = CorrelationId() + _ExceptionUtil.raiseOnError( + internals.blpapi_AbstractSession_openServiceAsync( + self.__handle, serviceName, correlationId + ) + ) + return correlationId + + def sendAuthorizationRequest( + self, + request: "typehints.Request", + identity: Identity, + correlationId: Optional[CorrelationId] = None, + eventQueue: Optional["typehints.EventQueue"] = None, + ) -> CorrelationId: + r"""Send the specified ``authorizationRequest``. + + Args: + request: Authorization request to send + identity: Identity to update with the results + correlationId: Correlation id to associate with the request + eventQueue: Event queue on which the events related to + this request will arrive + + Returns: + CorrelationId: The correlation id used to identify the Events + generated as a result of this call + + Send the specified ``authorizationRequest`` and update the specified + ``identity`` with the results. If the optionally specified + ``correlationId`` is supplied, it is used; otherwise create a + :class:`CorrelationId`. The actual :class:`CorrelationId` used is + returned. If the optionally specified ``eventQueue`` is supplied all + :class:`Event`\s relating to this :class:`Request` will arrive on that + :class:`EventQueue`. + + The underlying user information must remain valid until the + Request has completed successfully or failed. + + A successful request will generate zero or more + :attr:`~Event.PARTIAL_RESPONSE` :class:`Message`\s followed by + exactly one :attr:`~Event.RESPONSE` :class:`Message`. Once the final + :attr:`~Event.RESPONSE` :class:`Message` has been received the + specified ``identity`` will have been updated to contain the users + entitlement information and the :class:`CorrelationId` associated with + the request may be re-used. If the request fails at any stage a + :class:`~Event.REQUEST_STATUS` will be generated, the specified + ``identity`` will not be modified and the :class:`CorrelationId` may be + re-used. + + The ``identity`` supplied must have been returned from this Session's + :meth:`createIdentity()` method and must not be the session identity. + """ + + if correlationId is None: + correlationId = CorrelationId() + _ExceptionUtil.raiseOnError( + internals.blpapi_AbstractSession_sendAuthorizationRequest( + self.__handle, + get_handle(request), + get_handle(identity), + correlationId, + get_handle(eventQueue), + None, # no request label + ) + ) + if eventQueue is not None: + eventQueue._registerSession(self) + return correlationId + + def cancel( + self, + correlationId: Union[CorrelationId, Sequence[CorrelationId], None], + ) -> None: + """Cancel request(s) with a single ``correlationId`` or a list. + + Args: + correlationId: Correlation id(s) + associated with the request(s) to cancel + + For all specified ``correlationId`` values that identify + an ongoing request cancel that request. + + Once this call returns the specified ``correlationId`` will not be seen + in any subsequent :class:`Message` obtained from a + ``MessageIterator`` by calling ``next()``. + However, any :class:`Message` currently pointed to by a + ``MessageIterator`` when :meth:`cancel()` is called is not + affected even if it has the specified ``correlationId``. Also any + :class:`Message` where a reference has been retained by the application + may still contain the ``correlationId``. For these reasons, although + technically an application is free to re-use ``correlationId`` as soon + as this method returns it is preferable not to aggressively re-use + correlation IDs, particularly with an asynchronous Session. + """ + if correlationId is None: + return + if isinstance(correlationId, list): + cids = correlationId + else: + cids = [correlationId] + _ExceptionUtil.raiseOnError( + internals.blpapi_AbstractSession_cancel(self.__handle, cids, None) + ) # no request label + + def generateToken( + self, + correlationId: Optional[CorrelationId] = None, + eventQueue: Optional["typehints.EventQueue"] = None, + authId: Optional[str] = None, + ipAddress: Optional[str] = None, + ) -> CorrelationId: + """Generate a token to be used for authorization. + + Args: + correlationId: Correlation id to be associated with the request + eventQueue: Event queue on which to receive Events + related to this request + authId: The id used for authentication + ipAddress: IP of the machine used for authentication + + Returns: + CorrelationId: The correlation id used to identify the Events + generated as a result of this call + + Raises: + InvalidArgumentException: If the authentication options in + :class:`SessionOptions` or the arguments to the function are + invalid. + + The ``authId`` and ``ipAddress`` must be provided together and can only + be provided if the authentication mode is ``MANUAL``. + """ + if correlationId is None: + correlationId = CorrelationId() + + if authId is None and ipAddress is None: + _ExceptionUtil.raiseOnError( + internals.blpapi_AbstractSession_generateToken( + self.__handle, correlationId, get_handle(eventQueue) + ) + ) + elif authId is not None and ipAddress is not None: + _ExceptionUtil.raiseOnError( + internals.blpapi_AbstractSession_generateManualToken( + self.__handle, + correlationId, + authId, + ipAddress, + get_handle(eventQueue), + ) + ) + else: + raise exception.InvalidArgumentException( + "'authId' and 'ipAddress' must be provided together", 0 + ) + if eventQueue is not None: + eventQueue._registerSession(self) + return correlationId + + def getService(self, serviceName: str) -> Service: + """Return a :class:`Service` object representing the service. + + Args: + serviceName: Name of the service to retrieve + + Returns: + Service: Service identified by the service name + + Raises: + InvalidStateException: If the service identified by the specified + ``serviceName`` is not open already + + The ``serviceName`` must contain a fully qualified service name. That + is, it must be of the form ``///``. + """ + errorCode, service = internals.blpapi_AbstractSession_getService( + self.__handle, serviceName + ) + _ExceptionUtil.raiseOnError(errorCode) + return Service(service, {self}) + + def createIdentity(self) -> Identity: + """Create an :class:`Identity` which is valid but has not been + authorized. + + Returns: + Identity: Identity which is valid but has not been authorized + """ + return Identity( + internals.blpapi_AbstractSession_createIdentity(self.__handle), + (self,), + ) + + def generateAuthorizedIdentity( + self, + authOptions: "typehints.AuthOptions", + correlationId: Optional[CorrelationId] = None, + ) -> CorrelationId: + """Generates an authorized :class:`Identity` with the specified + ``authOptions`` and ``correlationId``. + + Args: + authOptions: Used to generate the :class:`Identity`. + correlationId: Optional. Will identify the messages + associated with the generated :class:`Identity`. + Returns: + CorrelationId: Identifies the aforementioned events and the + generated :class:`Identity`. + + If this is an asynchronous session then an :class:`Event` may be + delivered to the registered ``EventHandler`` before + :meth:`generateAuthorizedIdentity()` has returned. + + One or more :attr:`Event.AUTHORIZATION_STATUS` events, zero or more + :attr:`Event.TOKEN_STATUS` events, and zero or more + :attr:`Event.SERVICE_STATUS` events are generated. + + The behavior is undefined if either ``authOptions`` or + ``correlationId`` is ``None``. + """ + if correlationId is None: + correlationId = CorrelationId() + retcode = ( + internals.blpapi_AbstractSession_generateAuthorizedIdentityAsync( + self.__handle, get_handle(authOptions), correlationId + ) + ) + _ExceptionUtil.raiseOnError(retcode) + return correlationId + + def getAuthorizedIdentity( + self, correlationId: Optional[CorrelationId] = None + ) -> Identity: + """Returns the authorized :class:`Identity` associated with + ``correlationId``. If ``correlationId`` is not given, returns the + session identity. + + Args: + correlationId: Optional. Associated with an :class:`Identity`. + + Returns: + Identity: the :class:`Identity` associated with ``correlationId``. + + Raises: + NotFoundException: If there is no :class:`Identity` associated + with ``correlationId``, if the associated :class:`Identity` is + not authorized, or if ``correlationId`` is not given and the + session identity is not authorized. + """ + if correlationId is None: + correlationId = CorrelationId() + ( + retcode, + identity_handle, + ) = internals.blpapi_AbstractSession_getAuthorizedIdentity( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(retcode) + return Identity(identity_handle, (self,)) + + def sessionName(self) -> str: + """ + Returns: + The session name. + """ + (result, sessionName) = internals.blpapi_AbstractSession_sessionName( + self.__handle + ) + + _ExceptionUtil.raiseOnError(result) + return sessionName + + +__copyright__ = """ +Copyright 2019. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/auth.py b/src/blpapi/auth.py new file mode 100644 index 0000000..027337e --- /dev/null +++ b/src/blpapi/auth.py @@ -0,0 +1,248 @@ +# auth.py + +"""Provide a configuration to specify the settings used for authorization.""" + +from __future__ import annotations +from typing import Callable, Union +from .typehints import ( + BlpapiAuthOptionsHandle, + BlpapiAuthUserHandle, + BlpapiAuthTokenHandle, + BlpapiAuthAppHandle, +) +from . import internals +from .utils import get_handle +from .exception import _ExceptionUtil +from .chandle import CHandle + + +class AuthOptions(CHandle): + """Defines the authorization options which the user can set on + :class:`SessionOptions` as the authorization options for the session + identity or use to authorize other identities. + """ + + def __init__( + self, + handle: BlpapiAuthOptionsHandle, + **kwargs: Union[BlpapiAuthAppHandle, BlpapiAuthTokenHandle], + ) -> None: + """For internal use only.""" + noop = lambda *args: None + super(AuthOptions, self).__init__(handle, noop) + self.__handle = handle + self.__app_handle = kwargs.get("app_handle") + self.__token_handle = kwargs.get("token_handle") + self._options_dtor = internals.blpapi_AuthOptions_destroy + self._app_dtor = internals.blpapi_AuthApplication_destroy + self._token_dtor = internals.blpapi_AuthToken_destroy + + @classmethod + def createWithUser(cls: Callable, user: AuthUser) -> AuthOptions: + """Creates an :class:`AuthOptions` instance for User Mode with the + Operating System Login (Domain/User), Active Directory, or Email. + + Args: + user: user-specific authorization option. + + Returns: + Specifies User Mode with the Operating System Login + (Domain/User), Active Directory, or Email. + + The behavior is undefined when ``user`` was created with + :meth:`AuthUser.createWithManualOptions` or is ``None``. + """ + ( + retcode, + authOptions_handle, + ) = internals.blpapi_AuthOptions_create_forUserMode(get_handle(user)) + _ExceptionUtil.raiseOnError(retcode) + return cls(authOptions_handle) + + @classmethod + def createWithApp(cls: Callable, appName: str) -> AuthOptions: + """Create an :class:`AuthOptions` instance for Application Mode. + + Args: + appName: app name used for Application Mode. + + Returns: + Specifies Application Mode. + + The behavior is undefined when ``appName`` is ``None`` or ``""``. + """ + app_handle = AuthOptions._create_app_handle(appName) + ( + retcode, + authOptions_handle, + ) = internals.blpapi_AuthOptions_create_forAppMode(app_handle) + _ExceptionUtil.raiseOnError(retcode) + return cls(authOptions_handle, app_handle=app_handle) + + @classmethod + def createWithToken(cls: Callable, token: str) -> AuthOptions: + """Create an :class:`AuthOptions` instance for Manual Token Mode. + + Args: + token: token to use for Manual Token Mode. + + Returns: + Specifies Manual Token Mode. + + The behavior is undefined when ``token`` is ``None`` or ``""``. + """ + token_handle = AuthOptions._create_token_handle(token) + ( + retcode, + authOptions_handle, + ) = internals.blpapi_AuthOptions_create_forToken(token_handle) + _ExceptionUtil.raiseOnError(retcode) + return cls(authOptions_handle, token_handle=token_handle) + + @classmethod + def createWithUserAndApp( + cls: Callable, user: AuthUser, appName: str + ) -> AuthOptions: + """Create an :class:`AuthOptions` instance for User and Application + Mode. + + Args: + user: user-specific authorization option. + appName: app name used for Application Mode. + + Returns: + AuthOptions: an :class:`AuthOptions` that contains the + authorization option for the User+Application authorization + mode. + + The behavior is undefined when ``appName`` is ``None`` or ``""``. + """ + app_handle = AuthOptions._create_app_handle(appName) + ( + retcode, + authOptions_handle, + ) = internals.blpapi_AuthOptions_create_forUserAndAppMode( + get_handle(user), app_handle + ) + _ExceptionUtil.raiseOnError(retcode) + return cls(authOptions_handle, app_handle=app_handle) + + def destroy(self) -> None: + """Destroy this :class:`AuthOptions`.""" + if self.__handle: + self._options_dtor(self.__handle) + self.__handle = None + if self.__app_handle: + self._app_dtor(self.__app_handle) + self.__app_handle = None + if self.__token_handle: + self._token_dtor(self.__token_handle) + self.__token_handle = None + + @staticmethod + def _create_app_handle(appName: str) -> BlpapiAuthAppHandle: + """For internal use only.""" + retcode, app_handle = internals.blpapi_AuthApplication_create(appName) + _ExceptionUtil.raiseOnError(retcode) + return app_handle + + @staticmethod + def _create_token_handle(token: str) -> BlpapiAuthTokenHandle: + """For internal use only.""" + retcode, token_handle = internals.blpapi_AuthToken_create(token) + _ExceptionUtil.raiseOnError(retcode) + return token_handle + + +class AuthUser(CHandle): + """Contains user-specific authorization options.""" + + def __init__(self, handle: BlpapiAuthUserHandle) -> None: + """For internal use only.""" + super(AuthUser, self).__init__( + handle, internals.blpapi_AuthUser_destroy + ) + self.__handle = handle # pylint: disable=unused-private-member + + @classmethod + def createWithLogonName(cls: Callable) -> AuthUser: + """Creates an :class:`AuthUser` instance configured for Operating + System Login (Domain/User) authorization mode (OS_LOGON). + + Returns: + Configured for Operating System Login (Domain/User) mode. + """ + retcode, handle = internals.blpapi_AuthUser_createWithLogonName() + _ExceptionUtil.raiseOnError(retcode) + return cls(handle) + + @classmethod + def createWithActiveDirectoryProperty( + cls: Callable, propertyName: str + ) -> AuthUser: + """Creates an :class:`AuthUser` instance configured for Active + Directory authorization mode (DIRECTORY_SERVICE). + + Args: + propertyName: Active Directory property. + + Returns: + Configured for Active Directory (DIRECTORY_SERVICE) + authorization mode. + + The behavior is undefined when ``propertyName`` is ``""`` or + ``None``. + """ + ( + retcode, + handle, + ) = internals.blpapi_AuthUser_createWithActiveDirectoryProperty( + propertyName + ) + _ExceptionUtil.raiseOnError(retcode) + return cls(handle) + + @classmethod + def createWithManualOptions( + cls: Callable, userId: str, ipAddress: str + ) -> AuthUser: + """Creates an :class:`AuthUser` instance configured for manual + authorization. + + Args: + userId: user id. + ipAddress: IP address. + + Returns: + Configured for manual authorization. + + The behavior is undefined when either ``userId`` or ``ipAddress`` is + ``""`` or ``None``. + """ + retcode, handle = internals.blpapi_AuthUser_createWithManualOptions( + userId, ipAddress + ) + _ExceptionUtil.raiseOnError(retcode) + return cls(handle) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/chandle.py b/src/blpapi/chandle.py new file mode 100644 index 0000000..c0cce9b --- /dev/null +++ b/src/blpapi/chandle.py @@ -0,0 +1,68 @@ +# chandle.py + +"""A module which defines base class for blpapi classes. + +This file defines a 'CHandle' class. +It handles the life of an object with a handle from C layer. +""" + +from ctypes import c_void_p +from typing import Callable, Any + + +class CHandle: + """A base class for objects that rely on C handles""" + + def __init__(self, handle: Any, dtor: Callable) -> None: + """Set the handle and the dtor""" + # None case is for tests + assert isinstance(handle, c_void_p) or handle is None + self.__handle = handle + self._dtor = dtor + + def __del__(self) -> None: + """Destroy the object""" + try: + # print('destorying chandle', self.__handle, 'using', self._dtor) + self.destroy() + except (NameError, AttributeError): + pass + + def destroy(self) -> None: + """Destroy the handle using stored dtor""" + if self.__handle: + self._dtor(self.__handle) + self._dtor = None # type: ignore + self.__handle = None + + def _handle(self) -> Any: + """Return the internal implementation.""" + return self.__handle + + def isValid(self) -> bool: + """Returns: + ``True`` if this class holds a handle and the handle is not None. + """ + return self.__handle is not None and self.__handle.value is not None + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, co, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/constant.py b/src/blpapi/constant.py new file mode 100644 index 0000000..1a94adb --- /dev/null +++ b/src/blpapi/constant.py @@ -0,0 +1,369 @@ +# constant.py + +"""Provide a representation for schema-level enumeration constants. + +This file defines these classes: + 'Constant' - schema enumeration constant + 'ConstantList' - list of schema enumeration constants + +This component provides a representation of a schema enumeration constant, and +a representation for lists of such constants +""" + + +from typing import Any, Iterator as IteratorType, Optional, Set +from .exception import ( + _ExceptionUtil, + NotFoundException, + IndexOutOfRangeException, +) +from .name import Name, getNamePair +from .datatype import DataType +from .datetime import _DatetimeUtil +from . import typehints # pylint: disable=unused-import +from .typehints import ( + AnyPythonDatetime, + BlpapiConstantHandle, + BlpapiConstantListHandle, +) +from . import utils +from . import internals + +# pylint: disable=protected-access + + +class Constant: + r"""Represents the value of a schema enumeration constant. + + Constants can be any of the following :class:`DataType`\s: + :attr:`~DataType.BOOL`, :attr:`~DataType.CHAR`, :attr:`~DataType.BYTE`, + :attr:`~DataType.INT32`, :attr:`~DataType.INT64`, + :attr:`~DataType.FLOAT32`, :attr:`~DataType.FLOAT64`, + :attr:`~DataType.STRING`, :attr:`~DataType.DATE`, :attr:`~DataType.TIME`, + :attr:`~DataType.DATETIME`. This class provides access not only to to the + constant value, but also to the symbolic name, the description, and the + status of the constant. + + :class:`Constant` objects are read-only. + + Application clients never create :class:`Constant` object directly; + applications will typically work with :class:`Constant` objects returned + by other ``blpapi`` components. + """ + + def __init__( + self, + handle: BlpapiConstantHandle, + sessions: Optional[Set["typehints.AbstractSession"]], + ) -> None: + """ + Args: + handle: Handle to the internal implementation + sessions: Sessions to which this object is related to + """ + self.__handle = handle + self.__sessions = sessions + + def name(self) -> Name: + """ + Returns: + The symbolic name of this :class:`Constant`. + """ + return Name._createInternally( + internals.blpapi_Constant_name(self.__handle) + ) + + def description(self) -> str: + """ + Returns: + Human readable description of this :class:`Constant`. + """ + return internals.blpapi_Constant_description(self.__handle) + + def status(self) -> int: + """ + Returns: + Status of this :class:`Constant`. + + The possible return values are enumerated in :class:`SchemaStatus`. + """ + return internals.blpapi_Constant_status(self.__handle) + + def datatype(self) -> int: + """ + Returns: + Data type used to represent the value of this :class:`Constant`. + + The possible return values are enumerated in :class:`DataType`. + """ + return internals.blpapi_Constant_datatype(self.__handle) + + def getValueAsInteger(self) -> int: + """ + Returns: + Value of this object as an integer. + + Raises: + InvalidConversionException: If the value cannot be converted to an + integer. + """ + if self.datatype() == DataType.INT32: + errCode, value = internals.blpapi_Constant_getValueAsInt32( + self.__handle + ) + else: + errCode, value = internals.blpapi_Constant_getValueAsInt64( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return value + + def getValueAsFloat(self) -> float: + """ + Returns: + Value of this object as a float. + + Raises: + InvalidConversionException: If the value cannot be converted to a + float. + """ + if self.datatype() == DataType.FLOAT32: + errCode, value = internals.blpapi_Constant_getValueAsFloat32( + self.__handle + ) + else: + errCode, value = internals.blpapi_Constant_getValueAsFloat64( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return value + + def getValueAsDatetime(self) -> AnyPythonDatetime: + """ + Returns: + Value of this object as one of the datetime types. + + Raises: + InvalidConversionException: If the value cannot be converted to + one of the datetime types. + """ + errCode, value = internals.blpapi_Constant_getValueAsDatetime( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return _DatetimeUtil.convertToNativeNotHighPrecision(value) + + def getValueAsString(self) -> str: + """ + Returns: + Value of this object as a string. + + Raises: + InvalidConversionException: If the value cannot be converted to a + string. + """ + if self.datatype() == DataType.CHAR: + errCode, value = internals.blpapi_Constant_getValueAsChar( + self.__handle + ) + else: + errCode, value = internals.blpapi_Constant_getValueAsString( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return value + + def getValue(self) -> Any: + """ + Returns: + Value of this object as it is stored in the object. + """ + datatype = self.datatype() + valueGetter = _CONSTANT_VALUE_GETTER.get( + datatype, Constant.getValueAsString + ) + return valueGetter(self) + + def _sessions(self) -> Optional[Set["typehints.AbstractSession"]]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +class ConstantList: + """Represents a list of schema enumeration constants. + + As well as the list of :class:`Constant` objects, this class also provides + access to the symbolic name, description and status of the list as a whole. + All :class:`Constant` objects in a :class:`ConstantList` are of the same + :class:`DataType`. + + :class:`ConstantList` objects are read-only. + + Application clients never create :class:`ConstantList` object directly; + applications will typically work with :class:`ConstantList` objects + returned by other ``blpapi`` components. + """ + + def __init__( + self, + handle: BlpapiConstantListHandle, + sessions: Optional[Set["typehints.AbstractSession"]], + ) -> None: + """ + Args: + handle: Handle to the internal implementation + sessions: Sessions to which this object is related to + """ + self.__handle = handle + self.__sessions = sessions + + def __iter__(self) -> IteratorType: + """ + Returns: + Iterator over constants contained in this :class:`ConstantList` + """ + return utils.Iterator( + self, ConstantList.numConstants, ConstantList.getConstantAt + ) + + def name(self) -> Name: + """ + Returns: + Name: Symbolic name of this :class:`ConstantList` + """ + return Name._createInternally( + internals.blpapi_ConstantList_name(self.__handle) + ) + + def description(self) -> str: + """ + Returns: + str: Human readable description of this :class:`ConstantList` + """ + return internals.blpapi_ConstantList_description(self.__handle) + + def status(self) -> int: + """ + Returns: + int: Status of this :class:`ConstantList` + + The possible return values are enumerated in :class:`SchemaStatus` + """ + return internals.blpapi_ConstantList_status(self.__handle) + + def numConstants(self) -> int: + """ + Returns: + int: Number of :class:`Constant` objects in this list + """ + return internals.blpapi_ConstantList_numConstants(self.__handle) + + def datatype(self) -> int: + """ + Returns: + int: Data type used to represent the value of this constant + + The possible return values are enumerated in :class:`DataType`. + """ + return internals.blpapi_ConstantList_datatype(self.__handle) + + def hasConstant(self, name: Name) -> bool: + """ + Args: + name: Name of the constant + + Returns: + ``True`` if this :class:`ConstantList` contains an item with + this ``name``. + + Raises: + TypeError: If ``name`` is neither a :class:`Name` nor a string + """ + names = getNamePair(name) + return bool( + internals.blpapi_ConstantList_hasConstant( + self.__handle, names[0], names[1] + ) + ) + + def getConstant(self, name: Name) -> Constant: + """ + Args: + name: Name of the constant + + Returns: + Constant with the specified ``name`` + + Raises: + NotFoundException: If this :class:`ConstantList` does not contain a + :class:`Constant` with the specified ``name`` + """ + names = getNamePair(name) + res = internals.blpapi_ConstantList_getConstant( + self.__handle, names[0], names[1] + ) + if res is None: + errMessage = ( + f"Constant '{name!s}' is not found in '{self.name()!s}'." + ) + raise NotFoundException(errMessage, 0) + return Constant(res, self.__sessions) + + def getConstantAt(self, position: int) -> Constant: + """ + Args: + position: Position of the requested constant in the list + + Returns: + Constant at the specified ``position``. + + Raises: + IndexOutOfRangeException: If ``position`` is not in the range from + ``0`` to ``numConstants() - 1``. + """ + res = internals.blpapi_ConstantList_getConstantAt( + self.__handle, position + ) + if res is None: + errMessage = f"Index '{position}' out of bounds." + raise IndexOutOfRangeException(errMessage, 0) + return Constant(res, self.__sessions) + + def _sessions(self) -> Optional[Set["typehints.AbstractSession"]]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +_CONSTANT_VALUE_GETTER = { + DataType.CHAR: Constant.getValueAsString, + DataType.BYTE: Constant.getValueAsInteger, + DataType.INT32: Constant.getValueAsInteger, + DataType.INT64: Constant.getValueAsInteger, + DataType.FLOAT32: Constant.getValueAsFloat, + DataType.FLOAT64: Constant.getValueAsFloat, + DataType.STRING: Constant.getValueAsString, + DataType.DATE: Constant.getValueAsDatetime, + DataType.TIME: Constant.getValueAsDatetime, + DataType.DATETIME: Constant.getValueAsDatetime, +} + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/correlationid.py b/src/blpapi/correlationid.py new file mode 100644 index 0000000..7d1a1d1 --- /dev/null +++ b/src/blpapi/correlationid.py @@ -0,0 +1,265 @@ +from ctypes import ( + byref, + c_uint16, + c_void_p, + sizeof, +) +from . import internals +from . import pycbhelpers +from .ctypesutils import safePOD, py_objectFromVoid +from typing import Any + + +class CorrelationId: + r""" + A key used to identify individual subscriptions or requests. + + Two :class:`CorrelationId` objects are considered equal if they have the same + :meth:`type()` and: + + - Hold the same (not just equal!) objects, if the type is :attr:`OBJECT_TYPE`. + - Hold equal integers, if the type is :attr:`INT_TYPE` or :attr:`AUTOGEN_TYPE`. + + If the type is :attr:`UNSET_TYPE`, then the two :class:`CorrelationId` objects + are always equal (as the value of both will necessarily be ``None``). + + It is possible that a user constructed :class:`CorrelationId` and a + :class:`CorrelationId` generated by the API could return the same result for + :meth:`value()`. However, they will not compare equal because they have a + different :meth:`type()`. + + :class:`CorrelationId` objects are passed to many of the :class:`Session` + object methods which initiate asynchronous operations and are obtained from + :class:`Message` objects which are delivered as a result of those asynchronous + operations. + + When subscribing or requesting information, an application has the choice of + providing a :class:`CorrelationId` they construct themselves or allowing the + session to construct one for them. If the application supplies a + :class:`CorrelationId`, it must not re-use the value contained in it in another + :class:`CorrelationId`, whilst the original request or subscription is still + active. + + The ``xxx_TYPE`` class attributes represent the possible types of + :class:`CorrelationId`. + """ + + UNSET_TYPE = internals.CORRELATION_TYPE_UNSET + """The :class:`CorrelationId` is unset. That is, it was created by the + default :class:`CorrelationId` constructor.""" + + INT_TYPE = internals.CORRELATION_TYPE_INT + """The :class:`CorrelationId` was created from an :class:`int` or + :class:`long` supplied by the user.""" + + OBJECT_TYPE = internals.CORRELATION_TYPE_POINTER + """The :class:`CorrelationId` was created from an object supplied by + the user.""" + + AUTOGEN_TYPE = internals.CORRELATION_TYPE_AUTOGEN + """The :class:`CorrelationId` was created internally by API.""" + + MAX_CLASS_ID = internals.CORRELATION_MAX_CLASS_ID + """The maximum value allowed for ``classId``.""" + + STRUCT_SZ = sizeof(internals.CidStruct) + + __TYPE_NAMES = { + UNSET_TYPE: "UNSET", + INT_TYPE: "INTEGER", + OBJECT_TYPE: "OBJECT", + AUTOGEN_TYPE: "AUTOGEN", + } + + @staticmethod + def cidFromCPtr(ptr: int) -> "CorrelationId": + # used in _subscriptionPreprocessProxy + cid = internals.CidStruct.from_buffer_copy( + internals.CidStruct.from_address(ptr) + ) + return CorrelationId(cid) + + def __init__(self, *argv: Any, **_kwargs: Any) -> None: + r""" + ``CorrelationId([value[, classId=0]])`` constructs a :class:`CorrelationId` + object. + If ``value`` is an integer (either :class:`int` or :class:`long`) then the + created :class:`CorrelationId` will have type :attr:`INT_TYPE`. Otherwise, it + will have type :attr:`OBJECT_TYPE`. + If no arguments are specified, then the type will be :attr:`UNSET_TYPE`. + The maximum allowed ``classId`` value is :attr:`MAX_CLASS_ID`. + """ + argc = len(argv) + assert argc >= 0 and argc <= 2 + if argc == 0: # this is empty/default + self.flags = internals.CidFlags( + CorrelationId.STRUCT_SZ, CorrelationId.UNSET_TYPE, 0, 0 + ) + self.rawvalue = internals.CidValue(0) + elif isinstance(argv[0], int): # this is int + classid = ( + safePOD(argv[1], c_uint16).value + if argc > 1 and isinstance(argv[1], int) + else 0 + ) + self.flags = internals.CidFlags( + CorrelationId.STRUCT_SZ, CorrelationId.INT_TYPE, classid, 0 + ) + self.rawvalue = internals.CidValue(intValue=argv[0]) + elif isinstance(argv[0], internals.CidStruct): # this came from C + self.flags = argv[0].flags + if self.flags.valueType != CorrelationId.OBJECT_TYPE: + # this is an in-place value int/autogen, just store it + self.rawvalue = argv[0].rawvalue + else: + # this is an object, we need to handle lifetime + if ( + internals.is_known_obj(byref(argv[0].rawvalue.ptrValue)) + == 0 + ): + # must be recap + self.rawvalue = argv[0].rawvalue + # we must become co-owners and bump using C++ manager + pv = self.rawvalue.ptrValue + pv.manager( + byref(pv), + byref(argv[0].rawvalue.ptrValue), + internals.ManagedPtr.COPY, + ) + else: # it is a proper py-object + pyobj = CorrelationId._objectFromStruct(argv[0]) + self.rawvalue = internals.cidValueForObj(pyobj) + else: # this is a py-object, including None + classid = ( + safePOD(argv[1], c_uint16).value + if argc > 1 and isinstance(argv[1], int) + else 0 + ) + + self.flags = internals.CidFlags( + CorrelationId.STRUCT_SZ, CorrelationId.OBJECT_TYPE, classid, 0 + ) + self.rawvalue = internals.cidValueForObj(argv[0]) + + self.thestruct = internals.CidStruct( + flags=self.flags, rawvalue=self.rawvalue + ) + + def __del__(self) -> None: + if self.type() != CorrelationId.OBJECT_TYPE: + return + + # this is safe for py-object, recaps, and even None + pv = self.rawvalue.ptrValue + pv.manager(byref(pv), None, internals.ManagedPtr.DESTROY) # dec ref. + + def type(self) -> int: + r""" + Returns: + int: The type of this CorrelationId object (see the ``xxx_TYPE`` class + attributes) + """ + return self.thestruct.flags.valueType + + def classId(self) -> int: + r""" + Returns: + int: The user defined classification of this :class:`CorrelationId` + object + """ + return self.thestruct.flags.classId + + def _asInt(self) -> int: + return self.thestruct.rawvalue.intValue + + def value(self) -> Any: + """ + Returns: + int or long or object: The value of this CorrelationId object. + + The return value depends on this :class:`CorrelationId`'s value + type and could be: + + - Integer (``type() == CorrelationId.INT_TYPE`` + or ``type() == CorrelationId.AUTOGEN_TYPE``) + - Object (``type() == CorrelationId.OBJECT_TYPE``) + - ``None`` (``type() == CorrelationId.UNSET_TYPE``) + """ + valueType = self.type() + if ( + valueType == CorrelationId.INT_TYPE + or valueType == CorrelationId.AUTOGEN_TYPE + ): + return self._asInt() + elif valueType == CorrelationId.OBJECT_TYPE: + return self._asObject() + else: + return None + + @staticmethod + def _objectFromStruct(cid: internals.CidStruct) -> Any: + if cid.flags.valueType == CorrelationId.OBJECT_TYPE: + if internals.is_known_obj(byref(cid.rawvalue.ptrValue)) == 0: + # must be recaps then + return None + + pyobj = py_objectFromVoid(c_void_p(cid.rawvalue.ptrValue.pointer)) + # py_object is a thin wrapper, it does not bump the ref.count + # but this is fine, the receiver of this will + return pyobj.value + return None + + def _asObject(self) -> Any: + return CorrelationId._objectFromStruct(self.thestruct) + + def __repr__(self) -> str: + if self.type() == CorrelationId.OBJECT_TYPE: + return f"CorrelationId(flags={self.thestruct.flags}, rawvalue.ptrValue=object)" + return f"CorrelationId(flags={self.thestruct.flags}, rawvalue.intValue={self._asInt()})" + + def __str__(self) -> str: + """x.__str__() <==> str(x)""" + valueType = self.type() + valueTypeName = CorrelationId.__TYPE_NAMES[valueType] + + if valueType == CorrelationId.UNSET_TYPE: + return valueTypeName + else: + return f"({valueTypeName}: {self.value()!r}, ClassId: {self.classId()})" + + def __hash__(self) -> int: + if self.type() == CorrelationId.OBJECT_TYPE: + return hash( + ( + self.type(), + self.classId(), + self.thestruct.rawvalue.ptrValue.pointer, + ) + ) + return hash((self.type(), self.classId(), self._asInt())) + + def __eq__(self, other: Any) -> bool: + """x.__eq__(y) <==> x==y""" + try: + if self is other: + return True + if other is None: + return False + if self.type() != other.type(): + return False + if self.classId() != other.classId(): + return False + if self.type() == CorrelationId.OBJECT_TYPE: + # we care about it being SAME object, not just equal/equivalent + return self._asObject() is other._asObject() + return self._asInt() == other._asInt() + except Exception: # pylint: disable=broad-exception-caught + return NotImplemented + + def __ne__(self, other: Any) -> bool: + """x.__ne__(y) <==> x!=y""" + equal = self.__eq__(other) + return NotImplemented if equal is NotImplemented else not equal + + +pycbhelpers.correlationIdWrapper = CorrelationId.cidFromCPtr diff --git a/src/blpapi/ctypesutils.py b/src/blpapi/ctypesutils.py new file mode 100644 index 0000000..aa82572 --- /dev/null +++ b/src/blpapi/ctypesutils.py @@ -0,0 +1,137 @@ +from ctypes import ( + c_void_p, + POINTER, + cast, + py_object, + c_char, + c_uint16, +) +from typing import Any, Callable, Union, Optional, Tuple + + +def voidFromPyObject(obj: Any) -> c_void_p: + # an alternative would be c_void_p.from_buffer(py_object(obj)) + # use .value to get the address as an int + return c_void_p(id(obj)) + + +def voidFromPyFunction(cb: Callable) -> c_void_p: + return voidFromPyObject(cb) + + +def py_objectFromVoid(voidp: c_void_p) -> py_object: + return cast(voidp, py_object) + + +def pyObjectFromVoid(voidp: c_void_p) -> Any: + return py_objectFromVoid(voidp).value + + +_LIMITS = {c_uint16: [0, 0xFFFF]} + + +def safePOD(value: Union[int, float], ctype: Any) -> Any: + limits = _LIMITS[ctype] + if value <= limits[1] and value >= limits[0]: + return ctype(value) + raise OverflowError() + + +def getHandleFromPtr(outp: int) -> Optional[c_void_p]: + """Get c_void_p handle or None + + Some C interface functions will return NULL, when that happens we want + to return a None pointer in Python, rather than a c_void_p holding the + NULL value. + """ + return c_void_p(outp) if outp else None + + +def getHandleFromOutput(outp: Any, retCode: int) -> Optional[c_void_p]: + """Get c_void_p handle + + Special case: C layer populates the buffer with NULL. + The following statements are true (tested separately) + 1) outp is not None and type(outp) is POINTER(c_void_p) + 2) outp.contents is not None and type(outp.contents) is c_void_p + 3) but outp.contents.value is None, so its type is the NoneType not int + + i.e., it is always safe to access outp.contents as a valid c_void_p + """ + # if retCode != 0 there is no chance this None + # is used as handle by caller + return outp.contents if retCode == 0 else None + + +def getStrFromC( + value: Optional[bytes], dflt: Optional[str] = None +) -> Optional[str]: + """When restype = c_char_p ctypes will: + 1) provide a None for nullptr + 2) provide empty bytes object for empty string + 3) provide non-empty bytes object for non-empty string. + [2 and 3] are safe to decode. + We assume all such are null-terminated and not funny unicode""" + return value.decode() if value is not None else dflt + + +def getStrFromOutput( + outp: Any, retCode: int, dflt: Optional[str] = None +) -> Optional[str]: + if retCode != 0: + return dflt + value = outp.contents.value + return value.decode() if value is not None else dflt + + +def getSizedStrFromOutput( + outp: Any, outsz: Any, retCode: int, dflt: Optional[str] = None +) -> Optional[str]: + if retCode != 0: + return dflt + if not outp.contents.value or not outsz.contents.value: + return "" + return getSizedStrFromBuffer(outp.contents, outsz.contents.value) + + +def getSizedStrFromBuffer(outp: Any, outsz: Any) -> str: + return getSizedBytesFromBuffer(outp, outsz).decode() + + +def getSizedBytesFromOutput( + outp: Any, outsz: Any, retCode: int, dflt: Optional[bytes] = None +) -> Optional[bytes]: + if retCode != 0: + return dflt + if not outp.contents.value or not outsz.contents.value: + return b"" + return getSizedBytesFromBuffer(outp.contents, outsz.contents.value) + + +def getSizedBytesFromBuffer(outp: Any, outsz: int) -> bytes: + return bytes(cast(outp, POINTER(c_char * outsz)).contents) + + +def getPODFromOutput(outp: Any, retCode: int) -> Any: + return outp.contents.value if retCode == 0 else None + + +def getStructFromOutput(outp: Any, retCode: int) -> Any: + return outp.contents if retCode == 0 else None + + +def charPtrFromPyStr(val: Union[str, bytes, None]) -> bytes: + """Use for immutable null-terminated input strings + Works with None""" + return val.encode() if str == type(val) else val # type: ignore + + +def charPtrWithSizeFromPyStr( + val: Union[str, bytes, bytearray, None] +) -> Tuple[Optional[bytes], int]: + if str == type(val): + bts = val.encode() + return bts, len(bts) + if val is None: + return None, 0 + return val, len(val) # type: ignore diff --git a/blpapi/datatype.py b/src/blpapi/datatype.py similarity index 75% rename from blpapi/datatype.py rename to src/blpapi/datatype.py index cbcfac9..08c183b 100644 --- a/blpapi/datatype.py +++ b/src/blpapi/datatype.py @@ -6,35 +6,14 @@ 'DataType' - "enum" representing all possible data types in an Element. """ - - from . import internals from . import utils -from .compat import with_metaclass -@with_metaclass(utils.MetaClassForClassesWithEnums) -class DataType(object): - """Contains the possible data types which can be represented in an Element. - - Class attributes: - BOOL Boolean - CHAR Char - BYTE Unsigned 8 bit value - INT32 32 bit Integer - INT64 64 bit Integer - FLOAT32 32 bit Floating point - FLOAT64 64 bit Floating point - STRING ASCIIZ string - BYTEARRAY Opaque binary data - DATE Date - TIME Timestamp - DECIMAL Currently Unsuppored - DATETIME Date and time - ENUMERATION An opaque enumeration - SEQUENCE Sequence type - CHOICE Choice type - CORRELATION_ID Used for some internal messages +# pylint: disable=too-few-public-methods +class DataType(metaclass=utils.MetaClassForClassesWithEnums): + """Contains the possible data types which can be represented in an + :class:`Element`. """ BOOL = internals.DATATYPE_BOOL @@ -72,6 +51,7 @@ class DataType(object): CORRELATION_ID = internals.DATATYPE_CORRELATION_ID """Used for some internal messages""" + __copyright__ = """ Copyright 2012. Bloomberg Finance L.P. diff --git a/src/blpapi/datetime.py b/src/blpapi/datetime.py new file mode 100644 index 0000000..38e2425 --- /dev/null +++ b/src/blpapi/datetime.py @@ -0,0 +1,328 @@ +# datetime.py + +"""Utilities that deal with blpapi.Datetime data type""" + +from __future__ import annotations +import datetime as _dt +from typing import Any, Optional + +from .typehints import AnyPythonDatetime, BlpapiDatetime +from . import internals +from . import utils +from . import typehints # pylint: disable=unused-import + + +# pylint: disable=no-member +class FixedOffset(_dt.tzinfo, metaclass=utils.MetaClassForClassesWithEnums): + """Time zone information. + + Represents time zone information to be used with Python standard library + datetime classes. + + This class is intended to be used as ``tzinfo`` for Python standard library + :class:`datetime.datetime` and :class:`datetime.time` classes. These + classes are accepted by the blpapi package to set :attr:`~DataType.DATE`, + :attr:`~DataType.TIME` or :attr:`~DataType.DATETIME` elements. For example, + the :attr:`~DataType.DATETIME` element of a request could be set as:: + + value = datetime.datetime(1941, 6, 22, 4, 0, tzinfo=FixedOffset(4*60)) + request.getElement("last_trade").setValue(value) + + The :attr:`~DataType.TIME` element could be set in a similar way:: + + value = datetime.time(9, 0, 1, tzinfo=FixedOffset(-5*60)) + request.getElement("session_open").setValue(value) + + Note that you could use any other implementations of + :class:`datetime.tzinfo` with BLPAPI-Py, for example the widely used + ``pytz`` package (https://pypi.python.org/pypi/pytz/). + + For more details see datetime module documentation at + https://docs.python.org/library/datetime.html + """ + + def __init__(self, offsetInMinutes: int = 0) -> None: + """ + Args: + offsetInMinutes: Offset from UTC in minutes + + Creates an object that implements :class:`datetime.tzinfo` interface + and represents a timezone with the specified ``offsetInMinutes`` from + UTC. + """ + self.__offset = _dt.timedelta(minutes=offsetInMinutes) + + def utcoffset(self, dt: Optional[_dt.datetime]) -> _dt.timedelta: + del dt + return self.__offset + + def dst( + self, dt: Optional[_dt.datetime] + ) -> _dt.timedelta: # pylint: disable=no-self-use + del dt + return _dt.timedelta(0) + + def tzname(self, dt: Optional[_dt.datetime]) -> _dt.timedelta: # type: ignore # superclass returns str, but .__offset is a timedelta + del dt + return self.__offset + + def getOffsetInMinutes(self) -> int: + """ + Returns: + Offset from UTC in minutes + """ + return self.__offset.days * 24 * 60 + self.__offset.seconds // 60 + + def __hash__(self) -> int: + """x.__hash__() <==> hash(x)""" + return self.getOffsetInMinutes() + + def __eq__(self, other: FixedOffset) -> bool: # type: ignore # mypy wants us to accept arbitrary object and check isinstance() + """Let the equality operator work based on the time delta.""" + return self.getOffsetInMinutes() == other.getOffsetInMinutes() + + def __lt__(self, other: FixedOffset) -> bool: + """Let the comparison operator work based on the time delta.""" + return self.getOffsetInMinutes() < other.getOffsetInMinutes() + + def __le__(self, other: FixedOffset) -> bool: + """Let the comparison operator work based on the time delta.""" + return self.getOffsetInMinutes() <= other.getOffsetInMinutes() + + +# UTC timezone +UTC = FixedOffset(0) + + +class _DatetimeUtil(object): + """Utility methods that deal with BLPAPI dates and times.""" + + @staticmethod + def toPyTimeFromInts( + parts: int, + offset: int, + year: int, + month: int, + day: int, + hours: int, + minutes: int, + seconds: int, + useconds: int, + ) -> AnyPythonDatetime: + hasDate = ( + parts & internals.DATETIME_DATE_PART + == internals.DATETIME_DATE_PART + ) + hasTime = parts & internals.DATETIME_TIMEFRACSECONDS_PART != 0 + + tzinfo = ( + FixedOffset(offset) + if parts & internals.DATETIME_OFFSET_PART + else None + ) + + if hasDate and hasTime: + return _dt.datetime( + year, + month, + day, + hours, + minutes, + seconds, + useconds, + tzinfo, + ) + elif hasDate: + # Skip an offset, because it's not informative if there is a + # date without time + return _dt.date(year, month, day) + elif hasTime: + return _dt.time( + hours, + minutes, + seconds, + useconds, + tzinfo, + ) + return _dt.datetime.now() # unreachable + + @staticmethod + def convertToNative( + blpapiDatetimeObj: BlpapiDatetime, + ) -> AnyPythonDatetime: + """Convert BLPAPI Datetime object to a suitable Python object.""" + + isHighPrecision = isinstance( + blpapiDatetimeObj, internals.blpapi_HighPrecisionDatetime_tag + ) + + if not isHighPrecision: + raise ValueError( + "Datetime object is not high precision", blpapiDatetimeObj + ) + + blpapiDatetime = blpapiDatetimeObj.datetime + parts = blpapiDatetime.parts + hasDate = ( + parts & internals.DATETIME_DATE_PART + == internals.DATETIME_DATE_PART + ) + hasTime = parts & internals.DATETIME_TIMEFRACSECONDS_PART != 0 + microsecs = ( + ( + blpapiDatetime.milliSeconds * 1000 + + blpapiDatetimeObj.picoseconds // 1000 // 1000 + ) + if parts & internals.DATETIME_FRACSECONDS_PART + else 0 + ) + + return _DatetimeUtil._convertToNativeTypeHelper( + hasDate, hasTime, blpapiDatetime, microsecs + ) + + @staticmethod + def convertToNativeNotHighPrecision( + blpapiDatetime: BlpapiDatetime, + ) -> AnyPythonDatetime: + """Convert BLPAPI Datetime object to a suitable Python object. + This version should only be used for logging callback which does not + provide a high precision datetime alternative.""" + + parts = blpapiDatetime.parts + hasDate = ( + parts & internals.DATETIME_DATE_PART + == internals.DATETIME_DATE_PART + ) + hasTime = ( + parts & internals.DATETIME_TIME_PART + == internals.DATETIME_TIME_PART + ) + microsecs = ( + blpapiDatetime.milliSeconds * 1000 + if parts & internals.DATETIME_MILLISECONDS_PART + else 0 + ) + return _DatetimeUtil._convertToNativeTypeHelper( + hasDate, hasTime, blpapiDatetime, microsecs + ) + + @staticmethod + def _convertToNativeTypeHelper( + hasDate: bool, + hasTime: bool, + blpapiDatetime: BlpapiDatetime, + microsecs: int, + ) -> AnyPythonDatetime: + parts = blpapiDatetime.parts + tzinfo = ( + FixedOffset(blpapiDatetime.offset) + if parts & internals.DATETIME_OFFSET_PART + else None + ) + + if hasDate and hasTime: + return _dt.datetime( + blpapiDatetime.year, + blpapiDatetime.month, + blpapiDatetime.day, + blpapiDatetime.hours, + blpapiDatetime.minutes, + blpapiDatetime.seconds, + microsecs, + tzinfo, + ) + elif hasDate: + # Skip an offset, because it's not informative if there is a + # date without time + return _dt.date( + blpapiDatetime.year, blpapiDatetime.month, blpapiDatetime.day + ) + elif hasTime: + return _dt.time( + blpapiDatetime.hours, + blpapiDatetime.minutes, + blpapiDatetime.seconds, + microsecs, + tzinfo, + ) + + raise ValueError( + "Blpapi datetime object is invalid: missing" + " both date and time parts" + ) + + @staticmethod + def isDatetime(dtime: Any) -> bool: + """Return True if the parameter is one of Python date/time objects.""" + return isinstance(dtime, (_dt.datetime, _dt.date, _dt.time)) + + @staticmethod + def convertToBlpapi(dtime: AnyPythonDatetime) -> BlpapiDatetime: + "Convert a Python date/time object to a BLPAPI Datetime object." "" + highPrecDatetime = internals.blpapi_HighPrecisionDatetime_tag() + res = highPrecDatetime.datetime + offset = None + if isinstance(dtime, _dt.datetime): + offset = dtime.utcoffset() + res.year = dtime.year + res.month = dtime.month + res.day = dtime.day + res.hours = dtime.hour + res.minutes = dtime.minute + res.seconds = dtime.second + (res.milliSeconds, highPrecDatetime.picoseconds) = divmod( + dtime.microsecond, 1000 + ) + highPrecDatetime.picoseconds *= 1000 * 1000 + res.parts = ( + internals.DATETIME_DATE_PART + | internals.DATETIME_TIMEFRACSECONDS_PART + ) + elif isinstance(dtime, _dt.date): + res.year = dtime.year + res.month = dtime.month + res.day = dtime.day + res.parts = internals.DATETIME_DATE_PART + elif isinstance(dtime, _dt.time): + offset = dtime.utcoffset() + res.hours = dtime.hour + res.minutes = dtime.minute + res.seconds = dtime.second + (res.milliSeconds, highPrecDatetime.picoseconds) = divmod( + dtime.microsecond, 1000 + ) + highPrecDatetime.picoseconds *= 1000 * 1000 + res.parts = internals.DATETIME_TIMEFRACSECONDS_PART + else: + raise TypeError( + "Datetime can be created only from \ +datetime.datetime, datetime.date or datetime.time" + ) + if offset is not None: + offsetInMinutes = int(offset.total_seconds() // 60) + res.offset = offsetInMinutes + res.parts |= internals.DATETIME_OFFSET_PART + return highPrecDatetime + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/debug.py b/src/blpapi/debug.py new file mode 100644 index 0000000..2141b90 --- /dev/null +++ b/src/blpapi/debug.py @@ -0,0 +1,142 @@ +# debug.py + +"""Provide debugging information for import errors""" + +import platform +import os +from locale import getpreferredencoding + +from .debug_environment import get_env_diagnostics + + +def debug_load_error(error: ImportError) -> ImportError: + """Called when the module fails to import "internals". + Returns ImportError with some debugging message. + """ + # Try to load just the version.py + version_imported = True + import_error = "" + try: + from .version import version, cpp_sdk_version, expected_cpp_sdk_version + except ImportError as version_error: + import_error = _version_load_error(version_error) + version_imported = False + + if version_imported: + # If the version loading succeeds, the most likely reason for a failure + # is a mismatch between C++ and Python SDKs. + import_error = _version_mismatch_error( + error, version(), cpp_sdk_version(), expected_cpp_sdk_version() + ) + + # Environment diagnostics currently only works for windows + if platform.system().lower() == "windows": + env_diagnostics = get_env_diagnostics() + + full_error_msg = f""" +---------------------------- ENVIRONMENT ----------------------------- +{env_diagnostics} +---------------------------------------------------------------------- +{import_error} +""" + else: + full_error_msg = import_error + + # Also output the error message to a file if BLPAPI_DIAGNOSTICS is set + diagnostics_path_env_var = "BLPAPI_DIAGNOSTICS" + if diagnostics_path_env_var in os.environ: + diagnostics_path = os.environ[diagnostics_path_env_var] + try: + with open( + diagnostics_path, "w", encoding=getpreferredencoding() + ) as f: + f.write(full_error_msg) + except IOError: + print( + "Failed to write to path defined by" + f' {diagnostics_path_env_var}: "{diagnostics_path}"' + ) + + return ImportError(full_error_msg) + + +def _linker_env() -> str: + """Return the name of the right environment variable for linking in the + current platform. + """ + s = platform.system() + if s == "Windows": + env = "PATH" + elif s == "Darwin": + env = "DYLD_LIBRARY_PATH" + else: + env = "LD_LIBRARY_PATH" + return env + + +def _version_load_error(error: ImportError) -> str: + """Called when the module fails to import "versionhelper". + Returns some debugging message. + """ + msg = f"""{error} + +Could not open the C++ SDK library. + +Download and install the latest C++ SDK from: + + http://www.bloomberg.com/professional/api-library +""" + + if "add_dll_directory" in dir(os): + msg += """ +If the C++ SDK is already installed, Python 3.8+ on Windows requires that the +path to the library is added to 'add_dll_directory', i.e.: + + with os.add_dll_directory(''): + import blpapi +""" + else: + msg += f""" +If the C++ SDK is already installed, please ensure that the path to the library +was added to {_linker_env()} before entering the interpreter. + +If you are trying to build and install from source, you may instead find it +easier to simply install the wheel directly from pip, which will come bundled +with a compatible version of the C++ SDK. Simply run: +`pip install blpapi --index-url=https://bcms.bloomberg.com/pip/simple` + +""" + return msg + + +def _version_mismatch_error( + error: ImportError, + py_version: str, + cpp_version: str, + expected_cpp_sdk_version: str, +) -> str: + """Called when "import version" succeeds after "import internals" fails + Returns some debugging message. + """ + msg = f"""{error} + +Mismatch between C++ and Python SDK libraries. + +Python SDK version {py_version} +Found C++ SDK version {cpp_version} +Expected C++ SDK version >= {expected_cpp_sdk_version} + +Download and install the latest C++ SDK from: + + http://www.bloomberg.com/professional/api-library + +If a recent version of the C++ SDK is already installed, please ensure that the +path to the library is added to {_linker_env()} before entering the interpreter. + +If you are trying to build and install from source, you may instead find it +easier to simply install the wheel directly from pip, which will come bundled +with a compatible version of the C++ SDK. Simply run: +`pip install blpapi --index-url=https://bcms.bloomberg.com/pip/simple` + +""" + return msg diff --git a/src/blpapi/debug_environment.py b/src/blpapi/debug_environment.py new file mode 100644 index 0000000..cc88998 --- /dev/null +++ b/src/blpapi/debug_environment.py @@ -0,0 +1,106 @@ +""" +Print various potentially useful information to debug environment setup +related issues +""" + +import platform +import sys +import os +import pkgutil +import functools +from typing import Callable +from locale import getpreferredencoding + +from ctypes import util +from io import StringIO + + +def _path_diagnostics(print_to_str: Callable[[str], None]) -> None: + # Information for PATH related issues + print_to_str( + "blpapi 64-bit will be loaded from:" + f' "{util.find_library("blpapi3_64")}"' + ) + print_to_str( + "blpapi 32-bit will be loaded from:" + f' "{util.find_library("blpapi3_32")}"' + ) + print_to_str("System PATH: (* marks locations where blpapi was found)") + for p in os.environ["PATH"].split(os.pathsep): + if p: # Skip empty entries + dll_32 = os.path.join(p, "blpapi3_32.dll") + dll_64 = os.path.join(p, "blpapi3_64.dll") + found_blpapi_dll = os.path.isfile(dll_32) or os.path.isfile(dll_64) + print_to_str(f' {"*" if found_blpapi_dll else " "} "{p}"') + print_to_str("") + + +def _add_dll_directory_diagnostics( + print_to_str: Callable[[str], None] +) -> None: + print_to_str("This Python version does not use PATH to find dlls") + + +def get_env_diagnostics() -> str: + """ + Get various potentially useful information to debug environment setup + related issues + """ + + strIO = StringIO() + print_to_str = functools.partial(print, file=strIO) + + # General information about the platform + print_to_str("Platform:", platform.platform()) + print_to_str("Architecture:", platform.architecture()) + print_to_str("Python:", sys.version) + print_to_str("Python implementation:", platform.python_implementation()) + print_to_str() + + if "add_dll_directory" not in dir(os): + _path_diagnostics(print_to_str) + else: + _add_dll_directory_diagnostics(print_to_str) + # Check if the blpapi package has been installed. If not, + # include information about the current python environment + blpapi_package_found = False + for i in pkgutil.iter_modules(): + if i[1] == "blpapi": + # some modules don't have a .path (e.g. MetaPathFinder) + print_to_str(f'blpapi package at: "{i[0].path}"') # type: ignore + blpapi_package_found = True + + if not blpapi_package_found: + print_to_str("ERROR: Failed to find the blpapi package") + print_to_str(f'Python prefix: "{sys.prefix}"') + print_to_str("Python path:") + for p in sys.path: + print_to_str(f' "{p}"') + print_to_str() + + # There is currently a known issue where attempting to import blpapi + # from the local directory (e.g. if trying to run a script in the root + # of our repository) will fail. Check that this is not the case. + print_to_str(f'Current directory: "{os.getcwd()}"') + if os.path.isfile(os.path.join(".", "blpapi", "__init__.py")): + print_to_str("WARNING: Using the blpapi module from current path") + print_to_str( + " CWD files:", + ", ".join([x for x in os.listdir(".") if os.path.isfile(x)]), + ) + print_to_str( + " CWD dirs:", + ", ".join([x for x in os.listdir(".") if not os.path.isfile(x)]), + ) + + return strIO.getvalue() + + +if __name__ == "__main__": + env_diagnostics = get_env_diagnostics() + + if len(sys.argv) > 1: + with open(sys.argv[1], "w", encoding=getpreferredencoding()) as f: + print(env_diagnostics, file=f) + else: + print(env_diagnostics) diff --git a/src/blpapi/diagnosticsutil.py b/src/blpapi/diagnosticsutil.py new file mode 100644 index 0000000..ff09201 --- /dev/null +++ b/src/blpapi/diagnosticsutil.py @@ -0,0 +1,12 @@ +"""@PURPOSE: Provide api to access diagnostics information +on the blpapi library +@DESCRIPTION: This component provide a collection of functions which give +access to various sets of diagnostics information on the 'blpapi' library.""" + +from . import internals + + +def memoryInfo() -> str: + """Return the string describing the 'blpapi' library's memory usage; the + format of the string is platform-specific.""" + return internals.blpapi_DiagnosticsUtil_memoryInfo_wrapper() diff --git a/src/blpapi/element.py b/src/blpapi/element.py new file mode 100644 index 0000000..dc857e7 --- /dev/null +++ b/src/blpapi/element.py @@ -0,0 +1,1594 @@ +# element.py + +"""Provide a representation of an item in a message or request. + +This file defines these classes: + 'Element' - represents an item in a message. + +""" + +from __future__ import annotations +from .exception import _ExceptionUtil +from .exception import UnsupportedOperationException +from .datetime import _DatetimeUtil +from .datatype import DataType +from .name import Name, getNamePair +from .schema import SchemaElementDefinition +from .utils import Iterator, isNonScalarSequence +from .chandle import CHandle +from . import internals +from .typehints import ( + BlpapiNameOrIndex, + AnyPythonDatetime, + SupportedElementTypes, +) +from . import typehints # pylint: disable=unused-import +from collections.abc import Iterator as IteratorABC, Mapping +from typing import ( + Any, + Callable, + Dict, + Iterator as IteratorType, + List, + Optional, + Sequence, + Set, + Tuple, + Union, +) + + +# pylint: disable=protected-access,too-many-return-statements,too-many-public-methods +class ElementIterator(IteratorABC): + r"""An iterator over the objects within an :class:`Element`. + + If the :class:`Element` is a sequence or choice, this iterates over its + sub-:class:`Element`\s. Otherwise, iterate over the :class:`Element`'s + value(s). + """ + + def __init__(self, element: Element) -> None: + self._element = element + self._index = 0 + + def __next__(self) -> Union[SupportedElementTypes, Element]: + i = self._index + self._index += 1 + + if self._element.isComplexType(): + if self._element.numElements() > i: + return self._element.getElement(i) + # for array and scalar elements + elif self._element.numValues() > i: + return self._element.getValue(i) + + raise StopIteration() + + +class Element(CHandle): + """Represents an item in a message. + + An :class:`Element` can represent: + + - A single value of any data type supported by the Bloomberg API + - An array of values + - A sequence or a choice + + The value(s) in an :class:`Element` can be queried in a number of ways. For + an :class:`Element` which represents a single value or an array of values + use the :meth:`getValueAsBool()` etc. functions. For an :class:`Element` + which represents a sequence or choice use :meth:`getElementAsBool()` etc. + functions. In addition, for choices and sequences, :meth:`hasElement()` and + :meth:`getElement()` are useful. + + This example shows how to access the value of a scalar element ``s`` as a + floating point number:: + + f = s.getValueAsFloat() + + Similarly, this example shows how to retrieve the third value in an array + element ``a``, as a floating point number:: + + f = a.getValueAsFloat(2) + + Use :meth:`numValues()` to determine the number of values available. For + single values, it will return either ``0`` or ``1``. For arrays it will + return the actual number of values in the array. + + To retrieve values from a complex element types (sequences and choices) use + the ``getElementAs...()`` family of methods. This example shows how to get + the value of the element ``city`` in the sequence element ``address``:: + + name_city = Name("city") # Ideally defined once (globally or class level) + city = address.getElementAsString(name_city) + + Note: + ``getElementAsXYZ(name)`` method is a shortcut to + ``getElement(name).getValueAsXYZ()``. + + The value(s) of an :class:`Element` can be set in a number of ways. For an + :class:`Element` which represents a single value or an array of values use + the :meth:`setValue()` or :meth:`appendValue()` functions. For an element + which represents a sequence or a choice use the :meth:`setElement()` + functions. + + This example shows how to set the value of an :class:`Element` ``s``:: + + value=5 + s.setValue(value) + + This example shows how to append a value to an array element ``a``:: + + value=5 + a.appendValue(value) + + To set values in a complex element (a sequence or a choice) use the + :meth:`setElement()` family of functions. This example shows how to set the + value of the element ``city`` in the sequence element ``address`` to a + string:: + + name_city = Name("city") # Ideally defined once (globally or class level) + address.setElement(name_city, "New York") + + Methods which specify an :class:`Element` name accept name in two forms: + :class:`Name` or a string. Passing :class:`Name` is more efficient. + However, it requires the :class:`Name` to have been created in the global + name table. + + The form which takes a string is less efficient but will not cause a new + :class:`Name` to be created in the global name table. Because all valid + :class:`Element` names will have already been placed in the global name + table by the API if the supplied string cannot be found in the global name + table the appropriate error or exception can be returned. + + The API will convert data types as long as there is no loss of precision + involved. + + :class:`Element` objects are always created by the API, never directly by + the application. + """ + + __boolTraits = ( + internals.blpapi_Element_setElementBool, + internals.blpapi_Element_setValueBool, + None, + ) + + __datetimeTraits = ( + internals.blpapi_Element_setElementHighPrecisionDatetime, + internals.blpapi_Element_setValueHighPrecisionDatetime, + _DatetimeUtil.convertToBlpapi, + ) + + __int32Traits = ( + internals.blpapi_Element_setElementInt32, + internals.blpapi_Element_setValueInt32, + None, + ) + + __int64Traits = ( + internals.blpapi_Element_setElementInt64, + internals.blpapi_Element_setValueInt64, + None, + ) + + __floatTraits = ( + internals.blpapi_Element_setElementFloat, + internals.blpapi_Element_setValueFloat, + None, + ) + + __nameTraits = ( + internals.blpapi_Element_setElementFromName, + internals.blpapi_Element_setValueFromName, + Name._handle, + ) + + __stringTraits = ( + internals.blpapi_Element_setElementString, + internals.blpapi_Element_setValueString, + None, + ) + + __bytesTraits = ( + internals.blpapi_Element_setElementBytes, + internals.blpapi_Element_setValueBytes, + None, + ) + + __defaultTraits = ( + internals.blpapi_Element_setElementString, + internals.blpapi_Element_setValueString, + str, + ) + + @staticmethod + def __getTraits( + value: SupportedElementTypes, + ) -> Tuple[Callable, Callable, Optional[Any]]: + """traits dispatcher""" + if isinstance(value, str): + return Element.__stringTraits + if isinstance(value, bytes): + return Element.__bytesTraits + if isinstance(value, bool): + return Element.__boolTraits + if isinstance(value, int): + if -(2**31) <= value <= (2**31 - 1): + return Element.__int32Traits + if -(2**63) <= value <= (2**63 - 1): + return Element.__int64Traits + raise ValueError("value is out of element's supported range") + if isinstance(value, float): + return Element.__floatTraits + if _DatetimeUtil.isDatetime(value): + return Element.__datetimeTraits + if isinstance(value, Name): + return Element.__nameTraits + return Element.__defaultTraits + + def __assertIsValid(self) -> None: + if not self.isValid(): + raise RuntimeError("Element is not valid") + + def __init__( + self, + handle: "typehints.BlpapiElementHandle", + dataHolder: Optional[ + Union[Element, "typehints.Message", "typehints.Request"] + ], + ) -> None: + """Create an :class:`Element` object. + + Args: + handle: Handle to the internal implementation + dataHolder: The internal owner of underlying data + + If the specified ``handle`` is ``None``, create an uninitialized + :class:`Element`. The only valid operations to perform on an + uninitialized :class:`Element` are assignment, :meth:`isValid()`, and + destruction. + """ + noop = lambda *args: None + super(Element, self).__init__(handle, noop) + self.__dataHolder = dataHolder + + def _getDataHolder( + self, + ) -> Optional[Union[Element, "typehints.Message", "typehints.Request"]]: + """Return the owner of underlying data. For internal use.""" + return self if self.__dataHolder is None else self.__dataHolder + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) that this 'Element' is related to. + + For internal use.""" + if self.__dataHolder is None: + return set() + return self.__dataHolder._sessions() + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this Element. Call of 'str(element)' + is equivalent to 'element.toString()' called with default parameters. + + """ + + return self.toString() + + def __getitem__( + self, nameOrIndex: BlpapiNameOrIndex + ) -> Union[SupportedElementTypes, Element]: + """ + Args: + nameOrIndex: The :class:`Name` identifying the + :class:`Element` to retrieve from this :class:`Element`, or + the index to retrieve the value from this :class:`Element`. + + Returns: + If a :class:`Name` or :py:class:`str` is used, and the + :class:`Element` whose name is ``nameOrIndex`` is a sequence, + choice, array, or is null, that :class:`Element` is returned. + Otherwise, if a :class:`Name` or :py:class:`str` is used, return + the value of the :class:`Element`. If ``nameOrIndex`` is an + :py:class:`int`, return the value at index ``nameOrIndex`` in this + :class:`Element`. + + Raises: + KeyError: + If ``nameOrIndex`` is a :class:`Name` or :py:class:`str` and + this :class:`Element` does not contain a sub-:class:`Element` + with name ``nameOrIndex``. + InvalidConversionException: + If ``nameOrIndex`` is an :py:class:`int` and the data type of + this :class:`Element` is either a sequence or a choice. + IndexOutOfRangeException: + If ``nameOrIndex`` is an :py:class:`int` and + ``nameOrIndex`` >= :meth:`numValues`. + """ + # is index + if isinstance(nameOrIndex, int): + return self.getValue(nameOrIndex) + + # is name + if not self.hasElement(nameOrIndex): + raise KeyError( + f"Element {self.name()} " + f"does not contain element" + f" {nameOrIndex}" + ) + + element = self.getElement(nameOrIndex) + + if element.isComplexType() or element.isArray(): + return element + elif element.isNull(): + # Scalar element with a null value + return None + + return element.getValue() + + def __setitem__( + self, + name: Name, + value: Union[Mapping, Sequence, SupportedElementTypes], + ) -> None: + r""" + Args: + name: The :class:`Name` identifying one of this + :class:`Element`'s sub-:class:`Element`\s. + value: Used to format the :class:`Element`. See :meth:`fromPy` for + more details. + + Raises: + Exception: + If ``name`` does not identify one of this :class:`Element`'s + sub-:class:`Element`\s. + Exception: + If the :class:`Element` identified by ``name`` is has been + previously formatted. + Exception: + If the :class:`Element` identified by ``name`` cannot be + formatted by ``value`` (See :meth:`fromPy` for more details). + + Format this :class:`Element`'s sub-:class:`Element` identified by + ``name`` with ``value``. See :meth:`fromPy` for more details. + + Note: + :class:`Element`\s that have been previously formatted in any way + cannot be formatted further with this method. To further format an + :class:`Element`, use the get/set/append Element/Value methods. + Note: + :class:`Element`\s cannot be modified by index. + """ + if isinstance(name, int): + raise Exception("Elements cannot be formatted by index") + + self.getElement(name).fromPy(value) + + def __iter__(self) -> IteratorType: + r""" + Returns: + An iterator over the contents of this :class:`Element`. If this + :class:`Element` is a complex type (see :meth:`isComplexType`), + return an iterator over the :class:`Element`\s in this + :class:`Element`. Otherwise, return an iterator over this + :class:`Element`'s value(s). + """ + return ElementIterator(self) + + def __len__(self) -> int: + r""" + Returns: + If this :class:`Element` is a complex type + (see :meth:`isComplexType`), return the number of + :class:`Element`\s in this :class:`Element`. Otherwise, return the + number of values in this :class:`Element`. + """ + if self.isComplexType(): + return self.numElements() + + return self.numValues() + + def __contains__(self, item: SupportedElementTypes) -> bool: + """ + Args: + item: item to check for existence in this :class:`Element`. + + Returns: + If this :class:`Element` is a complex type, return whether + this :class:`Element` contains an :class:`Element` with the + specified :class:`Name` ``item``. Otherwise, return whether + ``item`` is a value in this :class:`Element`. + """ + if self.isComplexType(): + return self.hasElement(item) # type: ignore + return item in self.values() + + def name(self) -> Name: + """ + Returns: + If this :class:`Element` is part of a sequence or choice + :class:`Element`, then return the :class:`Name` of this + :class:`Element` within the sequence or choice :class:`Element` + that owns it. If this :class:`Element` is not part of a sequence + :class:`Element` (that is it is an entire :class:`Request` or + :class:`Message`) then return the :class:`Name` of the + :class:`Request` or :class:`Message`. + """ + + self.__assertIsValid() + return Name._createInternally( + internals.blpapi_Element_name(self._handle()) + ) + + def datatype(self) -> int: + """ + Returns: + Basic data type used to represent a value in this + :class:`Element`. + + The possible types are enumerated in :class:`DataType`. + """ + + self.__assertIsValid() + return internals.blpapi_Element_datatype(self._handle()) + + def isComplexType(self) -> bool: + """ + Returns: + ``True`` if ``datatype()==DataType.SEQUENCE`` or + ``datatype()==DataType.CHOICE`` and ``False`` otherwise. + """ + + self.__assertIsValid() + return bool(internals.blpapi_Element_isComplexType(self._handle())) + + def isArray(self) -> bool: + """ + Returns: + ``True`` if this element is an array. + + This element is an array if ``elementDefinition().maxValues()>1`` or if + ``elementDefinition().maxValues()==UNBOUNDED``. + """ + + self.__assertIsValid() + return bool(internals.blpapi_Element_isArray(self._handle())) + + def isValid(self) -> bool: # pylint: disable=useless-parent-delegation + """ + Returns: + ``True`` if this :class:`Element` is valid. An :class:`Element` + constructed using ``None`` for the ``handle`` is not valid until + the :class:`Element` has had a value assigned to it. + """ + return super().isValid() + + def isNull(self) -> bool: + """ + Returns: + ``True`` if this :class:`Element` has a null value. + """ + self.__assertIsValid() + return bool(internals.blpapi_Element_isNull(self._handle())) + + def isReadOnly(self) -> bool: + """ + Returns: + ``True`` if this :class:`Element` cannot be modified. + """ + self.__assertIsValid() + return bool(internals.blpapi_Element_isReadOnly(self._handle())) + + def elementDefinition(self) -> "typehints.SchemaElementDefinition": + """ + Return: + Reference to the read-only element + definition object that defines the properties of this elements + value. + """ + self.__assertIsValid() + return SchemaElementDefinition( + internals.blpapi_Element_definition(self._handle()), + self._sessions(), + ) + + def numValues(self) -> int: + """ + Returns: + Number of values contained by this element. + + The number of values is ``0`` if :meth:`isNull()` returns ``True``, and + no greater than ``1`` if :meth:`isComplexType()` returns ``True``. The + value returned will always be in the range defined by + ``elementDefinition().minValues()`` and + ``elementDefinition().maxValues()``. + """ + + self.__assertIsValid() + return internals.blpapi_Element_numValues(self._handle()) + + def numElements(self) -> int: + """ + Returns: + Number of elements in this element. + + The number of elements is ``0`` if :meth:`isComplexType()` returns + ``False``, and no greater than ``1`` if the :class:`DataType` is + :attr:`~DataType.CHOICE`; if the :class:`DataType` is + :attr:`~DataType.SEQUENCE` this may return any number (including + ``0``). + """ + + self.__assertIsValid() + return internals.blpapi_Element_numElements(self._handle()) + + def isNullValue(self, position: int = 0) -> bool: + """ + Args: + position: Position of the sub-element + + Returns: + ``True`` if the value of the sub-element at the ``position`` + is a null value. + + Raises: + Exception: If ``position >= numElements()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_isNullValue(self._handle(), position) + if res in (0, 1): + return bool(res) + _ExceptionUtil.raiseOnError(res) + return False # unreachable + + def toPy(self) -> Union[Dict, List, SupportedElementTypes]: + r""" + Returns: + A :py:class:`dict`, :py:class:`list`, or value representation of + this :class:`Element`. This is a deep copy containing only native + python datatypes, like :py:class:`list`, :py:class:`dict`, + :py:class:`str`, and :py:class:`int`. + + If an :class:`Element` is + + * a complex type, it is converted to a :py:class:`dict` whose keys are + the :py:class:`str` names of its sub-:class:`Element`\s. + * an array, it is converted to a :py:class:`list` of the + :class:`Element`'s values. + * null, it is converted an empty :py:class:`dict`. + + Otherwise, the :class:`Element` is converted to its associated value. + If that value was a :class:`Name`, it will be converted to a + :py:class:`str`. + + For example, the following ``exampleElement`` has the following BLPAPI + representation: + + >>> exampleElement + + .. code-block:: none + + exampleElement = { + complexElement = { + nullElement = { + } + } + arrayElement[] = { + arrayElement = { + id = 2 + endpoint = { + address = "127.0.0.1:8000" + } + } + } + valueElement = "Sample value" + nullValueElement = + } + + ``exampleElement`` produces the following Python representation: + + >>> exampleElement.toPy() + + .. code-block:: python + + { + "complexElement": { + "nullElement": {} + }, + "arrayElement": [ + { + "id": 2 + "endpoint": { + "address": "127.0.0.1:8000" + } + } + ], + "valueElement": "Sample value", + "nullValueElement": None + } + + """ + return internals.blpapi_Element_toPy(self._handle()) + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Format this :class:`Element` to the string at the specified + indentation level. + + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This element formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + + self.__assertIsValid() + return internals.blpapi_Element_printHelper( + self._handle(), level, spacesPerLevel + ) + + def getElement(self, nameOrIndex: BlpapiNameOrIndex) -> Element: + """ + Args: + nameOrIndex: Sub-element identifier + + Returns: + Sub-element identified by ``nameOrIndex`` + + Raises: + Exception: If ``nameOrIndex`` is a string or a :class:`Name` and + ``hasElement(nameOrIndex) != True``, or if ``nameOrIndex`` is an + integer and ``nameOrIndex >= numElements()``. Also if this + :class:`Element` is neither a sequence nor a choice. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``BlpapiNameOrStrOrIndex``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + if not isinstance(nameOrIndex, int): + self.__assertIsValid() + name = getNamePair(nameOrIndex) + res = internals.blpapi_Element_getElement( + self._handle(), name[0], name[1] + ) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + self.__assertIsValid() + res = internals.blpapi_Element_getElementAt( + self._handle(), nameOrIndex + ) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + + def elements(self) -> IteratorType: + """ + Note: prefer to iterate over this :class:`Element` directly instead + of calling this method. E.g. + + ```for e in element``` rather than ```for e in element.elements()``` + + Returns: + Iterator over elements contained in this :class:`Element`. + + Raises: + UnsupportedOperationException: If this :class:`Element` is not a + sequence. + """ + + if self.datatype() != DataType.SEQUENCE: + raise UnsupportedOperationException( + description="Only sequences are supported", errorCode=None + ) + return Iterator(self, Element.numElements, Element.getElement) + + def hasElement( + self, name: Name, excludeNullElements: bool = False + ) -> bool: + """ + Args: + name: Name of the element + excludeNullElements: Whether to exclude null elements + + Returns: + ``True`` if this :class:`Element` is a choice or sequence + (``isComplexType() == True``) and it contains an :class:`Element` + with the specified ``name``. + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + self.__assertIsValid() + namepair = getNamePair(name) + res = internals.blpapi_Element_hasElementEx( + self._handle(), + namepair[0], + namepair[1], + 1 if excludeNullElements else 0, + 0, + ) + return bool(res) + + def getChoice(self) -> Element: + """ + Returns: + The selection name of this element as :class:`Element`. + + Raises: + Exception: If ``datatype() != DataType.CHOICE`` + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getChoice(self._handle()) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + + def getValueAsBool(self, index: int = 0) -> bool: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a boolean. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to a boolean. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsBool(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return bool(res[1]) + + def getValueAsString(self, index: int = 0) -> str: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a string. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to a string. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsString(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return res[1] + + def getValueAsBytes(self, index: int = 0) -> bytes: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as bytes. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to bytes. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsBytes(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return res[1] + + def getValueAsDatetime(self, index: int = 0) -> AnyPythonDatetime: + r""" + Args: + index: Index of the value in the element + + Returns: + datetime.time or datetime.date or datetime.datetime: ``index``\th + entry in the :class:`Element` as one of the datetime types. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to a datetime. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsHighPrecisionDatetime( + self._handle(), index + ) + _ExceptionUtil.raiseOnError(res[0]) + # Return `None` when the `datetime` has no parts because our + # `convertToNative` function will raise an exception if there are + # no parts + if not res[1].datetime.parts: + return None # type: ignore + return _DatetimeUtil.convertToNative(res[1]) + + def getValueAsInteger(self, index: int = 0) -> int: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a integer + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to an integer. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsInt64(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return res[1] + + def getValueAsFloat(self, index: int = 0) -> float: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a float. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to an float. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsFloat64(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return res[1] + + def getValueAsName(self, index: int = 0) -> Name: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a Name. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to a :class:`Name`. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsName(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return Name._createInternally(res[1]) + + def getValueAsElement(self, index: int = 0) -> Element: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` as a Element. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` cannot be converted to an :class:`Element`. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + self.__assertIsValid() + res = internals.blpapi_Element_getValueAsElement(self._handle(), index) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + + def getValue( + self, index: int = 0 + ) -> Union[SupportedElementTypes, Element]: + r""" + Args: + index: Index of the value in the element + + Returns: + ``index``\th entry in the :class:`Element` defined by this + element's datatype. + + Raises: + InvalidConversionException: If the data type of this + :class:`Element` is either a sequence or a choice. + IndexOutOfRangeException: If ``index >= numValues()``. + """ + + datatype = self.datatype() + valueGetter = _ELEMENT_VALUE_GETTER.get( + datatype, Element.getValueAsString + ) + return valueGetter(self, index) # type: ignore + + def values(self) -> IteratorType: + """ + Note: prefer to iterate over this :class:`Element` directly instead + of calling this method. E.g. + + ```for e in element``` rather than ```for e in element.values()``` + + Returns: + Iterator over values contained in this :class:`Element`. + + If :meth:`isComplexType()` returns ``True`` for this :class:`Element`, + the empty iterator is returned. + """ + + if self.isComplexType(): + return iter(()) # empty tuple + datatype = self.datatype() + valueGetter = _ELEMENT_VALUE_GETTER.get( + datatype, Element.getValueAsString + ) + return Iterator(self, Element.numValues, valueGetter) + + def getElementAsBool(self, name: Name) -> bool: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as a boolean + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as a boolean. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsBool() + + def getElementAsString(self, name: Name) -> str: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as a string + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as a string. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsString() + + def getElementAsBytes(self, name: Name) -> bytes: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as bytes + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as bytes. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsBytes() + + def getElementAsDatetime(self, name: Name) -> AnyPythonDatetime: + """ + Args: + name: Sub-element identifier + + Returns: + datetime.time or datetime.date or datetime.datetime: This element's + sub-element with ``name`` as one of the datetime types + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as a datetime. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsDatetime() + + def getElementAsInteger(self, name: Name) -> int: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as an integer + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as an integer. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsInteger() + + def getElementAsFloat(self, name: Name) -> float: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as a float + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as a float. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsFloat() + + def getElementAsName(self, name: Name) -> Name: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` as a :class:`Name` + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``, or + in case the element's value can't be returned as a + :class:`Name`. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValueAsName() + + def getElementValue( + self, name: Name + ) -> Union[SupportedElementTypes, Element]: + """ + Args: + name: Sub-element identifier + + Returns: + This element's sub-element with ``name`` defined by its datatype + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this :class:`Element` is neither a sequence nor a choice, or + in case it has no sub-element with the specified ``name``. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + return self.getElement(name).getValue() + + def setElement(self, name: Name, value: SupportedElementTypes) -> None: + """Set this Element's sub-element with 'name' to the specified 'value'. + + Args: + name: Sub-element identifier + value: Value to set the sub-element to + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string, or + if this element has no sub-element with the specified ``name``, + or if the :class:`Element` identified by the specified ``name`` + cannot be initialized from the type of the specified ``value``. + + This method can process the following types of ``value`` without + conversion: + + - boolean + - integers + - float + - string + - bytes + - datetypes (``datetime.time``, ``datetime.date`` or + ``datetime.datetime``) + - :class:`Name` + + Any other ``value`` will be converted to a string with ``str`` function + and then processed in the same way as string ``value``. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + self.__assertIsValid() + + traits = Element.__getTraits(value) + namepair = getNamePair(name) + if traits[2] is not None: + value = traits[2](value) + _ExceptionUtil.raiseOnError( + traits[0](self._handle(), namepair[0], namepair[1], value) + ) + + def setValue(self, value: SupportedElementTypes, index: int = 0) -> None: + r"""Set the specified ``index``\th entry in this :class:`Element` to + the ``value``. + + Args: + index (int): Index of the sub-element + value: Value to set the sub-element to + + Raises: + Exception: If this :class:`Element`'s datatype can't be + initialized with the type of the specified ``value``, or if + ``index >= numValues()``. + + This method can process the following types of ``value`` without + conversion: + + - boolean + - integers + - float + - string + - bytes + - datetypes (``datetime.time``, ``datetime.date`` or + ``datetime.datetime``) + - :class:`Name` + + Any other ``value`` will be converted to a string with ``str`` function + and then processed in the same way as string ``value``. + """ + + self.__assertIsValid() + traits = Element.__getTraits(value) + if traits[2] is not None: + value = traits[2](value) + _ExceptionUtil.raiseOnError(traits[1](self._handle(), value, index)) + + def appendValue(self, value: SupportedElementTypes) -> None: + r"""Append the specified ``value`` to this :class:`Element`\s entries + at the end. + + Args: + value: Value to append + + Raises: + Exception: If this :class:`Element`'s datatype can't be + initialized from the type of the specified ``value``, or if the + current size of this :class:`Element` (:meth:`numValues()`) is + equal to the maximum defined by + ``elementDefinition().maxValues()``. + + This method can process the following types of ``value`` without + conversion: + + - boolean + - integers + - float + - string + - datetypes (``datetime.time``, ``datetime.date`` or + ``datetime.datetime``) + - :class:`Name` + + Any other ``value`` will be converted to a string with ``str`` function + and then processed in the same way as string ``value``. + + Arrays of bytes are not supported. + """ + + self.setValue(value, internals.ELEMENT_INDEX_END) + + def appendElement(self) -> Element: + r"""Append a new element to this array :class:`Element`. + + Returns: + The newly appended element + + Raises: + Exception: If this :class:`Element` is not an array of sequence or + choice :class:`Element`\s. + + """ + + self.__assertIsValid() + res = internals.blpapi_Element_appendElement(self._handle()) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + + def setChoice(self, selectionName: Name) -> Element: + """Set this :class:`Element`'s active element to ``selectionName``. + + Args: + selectionName: Name of the element to set the active choice + + Returns: + The newly active element + + Raises: + Exception: If ``selectionName`` is neither a :class:`Name` nor a + string, or if this :class:`Element` is not a choice. + """ + + self.__assertIsValid() + name = getNamePair(selectionName) + res = internals.blpapi_Element_setChoice( + self._handle(), name[0], name[1], 0 + ) + _ExceptionUtil.raiseOnError(res[0]) + return Element(res[1], self._getDataHolder()) + + def fromPy( + self, value: Union[Mapping, Sequence, SupportedElementTypes] + ) -> None: + r"""Format this :class:`Element` with the provided native Python value. + + Args: + value: Used to format this :class:`Element` + + Raises: + Exception: + If the provided value does not properly represent the structure + of this :class:`Element`. + Exception: + If this method is used to format an :class:`Element` that has + already been formatted. + + If the :class:`Element` is + + * a complex type, it is formatted using a + :py:class:`collections.abc.Mapping` (e.g. :py:class:`dict`) whose + keys are the :py:class:`str` names of its sub-:class:`Element`\s. + * an array, it is formatted using a + :py:class:`collections.abc.Sequence` (e.g. :py:class:`list`) of the + :class:`Element`'s values (see note below for more detais). + * null, it is formatted using an empty + :py:class:`collections.abc.Mapping`. + + Otherwise, the :class:`Element` is formatted using its associated + value (e.g :py:class:`str` or :py:class:`int`). + + Note: + Although :py:class:`str`, :py:class:`bytearray`, and + :py:class:`memoryview` are sub-types of + :py:class:`collections.abc.Sequence`, :meth:`fromPy` treats them as + scalars of type string and will use them to format scalar + :class:`Element`\s. If you wish to format an array + :class:`Element` with instances of the aforementioned types, put + them in a different :py:class:`collections.abc.Sequence`, like + :py:class:`list`. + + Note: + Although :py:class:`bytes` is sub-type of + :py:class:`collections.abc.Sequence`, :meth:`fromPy` treats it as a + scalar of type :py:class:`bytes` and will use it to format scalar + :class:`Element`. Arrays of :py:class:`bytes` are not supported. + + Note: + Using :meth:`fromPy` to format an :class:`Element` or one of its + sub-:class:`Element`\s that has already been formatted is not + supported. To further format an :class:`Element`, use the + get/set/append Element/Value methods. + + For example, the following ``exampleElement`` has the following BLPAPI + representation: + + .. code-block:: none + + exampleElement = { + complexElement = { + nullElement = { + } + } + arrayElement[] = { + arrayElement = { + id = 2 + endpoint = { + address = "127.0.0.1:8000" + } + } + } + valueElement = "Sample value" + nullValueElement = + } + + ``exampleElement`` can be created with the following code: + + .. code-block:: python + + exampleRequest = service.createRequest("ExampleRequest") + exampleElement = exampleRequest.asElement() + + complexElement = exampleElement.getElement("complexElement") + complexElement.getElement("nullElement") + + arrayElement = exampleElement.getElement("arrayElement") + array = arrayElement.appendElement() + arrayValue.setElement("id", 2) + endpointElement = arrayValue.getElement("endpoint") + endpointElement.setElement("address", "127.0.0.1:8000") + + exampleElement.setElement("valueElement", "Sample value") + + :meth:`fromPy` can be used to format ``exampleElement`` the same way: + + .. code-block:: python + + exampleRequest = service.createRequest("ExampleRequest") + exampleElement = exampleRequest.asElement() + exampleElementAsDict = { + "complexElement": { + "nullElement": {} + }, + "arrayElement": [ + { + "id": 2, + "endpoint": { + "address": "127.0.0.1:8000" + } + } + ], + "valueElement": "Sample value", + "nullValueElement": None + } + exampleElement.fromPy(exampleElementAsDict) + + :meth:`fromPy` can also be called with + :class:`collections.abc.Sequence`\s and scalar values to format array + :class:`Element`\s and scalar :class:`Element`\s, respectively. + + .. code-block:: python + + arrayElementAsList = [{ + "id": 2, + "endpoint": { "address": "127.0.0.1:8000" } + }] + arrayElement = exampleElement.getElement("arrayElement") + arrayElement.fromPy(arrayElementAsList) + + exampleElement.getElement("valueElement").fromPy("Sample value") + + Calling :meth:`toPy` on an :class:`Element` formatted by :meth:`fromPy` + with a given value will return an equal value. Continuing from the + preceding example: + + .. code-block:: python + + exampleElement.fromPy(exampleElementAsDict) + print(exampleElementAsDict == exampleElement.toPy()) # True + + """ + self._fromPyHelper(value) + + def _fromPyHelper( + self, + value: Union[Mapping, Sequence, SupportedElementTypes], + name: Optional[Name] = None, + path: Optional[str] = None, + ) -> None: + """Helper method for `fromPy`. + + Args: + value: Used to format this `Element` or the `Element` specified + by ``name``. + name: If ``name`` is ``None``, format this `Element` + with ``value``. Otherwise, ``name`` refers to this `Element`'s + sub-`Element` that will be formatted with ``value``. + path: The path uniquely identifying this `Element`, starting + from the root `Element`. + """ + # Note, the double exception throwing has no good solution in Python 2, + # but Python 3 has exception chaining that we should use when we can + + activeElement = self + + def getActivePathMessage(isArrayEntry: bool = False) -> str: + elementType = "scalar" + if activeElement.isArray(): + elementType = "array" + elif activeElement.isComplexType(): + elementType = "complex" + + arrayEntryText = "an entry in " if isArrayEntry else "" + return ( + f"While operating on {arrayEntryText}{elementType} " + f" Element `{path}`, " + ) + + if path is None: + path = str(activeElement.name()) + if name is not None: + try: + activeElement = self.getElement(name) + path += "/" + str(activeElement.name()) + except Exception as exc: + errorMsg = f"encountered error: {exc}" + raise Exception(getActivePathMessage() + errorMsg) + + if activeElement.numElements() or activeElement.numValues(): + errorMsg = "this Element has already been formatted" + raise Exception(getActivePathMessage() + errorMsg) + + if isinstance(value, Mapping): + if not activeElement.isComplexType(): + errorMsg = ( + "encountered a `Mapping` instance while" + " formatting a non-complex Element" + ) + raise Exception(getActivePathMessage() + errorMsg) + + complexElement = activeElement + for subName in value: + subValue = value[subName] + complexElement._fromPyHelper(subValue, subName, path) + + elif isNonScalarSequence(value): + if not activeElement.isArray(): + errorMsg = ( + "encountered a `Sequence` while formatting a" + " non-array Element" + ) + raise Exception(getActivePathMessage() + errorMsg) + + arrayElement = activeElement + typeDef = arrayElement.elementDefinition().typeDefinition() + arrayValuesAreScalar = not typeDef.isComplexType() + for index, val in enumerate(value): # type: ignore + if isinstance(val, Mapping): + if arrayValuesAreScalar: + path += f"[{index}]" + errorMsg = ( + "encountered a `Mapping` where a scalar" + " value was expected." + ) + raise Exception( + getActivePathMessage(isArrayEntry=True) + errorMsg + ) + + appendedElement = arrayElement.appendElement() + arrayEntryPath = path + f"[{index}]" + appendedElement._fromPyHelper(val, path=arrayEntryPath) + elif isNonScalarSequence(val): + path += f"[{index}]" + expectedObject = ( + "scalar value" if arrayValuesAreScalar else "`Mapping`" + ) + errorMsg = ( + f"encountered a nested `Sequence` where a " + f"{expectedObject} was expected." + ) + raise Exception( + getActivePathMessage(isArrayEntry=True) + errorMsg + ) + + else: + if not arrayValuesAreScalar: + path += f"[{index}]" + errorMsg = ( + "encountered a scalar value where a" + " `Mapping` was expected." + ) + raise Exception( + getActivePathMessage(isArrayEntry=True) + errorMsg + ) + + try: + arrayElement.appendValue(val) + except Exception as exc: + path += f"[{index}]" + errorMsg = f"encountered error: {exc}" + raise Exception( + getActivePathMessage(isArrayEntry=True) + errorMsg + ) + else: + if value is None: + return + + if activeElement.isComplexType() or activeElement.isArray(): + errorMsg = ( + f"encountered an incompatible type, {type(value)}," + " for a non-scalar Element" + ) + raise Exception(getActivePathMessage() + errorMsg) + + try: + activeElement.setValue(value) # type: ignore + except Exception as exc: + errorMsg = f"encountered error: {exc}" + raise Exception(getActivePathMessage() + errorMsg) + + +_ELEMENT_VALUE_GETTER = { + DataType.BOOL: Element.getValueAsBool, + DataType.CHAR: Element.getValueAsString, + DataType.BYTE: Element.getValueAsInteger, + DataType.INT32: Element.getValueAsInteger, + DataType.INT64: Element.getValueAsInteger, + DataType.FLOAT32: Element.getValueAsFloat, + DataType.FLOAT64: Element.getValueAsFloat, + DataType.STRING: Element.getValueAsString, + DataType.DATE: Element.getValueAsDatetime, + DataType.TIME: Element.getValueAsDatetime, + DataType.DATETIME: Element.getValueAsDatetime, + DataType.BYTEARRAY: Element.getValueAsBytes, + DataType.ENUMERATION: Element.getValueAsName, + DataType.SEQUENCE: Element.getValueAsElement, + DataType.CHOICE: Element.getValueAsElement, +} + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/event.py b/src/blpapi/event.py new file mode 100644 index 0000000..7c1187d --- /dev/null +++ b/src/blpapi/event.py @@ -0,0 +1,253 @@ +# event.py + +"""A module which defines events related operations. + +This file defines an 'Event'. One or more 'Event's are generated as a result of +a subscription or a request. 'Event's contain 'Message' objects which can be +accessed using a 'MessageIterator'. This file also defines a 'EventQueue' for +handling replies synchronously. + +Usage +----- +The following code snippet shows how a 'EventQueue' is used with a +'generateToken' request. For any established session 'session' pass an +'EventQueue' object 'tokenEventQueue' when calling 'generateToken'. All +'Event's in responses to 'generateToken' request will be returned in +'tokenEventQueue'. + + tokenEventQueue = EventQueue() + session.generateToken(eventQueue=tokenEventQueue) + +Synchronously read the response 'event' and parse over messages using 'token' + + ev = tokenEventStatus.nextEvent() + token = None + if ev.eventType() == blpapi.Event.TOKEN_STATUS: + for msg in ev: + if msg.messageType() == TOKEN_SUCCESS: + token = msg.getElementAsString(TOKEN) + elif msg.messageType() == TOKEN_FAILURE: + break + if not token: + raise Exception("Failed to get token") + +""" +from __future__ import annotations +from typing import Iterator as IteratorType, Optional, Set +from collections.abc import Iterator as IteratorABC +from .message import Message +from . import internals +from . import utils +from .utils import get_handle +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiEventHandle + + +class MessageIterator(CHandle, IteratorABC): + """An iterator over the :class:`Message` objects within an :class:`Event`. + + Few clients will ever make direct use of :class:`MessageIterator` objects; + Python ``for`` loops allow clients to operate directly in terms of + :class:`Event` and :class:`Message` objects. + """ + + def __init__(self, event: Event) -> None: + selfhandle = internals.blpapi_MessageIterator_create(get_handle(event)) + super(MessageIterator, self).__init__( + selfhandle, internals.blpapi_MessageIterator_destroy + ) + self.__handle = selfhandle + self.__event = event + + def __iter__(self) -> IteratorType: + return self + + def __next__(self) -> Message: + retCode, message = internals.blpapi_MessageIterator_next(self.__handle) + if retCode: + raise StopIteration() + else: + return Message(message, self.__event) + + +class Event(CHandle, metaclass=utils.MetaClassForClassesWithEnums): + """A single event resulting from a subscription or a request. + + :class:`Event` objects are created by the API and passed to the application + either through a registered ``eventHandler`` or :class:`EventQueue` or + returned either from the ``nextEvent()`` or ``tryNextEvent()`` methods. + :class:`Event` objects contain :class:`Message` objects which can be + accessed using an iteration over :class:`Event`:: + + for message in event: + ... + + The :class:`Event` object is a handle to an event. The event is the basic + unit of work provided to applications. Each :class:`Event` object consists + of an ``eventType`` attribute and zero or more :class:`Message` objects. + + :class:`Event` objects are always created by the API, never directly by the + application. + + The class attributes represent the possible types of event. + """ + + ADMIN = internals.EVENTTYPE_ADMIN + """Admin event""" + SESSION_STATUS = internals.EVENTTYPE_SESSION_STATUS + """Status updates for a session""" + SUBSCRIPTION_STATUS = internals.EVENTTYPE_SUBSCRIPTION_STATUS + """Status updates for a subscription""" + REQUEST_STATUS = internals.EVENTTYPE_REQUEST_STATUS + """Status updates for a request""" + RESPONSE = internals.EVENTTYPE_RESPONSE + """The final (possibly only) response to a request""" + PARTIAL_RESPONSE = internals.EVENTTYPE_PARTIAL_RESPONSE + """A partial response to a request""" + SUBSCRIPTION_DATA = internals.EVENTTYPE_SUBSCRIPTION_DATA + """Data updates resulting from a subscription""" + SERVICE_STATUS = internals.EVENTTYPE_SERVICE_STATUS + """Status updates for a service""" + TIMEOUT = internals.EVENTTYPE_TIMEOUT + """An Event returned from nextEvent() if it timed out""" + AUTHORIZATION_STATUS = internals.EVENTTYPE_AUTHORIZATION_STATUS + """Status updates for user authorization""" + RESOLUTION_STATUS = internals.EVENTTYPE_RESOLUTION_STATUS + """Status updates for a resolution operation""" + TOPIC_STATUS = internals.EVENTTYPE_TOPIC_STATUS + """Status updates about topics for service providers""" + TOKEN_STATUS = internals.EVENTTYPE_TOKEN_STATUS + """Status updates for a generate token request""" + REQUEST = internals.EVENTTYPE_REQUEST + """Request event""" + UNKNOWN = -1 + """Unknown event""" + + def __init__( + self, + handle: BlpapiEventHandle, + sessions: Optional[Set["typehints.AbstractSession"]] = None, + ): + super(Event, self).__init__(handle, internals.blpapi_Event_release) + self.__handle = handle + self.__sessions = sessions if sessions is not None else set() + + def eventType(self) -> int: + """ + Returns: + Type of messages contained by this :class:`Event`. + """ + return internals.blpapi_Event_eventType(self.__handle) + + def __iter__(self) -> IteratorType: + """ + Returns: + Iterator over messages contained in this :class:`Event`. + """ + return MessageIterator(self) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) that this 'Event' is related to. + + For internal use.""" + return self.__sessions + + # Protect enumeration constant(s) defined in this class and in classes + # derived from this class from changes: + + +class EventQueue(CHandle): + """A construct used to handle replies to request synchronously. + + When a request is submitted an application can either handle the responses + asynchronously as they arrive or use an :class:`EventQueue` to handle all + responses for a given request or requests synchronously. The + :class:`EventQueue` will only deliver responses to the request(s) it is + associated with. + """ + + def __init__(self) -> None: + """ + Construct an empty :class:`EventQueue` which can be passed to + :meth:`~Session.sendRequest()` and + :meth:`~Session.sendAuthorizationRequest()` methods. + """ + selfhandle = internals.blpapi_EventQueue_create() + super(EventQueue, self).__init__( + selfhandle, internals.blpapi_EventQueue_destroy + ) + self.__handle = selfhandle + self.__sessions: Set["typehints.AbstractSession"] = set() + + def nextEvent(self, timeout: int = 0) -> Event: + """ + Args: + timeout: Timeout threshold in milliseconds. + + Returns: + The next :class:`Event` available from the + :class:`EventQueue`. + + If the specified ``timeout`` is zero this method will wait forever for + the next event. If the specified ``timeout`` is non zero then if no + :class:`Event` is available within the specified ``timeout`` an + :class:`Event` with type of :attr:`~Event.TIMEOUT` will be returned. + """ + res = internals.blpapi_EventQueue_nextEvent(self.__handle, timeout) + return Event(res, self._getSessions()) + + def tryNextEvent(self) -> Optional[Event]: + """ + Returns: + If the :class:`EventQueue` is non-empty, the next + :class:`Event` available, otherwise ``None``. + """ + res = internals.blpapi_EventQueue_tryNextEvent(self.__handle) + if res[0]: + return None + return Event(res[1], self._getSessions()) + + def purge(self) -> None: + """Purge any :class:`Event` objects in this :class:`EventQueue`. + + Purges any :class:`Event` objects in this :class:`EventQueue` which + have not been processed and cancel any pending requests linked to this + :class:`EventQueue`. The :class:`EventQueue` can subsequently be + re-used for a subsequent request. + """ + internals.blpapi_EventQueue_purge(self.__handle) + self.__sessions.clear() + + def _registerSession(self, session: "typehints.AbstractSession") -> None: + """Add a new session to this 'EventQueue'. For internal use.""" + self.__sessions.add(session) + + def _getSessions(self) -> Set["typehints.AbstractSession"]: + """Get a set of sessions this EventQueue related to. + + For internal use. + """ + return self.__sessions + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/eventdispatcher.py b/src/blpapi/eventdispatcher.py new file mode 100644 index 0000000..936f545 --- /dev/null +++ b/src/blpapi/eventdispatcher.py @@ -0,0 +1,109 @@ +# eventdispatcher.py + +"""Provide a dispatcher to dispatch events. + +This component implements a dispatcher to dispatch events from one or more +Sessions through callbacks. +""" + +import warnings +from . import internals +from .chandle import CHandle + + +class EventDispatcher(CHandle): + """Dispatches events from one or more Sessions through callbacks + + :class:`EventDispatcher` objects are optionally specified when Session + objects are created. A single :class:`EventDispatcher` can be shared by + multiple Session objects. + + The :class:`EventDispatcher` provides an event-driven interface, generating + callbacks from one or more internal threads for one or more sessions. + """ + + __handle = None # pylint: disable=unused-private-member + + def __init__(self, numDispatcherThreads: int = 1) -> None: + """Construct an :class:`EventDispatcher`. + + Args: + numDispatcherThreads: Number of dispatcher threads + + If ``numDispatcherThreads`` is ``1`` (the default) then a single + internal thread is created to dispatch events. If + ``numDispatcherThreads`` is greater than ``1`` then an internal pool of + ``numDispatcherThreads`` threads is created to dispatch events. The + behavior is undefined if ``numDispatcherThreads`` is ``0``. + """ + selfhandle = internals.blpapi_EventDispatcher_create( + numDispatcherThreads + ) + super(EventDispatcher, self).__init__( + selfhandle, internals.blpapi_EventDispatcher_destroy + ) + self.__handle = selfhandle + + def start(self) -> int: + """Start generating callbacks for events from sessions associated with + this :class:`EventDispatcher`. + """ + + return internals.blpapi_EventDispatcher_start(self.__handle) + + def stop(self, async_: bool = False, **kwargs: bool) -> int: + """Stop generating callbacks. + + Args: + async\\_ : Whether to execute this method asynchronously + + Stop generating callbacks for events from sessions associated with this + :class:`EventDispatcher`. If the specified ``async_`` is ``False`` (the + default) then this method blocks until all current callbacks which were + dispatched through this :class:`EventDispatcher` have completed. If + ``async_`` is ``True``, this method returns immediately and no further + callbacks will be dispatched. + + Note: + If stop is called with ``async_`` of ``False`` from within a + callback dispatched by this :class:`EventDispatcher` then the + ``async_`` parameter is overridden to ``True``. + """ + + if "async" in kwargs: + warnings.warn( + "async parameter has been deprecated in favor of async_", + DeprecationWarning, + ) + async_ = kwargs.pop("async") + + if kwargs: + raise TypeError( + "EventDispatcher.stop() got an unexpected keyword " + "argument. Only 'async' is allowed for backwards " + "compatibility." + ) + + return internals.blpapi_EventDispatcher_stop(self.__handle, async_) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/eventformatter.py b/src/blpapi/eventformatter.py new file mode 100644 index 0000000..2ef3293 --- /dev/null +++ b/src/blpapi/eventformatter.py @@ -0,0 +1,735 @@ +# eventformatter.py + +"""Add messages to an Event for publishing + +This component adds messages to an Event which can be later published. +""" + +from .exception import ( + _ExceptionUtil, + InvalidConversionException, + IndexOutOfRangeException, + InvalidArgumentException, + NotFoundException, +) +from .datetime import _DatetimeUtil +from .message import Message +from .name import Name, getNamePair +from . import internals +from .utils import get_handle, invoke_if_valid, isNonScalarSequence +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + +from collections import deque +from collections.abc import Mapping +from typing import Any, Callable, Deque, Optional, Tuple, Union +from typing import Mapping as MappingType + + +class EventFormatter(CHandle): + r""":class:`EventFormatter` is used to populate :class:`Event`\s for + publishing. + + An :class:`EventFormatter` is created from an :class:`Event` obtained from + :class:`~Service.createPublishEvent()` on :class:`Service`. Once the + :class:`Message` or :class:`Message`\s have been appended to the + :class:`Event` using the :class:`EventFormatter` the :class:`Event` can be + published using :meth:`~ProviderSession.publish()` on the + :class:`ProviderSession`. + + :class:`EventFormatter` objects cannot be copied to ensure that there is + no ambiguity about what happens if two :class:`EventFormatter`\s are both + formatting the same :class:`Event`. + + The :class:`EventFormatter` supports appending message of the same type + multiple times in the same :class:`Event`. However the + :class:`EventFormatter` supports write once only to each field. It is an + error to call :meth:`setElement()` or :meth:`pushElement()` for the same + name more than once at a particular level of the schema when creating a + message. + """ + + __boolTraits = ( + internals.blpapi_EventFormatter_setValueBool, + internals.blpapi_EventFormatter_appendValueBool, + None, + ) + + __datetimeTraits = ( + internals.blpapi_EventFormatter_setValueHighPrecisionDatetime, + internals.blpapi_EventFormatter_appendValueHighPrecisionDatetime, + _DatetimeUtil.convertToBlpapi, + ) + + __int32Traits = ( + internals.blpapi_EventFormatter_setValueInt32, + internals.blpapi_EventFormatter_appendValueInt32, + None, + ) + + __int64Traits = ( + internals.blpapi_EventFormatter_setValueInt64, + internals.blpapi_EventFormatter_appendValueInt64, + None, + ) + + __floatTraits = ( + internals.blpapi_EventFormatter_setValueFloat, + internals.blpapi_EventFormatter_appendValueFloat, + None, + ) + + # pylint: disable=protected-access + __nameTraits = ( + internals.blpapi_EventFormatter_setValueFromName, + internals.blpapi_EventFormatter_appendValueFromName, + Name._handle, + ) + + __stringTraits = ( + internals.blpapi_EventFormatter_setValueString, + internals.blpapi_EventFormatter_appendValueString, + None, + ) + + __bytesTraits = ( + internals.blpapi_EventFormatter_setValueBytes, + None, + None, + ) + + __defaultTraits = ( + internals.blpapi_EventFormatter_setValueString, + internals.blpapi_EventFormatter_appendValueString, + str, + ) + + # pylint: disable=too-many-return-statements + @staticmethod + def __getTraits( + value: Any, + ) -> Tuple[Callable, Optional[Callable], Optional[Callable]]: + """Returns traits for value based on its type""" + if isinstance(value, str): + return EventFormatter.__stringTraits + if isinstance(value, bytes): + return EventFormatter.__bytesTraits + if isinstance(value, bool): + return EventFormatter.__boolTraits + if isinstance(value, int): + if -(2**31) <= value <= (2**31 - 1): + return EventFormatter.__int32Traits + if -(2**63) <= value <= (2**63 - 1): + return EventFormatter.__int64Traits + raise InvalidConversionException( + f"Value is out of supported range (INT64): {value}", 0 + ) + if isinstance(value, float): + return EventFormatter.__floatTraits + if _DatetimeUtil.isDatetime(value): + return EventFormatter.__datetimeTraits + if isinstance(value, Name): + return EventFormatter.__nameTraits + return EventFormatter.__defaultTraits + + def __init__(self, event: "typehints.Event") -> None: + r"""Create an :class:`EventFormatter` to create :class:`Message`\s in + the specified ``event``. + + Args: + event: Event to be formatted + + An :class:`Event` may only be referenced by one :class:`EventFormatter` + at any time. Attempting to create a second :class:`EventFormatter` + referencing the same :class:`Event` will result in an exception being + raised. + """ + selfhandle = internals.blpapi_EventFormatter_create(get_handle(event)) + super(EventFormatter, self).__init__( + selfhandle, internals.blpapi_EventFormatter_destroy + ) + self.__handle = selfhandle + self.latestMessageName: Optional[Union[Name, str]] = None + + def appendMessage( + self, + messageType: Name, + topic: "typehints.Topic", + sequenceNumber: Optional[int] = None, + ) -> None: + """Append an (empty) message to the :class:`Event` referenced by this + :class:`EventFormatter` + + Args: + messageType: Type of the message + topic: Topic to publish the message under + sequenceNumber: Sequence number of the message + + After a message has been appended its elements can be set using the + various :meth:`setElement()` methods. + + Note: + It is expected that ``sequenceNumber`` is greater (unless the value + wrapped or ``None`` is specified) than the last value used in any + previous message on this ``topic``, otherwise the behavior is + undefined. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + name = getNamePair(messageType) + + if sequenceNumber is None: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendMessage( + self.__handle, name[0], name[1], get_handle(topic) + ) + ) + else: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendMessageSeq( + self.__handle, + name[0], + name[1], + get_handle(topic), + sequenceNumber, + 0, + ) + ) + + self.latestMessageName = messageType + + def appendResponse(self, operationName: Name) -> None: + """Append an (empty) response message for the specified + ``operationName``. + + Args: + operationName: Name of the operation whose response type to use + + Append an (empty) response message for the specified ``operationName`` + (e.g. ``ReferenceDataRequest``) that will be sent in response to the + previously received operation request. After a message for this + operation has been appended its elements can be set using the + :meth:`setElement()` method. Only one response can be appended. + + Note: + The behavior is undefined unless the :class:`Event` is currently + empty. + + Note: + For ``PermissionRequest`` messages, use the ``PermissionResponse`` + operation name. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``operationName``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + name = getNamePair(operationName) + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendResponse( + self.__handle, name[0], name[1] + ) + ) + + self.latestMessageName = "" + + def appendRecapMessage( + self, + topic: "typehints.Topic", + correlationId: Optional["typehints.CorrelationId"] = None, + sequenceNumber: Optional[int] = None, + fragmentType: int = Message.FRAGMENT_NONE, + ) -> None: + """Append a (empty) recap message to the :class:`Event` referenced by + this :class:`EventFormatter`. + + Args: + topic: Topic to publish under + correlationId: Specify if recap message + added in response to a ``TOPIC_RECAP`` message + sequenceNumber: Sequence number of the message + fragmentType: Type of the message fragment + + Specify the optional ``correlationId`` if this recap message is added + in response to a ``TOPIC_RECAP`` message. + + After a message has been appended its elements can be set using the + various :meth:`setElement()` methods. It is an error to create append a + recap message to an Admin event. + + Single-tick recap messages should have ``fragmentType`` set to + :attr:`Message.FRAGMENT_NONE`. Multi-tick recaps can have either + :attr:`Message.FRAGMENT_START`, :attr:`Message.FRAGMENT_INTERMEDIATE`, + or :attr:`Message.FRAGMENT_END` as the ``fragmentType``. + + Note: + It is expected that ``sequenceNumber`` is greater (unless the value + wrapped or ``None`` is specified) than the last value used in any + previous message on this ``topic``, otherwise the behavior is + undefined. + """ + + cIdHandle = correlationId + + if sequenceNumber is None: + if fragmentType == Message.FRAGMENT_NONE: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendRecapMessage( + self.__handle, get_handle(topic), cIdHandle + ) + ) + else: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendFragmentedRecapMessage( + self.__handle, + None, + None, + get_handle(topic), + cIdHandle, + fragmentType, + ) + ) + else: + if fragmentType == Message.FRAGMENT_NONE: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendRecapMessageSeq( + self.__handle, + get_handle(topic), + cIdHandle, + sequenceNumber, + 0, + ) + ) + else: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendFragmentedRecapMessageSeq( + self.__handle, + None, + None, + get_handle(topic), + fragmentType, + sequenceNumber, + ) + ) + + self.latestMessageName = "" + + def setElement(self, name: Name, value: Any) -> None: + """Set an element in the :class:`Event` referenced by this + :class:`EventFormatter`. + + Args: + name: Name of the element to set + value (bool or str or bytes or int or float or ~datetime.datetime or Name): + Value to set the element to + + If the ``name`` is invalid for the current message, or if + :meth:`appendMessage()` has never been called, or if the element + identified by ``name`` has already been set, an exception will be + raised. + + Note: + Clients wishing to format and publish null values (e.g. for the + purpose of cache management) should *not* use this function; use + :meth:`setElementNull` instead. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + traits = EventFormatter.__getTraits(value) + namepair = getNamePair(name) + value = invoke_if_valid(traits[2], value) + _ExceptionUtil.raiseOnError( + traits[0](self.__handle, namepair[0], namepair[1], value) + ) + + def setElementNull(self, name: Name) -> None: + """Create a null element with the specified ``name``. + + Args: + name: Name of the element + + Note: + Whether or not fields containing null values are published to + subscribers depends on the details of the service and schema + configuration. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + namepair = getNamePair(name) + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_setValueNull( + self.__handle, namepair[0], namepair[1] + ) + ) + + def pushElement(self, name: Name) -> None: + """Change the level at which this :class:`EventFormatter` is operating. + + Args: + name: Name of the element that is used to determine + the level + + After this returns the context of the :class:`EventFormatter` is set to + the element ``name`` in the schema and any calls to + :meth:`setElement()` or :meth:`pushElement()` are applied at that + level. + + If ``name`` represents an array of scalars then :meth:`appendValue()` + must be used to add values. + + If ``name`` represents an array of complex types then + :meth:`appendElement()` creates the first entry and sets the context of + the :class:`EventFormatter` to that element. + + Calling :meth:`appendElement()` again will create another entry. + + If the ``name`` is invalid for the current message, if + :meth:`appendMessage()` has never been called or if the element + identified by ``name`` has already been set an exception is raised. + + Note: + The element ``name`` must identify either a choice, a sequence or + an array at the current level of the schema or the behavior is + undefined. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + namepair = getNamePair(name) + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_pushElement( + self.__handle, namepair[0], namepair[1] + ) + ) + + def popElement(self) -> None: + """Undo the most recent call to :meth:`pushElement` or + :meth:`appendElement` on this :class:`EventFormatter` and return the + context of the :class:`EventFormatter` to where it was before the call + to :meth:`pushElement` or :meth:`appendElement`. Once + :meth:`popElement` has been called it is invalid to attempt to + re-visit the same context. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_popElement(self.__handle) + ) + + def appendValue(self, value: Any) -> None: + """ + Args: + value (bool or str or int or float or ~datetime.datetime or Name): + Value to append + """ + traits = EventFormatter.__getTraits(value) + if traits[1] is None: + raise NotImplementedError("Arrays of bytes are not supported.") + value = invoke_if_valid(traits[2], value) + _ExceptionUtil.raiseOnError(traits[1](self.__handle, value)) + + def appendElement(self) -> None: + _ExceptionUtil.raiseOnError( + internals.blpapi_EventFormatter_appendElement(self.__handle) + ) + + def fromPy(self, value: MappingType) -> None: + r""" + Format this :class:`EventFormatter`'s underlying :class:`Event` using + ``value``. + + Args: + value (collections.abc.Mapping): the object used for formatting + + Raises: + Exception: if ``value`` cannot properly format the :class:`Event` + + The ``value`` used to format the :class:`Event` is always a + :py:class:`collections.abc.Mapping` instance. The keys are + :class:`Name` or :py:class:`str` instances, and the values vary + depending on the :class:`Element` being formatted. + + If the :class:`Element` identified by the key is + + * a complex type, it is formatted using a + :py:class:`collections.abc.Mapping` whose keys are the names of its + sub-:class:`Element`\s. + * an array, it is formatted using a + :py:class:`collections.abc.Sequence` of the :class:`Element`'s + values (see note below for more details). + + Otherwise, the :class:`Element` is formatted using its associated + scalar value (e.g. :py:class:`str` or :py:class:`int`). + + Note: + Although :py:class:`str`, :py:class:`bytearray`, and + :py:class:`memoryview` are sub-types of + :py:class:`collections.abc.Sequence`, :meth:`fromPy` treats them as + scalars of type string and will use them to format scalar + :class:`Element`\s. If you wish to format an array + :class:`Element` with instances of the aforementioned types, put + them in a different :py:class:`collections.abc.Sequence`, like + :py:class:`list`. + + Note: + Although :py:class:`bytes` is sub-type of + :py:class:`collections.abc.Sequence`, :meth:`fromPy` treats it as a + scalar of type :py:class:`bytes` and will use it to format scalar + :class:`Element`. Arrays of :py:class:`bytes` are not supported. + + For null :class:`Element`\s: + + * A null complex :class:`Element` is formatted using an empty + :py:class:`collections.abc.Mapping`. + * A null scalar :class:`Element` is formatted using ``None``. + * An empty array :class:`Element` is formatted using an empty + :py:class:`collections.abc.Sequence`. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + MappingType key. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + + Note: + The behavior is undefined if :meth:`fromPy` is used to format an + :class:`Event` that has already been formatted. Further formatting + after :meth:`fromPy` is also undefined. + + For example, the following ``SampleOperation`` has the following BLPAPI + representation: + + .. code-block:: none + + SampleOperation = { + complexElement = { + nullElement = { + } + } + scalarArray[] = { + "value1", "value2" + } + complexArray[] = { + complexArray = { + value = 1 + message = "msg" + } + } + valueElement = "value" + nullValueElement = + } + + ``SampleOperation`` can be created with the following code: + + .. code-block:: python + + response = service.createResponseEvent(CorrelationId(0)) + ef = EventFormatter(response) + ef.appendResponse("SampleOperation") + + ef.pushElement("complexElement") + ef.setElementNull("nullElement") + ef.popElement() + ef.pushElement("scalarArray") + ef.appendValue("value1") + ef.appendValue("value2") + ef.popElement() + ef.pushElement("complexArray") + ef.appendElement() + ef.setElement("value", 1) + ef.setElement("message", "msg") + ef.popElement() + ef.popElement() + ef.setElement("valueElement", "value") + ef.setElementNull("nullValueElement") + + :meth:`fromPy` can be used to format ``SampleOperation`` the same way: + + .. code-block:: python + + response = service.createResponseEvent(CorrelationId(0)) + ef = EventFormatter(response) + ef.appendResponse("SampleOperation") + sampleResponseAsDict = { + "complexElement": { + "nullElement": { + } + }, + "scalarArray": [ + "value1", "value2" + ], + "complexArray": [ + { + "value": 1 + "message": "msg" + } + ], + "valueElement": "value", + "nullValueElement": None + } + ef.fromPy(sampleResponseAsDict) + """ + + if not isinstance(value, Mapping): + raise Exception("`value` must be a `Mapping` instance") + self._fromPyHelper(value) + + def _fromPyHelper( + self, + value: Any, + name: Optional[Union[Name, str]] = None, + dpath: Optional[Deque[Union[Name, str]]] = None, + ) -> None: + """ + Args: + value (Mapping or Sequence or scalar-type): used to format the + :class:`Element` at the current level + name: the :class:`blpapi.Name` + identifying the :class:`Element` to be formatted. If ``name`` + is ``None``, format the :class:`Event` at the current level. + dpath: represents the level at which this + :class:`Eventformatter` is operating + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + path = deque() if dpath is None else dpath + namestr = "" if name is None else str(name) + + def getPathErrorMessage() -> str: + path.appendleft(str(self.latestMessageName)) + pathStr = "/".join([str(p) for p in path]) + return f"While operating on Element `{pathStr}`, " + + if isinstance(value, Mapping): + for key, val in value.items(): + if isinstance(val, Mapping): + if val: + try: + self.pushElement(key) + except Exception as exc: + raise Exception( + getPathErrorMessage() + + _fromPyErrorTemplate.format(exc) + ) + + path.append(key) + self._fromPyHelper(val, name=key, dpath=path) + self.popElement() + path.pop() + else: + try: + self.setElementNull(key) + except (NotFoundException, Exception) as exc: + raise Exception( + getPathErrorMessage() + + _fromPyErrorTemplate.format(exc) + ) + else: + self._fromPyHelper(val, name=key, dpath=path) + + elif isNonScalarSequence(value): + try: + self.pushElement(Name(namestr)) + except Exception as exc: + raise Exception( + getPathErrorMessage() + _fromPyErrorTemplate.format(exc) + ) + + for index, val in enumerate(value): + path.append(f"{namestr}[{index}]") + + if isinstance(val, Mapping): + try: + self.appendElement() + except Exception as exc: + errorMsg = ( + "encountered a `Mapping` where a scalar " + f"value was expected. Error: {exc}" + ) + raise Exception(getPathErrorMessage() + errorMsg) + + self._fromPyHelper(val, dpath=path) + self.popElement() + elif isNonScalarSequence(val): + errorMsg = ( + "encountered nested `Sequences`s. An array of" + " array Elements should be represented as" + " `Sequence`s of `Mappings`s with `Sequence`" + " values." + ) + raise Exception(getPathErrorMessage() + errorMsg) + else: + try: + self.appendValue(val) + except Exception as exc: + raise Exception( + getPathErrorMessage() + + _fromPyErrorTemplate.format(exc) + ) + + path.pop() + + self.popElement() + + else: + try: + if value is None: + self.setElementNull(Name(namestr)) + else: + self.setElement(Name(namestr), value) + except IndexOutOfRangeException: + path.append(namestr) + errorMsg = ( + "attempted to format an array Element using a" + " scalar value. Array Elements are formatted with" + " `Sequence`s." + ) + raise Exception(getPathErrorMessage() + errorMsg) + except ( + InvalidConversionException, + InvalidArgumentException, + ) as exc: + path.append(namestr) + raise Exception( + getPathErrorMessage() + _fromPyErrorTemplate.format(exc) + ) + except Exception as exc: + raise Exception( + getPathErrorMessage() + _fromPyErrorTemplate.format(exc) + ) + + +_fromPyErrorTemplate = "encountered Error: {}" + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/blpapi/exception.py b/src/blpapi/exception.py similarity index 80% rename from blpapi/exception.py rename to src/blpapi/exception.py index fa04f82..b2fa88a 100644 --- a/blpapi/exception.py +++ b/src/blpapi/exception.py @@ -5,13 +5,12 @@ This file defines various exceptions that blpapi can raise. """ +from builtins import Exception as _StandardException +from typing import Optional, Type +from . import internals -try: - from builtins import Exception as _StandardException -except ImportError: - from __builtin__ import Exception as _StandardException -from . import internals +# pylint: disable=redefined-builtin class Exception(_StandardException): @@ -19,19 +18,26 @@ class Exception(_StandardException): Objects of this class contain the error description for the exception. """ - def __init__(self, description, errorCode): + + def __init__(self, description: str, errorCode: Optional[int]) -> None: + """Create a blpapi exception + + Args: + description: Description of the error + errorCode: Code corresponding to the error + """ _StandardException.__init__(self, description, errorCode) - def __str__(self): - return "{0} ({1:#010x})".format(self.args[0], self.args[1]) + def __str__(self) -> str: + args_arr = list(self.args) + return f"{args_arr[0]} ({args_arr[1]:#010x})" class DuplicateCorrelationIdException(Exception): """Duplicate CorrelationId exception. - The class defines an exception for non unqiue 'blpapi.CorrelationId'. + The class defines an exception for non unique :class:`CorrelationId`. """ - pass class InvalidStateException(Exception): @@ -40,7 +46,6 @@ class InvalidStateException(Exception): This class defines an exception for calling methods on an object that is not in a valid state. """ - pass class InvalidArgumentException(Exception): @@ -49,7 +54,6 @@ class InvalidArgumentException(Exception): This class defines an exception for invalid arguments on method invocations. """ - pass class InvalidConversionException(Exception): @@ -57,7 +61,6 @@ class InvalidConversionException(Exception): This class defines an exception for invalid conversion of data. """ - pass class IndexOutOfRangeException(Exception): @@ -66,7 +69,6 @@ class IndexOutOfRangeException(Exception): This class defines an exception to capture the error when an invalid index is used for an operation that needs index. """ - pass class NotFoundException(Exception): @@ -76,7 +78,6 @@ class NotFoundException(Exception): found for an operation. """ - pass class FieldNotFoundException(Exception): @@ -84,9 +85,9 @@ class FieldNotFoundException(Exception): This class defines an exception to capture the error when an invalid field is used for operation. - DEPRECATED + + **DEPRECATED** """ - pass class UnsupportedOperationException(Exception): @@ -94,7 +95,6 @@ class UnsupportedOperationException(Exception): This class defines an exception for unsupported operations. """ - pass class UnknownErrorException(Exception): @@ -103,11 +103,11 @@ class UnknownErrorException(Exception): This class defines an exception for errors that do not fall in any predefined category. """ - pass -class _ExceptionUtil(object): +class _ExceptionUtil: """Internal exception generating class.""" + __errorClasses = { internals.INVALIDSTATE_CLASS: InvalidStateException, internals.INVALIDARG_CLASS: InvalidArgumentException, @@ -115,19 +115,23 @@ class _ExceptionUtil(object): internals.BOUNDSERROR_CLASS: IndexOutOfRangeException, internals.NOTFOUND_CLASS: NotFoundException, internals.FLDNOTFOUND_CLASS: FieldNotFoundException, - internals.UNSUPPORTED_CLASS: UnsupportedOperationException + internals.UNSUPPORTED_CLASS: UnsupportedOperationException, } @staticmethod - def __getErrorClass(errorCode): + def __getErrorClass(errorCode: int) -> Type: + """returns proper error class for the code""" if errorCode == internals.ERROR_DUPLICATE_CORRELATIONID: return DuplicateCorrelationIdException - errorClass = errorCode & 0xff0000 - return _ExceptionUtil.__errorClasses.get(errorClass, - UnknownErrorException) + errorClass = errorCode & 0xFF0000 + return _ExceptionUtil.__errorClasses.get( + errorClass, UnknownErrorException + ) @staticmethod - def raiseException(errorCode, description=None): + def raiseException( + errorCode: int, description: Optional[str] = None + ) -> None: """Throw the appropriate exception for the specified 'errorCode'.""" if description is None: description = internals.blpapi_getLastErrorDescription(errorCode) @@ -137,13 +141,16 @@ def raiseException(errorCode, description=None): raise errorClass(description, errorCode) @staticmethod - def raiseOnError(errorCode, description=None): + def raiseOnError( + errorCode: int, description: Optional[str] = None + ) -> None: """Throw the appropriate exception for the specified 'errorCode' if the 'errorCode != 0'. """ if errorCode: _ExceptionUtil.raiseException(errorCode, description) + __copyright__ = """ Copyright 2012. Bloomberg Finance L.P. diff --git a/src/blpapi/ffi_utils.c b/src/blpapi/ffi_utils.c new file mode 100644 index 0000000..e202e04 --- /dev/null +++ b/src/blpapi/ffi_utils.c @@ -0,0 +1,337 @@ +#define Py_LIMITED_API 0x03080000 +#include + +#include "blpapi_element.h" +#include "blpapi_correlationid.h" + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +#define PEXPRT __declspec(dllexport) +#else +#define PEXPRT +#endif + +PEXPRT PyObject* blpapi_Element_toPy(blpapi_Element_t *element); + +// this is only needed for windows as the linker will add an /EXPORT +void PyInit_ffiutils(void) { +} + +PyObject* getScalarValue(const blpapi_Element_t* element, const int index) { + const int datatype = blpapi_Element_datatype(element); + + switch (datatype) { + case BLPAPI_DATATYPE_BOOL: { + blpapi_Bool_t boolBuffer; + if (0 != blpapi_Element_getValueAsBool(element, + &boolBuffer, + index)) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting bool"); + return NULL; + } + return PyBool_FromLong(boolBuffer); + } + case BLPAPI_DATATYPE_BYTE: + case BLPAPI_DATATYPE_INT32: + case BLPAPI_DATATYPE_INT64: { + blpapi_Int64_t int64Buffer; + if (0 != blpapi_Element_getValueAsInt64(element, + &int64Buffer, + index)) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting int"); + return NULL; + } + return PyLong_FromLongLong(int64Buffer); + } + case BLPAPI_DATATYPE_FLOAT32: + case BLPAPI_DATATYPE_FLOAT64: { + blpapi_Float64_t floatBuffer; + if (0 != blpapi_Element_getValueAsFloat64(element, + &floatBuffer, + index)) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting float"); + return NULL; + } + return PyFloat_FromDouble(floatBuffer); + } + case BLPAPI_DATATYPE_CHAR: + case BLPAPI_DATATYPE_STRING: + case BLPAPI_DATATYPE_ENUMERATION: { + const char* strValue; + if (0 != blpapi_Element_getValueAsString(element, + &strValue, + index)) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting string"); + return NULL; + } + return PyUnicode_FromString(strValue); + } + case BLPAPI_DATATYPE_BYTEARRAY: { + const char* bytesValue = 0; + size_t bytesLength = 0; + if (0 != blpapi_Element_getValueAsBytes(element, + &bytesValue, + &bytesLength, + index)) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting bytes"); + return NULL; + } + return PyBytes_FromStringAndSize(bytesValue, bytesLength); + } + case BLPAPI_DATATYPE_DATE: + case BLPAPI_DATATYPE_TIME: + case BLPAPI_DATATYPE_DATETIME: { + static PyObject* blpapiDatetimeModule = NULL; + static PyObject* datetimeUtil = NULL; + static PyObject* convertToPyTime = NULL; + blpapi_HighPrecisionDatetime_t highPrecisionDatetimeBuffer; + + /* + Py_LIMITED_API blocks the use of macros from datetime.h + we need to call conversion code from python... + */ + // initialize static variables once + if (convertToPyTime == NULL) { + blpapiDatetimeModule = + PyImport_ImportModule("blpapi.datetime"); + if (blpapiDatetimeModule == NULL) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting blpapi.datetime"); + return NULL; + } + datetimeUtil = + PyObject_GetAttr(blpapiDatetimeModule, + PyUnicode_FromString("_DatetimeUtil")); + if (datetimeUtil == NULL) { + Py_DECREF(blpapiDatetimeModule); + PyErr_SetString( + PyExc_Exception, + "Internal error getting _DatetimeUtil"); + return NULL; + } + convertToPyTime = PyObject_GetAttr( + datetimeUtil, PyUnicode_FromString("toPyTimeFromInts")); + if (convertToPyTime == NULL) { + Py_DECREF(blpapiDatetimeModule); + Py_DECREF(datetimeUtil); + PyErr_SetString( + PyExc_Exception, + "Internal error getting 'toPyTimeFromInts'"); + return NULL; + } + } + + if (blpapi_Element_getValueAsHighPrecisionDatetime( + element, + &highPrecisionDatetimeBuffer, + index) != 0) { + PyErr_SetString( + PyExc_Exception, + "Internal error getting datetime"); + return NULL; + } + + // Return `None` when the `datetime` has no parts because our + if (!highPrecisionDatetimeBuffer.datetime.parts) { + Py_RETURN_NONE; // inc ref and return + } + + return PyObject_CallFunction( + convertToPyTime, "iiiiiiiii", + highPrecisionDatetimeBuffer.datetime.parts, + highPrecisionDatetimeBuffer.datetime.offset, + highPrecisionDatetimeBuffer.datetime.year, + highPrecisionDatetimeBuffer.datetime.month, + highPrecisionDatetimeBuffer.datetime.day, + highPrecisionDatetimeBuffer.datetime.hours, + highPrecisionDatetimeBuffer.datetime.minutes, + highPrecisionDatetimeBuffer.datetime.seconds, + (highPrecisionDatetimeBuffer.datetime.milliSeconds * 1000) + + (highPrecisionDatetimeBuffer.picoseconds / 1000000) + ); + } + case BLPAPI_DATATYPE_SEQUENCE: + case BLPAPI_DATATYPE_CHOICE: + default: { + PyErr_SetString(PyExc_Exception, "Internal datatype error"); + return NULL; + } + } +} + +PyObject* complexElementToPy(blpapi_Element_t *element) { + PyObject* pyDict = PyDict_New(); + PyObject* subElementPy = NULL; + unsigned int i; + if (pyDict == NULL) { + goto ERROR; + } + + for (i = 0; i < blpapi_Element_numElements(element); ++i) { + blpapi_Element_t* subElement; + const char* name; + if (0 != blpapi_Element_getElementAt(element, &subElement, i)) { + PyErr_SetString(PyExc_Exception, + "Internal error in `Element.toPy`"); + goto ERROR; + } + name = blpapi_Element_nameString(subElement); + subElementPy = blpapi_Element_toPy(subElement); + if (subElementPy == NULL) { + goto ERROR; + } + // does not steal ref to value + if (PyDict_SetItemString(pyDict, name, subElementPy)) { + goto ERROR; + } + Py_DECREF(subElementPy); + } + return pyDict; +ERROR: + Py_XDECREF(pyDict); + Py_XDECREF(subElementPy); + // Ensure that we set an error before returning NULL + if (PyErr_Occurred() == NULL) { + PyErr_SetString( + PyExc_Exception, + "Internal error converting a complex Element"); + } + return NULL; +} + +PyObject* arrayElementToPy(blpapi_Element_t *element) { + const unsigned int numValues = blpapi_Element_numValues(element); + PyObject* pyList = PyList_New(numValues); + PyObject* pyValue = NULL; + + const blpapi_SchemaElementDefinition_t* definition + = blpapi_Element_definition(element); + const blpapi_SchemaTypeDefinition_t* typeDefinition + = blpapi_SchemaElementDefinition_type(definition); + + unsigned int i; + if (pyList == NULL) { + goto ERROR; + } + + // complex values + if (blpapi_SchemaTypeDefinition_isComplexType(typeDefinition)) { + for (i = 0; i < numValues; ++i) { + blpapi_Element_t* result; + if (0 != blpapi_Element_getValueAsElement(element, &result, i)) { + PyErr_SetString( + PyExc_Exception, + "Internal error in blpapi_Element_getValueAsElement"); + goto ERROR; + } + pyValue = blpapi_Element_toPy(result); + if (pyValue == NULL) { + goto ERROR; + } + // see https://docs.python.org/3/c-api/list.html#c.PyList_SetItem + PyList_SetItem(pyList, i, pyValue); + } + } + else { + // non complex values + for (i = 0; i < numValues; ++i) { + pyValue = getScalarValue(element, i); + if (pyValue == NULL) { + goto ERROR; + } + PyList_SetItem(pyList, i, pyValue); + } + } + return pyList; + +ERROR: + Py_XDECREF(pyList); + Py_XDECREF(pyValue); + // Ensure that we set an error before returning NULL + if (PyErr_Occurred() == NULL) { + PyErr_SetString( + PyExc_Exception, + "Internal error converting an array Element"); + } + return NULL; +} + +PyObject* blpapi_Element_toPy(blpapi_Element_t *element) { + if (blpapi_Element_isComplexType(element)) { + return complexElementToPy(element); + } + else if (blpapi_Element_isArray(element)) { + return arrayElementToPy(element); + } + else if (blpapi_Element_isNull(element)) { + Py_RETURN_NONE; // inc ref and return + } + else { + return getScalarValue(element, 0); + } +} + +/* decrefs allow python code to decrement ref. count of objects, + even if they are not yet pointed to by blpapi_ManagedPtr_t struct. +*/ +PEXPRT void incref(PyObject *obj); +void incref(PyObject *obj) +{ + PyGILState_STATE s = PyGILState_Ensure(); + Py_XINCREF(obj); + PyGILState_Release(s); +} + +/* This function implements the interface for managing objects from C. + We are ensuring GIL in this implementation, but those calls + can be nested and will not cause a deadlock if a call to managerFunc + is interrupted by GC that needs to decref. + Note: INCREF/DECREF are not atomic in the C-sense, but will not be + interrupted by Python interpreted thread. + */ +PEXPRT int managerFunc(void * mptr, void * sptr, int operation) +{ + PyGILState_STATE s = PyGILState_Ensure(); + + blpapi_ManagedPtr_t * managedPtr = (blpapi_ManagedPtr_t *) mptr; + blpapi_ManagedPtr_t * srcPtr = (blpapi_ManagedPtr_t *) sptr; + + if (operation == BLPAPI_MANAGEDPTR_COPY) { + managedPtr->pointer = srcPtr->pointer; + managedPtr->manager = srcPtr->manager; + Py_XINCREF((PyObject *) (managedPtr->pointer)); + } + else if (operation == BLPAPI_MANAGEDPTR_DESTROY) { + Py_XDECREF((PyObject *) (managedPtr->pointer)); + } + + PyGILState_Release(s); + return 0; +} + +/* Used to set the function pointer to our manager inside cid structure */ +PEXPRT void setmptr(void *s); +void setmptr(void *s) { + blpapi_ManagedPtr_t *p = (blpapi_ManagedPtr_t *) s; + p->manager = (blpapi_ManagedPtr_ManagerFunction_t ) &managerFunc; +} + +/* Used to check if the manager used by a cid is the one we set. +If it is not the same, it must be a C++ cb set for recaps. +This function will be removed when recap cids are fixed. +*/ +PEXPRT int is_known_obj(void *s); +int is_known_obj(void *s) { + blpapi_ManagedPtr_t *p = (blpapi_ManagedPtr_t *) s; + return p->manager == (blpapi_ManagedPtr_ManagerFunction_t ) &managerFunc; +} diff --git a/blpapi/highresclock.py b/src/blpapi/highresclock.py similarity index 52% rename from blpapi/highresclock.py rename to src/blpapi/highresclock.py index b9f9152..352758c 100644 --- a/blpapi/highresclock.py +++ b/src/blpapi/highresclock.py @@ -1,15 +1,22 @@ # coding: utf-8 +""" Support highres clock""" -from __future__ import absolute_import from blpapi import internals from blpapi.datetime import _DatetimeUtil, UTC +import datetime -def now(tzinfo=UTC): + +def now(tzinfo: datetime.tzinfo = UTC) -> datetime.datetime: """Return the current time using the same clock as is used to measure the 'timeReceived' value on incoming messages; note that this is *not* necessarily the same clock as is accessed by calls to 'datetime.now'. The resulting datetime will be represented using the specified 'tzinfo'. """ - original = internals.blpapi_HighResolutionClock_now_wrapper() + err_code, time_point = internals.blpapi_HighResolutionClock_now() + if err_code != 0: + raise RuntimeError("High resolution clock error") + original = internals.blpapi_HighPrecisionDatetime_fromTimePoint_wrapper( + time_point + ) native = _DatetimeUtil.convertToNative(original) - return native.astimezone(tzinfo) + return native.astimezone(tzinfo) # type: ignore diff --git a/src/blpapi/identity.py b/src/blpapi/identity.py new file mode 100644 index 0000000..6a3f761 --- /dev/null +++ b/src/blpapi/identity.py @@ -0,0 +1,206 @@ +# identity.py + +"""Provide access to the entitlements for a user. + +This component provides an identification of a user and implements the access +to the entitlements. +""" +from ctypes import c_int +from typing import List, Sequence, Tuple, Union +from .typehints import BlpapiIdentityHandle +from .element import Element +from .exception import _ExceptionUtil +from . import internals +from . import utils +from . import typehints # pylint: disable=unused-import +from .utils import get_handle +from .chandle import CHandle + + +class Identity(CHandle, metaclass=utils.MetaClassForClassesWithEnums): + """Provides access to the entitlements for a specific user. + + An unauthorized Identity is created using + :meth:`~Session.createIdentity()`. Once an :class:`Identity` has been + created it can be authorized using + :meth:`~Session.sendAuthorizationRequest()`. The authorized + :class:`Identity` can then be queried or used in + :meth:`~Session.subscribe()` or :meth:`~Session.sendRequest()` calls. + + Once authorized, an :class:`Identity` has access to the entitlements of the + user which it was validated for. + + :class:`Identity` objects are always created by the API, never directly by + the application. + + The class attributes represent the various seat types. + """ + + INVALID_SEAT = internals.SEATTYPE_INVALID_SEAT + """Unknown seat type""" + BPS = internals.SEATTYPE_BPS + """Bloomberg Professional Service""" + NONBPS = internals.SEATTYPE_NONBPS + """Non-BPS""" + + def __init__( + self, + handle: BlpapiIdentityHandle, + sessions: Sequence["typehints.AbstractSession"], + ): + """Create an :class:`Identity` associated with the ``sessions`` + + Args: + handle: Handle to the internal implementation + sessions: Sessions associated with this object + """ + super(Identity, self).__init__( + handle, internals.blpapi_Identity_release + ) + self.__handle = handle # pylint: disable=unused-private-member + self.__sessions = sessions # pylint: disable=unused-private-member + + def hasEntitlements( + self, + service: "typehints.Service", + entitlements: Union[Sequence[int], "typehints.Element"], + ) -> bool: + """ + Args: + service: Service to check authorization for + entitlements: EIDs to check authorization for + + Returns: + ``True`` if this :class:`Identity` is authorized for the + specified ``service`` and for each of the entitlement IDs contained + in the specified ``entitlements``. + + If :class:`Element` is supplied for ``entitlements``, it must be an + array of integers. + """ + if isinstance(entitlements, Element): + res = internals.blpapi_Identity_hasEntitlements( + self.__handle, + get_handle(service), + get_handle(entitlements), + None, + 0, + None, + None, + ) + else: + # Otherwise, assume entitlements is a list, or tuple, etc + numberOfEIDs = len(entitlements) + carrayOfEIDs = (c_int * numberOfEIDs)(*entitlements) + res = internals.blpapi_Identity_hasEntitlements( + self.__handle, + get_handle(service), + None, + carrayOfEIDs, + numberOfEIDs, + None, + None, + ) + return True if res else False + + def getFailedEntitlements( + self, + service: "typehints.Service", + entitlements: Union[Sequence[int], "typehints.Element"], + ) -> Tuple[bool, List[int]]: + """ + Args: + service: Service to check authorization for + entitlements: EIDs to check authorization for + + Returns: + Tuple where the boolean is True if this + :class:`Identity` is authorized for the specified ``service`` and + all of the specified ``entitlements``, and the list is a subset of + ``entitlements`` for which this :class:`Identity` is not + authorized. + + Note: + The contents of the returned list are not specified if this + identity is not authorized for ``service``. + """ + if isinstance(entitlements, Element): + maxFailedEIDs = entitlements.numValues() + failedEIDs = (c_int * maxFailedEIDs)() + failedEIDsSize = c_int(maxFailedEIDs) + res = internals.blpapi_Identity_hasEntitlements( + self.__handle, + get_handle(service), + get_handle(entitlements), + None, + 0, + failedEIDs, + failedEIDsSize, + ) + else: + # Otherwise, assume entitlements is a list, or tuple, etc + numberOfEIDs = len(entitlements) + carrayOfEIDs = (c_int * numberOfEIDs)(*entitlements) + maxFailedEIDs = numberOfEIDs + failedEIDs = (c_int * maxFailedEIDs)() + failedEIDsSize = c_int(maxFailedEIDs) + res = internals.blpapi_Identity_hasEntitlements( + self.__handle, + get_handle(service), + None, + carrayOfEIDs, + numberOfEIDs, + failedEIDs, + failedEIDsSize, + ) + result = [] + for i in range(failedEIDsSize.value): + result.append(failedEIDs[i]) + return (True if res else False, result) + + def isAuthorized(self, service: "typehints.Service") -> bool: + """ + Args: + service: Service to check authorization for + + Returns: + ``True`` if this :class:`Identity` is authorized for the + specified ``service``, ``False`` otherwise. + """ + res = internals.blpapi_Identity_isAuthorized( + self.__handle, get_handle(service) + ) + return True if res else False + + def getSeatType(self) -> int: + """ + Returns: + Seat type of this identity. + + The class attributes of :class:`Identity` represent the seat types. + """ + res = internals.blpapi_Identity_getSeatType(self.__handle) + _ExceptionUtil.raiseOnError(res[0]) + return res[1] + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/internals.py b/src/blpapi/internals.py new file mode 100644 index 0000000..a3ddddc --- /dev/null +++ b/src/blpapi/internals.py @@ -0,0 +1,8394 @@ +""" +This module defines C-wrappers for BLPAPI + +Copyright 2023. Bloomberg Finance L.P. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" + +import platform +import glob +import os +from typing import Optional, List, Callable, Any + +# Note: all functions here assume we are given an opaque handle, +# not the python wrapper object, even though paramter names don't have "handle" suffix + +from ctypes import ( + CDLL, + PyDLL, + CFUNCTYPE, + POINTER, + Structure, + byref, + cast, + c_char, + c_char_p, + c_double, + c_float, + c_int, + c_int16, + c_int64, + c_size_t, + c_uint, + c_uint16, + c_uint32, + c_uint64, + c_uint8, + c_void_p, + create_string_buffer, + pointer, + py_object, +) +from ctypes import Union as CUnion +from io import StringIO + +from .ctypesutils import ( + charPtrWithSizeFromPyStr, + charPtrFromPyStr, + getHandleFromPtr, + getHandleFromOutput, + getSizedStrFromOutput, + getStrFromC, + getStrFromOutput, + getPODFromOutput, + getStructFromOutput, + getSizedStrFromBuffer, + getSizedBytesFromOutput, + voidFromPyObject, + voidFromPyFunction, +) + + +# ============= Library loading +def _loadLibrary() -> Any: + """Load blpapi shared library/dll""" + bitness = "64" if platform.architecture()[0].startswith("64") else "32" + prefix = "" if platform.system().lower() == "windows" else "lib" + libsuffix = ".dll" if platform.system().lower() == "windows" else ".so" + topysuffix = ".pyd" if platform.system().lower() == "windows" else ".so" + libname = f"{prefix}blpapi3_{bitness}{libsuffix}" + + # it is either next to this file (we are in wheel) + # or the usual locations (including set LD_LIBRARY_PATH) + try: + libpath = os.path.join( + os.path.abspath(os.path.dirname(__file__)), libname + ) + lib = CDLL(libpath) + except OSError: + lib = CDLL(libname) + + for filename in glob.glob( + os.path.join( + os.path.abspath(os.path.dirname(__file__)), + "ffiutils.*" + topysuffix, + ) + ): + toPy = PyDLL(filename) + break + return lib, toPy + + +libblpapict, libffastcalls = _loadLibrary() +libffastcalls.blpapi_Element_toPy.restype = py_object + +libffastcalls.incref.argtypes = [py_object] +incref = libffastcalls.incref + +libffastcalls.setmptr.argtypes = [c_void_p] +setmptr = libffastcalls.setmptr + +libffastcalls.is_known_obj.restype = c_int +libffastcalls.is_known_obj.argtypes = [c_void_p] +is_known_obj = libffastcalls.is_known_obj + +from .pycbhelpers import ( + any_printer, + anySessionEventHandlerWrapper, + anySessionSubErrorHandlerWrapper, + StreamWrapper, +) + + +class BDatetime(Structure): + _fields_ = [ + ("parts", c_uint8), + ("hours", c_uint8), + ("minutes", c_uint8), + ("seconds", c_uint8), + ("milliSeconds", c_uint16), + ("month", c_uint8), + ("day", c_uint8), + ("year", c_uint16), + ("offset", c_int16), + ] + + +class HighPrecisionDatetime(Structure): + _fields_ = [ + ("datetime", BDatetime), + ("picoseconds", c_uint32), + ] + + +class TimePoint(Structure): + _fields_ = [ + ("d_value", c_int64), + ] + + +class CidFlags(Structure): + _fields_ = [ + ("size", c_uint, 8), + ("valueType", c_uint, 4), + ("classId", c_uint, 16), + ("reserved", c_uint, 4), + ] + + def __str__(self) -> str: + return f"[valtype: {self.valueType}, classid: {self.classId}, sz: {self.size}]" + + +class ManagedPtrData(CUnion): + _fields_ = [("intValue", c_int), ("ptr", c_void_p)] + + +ManagedPtr_ManagerFunction_t = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int) + + +class ManagedPtr(Structure): + _fields_ = [ + ("pointer", c_void_p), + ("userData", ManagedPtrData * 4), + ("manager", ManagedPtr_ManagerFunction_t), + ] + + COPY = 1 + DESTROY = -1 + + def __str__(self) -> str: + return f"[ptr: {hex(self.pointer)}, ud[0]: {hex(self.userData[0].ptr)}, ud[1]: {hex(self.userData[1].ptr)}, ud[2]: {self.userData[2].ptr}, ud[3]: {self.userData[3].ptr}, mgr: {cast(self.manager, c_void_p)}]" + + +class CidValue(CUnion): + _fields_ = [("intValue", c_uint64), ("ptrValue", ManagedPtr)] + + def __str__(self) -> str: + return f"[int: {self.intValue}, ptr: {self.ptrValue}]" + + +class CidStruct(Structure): + _fields_ = [("flags", CidFlags), ("rawvalue", CidValue)] + + empty_arr = (ManagedPtrData * 4)() # empty value + + +def cidValueForObj(pyobj: Optional[Any]) -> CidValue: + ptr = c_void_p(id(pyobj)) + mptr = ManagedPtr( + pointer=ptr, + userData=CidStruct.empty_arr, + manager=ManagedPtr_ManagerFunction_t(), + ) + setmptr(byref(mptr)) + + # we always bump here, as we don't know how it is to be used + # could use ptrValue.manager as well at this point + incref(pyobj) + + # DANGER ZONE: since we decoupled the lifecycle of CidStruct + # and CorrelationId, if this CidValue isn't used by a CorrelationId + # then we WILL leak pyobj as nothing will decref it. + return CidValue(ptrValue=mptr) + + +##################### Constants + +UNKNOWN_CLASS = 0x00000 +INVALIDSTATE_CLASS = 0x10000 +INVALIDARG_CLASS = 0x20000 +IOERROR_CLASS = 0x30000 +CNVERROR_CLASS = 0x40000 +BOUNDSERROR_CLASS = 0x50000 +NOTFOUND_CLASS = 0x60000 +FLDNOTFOUND_CLASS = 0x70000 +UNSUPPORTED_CLASS = 0x80000 + +ERROR_UNKNOWN = UNKNOWN_CLASS | 1 +ERROR_ILLEGAL_ARG = INVALIDARG_CLASS | 2 +ERROR_ILLEGAL_ACCESS = UNSUPPORTED_CLASS | 3 +ERROR_INVALID_SESSION = INVALIDARG_CLASS | 4 +ERROR_DUPLICATE_CORRELATIONID = INVALIDARG_CLASS | 5 +ERROR_INTERNAL_ERROR = UNKNOWN_CLASS | 6 +ERROR_RESOLVE_FAILED = IOERROR_CLASS | 7 +ERROR_CONNECT_FAILED = IOERROR_CLASS | 8 +ERROR_ILLEGAL_STATE = INVALIDSTATE_CLASS | 9 +ERROR_CODEC_FAILURE = UNKNOWN_CLASS | 10 +ERROR_INDEX_OUT_OF_RANGE = BOUNDSERROR_CLASS | 11 +ERROR_INVALID_CONVERSION = CNVERROR_CLASS | 12 +ERROR_ITEM_NOT_FOUND = NOTFOUND_CLASS | 13 +ERROR_IO_ERROR = IOERROR_CLASS | 14 +ERROR_CORRELATION_NOT_FOUND = NOTFOUND_CLASS | 15 +ERROR_SERVICE_NOT_FOUND = NOTFOUND_CLASS | 16 +ERROR_LOGON_LOOKUP_FAILED = UNKNOWN_CLASS | 17 +ERROR_DS_LOOKUP_FAILED = UNKNOWN_CLASS | 18 +ERROR_UNSUPPORTED_OPERATION = UNSUPPORTED_CLASS | 19 +ERROR_DS_PROPERTY_NOT_FOUND = NOTFOUND_CLASS | 20 +ERROR_MSG_TOO_LARGE = INVALIDARG_CLASS | 21 + +CLIENTMODE_AUTO = 0 +CLIENTMODE_DAPI = 1 +CLIENTMODE_SAPI = 2 +CLIENTMODE_COMPAT_33X = 16 + +CORRELATION_TYPE_UNSET = 0 +CORRELATION_TYPE_INT = 1 +CORRELATION_TYPE_POINTER = 2 +CORRELATION_TYPE_AUTOGEN = 3 +CORRELATION_MAX_CLASS_ID = 65535 + +DATATYPE_BOOL = 1 # Bool +DATATYPE_CHAR = 2 # Char +DATATYPE_BYTE = 3 # Unsigned 8 bit value +DATATYPE_INT32 = 4 # 32 bit Integer +DATATYPE_INT64 = 5 # 64 bit Integer +DATATYPE_FLOAT32 = 6 # 32 bit Floating point - IEEE +DATATYPE_FLOAT64 = 7 # 64 bit Floating point - IEEE +DATATYPE_STRING = 8 # ASCIIZ string +DATATYPE_BYTEARRAY = 9 # Opaque binary data +DATATYPE_DATE = 10 # Date +DATATYPE_TIME = 11 # Timestamp +DATATYPE_DECIMAL = 12 # +DATATYPE_DATETIME = 13 # Date and time +DATATYPE_ENUMERATION = 14 # An opaque enumeration +DATATYPE_SEQUENCE = 15 # Sequence type +DATATYPE_CHOICE = 16 # Choice type +DATATYPE_CORRELATION_ID = 17 # Used for some internal messages + +DATETIME_YEAR_PART = 0x1 +DATETIME_MONTH_PART = 0x2 +DATETIME_DAY_PART = 0x4 +DATETIME_OFFSET_PART = 0x8 +DATETIME_HOURS_PART = 0x10 +DATETIME_MINUTES_PART = 0x20 +DATETIME_SECONDS_PART = 0x40 +DATETIME_MILLISECONDS_PART = 0x80 +DATETIME_FRACSECONDS_PART = 0x80 +DATETIME_DATE_PART = ( + DATETIME_YEAR_PART | DATETIME_MONTH_PART | DATETIME_DAY_PART +) +DATETIME_TIME_PART = ( + DATETIME_HOURS_PART | DATETIME_MINUTES_PART | DATETIME_SECONDS_PART +) +DATETIME_TIMEMILLI_PART = DATETIME_TIME_PART | DATETIME_MILLISECONDS_PART +DATETIME_TIMEFRACSECONDS_PART = DATETIME_TIME_PART | DATETIME_FRACSECONDS_PART + +ELEMENTDEFINITION_UNBOUNDED = -1 +ELEMENT_INDEX_END = 0xFFFFFFFF + +EVENTTYPE_ADMIN = 1 +EVENTTYPE_SESSION_STATUS = 2 +EVENTTYPE_SUBSCRIPTION_STATUS = 3 +EVENTTYPE_REQUEST_STATUS = 4 +EVENTTYPE_RESPONSE = 5 +EVENTTYPE_PARTIAL_RESPONSE = 6 +EVENTTYPE_SUBSCRIPTION_DATA = 8 +EVENTTYPE_SERVICE_STATUS = 9 +EVENTTYPE_TIMEOUT = 10 +EVENTTYPE_AUTHORIZATION_STATUS = 11 +EVENTTYPE_RESOLUTION_STATUS = 12 +EVENTTYPE_TOPIC_STATUS = 13 +EVENTTYPE_TOKEN_STATUS = 14 +EVENTTYPE_REQUEST = 15 + +MESSAGE_FRAGMENT_NONE = 0 +MESSAGE_FRAGMENT_START = 1 +MESSAGE_FRAGMENT_INTERMEDIATE = 2 +MESSAGE_FRAGMENT_END = 3 +MESSAGE_RECAPTYPE_NONE = 0 +MESSAGE_RECAPTYPE_SOLICITED = 1 +MESSAGE_RECAPTYPE_UNSOLICITED = 2 + +REGISTRATIONPARTS_DEFAULT = 0x1 +REGISTRATIONPARTS_PUBLISHING = 0x2 +REGISTRATIONPARTS_OPERATIONS = 0x4 +REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION = 0x8 +REGISTRATIONPARTS_PUBLISHER_RESOLUTION = 0x10 + +RESOLVEMODE_DONT_REGISTER_SERVICES = 0 +RESOLVEMODE_AUTO_REGISTER_SERVICES = 1 + +RESOLUTIONLIST_UNRESOLVED = 0 +RESOLUTIONLIST_RESOLVED = 1 +RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE = 2 +RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED = 3 +RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC = 4 +RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED = 5 + +SEATTYPE_INVALID_SEAT = -1 +SEATTYPE_BPS = 0 +SEATTYPE_NONBPS = 1 + +_INT_MAX = 2147483647 +SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW = 0 +SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM = _INT_MAX // 2 +SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH = _INT_MAX + +# schema status +STATUS_ACTIVE = 0 +STATUS_DEPRECATED = 1 +STATUS_INACTIVE = 2 +STATUS_PENDING_DEPRECATION = 3 + +SUBSCRIPTIONSTATUS_UNSUBSCRIBED = 0 +SUBSCRIPTIONSTATUS_SUBSCRIBING = 1 +SUBSCRIPTIONSTATUS_SUBSCRIBED = 2 +SUBSCRIPTIONSTATUS_CANCELLED = 3 +SUBSCRIPTIONSTATUS_PENDING_CANCELLATION = 4 + +SUBSCRIPTIONPREPROCESS_INVALID_SUBSCRIPTION_STRING = 1 +SUBSCRIPTIONPREPROCESS_CORRELATIONID_ERROR = 2 + +TOPICLIST_NOT_CREATED = 0 +TOPICLIST_CREATED = 1 +TOPICLIST_FAILURE = 2 + +ZFPUTIL_REMOTE_8194 = 8194 +ZFPUTIL_REMOTE_8196 = 8196 + +blpapi_Logging_SEVERITY_OFF = 0 +blpapi_Logging_SEVERITY_FATAL = 1 +blpapi_Logging_SEVERITY_ERROR = 2 +blpapi_Logging_SEVERITY_WARN = 3 +blpapi_Logging_SEVERITY_INFO = 4 +blpapi_Logging_SEVERITY_DEBUG = 5 +blpapi_Logging_SEVERITY_TRACE = 6 + +##################### Functions + +l_blpapi_AbstractSession_cancel = ( + libblpapict.blpapi_AbstractSession_cancel +) # int +l_blpapi_AbstractSession_cancel.argtypes = [ + c_void_p, + c_void_p, + c_size_t, + c_char_p, + c_int, +] +l_blpapi_AbstractSession_createIdentity = ( + libblpapict.blpapi_AbstractSession_createIdentity +) +l_blpapi_AbstractSession_createIdentity.restype = c_void_p +l_blpapi_AbstractSession_generateAuthorizedIdentityAsync = ( + libblpapict.blpapi_AbstractSession_generateAuthorizedIdentityAsync +) # int +l_blpapi_AbstractSession_generateToken = ( + libblpapict.blpapi_AbstractSession_generateToken +) # int +l_blpapi_AbstractSession_generateManualToken = ( + libblpapict.blpapi_AbstractSession_generateManualToken +) # int +l_blpapi_AbstractSession_getAuthorizedIdentity = ( + libblpapict.blpapi_AbstractSession_getAuthorizedIdentity +) # int +l_blpapi_AbstractSession_openService = ( + libblpapict.blpapi_AbstractSession_openService +) # int +l_blpapi_AbstractSession_openServiceAsync = ( + libblpapict.blpapi_AbstractSession_openServiceAsync +) # int +l_blpapi_AbstractSession_getService = ( + libblpapict.blpapi_AbstractSession_getService +) # int +l_blpapi_AbstractSession_sendAuthorizationRequest = ( + libblpapict.blpapi_AbstractSession_sendAuthorizationRequest +) # int +l_blpapi_AbstractSession_sessionName = ( + libblpapict.blpapi_AbstractSession_sessionName +) # int + +l_blpapi_AuthApplication_create = ( + libblpapict.blpapi_AuthApplication_create +) # int +l_blpapi_AuthApplication_destroy = libblpapict.blpapi_AuthApplication_destroy +l_blpapi_AuthApplication_destroy.restype = None + +l_blpapi_AuthOptions_create_default = ( + libblpapict.blpapi_AuthOptions_create_default +) # int +l_blpapi_AuthOptions_create_forAppMode = ( + libblpapict.blpapi_AuthOptions_create_forAppMode +) # int +l_blpapi_AuthOptions_create_forToken = ( + libblpapict.blpapi_AuthOptions_create_forToken +) # int +l_blpapi_AuthOptions_create_forUserAndAppMode = ( + libblpapict.blpapi_AuthOptions_create_forUserAndAppMode +) # int +l_blpapi_AuthOptions_create_forUserMode = ( + libblpapict.blpapi_AuthOptions_create_forUserMode +) # int +l_blpapi_AuthOptions_destroy = libblpapict.blpapi_AuthOptions_destroy +l_blpapi_AuthOptions_destroy.restype = None + +l_blpapi_AuthToken_create = libblpapict.blpapi_AuthToken_create # int +l_blpapi_AuthToken_destroy = libblpapict.blpapi_AuthToken_destroy +l_blpapi_AuthToken_destroy.restype = None + +l_blpapi_AuthUser_createWithActiveDirectoryProperty = ( + libblpapict.blpapi_AuthUser_createWithActiveDirectoryProperty +) # int +l_blpapi_AuthUser_createWithLogonName = ( + libblpapict.blpapi_AuthUser_createWithLogonName +) # int +l_blpapi_AuthUser_createWithManualOptions = ( + libblpapict.blpapi_AuthUser_createWithManualOptions +) # int +l_blpapi_AuthUser_destroy = libblpapict.blpapi_AuthUser_destroy +l_blpapi_AuthUser_destroy.restype = None + +l_blpapi_Constant_datatype = libblpapict.blpapi_Constant_datatype # int +l_blpapi_Constant_description = libblpapict.blpapi_Constant_description +l_blpapi_Constant_description.restype = c_char_p +l_blpapi_Constant_getValueAsChar = ( + libblpapict.blpapi_Constant_getValueAsChar +) # int +l_blpapi_Constant_getValueAsDatetime = ( + libblpapict.blpapi_Constant_getValueAsDatetime +) # int +l_blpapi_Constant_getValueAsFloat32 = ( + libblpapict.blpapi_Constant_getValueAsFloat32 +) # int +l_blpapi_Constant_getValueAsFloat64 = ( + libblpapict.blpapi_Constant_getValueAsFloat64 +) # int +l_blpapi_Constant_getValueAsInt32 = ( + libblpapict.blpapi_Constant_getValueAsInt32 +) # int +l_blpapi_Constant_getValueAsInt64 = ( + libblpapict.blpapi_Constant_getValueAsInt64 +) # int +l_blpapi_Constant_getValueAsString = ( + libblpapict.blpapi_Constant_getValueAsString +) # int +l_blpapi_Constant_name = libblpapict.blpapi_Constant_name +l_blpapi_Constant_name.restype = c_void_p +l_blpapi_Constant_status = libblpapict.blpapi_Constant_status # int + +l_blpapi_ConstantList_datatype = ( + libblpapict.blpapi_ConstantList_datatype +) # int +l_blpapi_ConstantList_description = libblpapict.blpapi_ConstantList_description +l_blpapi_ConstantList_description.restype = c_char_p +l_blpapi_ConstantList_getConstant = libblpapict.blpapi_ConstantList_getConstant +l_blpapi_ConstantList_getConstant.restype = c_void_p +l_blpapi_ConstantList_getConstantAt = ( + libblpapict.blpapi_ConstantList_getConstantAt +) +l_blpapi_ConstantList_getConstantAt.restype = c_void_p +l_blpapi_ConstantList_name = libblpapict.blpapi_ConstantList_name +l_blpapi_ConstantList_name.restype = c_void_p +l_blpapi_ConstantList_numConstants = ( + libblpapict.blpapi_ConstantList_numConstants +) # int +l_blpapi_ConstantList_status = libblpapict.blpapi_ConstantList_status # int + +l_blpapi_DiagnosticsUtil_memoryInfo = ( + libblpapict.blpapi_DiagnosticsUtil_memoryInfo +) # int + +l_blpapi_Element_appendElement = ( + libblpapict.blpapi_Element_appendElement +) # int +l_blpapi_Element_datatype = libblpapict.blpapi_Element_datatype # int +l_blpapi_Element_definition = libblpapict.blpapi_Element_definition +l_blpapi_Element_definition.restype = c_void_p +l_blpapi_Element_getChoice = libblpapict.blpapi_Element_getChoice # int +l_blpapi_Element_getElement = libblpapict.blpapi_Element_getElement # int +l_blpapi_Element_getElementAt = libblpapict.blpapi_Element_getElementAt # int +l_blpapi_Element_getValueAsBool = ( + libblpapict.blpapi_Element_getValueAsBool +) # int +l_blpapi_Element_getValueAsBytes = ( + libblpapict.blpapi_Element_getValueAsBytes +) # int +l_blpapi_Element_getValueAsChar = ( + libblpapict.blpapi_Element_getValueAsChar +) # int +l_blpapi_Element_getValueAsElement = ( + libblpapict.blpapi_Element_getValueAsElement +) # int +l_blpapi_Element_getValueAsFloat32 = ( + libblpapict.blpapi_Element_getValueAsFloat32 +) # int +l_blpapi_Element_getValueAsFloat64 = ( + libblpapict.blpapi_Element_getValueAsFloat64 +) # int +l_blpapi_Element_getValueAsHighPrecisionDatetime = ( + libblpapict.blpapi_Element_getValueAsHighPrecisionDatetime +) # int +l_blpapi_Element_getValueAsInt32 = ( + libblpapict.blpapi_Element_getValueAsInt32 +) # int +l_blpapi_Element_getValueAsInt64 = ( + libblpapict.blpapi_Element_getValueAsInt64 +) # int +l_blpapi_Element_getValueAsName = ( + libblpapict.blpapi_Element_getValueAsName +) # int +l_blpapi_Element_getValueAsString = ( + libblpapict.blpapi_Element_getValueAsString +) # int +l_blpapi_Element_hasElementEx = libblpapict.blpapi_Element_hasElementEx # int +l_blpapi_Element_isArray = libblpapict.blpapi_Element_isArray # int +l_blpapi_Element_isComplexType = ( + libblpapict.blpapi_Element_isComplexType +) # int +l_blpapi_Element_isNull = libblpapict.blpapi_Element_isNull # int +l_blpapi_Element_isNullValue = libblpapict.blpapi_Element_isNullValue # int +l_blpapi_Element_isReadOnly = libblpapict.blpapi_Element_isReadOnly # int +l_blpapi_Element_name = libblpapict.blpapi_Element_name +l_blpapi_Element_name.restype = c_void_p +l_blpapi_Element_numElements = libblpapict.blpapi_Element_numElements +l_blpapi_Element_numElements.restype = c_size_t +l_blpapi_Element_numValues = libblpapict.blpapi_Element_numValues +l_blpapi_Element_numValues.restype = c_size_t +l_blpapi_Element_print = libblpapict.blpapi_Element_print # int +l_blpapi_Element_setChoice = libblpapict.blpapi_Element_setChoice # int +l_blpapi_Element_setElementBool = ( + libblpapict.blpapi_Element_setElementBool +) # int +l_blpapi_Element_setElementBytes = ( + libblpapict.blpapi_Element_setElementBytes +) # int +l_blpapi_Element_setElementFloat32 = ( + libblpapict.blpapi_Element_setElementFloat32 +) # int +l_blpapi_Element_setElementFloat64 = ( + libblpapict.blpapi_Element_setElementFloat64 +) # int +l_blpapi_Element_setElementFromName = ( + libblpapict.blpapi_Element_setElementFromName +) # int +l_blpapi_Element_setElementHighPrecisionDatetime = ( + libblpapict.blpapi_Element_setElementHighPrecisionDatetime +) # int +l_blpapi_Element_setElementInt32 = ( + libblpapict.blpapi_Element_setElementInt32 +) # int +l_blpapi_Element_setElementInt64 = ( + libblpapict.blpapi_Element_setElementInt64 +) # int +l_blpapi_Element_setElementString = ( + libblpapict.blpapi_Element_setElementString +) # int +l_blpapi_Element_setValueBool = libblpapict.blpapi_Element_setValueBool # int +l_blpapi_Element_setValueBytes = ( + libblpapict.blpapi_Element_setValueBytes +) # int +l_blpapi_Element_setValueFloat32 = ( + libblpapict.blpapi_Element_setValueFloat32 +) # int +l_blpapi_Element_setValueFloat64 = ( + libblpapict.blpapi_Element_setValueFloat64 +) # int +l_blpapi_Element_setValueFromName = ( + libblpapict.blpapi_Element_setValueFromName +) # int +l_blpapi_Element_setValueHighPrecisionDatetime = ( + libblpapict.blpapi_Element_setValueHighPrecisionDatetime +) # int +l_blpapi_Element_setValueInt32 = ( + libblpapict.blpapi_Element_setValueInt32 +) # int +l_blpapi_Element_setValueInt64 = ( + libblpapict.blpapi_Element_setValueInt64 +) # int +l_blpapi_Element_setValueString = ( + libblpapict.blpapi_Element_setValueString +) # int + +l_blpapi_Event_eventType = libblpapict.blpapi_Event_eventType # int +l_blpapi_Event_release = libblpapict.blpapi_Event_release # int + +l_blpapi_EventDispatcher_create = libblpapict.blpapi_EventDispatcher_create +l_blpapi_EventDispatcher_create.restype = c_void_p +l_blpapi_EventDispatcher_destroy = libblpapict.blpapi_EventDispatcher_destroy +l_blpapi_EventDispatcher_destroy.restype = None +l_blpapi_EventDispatcher_start = ( + libblpapict.blpapi_EventDispatcher_start +) # int +l_blpapi_EventDispatcher_stop = libblpapict.blpapi_EventDispatcher_stop # int + +l_blpapi_EventFormatter_appendElement = ( + libblpapict.blpapi_EventFormatter_appendElement +) # int +l_blpapi_EventFormatter_appendFragmentedRecapMessage = ( + libblpapict.blpapi_EventFormatter_appendFragmentedRecapMessage +) # int +l_blpapi_EventFormatter_appendFragmentedRecapMessage.argtypes = [ + c_void_p, + c_char_p, + c_void_p, + c_void_p, + c_void_p, + c_int, +] +l_blpapi_EventFormatter_appendFragmentedRecapMessageSeq = ( + libblpapict.blpapi_EventFormatter_appendFragmentedRecapMessageSeq +) # int +l_blpapi_EventFormatter_appendFragmentedRecapMessageSeq.argtypes = [ + c_void_p, + c_char_p, + c_void_p, + c_void_p, + c_int, + c_uint, +] +l_blpapi_EventFormatter_appendMessage = ( + libblpapict.blpapi_EventFormatter_appendMessage +) # int +l_blpapi_EventFormatter_appendMessageSeq = ( + libblpapict.blpapi_EventFormatter_appendMessageSeq +) # int +l_blpapi_EventFormatter_appendRecapMessage = ( + libblpapict.blpapi_EventFormatter_appendRecapMessage +) # int +l_blpapi_EventFormatter_appendRecapMessageSeq = ( + libblpapict.blpapi_EventFormatter_appendRecapMessageSeq +) # int +l_blpapi_EventFormatter_appendResponse = ( + libblpapict.blpapi_EventFormatter_appendResponse +) # int +l_blpapi_EventFormatter_appendValueBool = ( + libblpapict.blpapi_EventFormatter_appendValueBool +) # int +l_blpapi_EventFormatter_appendValueChar = ( + libblpapict.blpapi_EventFormatter_appendValueChar +) # int +l_blpapi_EventFormatter_appendValueDatetime = ( + libblpapict.blpapi_EventFormatter_appendValueDatetime +) # int +l_blpapi_EventFormatter_appendValueFloat32 = ( + libblpapict.blpapi_EventFormatter_appendValueFloat32 +) # int +l_blpapi_EventFormatter_appendValueFloat64 = ( + libblpapict.blpapi_EventFormatter_appendValueFloat64 +) # int +l_blpapi_EventFormatter_appendValueFromName = ( + libblpapict.blpapi_EventFormatter_appendValueFromName +) # int +l_blpapi_EventFormatter_appendValueInt32 = ( + libblpapict.blpapi_EventFormatter_appendValueInt32 +) # int +l_blpapi_EventFormatter_appendValueInt64 = ( + libblpapict.blpapi_EventFormatter_appendValueInt64 +) # int +l_blpapi_EventFormatter_appendValueString = ( + libblpapict.blpapi_EventFormatter_appendValueString +) # int +l_blpapi_EventFormatter_create = libblpapict.blpapi_EventFormatter_create +l_blpapi_EventFormatter_create.restype = c_void_p +l_blpapi_EventFormatter_destroy = libblpapict.blpapi_EventFormatter_destroy +l_blpapi_EventFormatter_destroy.restype = None +l_blpapi_EventFormatter_popElement = ( + libblpapict.blpapi_EventFormatter_popElement +) # int +l_blpapi_EventFormatter_pushElement = ( + libblpapict.blpapi_EventFormatter_pushElement +) # int +l_blpapi_EventFormatter_setValueBool = ( + libblpapict.blpapi_EventFormatter_setValueBool +) # int +l_blpapi_EventFormatter_setValueBytes = ( + libblpapict.blpapi_EventFormatter_setValueBytes +) # int +l_blpapi_EventFormatter_setValueChar = ( + libblpapict.blpapi_EventFormatter_setValueChar +) # int +l_blpapi_EventFormatter_setValueDatetime = ( + libblpapict.blpapi_EventFormatter_setValueDatetime +) # int +l_blpapi_EventFormatter_setValueFloat32 = ( + libblpapict.blpapi_EventFormatter_setValueFloat32 +) # int +l_blpapi_EventFormatter_setValueFloat64 = ( + libblpapict.blpapi_EventFormatter_setValueFloat64 +) # int +l_blpapi_EventFormatter_setValueFromName = ( + libblpapict.blpapi_EventFormatter_setValueFromName +) # int +l_blpapi_EventFormatter_setValueHighPrecisionDatetime = ( + libblpapict.blpapi_EventFormatter_setValueHighPrecisionDatetime +) # int +l_blpapi_EventFormatter_appendValueHighPrecisionDatetime = ( + libblpapict.blpapi_EventFormatter_appendValueHighPrecisionDatetime +) # int +l_blpapi_EventFormatter_setValueInt32 = ( + libblpapict.blpapi_EventFormatter_setValueInt32 +) # int +l_blpapi_EventFormatter_setValueInt64 = ( + libblpapict.blpapi_EventFormatter_setValueInt64 +) # int +l_blpapi_EventFormatter_setValueNull = ( + libblpapict.blpapi_EventFormatter_setValueNull +) # int +l_blpapi_EventFormatter_setValueString = ( + libblpapict.blpapi_EventFormatter_setValueString +) # int + +l_blpapi_EventQueue_create = libblpapict.blpapi_EventQueue_create +l_blpapi_EventQueue_create.restype = c_void_p +l_blpapi_EventQueue_destroy = libblpapict.blpapi_EventQueue_destroy # int +l_blpapi_EventQueue_nextEvent = libblpapict.blpapi_EventQueue_nextEvent +l_blpapi_EventQueue_nextEvent.restype = c_void_p +l_blpapi_EventQueue_purge = libblpapict.blpapi_EventQueue_purge # int +l_blpapi_EventQueue_tryNextEvent = ( + libblpapict.blpapi_EventQueue_tryNextEvent +) # int + +l_blpapi_HighPrecisionDatetime_fromTimePoint = ( + libblpapict.blpapi_HighPrecisionDatetime_fromTimePoint +) # int + +l_blpapi_HighResolutionClock_now = ( + libblpapict.blpapi_HighResolutionClock_now +) # int + +l_blpapi_Identity_getSeatType = libblpapict.blpapi_Identity_getSeatType # int +l_blpapi_Identity_hasEntitlements = ( + libblpapict.blpapi_Identity_hasEntitlements +) # int +l_blpapi_Identity_isAuthorized = ( + libblpapict.blpapi_Identity_isAuthorized +) # int +l_blpapi_Identity_release = libblpapict.blpapi_Identity_release +l_blpapi_Identity_release.restype = None + +l_blpapi_Logging_logTestMessage = libblpapict.blpapi_Logging_logTestMessage +l_blpapi_Logging_logTestMessage.restype = None +l_blpapi_Logging_registerCallback = ( + libblpapict.blpapi_Logging_registerCallback +) # int + +l_blpapi_MessageFormatter_FormatMessageJson = ( + libblpapict.blpapi_MessageFormatter_FormatMessageJson +) # int +l_blpapi_MessageFormatter_FormatMessageXml = ( + libblpapict.blpapi_MessageFormatter_FormatMessageXml +) # int +l_blpapi_MessageFormatter_appendElement = ( + libblpapict.blpapi_MessageFormatter_appendElement +) # int +l_blpapi_MessageFormatter_appendValueBool = ( + libblpapict.blpapi_MessageFormatter_appendValueBool +) # int +l_blpapi_MessageFormatter_appendValueChar = ( + libblpapict.blpapi_MessageFormatter_appendValueChar +) # int +l_blpapi_MessageFormatter_appendValueDatetime = ( + libblpapict.blpapi_MessageFormatter_appendValueDatetime +) # int +l_blpapi_MessageFormatter_appendValueFloat32 = ( + libblpapict.blpapi_MessageFormatter_appendValueFloat32 +) # int +l_blpapi_MessageFormatter_appendValueFloat64 = ( + libblpapict.blpapi_MessageFormatter_appendValueFloat64 +) # int +l_blpapi_MessageFormatter_appendValueFromName = ( + libblpapict.blpapi_MessageFormatter_appendValueFromName +) # int +l_blpapi_MessageFormatter_appendValueHighPrecisionDatetime = ( + libblpapict.blpapi_MessageFormatter_appendValueHighPrecisionDatetime +) # int +l_blpapi_MessageFormatter_appendValueInt32 = ( + libblpapict.blpapi_MessageFormatter_appendValueInt32 +) # int +l_blpapi_MessageFormatter_appendValueInt64 = ( + libblpapict.blpapi_MessageFormatter_appendValueInt64 +) # int +l_blpapi_MessageFormatter_appendValueString = ( + libblpapict.blpapi_MessageFormatter_appendValueString +) # int +l_blpapi_MessageFormatter_destroy = ( + libblpapict.blpapi_MessageFormatter_destroy +) # int +l_blpapi_MessageFormatter_popElement = ( + libblpapict.blpapi_MessageFormatter_popElement +) # int +l_blpapi_MessageFormatter_pushElement = ( + libblpapict.blpapi_MessageFormatter_pushElement +) # int +l_blpapi_MessageFormatter_setValueBool = ( + libblpapict.blpapi_MessageFormatter_setValueBool +) # int +l_blpapi_MessageFormatter_setValueBytes = ( + libblpapict.blpapi_MessageFormatter_setValueBytes +) # int +l_blpapi_MessageFormatter_setValueChar = ( + libblpapict.blpapi_MessageFormatter_setValueBool +) # int +l_blpapi_MessageFormatter_setValueDatetime = ( + libblpapict.blpapi_MessageFormatter_setValueDatetime +) # int +l_blpapi_MessageFormatter_setValueFloat32 = ( + libblpapict.blpapi_MessageFormatter_setValueFloat32 +) # int +l_blpapi_MessageFormatter_setValueFloat64 = ( + libblpapict.blpapi_MessageFormatter_setValueFloat64 +) # int +l_blpapi_MessageFormatter_setValueFromName = ( + libblpapict.blpapi_MessageFormatter_setValueFromName +) # int +l_blpapi_MessageFormatter_setValueHighPrecisionDatetime = ( + libblpapict.blpapi_MessageFormatter_setValueHighPrecisionDatetime +) # int +l_blpapi_MessageFormatter_setValueInt32 = ( + libblpapict.blpapi_MessageFormatter_setValueInt32 +) # int +l_blpapi_MessageFormatter_setValueInt64 = ( + libblpapict.blpapi_MessageFormatter_setValueInt64 +) # int +l_blpapi_MessageFormatter_setValueNull = ( + libblpapict.blpapi_MessageFormatter_setValueNull +) # int +l_blpapi_MessageFormatter_setValueString = ( + libblpapict.blpapi_MessageFormatter_setValueString +) # int + +l_blpapi_MessageIterator_create = libblpapict.blpapi_MessageIterator_create +l_blpapi_MessageIterator_create.restype = c_void_p +l_blpapi_MessageIterator_destroy = libblpapict.blpapi_MessageIterator_destroy +l_blpapi_MessageIterator_destroy.restype = None +l_blpapi_MessageIterator_next = libblpapict.blpapi_MessageIterator_next # int + +l_blpapi_Message_addRef = libblpapict.blpapi_Message_addRef # int +l_blpapi_Message_correlationId = libblpapict.blpapi_Message_correlationId +l_blpapi_Message_correlationId.restype = CidStruct +l_blpapi_Message_elements = libblpapict.blpapi_Message_elements +l_blpapi_Message_elements.restype = c_void_p +l_blpapi_Message_fragmentType = libblpapict.blpapi_Message_fragmentType # int +l_blpapi_Message_getRequestId = libblpapict.blpapi_Message_getRequestId # int +l_blpapi_Message_messageType = libblpapict.blpapi_Message_messageType +l_blpapi_Message_messageType.restype = c_void_p +l_blpapi_Message_numCorrelationIds = ( + libblpapict.blpapi_Message_numCorrelationIds +) # int +l_blpapi_Message_print = libblpapict.blpapi_Message_print # int +l_blpapi_Message_recapType = libblpapict.blpapi_Message_recapType # int +l_blpapi_Message_release = libblpapict.blpapi_Message_release # int +l_blpapi_Message_service = libblpapict.blpapi_Message_service +l_blpapi_Message_service.restype = c_void_p +l_blpapi_Message_timeReceived = libblpapict.blpapi_Message_timeReceived # int + +l_blpapi_MessageProperties_create = ( + libblpapict.blpapi_MessageProperties_create +) # int +l_blpapi_MessageProperties_destroy = ( + libblpapict.blpapi_MessageProperties_destroy +) +l_blpapi_MessageProperties_destroy.restype = None +l_blpapi_MessageProperties_setCorrelationIds = ( + libblpapict.blpapi_MessageProperties_setCorrelationIds +) # int +l_blpapi_MessageProperties_setRecapType = ( + libblpapict.blpapi_MessageProperties_setRecapType +) # int +l_blpapi_MessageProperties_setRequestId = ( + libblpapict.blpapi_MessageProperties_setRequestId +) # int +l_blpapi_MessageProperties_setService = ( + libblpapict.blpapi_MessageProperties_setService +) # int +l_blpapi_MessageProperties_setTimeReceived = ( + libblpapict.blpapi_MessageProperties_setTimeReceived +) # int + +l_blpapi_Name_create = libblpapict.blpapi_Name_create +l_blpapi_Name_create.restype = c_void_p +l_blpapi_Name_destroy = libblpapict.blpapi_Name_destroy +l_blpapi_Name_destroy.restype = None +l_blpapi_Name_equalsStr = libblpapict.blpapi_Name_equalsStr # int +l_blpapi_Name_findName = libblpapict.blpapi_Name_findName +l_blpapi_Name_findName.restype = c_void_p +l_blpapi_Name_length = libblpapict.blpapi_Name_length +l_blpapi_Name_length.restype = c_size_t +l_blpapi_Name_string = libblpapict.blpapi_Name_string +l_blpapi_Name_string.restype = c_char_p + +l_blpapi_Operation_description = libblpapict.blpapi_Operation_description +l_blpapi_Operation_description.restype = c_char_p +l_blpapi_Operation_name = libblpapict.blpapi_Operation_name +l_blpapi_Operation_name.restype = c_char_p +l_blpapi_Operation_numResponseDefinitions = ( + libblpapict.blpapi_Operation_numResponseDefinitions +) # int +l_blpapi_Operation_requestDefinition = ( + libblpapict.blpapi_Operation_requestDefinition +) # int +l_blpapi_Operation_responseDefinition = ( + libblpapict.blpapi_Operation_responseDefinition +) # int + +l_blpapi_ProviderSession_activateSubServiceCodeRange = ( + libblpapict.blpapi_ProviderSession_activateSubServiceCodeRange +) # int +l_blpapi_ProviderSession_create = libblpapict.blpapi_ProviderSession_create +l_blpapi_ProviderSession_create.restype = c_void_p +l_blpapi_ProviderSession_createTopics = ( + libblpapict.blpapi_ProviderSession_createTopics +) # int +l_blpapi_ProviderSession_createTopicsAsync = ( + libblpapict.blpapi_ProviderSession_createTopicsAsync +) # int +l_blpapi_ProviderSession_createServiceStatusTopic = ( + libblpapict.blpapi_ProviderSession_createServiceStatusTopic +) # int +l_blpapi_ProviderSession_deactivateSubServiceCodeRange = ( + libblpapict.blpapi_ProviderSession_deactivateSubServiceCodeRange +) # int +l_blpapi_ProviderSession_deleteTopics = ( + libblpapict.blpapi_ProviderSession_deleteTopics +) # int +l_blpapi_ProviderSession_deregisterService = ( + libblpapict.blpapi_ProviderSession_deregisterService +) # int +l_blpapi_ProviderSession_destroy = libblpapict.blpapi_ProviderSession_destroy +l_blpapi_ProviderSession_destroy.restype = None +l_blpapi_ProviderSession_flushPublishedEvents = ( + libblpapict.blpapi_ProviderSession_flushPublishedEvents +) # int +l_blpapi_ProviderSession_getAbstractSession = ( + libblpapict.blpapi_ProviderSession_getAbstractSession +) +l_blpapi_ProviderSession_getAbstractSession.restype = c_void_p +l_blpapi_ProviderSession_getTopic = ( + libblpapict.blpapi_ProviderSession_getTopic +) # int +l_blpapi_ProviderSession_nextEvent = ( + libblpapict.blpapi_ProviderSession_nextEvent +) # int +l_blpapi_ProviderSession_publish = ( + libblpapict.blpapi_ProviderSession_publish +) # int +l_blpapi_ProviderSession_registerService = ( + libblpapict.blpapi_ProviderSession_registerService +) # int +l_blpapi_ProviderSession_registerServiceAsync = ( + libblpapict.blpapi_ProviderSession_registerServiceAsync +) # int +l_blpapi_ProviderSession_resolve = ( + libblpapict.blpapi_ProviderSession_resolve +) # int +l_blpapi_ProviderSession_resolveAsync = ( + libblpapict.blpapi_ProviderSession_resolveAsync +) # int +l_blpapi_ProviderSession_sendResponse = ( + libblpapict.blpapi_ProviderSession_sendResponse +) # int +l_blpapi_ProviderSession_start = ( + libblpapict.blpapi_ProviderSession_start +) # int +l_blpapi_ProviderSession_startAsync = ( + libblpapict.blpapi_ProviderSession_startAsync +) # int +l_blpapi_ProviderSession_stop = libblpapict.blpapi_ProviderSession_stop # int +l_blpapi_ProviderSession_stopAsync = ( + libblpapict.blpapi_ProviderSession_stopAsync +) # int +l_blpapi_ProviderSession_terminateSubscriptionsOnTopics = ( + libblpapict.blpapi_ProviderSession_terminateSubscriptionsOnTopics +) # int +l_blpapi_ProviderSession_tryNextEvent = ( + libblpapict.blpapi_ProviderSession_tryNextEvent +) # int + +l_blpapi_RequestTemplate_release = ( + libblpapict.blpapi_RequestTemplate_release +) # int + +l_blpapi_Request_destroy = libblpapict.blpapi_Request_destroy +l_blpapi_Request_destroy.restype = None +l_blpapi_Request_elements = libblpapict.blpapi_Request_elements +l_blpapi_Request_elements.restype = c_void_p +l_blpapi_Request_getRequestId = libblpapict.blpapi_Request_getRequestId # int + +l_blpapi_ResolutionList_extractAttributeFromResolutionSuccess = ( + libblpapict.blpapi_ResolutionList_extractAttributeFromResolutionSuccess +) +l_blpapi_ResolutionList_extractAttributeFromResolutionSuccess.restype = ( + c_void_p +) + +l_blpapi_ResolutionList_create = libblpapict.blpapi_ResolutionList_create +l_blpapi_ResolutionList_create.restype = c_void_p + +l_blpapi_ResolutionList_destroy = libblpapict.blpapi_ResolutionList_destroy +l_blpapi_ResolutionList_destroy.restype = None +l_blpapi_ResolutionList_add = libblpapict.blpapi_ResolutionList_add # int +l_blpapi_ResolutionList_addFromMessage = ( + libblpapict.blpapi_ResolutionList_addFromMessage +) # int +l_blpapi_ResolutionList_addAttribute = ( + libblpapict.blpapi_ResolutionList_addAttribute +) # int +l_blpapi_ResolutionList_correlationIdAt = ( + libblpapict.blpapi_ResolutionList_correlationIdAt +) # int +l_blpapi_ResolutionList_topicString = ( + libblpapict.blpapi_ResolutionList_topicString +) # int +l_blpapi_ResolutionList_topicStringAt = ( + libblpapict.blpapi_ResolutionList_topicStringAt +) # int +l_blpapi_ResolutionList_status = ( + libblpapict.blpapi_ResolutionList_status +) # int +l_blpapi_ResolutionList_statusAt = ( + libblpapict.blpapi_ResolutionList_statusAt +) # int +l_blpapi_ResolutionList_attribute = ( + libblpapict.blpapi_ResolutionList_attribute +) # int +l_blpapi_ResolutionList_attributeAt = ( + libblpapict.blpapi_ResolutionList_attributeAt +) # int +l_blpapi_ResolutionList_message = ( + libblpapict.blpapi_ResolutionList_message +) # int +l_blpapi_ResolutionList_messageAt = ( + libblpapict.blpapi_ResolutionList_messageAt +) # int +l_blpapi_ResolutionList_size = libblpapict.blpapi_ResolutionList_size # int + +l_blpapi_SchemaElementDefinition_description = ( + libblpapict.blpapi_SchemaElementDefinition_description +) +l_blpapi_SchemaElementDefinition_description.restype = c_char_p +l_blpapi_SchemaElementDefinition_getAlternateName = ( + libblpapict.blpapi_SchemaElementDefinition_getAlternateName +) +l_blpapi_SchemaElementDefinition_getAlternateName.restype = c_void_p +l_blpapi_SchemaElementDefinition_name = ( + libblpapict.blpapi_SchemaElementDefinition_name +) +l_blpapi_SchemaElementDefinition_name.restype = c_void_p +l_blpapi_SchemaElementDefinition_print = ( + libblpapict.blpapi_SchemaElementDefinition_print +) # int +l_blpapi_SchemaElementDefinition_status = ( + libblpapict.blpapi_SchemaElementDefinition_status +) # int +l_blpapi_SchemaElementDefinition_type = ( + libblpapict.blpapi_SchemaElementDefinition_type +) +l_blpapi_SchemaElementDefinition_type.restype = c_void_p + +l_blpapi_SchemaTypeDefinition_datatype = ( + libblpapict.blpapi_SchemaTypeDefinition_datatype +) # int +l_blpapi_SchemaTypeDefinition_description = ( + libblpapict.blpapi_SchemaTypeDefinition_description +) +l_blpapi_SchemaTypeDefinition_description.restype = c_char_p +l_blpapi_SchemaTypeDefinition_isComplexType = ( + libblpapict.blpapi_SchemaTypeDefinition_isComplexType +) +l_blpapi_SchemaTypeDefinition_enumeration = ( + libblpapict.blpapi_SchemaTypeDefinition_enumeration +) +l_blpapi_SchemaTypeDefinition_enumeration.restype = c_void_p +l_blpapi_SchemaTypeDefinition_getElementDefinition = ( + libblpapict.blpapi_SchemaTypeDefinition_getElementDefinition +) +l_blpapi_SchemaTypeDefinition_getElementDefinition.restype = c_void_p +l_blpapi_SchemaTypeDefinition_getElementDefinitionAt = ( + libblpapict.blpapi_SchemaTypeDefinition_getElementDefinitionAt +) +l_blpapi_SchemaTypeDefinition_getElementDefinitionAt.restype = c_void_p +l_blpapi_SchemaTypeDefinition_isComplexType = ( + libblpapict.blpapi_SchemaTypeDefinition_isComplexType +) # int +l_blpapi_SchemaTypeDefinition_isEnumerationType = ( + libblpapict.blpapi_SchemaTypeDefinition_isEnumerationType +) # int +l_blpapi_SchemaTypeDefinition_isSimpleType = ( + libblpapict.blpapi_SchemaTypeDefinition_isSimpleType +) # int +l_blpapi_SchemaElementDefinition_maxValues = ( + libblpapict.blpapi_SchemaElementDefinition_maxValues +) +l_blpapi_SchemaElementDefinition_maxValues.restype = c_size_t +l_blpapi_SchemaElementDefinition_minValues = ( + libblpapict.blpapi_SchemaElementDefinition_minValues +) +l_blpapi_SchemaElementDefinition_minValues.restype = c_size_t +l_blpapi_SchemaElementDefinition_numAlternateNames = ( + libblpapict.blpapi_SchemaElementDefinition_numAlternateNames +) +l_blpapi_SchemaElementDefinition_numAlternateNames.restype = c_size_t +l_blpapi_SchemaTypeDefinition_name = ( + libblpapict.blpapi_SchemaTypeDefinition_name +) +l_blpapi_SchemaTypeDefinition_name.restype = c_void_p +l_blpapi_SchemaTypeDefinition_numElementDefinitions = ( + libblpapict.blpapi_SchemaTypeDefinition_numElementDefinitions +) +l_blpapi_SchemaTypeDefinition_numElementDefinitions.restype = c_size_t +l_blpapi_SchemaTypeDefinition_print = ( + libblpapict.blpapi_SchemaTypeDefinition_print +) # int +l_blpapi_SchemaTypeDefinition_status = ( + libblpapict.blpapi_SchemaTypeDefinition_status +) # int + +l_blpapi_Service_addRef = libblpapict.blpapi_Service_addRef # int +l_blpapi_Service_authorizationServiceName = ( + libblpapict.blpapi_Service_authorizationServiceName +) +l_blpapi_Service_authorizationServiceName.restype = c_char_p +l_blpapi_Service_createAdminEvent = ( + libblpapict.blpapi_Service_createAdminEvent +) # int +l_blpapi_Service_createAuthorizationRequest = ( + libblpapict.blpapi_Service_createAuthorizationRequest +) # int +l_blpapi_Service_createPublishEvent = ( + libblpapict.blpapi_Service_createPublishEvent +) # int +l_blpapi_Service_createRequest = ( + libblpapict.blpapi_Service_createRequest +) # int +l_blpapi_Service_createResponseEvent = ( + libblpapict.blpapi_Service_createResponseEvent +) # int +l_blpapi_Service_description = libblpapict.blpapi_Service_description +l_blpapi_Service_description.restype = c_char_p +l_blpapi_Service_getEventDefinition = ( + libblpapict.blpapi_Service_getEventDefinition +) # int +l_blpapi_Service_getEventDefinitionAt = ( + libblpapict.blpapi_Service_getEventDefinitionAt +) # int +l_blpapi_Service_getOperation = libblpapict.blpapi_Service_getOperation # int +l_blpapi_Service_getOperationAt = ( + libblpapict.blpapi_Service_getOperationAt +) # int +l_blpapi_Service_name = libblpapict.blpapi_Service_name +l_blpapi_Service_name.restype = c_char_p +l_blpapi_Service_numEventDefinitions = ( + libblpapict.blpapi_Service_numEventDefinitions +) # int +l_blpapi_Service_numOperations = ( + libblpapict.blpapi_Service_numOperations +) # int +l_blpapi_Service_print = libblpapict.blpapi_Service_print # int +l_blpapi_Service_release = libblpapict.blpapi_Service_release +l_blpapi_Service_release.restype = None + +l_blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange = ( + libblpapict.blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange +) # int +l_blpapi_ServiceRegistrationOptions_create = ( + libblpapict.blpapi_ServiceRegistrationOptions_create +) +l_blpapi_ServiceRegistrationOptions_create.restype = c_void_p +l_blpapi_ServiceRegistrationOptions_destroy = ( + libblpapict.blpapi_ServiceRegistrationOptions_destroy +) +l_blpapi_ServiceRegistrationOptions_destroy.restype = None +l_blpapi_ServiceRegistrationOptions_getGroupId = ( + libblpapict.blpapi_ServiceRegistrationOptions_getGroupId +) # int +l_blpapi_ServiceRegistrationOptions_getGroupId.argtypes = [ + c_void_p, + c_char_p, + POINTER(c_int), +] +l_blpapi_ServiceRegistrationOptions_getServicePriority = ( + libblpapict.blpapi_ServiceRegistrationOptions_getServicePriority +) # int +l_blpapi_ServiceRegistrationOptions_setGroupId = ( + libblpapict.blpapi_ServiceRegistrationOptions_setGroupId +) +l_blpapi_ServiceRegistrationOptions_setGroupId.restype = None +l_blpapi_ServiceRegistrationOptions_getPartsToRegister = ( + libblpapict.blpapi_ServiceRegistrationOptions_getPartsToRegister +) # int +l_blpapi_ServiceRegistrationOptions_setPartsToRegister = ( + libblpapict.blpapi_ServiceRegistrationOptions_setPartsToRegister +) +l_blpapi_ServiceRegistrationOptions_setPartsToRegister.restype = None +l_blpapi_ServiceRegistrationOptions_setServicePriority = ( + libblpapict.blpapi_ServiceRegistrationOptions_setServicePriority +) # int +l_blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges = ( + libblpapict.blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges +) +l_blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges.restype = ( + None +) + +l_blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg = ( + libblpapict.blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg +) # int +l_blpapi_SessionOptions_applicationIdentityKey = ( + libblpapict.blpapi_SessionOptions_applicationIdentityKey +) # int +l_blpapi_SessionOptions_authenticationOptions = ( + libblpapict.blpapi_SessionOptions_authenticationOptions +) +l_blpapi_SessionOptions_authenticationOptions.restype = c_char_p +l_blpapi_SessionOptions_autoRestartOnDisconnection = ( + libblpapict.blpapi_SessionOptions_autoRestartOnDisconnection +) # int +l_blpapi_SessionOptions_bandwidthSaveModeDisabled = ( + libblpapict.blpapi_SessionOptions_bandwidthSaveModeDisabled +) # int +l_blpapi_SessionOptions_clientMode = ( + libblpapict.blpapi_SessionOptions_clientMode +) # int +l_blpapi_SessionOptions_connectTimeout = ( + libblpapict.blpapi_SessionOptions_connectTimeout +) +l_blpapi_SessionOptions_connectTimeout.restype = c_uint32 +l_blpapi_SessionOptions_create = libblpapict.blpapi_SessionOptions_create +l_blpapi_SessionOptions_create.restype = c_void_p +l_blpapi_SessionOptions_defaultKeepAliveInactivityTime = ( + libblpapict.blpapi_SessionOptions_defaultKeepAliveInactivityTime +) # int +l_blpapi_SessionOptions_defaultKeepAliveResponseTimeout = ( + libblpapict.blpapi_SessionOptions_defaultKeepAliveResponseTimeout +) # int +l_blpapi_SessionOptions_defaultServices = ( + libblpapict.blpapi_SessionOptions_defaultServices +) +l_blpapi_SessionOptions_defaultServices.restype = c_char_p +l_blpapi_SessionOptions_defaultSubscriptionService = ( + libblpapict.blpapi_SessionOptions_defaultSubscriptionService +) +l_blpapi_SessionOptions_defaultSubscriptionService.restype = c_char_p +l_blpapi_SessionOptions_defaultTopicPrefix = ( + libblpapict.blpapi_SessionOptions_defaultTopicPrefix +) +l_blpapi_SessionOptions_defaultTopicPrefix.restype = c_char_p +l_blpapi_SessionOptions_destroy = libblpapict.blpapi_SessionOptions_destroy +l_blpapi_SessionOptions_destroy.restype = None +l_blpapi_SessionOptions_flushPublishedEventsTimeout = ( + libblpapict.blpapi_SessionOptions_flushPublishedEventsTimeout +) # int +l_blpapi_SessionOptions_getServerAddressWithProxy = ( + libblpapict.blpapi_SessionOptions_getServerAddressWithProxy +) # int +l_blpapi_SessionOptions_keepAliveEnabled = ( + libblpapict.blpapi_SessionOptions_keepAliveEnabled +) # int +l_blpapi_SessionOptions_maxEventQueueSize = ( + libblpapict.blpapi_SessionOptions_maxEventQueueSize +) +l_blpapi_SessionOptions_maxEventQueueSize.restype = c_size_t +l_blpapi_SessionOptions_maxPendingRequests = ( + libblpapict.blpapi_SessionOptions_maxPendingRequests +) # int +l_blpapi_SessionOptions_numServerAddresses = ( + libblpapict.blpapi_SessionOptions_numServerAddresses +) # int +l_blpapi_SessionOptions_numStartAttempts = ( + libblpapict.blpapi_SessionOptions_numStartAttempts +) # int +l_blpapi_SessionOptions_print = libblpapict.blpapi_SessionOptions_print # int +l_blpapi_SessionOptions_print.argtypes = [ + c_void_p, + c_void_p, + c_void_p, # as py_object it segfaults, we cast in any_printer instead + c_int, + c_int, +] +l_blpapi_SessionOptions_recordSubscriptionDataReceiveTimes = ( + libblpapict.blpapi_SessionOptions_recordSubscriptionDataReceiveTimes +) # int +l_blpapi_SessionOptions_removeServerAddress = ( + libblpapict.blpapi_SessionOptions_removeServerAddress +) # int +l_blpapi_SessionOptions_serverHost = ( + libblpapict.blpapi_SessionOptions_serverHost +) +l_blpapi_SessionOptions_serverHost.restype = c_char_p +l_blpapi_SessionOptions_serverPort = ( + libblpapict.blpapi_SessionOptions_serverPort +) +l_blpapi_SessionOptions_serverPort.restype = c_uint32 +l_blpapi_SessionOptions_serviceCheckTimeout = ( + libblpapict.blpapi_SessionOptions_serviceCheckTimeout +) # int +l_blpapi_SessionOptions_serviceDownloadTimeout = ( + libblpapict.blpapi_SessionOptions_serviceDownloadTimeout +) # int +l_blpapi_SessionOptions_sessionName = ( + libblpapict.blpapi_SessionOptions_sessionName +) # int +l_blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg = ( + libblpapict.blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg +) +l_blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg.restype = None +l_blpapi_SessionOptions_setApplicationIdentityKey = ( + libblpapict.blpapi_SessionOptions_setApplicationIdentityKey +) # int +l_blpapi_SessionOptions_setAuthenticationOptions = ( + libblpapict.blpapi_SessionOptions_setAuthenticationOptions +) +l_blpapi_SessionOptions_setAuthenticationOptions.restype = None +l_blpapi_SessionOptions_setAutoRestartOnDisconnection = ( + libblpapict.blpapi_SessionOptions_setAutoRestartOnDisconnection +) +l_blpapi_SessionOptions_setAutoRestartOnDisconnection.restype = None +l_blpapi_SessionOptions_setBandwidthSaveModeDisabled = ( + libblpapict.blpapi_SessionOptions_setBandwidthSaveModeDisabled +) # int +l_blpapi_SessionOptions_setClientMode = ( + libblpapict.blpapi_SessionOptions_setClientMode +) +l_blpapi_SessionOptions_setClientMode.restype = None +l_blpapi_SessionOptions_setConnectTimeout = ( + libblpapict.blpapi_SessionOptions_setConnectTimeout +) # int +l_blpapi_SessionOptions_setDefaultKeepAliveInactivityTime = ( + libblpapict.blpapi_SessionOptions_setDefaultKeepAliveInactivityTime +) # int +l_blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout = ( + libblpapict.blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout +) # int +l_blpapi_SessionOptions_setDefaultServices = ( + libblpapict.blpapi_SessionOptions_setDefaultServices +) # int +l_blpapi_SessionOptions_setDefaultSubscriptionService = ( + libblpapict.blpapi_SessionOptions_setDefaultSubscriptionService +) # int +l_blpapi_SessionOptions_setDefaultTopicPrefix = ( + libblpapict.blpapi_SessionOptions_setDefaultTopicPrefix +) +l_blpapi_SessionOptions_setDefaultTopicPrefix.restype = None +l_blpapi_SessionOptions_setFlushPublishedEventsTimeout = ( + libblpapict.blpapi_SessionOptions_setFlushPublishedEventsTimeout +) # int +l_blpapi_SessionOptions_setKeepAliveEnabled = ( + libblpapict.blpapi_SessionOptions_setKeepAliveEnabled +) # int +l_blpapi_SessionOptions_setMaxEventQueueSize = ( + libblpapict.blpapi_SessionOptions_setMaxEventQueueSize +) +l_blpapi_SessionOptions_setMaxEventQueueSize.restype = None +l_blpapi_SessionOptions_setMaxPendingRequests = ( + libblpapict.blpapi_SessionOptions_setMaxPendingRequests +) +l_blpapi_SessionOptions_setMaxPendingRequests.restype = None +l_blpapi_SessionOptions_setNumStartAttempts = ( + libblpapict.blpapi_SessionOptions_setNumStartAttempts +) +l_blpapi_SessionOptions_setNumStartAttempts.restype = None +l_blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes = ( + libblpapict.blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes +) +l_blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes.restype = None +l_blpapi_SessionOptions_setServerAddress = ( + libblpapict.blpapi_SessionOptions_setServerAddress +) # int +l_blpapi_SessionOptions_setServerAddressWithProxy = ( + libblpapict.blpapi_SessionOptions_setServerAddressWithProxy +) # int +l_blpapi_SessionOptions_setServerHost = ( + libblpapict.blpapi_SessionOptions_setServerHost +) # int +l_blpapi_SessionOptions_setServerPort = ( + libblpapict.blpapi_SessionOptions_setServerPort +) # int +l_blpapi_SessionOptions_setServiceCheckTimeout = ( + libblpapict.blpapi_SessionOptions_setServiceCheckTimeout +) # int +l_blpapi_SessionOptions_setServiceDownloadTimeout = ( + libblpapict.blpapi_SessionOptions_setServiceDownloadTimeout +) # int +l_blpapi_SessionOptions_setSessionIdentityOptions = ( + libblpapict.blpapi_SessionOptions_setSessionIdentityOptions +) # int +l_blpapi_SessionOptions_setSessionName = ( + libblpapict.blpapi_SessionOptions_setSessionName +) # int +l_blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark = ( + libblpapict.blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark +) # int +l_blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark = ( + libblpapict.blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark +) # int +l_blpapi_SessionOptions_setTlsOptions = ( + libblpapict.blpapi_SessionOptions_setTlsOptions +) +l_blpapi_SessionOptions_setTlsOptions.restype = None +l_blpapi_SessionOptions_slowConsumerWarningHiWaterMark = ( + libblpapict.blpapi_SessionOptions_slowConsumerWarningHiWaterMark +) +l_blpapi_SessionOptions_slowConsumerWarningHiWaterMark.restype = c_float +l_blpapi_SessionOptions_slowConsumerWarningLoWaterMark = ( + libblpapict.blpapi_SessionOptions_slowConsumerWarningLoWaterMark +) +l_blpapi_SessionOptions_slowConsumerWarningLoWaterMark.restype = c_float + +l_blpapi_Session_create = libblpapict.blpapi_Session_create +l_blpapi_Session_create.restype = c_void_p +l_blpapi_Session_createSnapshotRequestTemplate = ( + libblpapict.blpapi_Session_createSnapshotRequestTemplate +) # int +l_blpapi_Session_createSnapshotRequestTemplate.argtypes = [ + c_void_p, + c_void_p, + c_char_p, + c_void_p, + c_void_p, +] +l_blpapi_Session_destroy = libblpapict.blpapi_Session_destroy +l_blpapi_Session_destroy.restype = None +l_blpapi_Session_getAbstractSession = ( + libblpapict.blpapi_Session_getAbstractSession +) +l_blpapi_Session_getAbstractSession.restype = c_void_p +l_blpapi_Session_nextEvent = libblpapict.blpapi_Session_nextEvent # int +l_blpapi_Session_resubscribe = libblpapict.blpapi_Session_resubscribe # int +l_blpapi_Session_resubscribeEx = ( + libblpapict.blpapi_Session_resubscribeEx +) # int +l_blpapi_Session_resubscribeWithId = ( + libblpapict.blpapi_Session_resubscribeWithId +) # int +l_blpapi_Session_resubscribeWithIdEx = ( + libblpapict.blpapi_Session_resubscribeWithIdEx +) # int +l_blpapi_Session_sendRequest = libblpapict.blpapi_Session_sendRequest # int +l_blpapi_Session_sendRequestTemplate = ( + libblpapict.blpapi_Session_sendRequestTemplate +) # int +l_blpapi_Session_setStatusCorrelationId = ( + libblpapict.blpapi_Session_setStatusCorrelationId +) # int +l_blpapi_Session_start = libblpapict.blpapi_Session_start # int +l_blpapi_Session_startAsync = libblpapict.blpapi_Session_startAsync # int +l_blpapi_Session_stop = libblpapict.blpapi_Session_stop # int +l_blpapi_Session_stopAsync = libblpapict.blpapi_Session_stopAsync # int +l_blpapi_Session_subscribe = libblpapict.blpapi_Session_subscribe # int +l_blpapi_Session_subscribeEx = libblpapict.blpapi_Session_subscribeEx # int +l_blpapi_Session_tryNextEvent = libblpapict.blpapi_Session_tryNextEvent # int +l_blpapi_Session_unsubscribe = libblpapict.blpapi_Session_unsubscribe # int + +l_blpapi_Socks5Config_create = libblpapict.blpapi_Socks5Config_create +l_blpapi_Socks5Config_create.restype = c_void_p +l_blpapi_Socks5Config_destroy = libblpapict.blpapi_Socks5Config_destroy +l_blpapi_Socks5Config_destroy.restype = None +l_blpapi_Socks5Config_print = libblpapict.blpapi_Socks5Config_print # int + +l_blpapi_SubscriptionList_add = libblpapict.blpapi_SubscriptionList_add # int +l_blpapi_SubscriptionList_add.argtypes = [ + c_void_p, + c_char_p, + c_void_p, + c_void_p, + c_void_p, + c_size_t, + c_size_t, +] +l_blpapi_SubscriptionList_addResolved = ( + libblpapict.blpapi_SubscriptionList_addResolved +) # int +l_blpapi_SubscriptionList_append = ( + libblpapict.blpapi_SubscriptionList_append +) # int +l_blpapi_SubscriptionList_clear = ( + libblpapict.blpapi_SubscriptionList_clear +) # int +l_blpapi_SubscriptionList_correlationIdAt = ( + libblpapict.blpapi_SubscriptionList_correlationIdAt +) # int +l_blpapi_SubscriptionList_create = libblpapict.blpapi_SubscriptionList_create +l_blpapi_SubscriptionList_create.restype = c_void_p +l_blpapi_SubscriptionList_destroy = libblpapict.blpapi_SubscriptionList_destroy +l_blpapi_SubscriptionList_destroy.restype = None +l_blpapi_SubscriptionList_isResolvedAt = ( + libblpapict.blpapi_SubscriptionList_isResolvedAt +) # int +l_blpapi_SubscriptionList_size = ( + libblpapict.blpapi_SubscriptionList_size +) # int +l_blpapi_SubscriptionList_topicStringAt = ( + libblpapict.blpapi_SubscriptionList_topicStringAt +) # int + +l_blpapi_TestUtil_appendMessage = ( + libblpapict.blpapi_TestUtil_appendMessage +) # int +l_blpapi_TestUtil_createEvent = libblpapict.blpapi_TestUtil_createEvent # int +l_blpapi_TestUtil_createTopic = libblpapict.blpapi_TestUtil_createTopic # int +l_blpapi_TestUtil_deserializeService = ( + libblpapict.blpapi_TestUtil_deserializeService +) # int +l_blpapi_TestUtil_getAdminMessageDefinition = ( + libblpapict.blpapi_TestUtil_getAdminMessageDefinition +) # int +l_blpapi_TestUtil_serializeService = ( + libblpapict.blpapi_TestUtil_serializeService +) # int + +l_blpapi_TlsOptions_createFromBlobs = ( + libblpapict.blpapi_TlsOptions_createFromBlobs +) +l_blpapi_TlsOptions_createFromBlobs.restype = c_void_p +l_blpapi_TlsOptions_createFromFiles = ( + libblpapict.blpapi_TlsOptions_createFromFiles +) +l_blpapi_TlsOptions_createFromFiles.restype = c_void_p +l_blpapi_TlsOptions_destroy = libblpapict.blpapi_TlsOptions_destroy +l_blpapi_TlsOptions_destroy.restype = None +l_blpapi_TlsOptions_setCrlFetchTimeoutMs = ( + libblpapict.blpapi_TlsOptions_setCrlFetchTimeoutMs +) +l_blpapi_TlsOptions_setCrlFetchTimeoutMs.restype = None +l_blpapi_TlsOptions_setTlsHandshakeTimeoutMs = ( + libblpapict.blpapi_TlsOptions_setTlsHandshakeTimeoutMs +) +l_blpapi_TlsOptions_setTlsHandshakeTimeoutMs.restype = None + +l_blpapi_Topic_compare = libblpapict.blpapi_Topic_compare # int +l_blpapi_Topic_destroy = libblpapict.blpapi_Topic_destroy +l_blpapi_Topic_destroy.restype = None +l_blpapi_Topic_isActive = libblpapict.blpapi_Topic_isActive # int +l_blpapi_Topic_service = libblpapict.blpapi_Topic_service +l_blpapi_Topic_service.restype = c_void_p + +l_blpapi_TopicList_add = libblpapict.blpapi_TopicList_add # int +l_blpapi_TopicList_addFromMessage = ( + libblpapict.blpapi_TopicList_addFromMessage +) # int +l_blpapi_TopicList_correlationIdAt = ( + libblpapict.blpapi_TopicList_correlationIdAt +) # int +l_blpapi_TopicList_correlationIdAt.argtypes = [c_void_p, c_void_p, c_size_t] +l_blpapi_TopicList_create = libblpapict.blpapi_TopicList_create +l_blpapi_TopicList_create.restype = c_void_p +l_blpapi_TopicList_destroy = libblpapict.blpapi_TopicList_destroy +l_blpapi_TopicList_destroy.restype = None +l_blpapi_TopicList_message = libblpapict.blpapi_TopicList_message # int +l_blpapi_TopicList_messageAt = libblpapict.blpapi_TopicList_messageAt # int +l_blpapi_TopicList_size = libblpapict.blpapi_TopicList_size # int +l_blpapi_TopicList_status = libblpapict.blpapi_TopicList_status # int +l_blpapi_TopicList_statusAt = libblpapict.blpapi_TopicList_statusAt # int +l_blpapi_TopicList_topicString = ( + libblpapict.blpapi_TopicList_topicString +) # int +l_blpapi_TopicList_topicStringAt = ( + libblpapict.blpapi_TopicList_topicStringAt +) # int + +l_blpapi_ZfpUtil_getOptionsForLeasedLines = ( + libblpapict.blpapi_ZfpUtil_getOptionsForLeasedLines +) # int + +l_blpapi_getLastErrorDescription = libblpapict.blpapi_getLastErrorDescription +l_blpapi_getLastErrorDescription.restype = c_char_p + +l_blpapi_getVersionInfo = libblpapict.blpapi_getVersionInfo +l_blpapi_getVersionInfo.restype = None +l_blpapi_getVersionInfo.argtypes = [ + POINTER(c_int), + POINTER(c_int), + POINTER(c_int), + POINTER(c_int), +] + + +# signature: int blpapi_AbstractSession_cancel(blpapi_AbstractSession_t *session,const blpapi_CorrelationId_t *correlationIds,size_t numCorrelationIds,const char *requestLabel,int requestLabelLen); +def _blpapi_AbstractSession_cancel(session, correlationIds, requestLabel): + szcids = len(correlationIds) + if szcids > 1: + arraytype = CidStruct * szcids + ptrs = arraytype(*[c.thestruct for c in correlationIds]) + oneptr = pointer(ptrs) + elif szcids == 1: + oneptr = byref(correlationIds[0].thestruct) + else: + oneptr = c_void_p() + + label, sz = charPtrWithSizeFromPyStr(requestLabel) + retCode = l_blpapi_AbstractSession_cancel( + session, + oneptr, + c_size_t(szcids), + label, + sz, # int + ) + return retCode + + +# signature: blpapi_Identity_t *blpapi_AbstractSession_createIdentity(blpapi_AbstractSession_t *session); +def _blpapi_AbstractSession_createIdentity(session): + return getHandleFromPtr(l_blpapi_AbstractSession_createIdentity(session)) + + +# signature: int blpapi_AbstractSession_generateAuthorizedIdentityAsync(blpapi_AbstractSession_t *session,const blpapi_AuthOptions_t *authOptions,blpapi_CorrelationId_t *cid); +def _blpapi_AbstractSession_generateAuthorizedIdentityAsync( + session, authOptions, cid +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(cid.thestruct) + + return l_blpapi_AbstractSession_generateAuthorizedIdentityAsync( + session, authOptions, cidp + ) + + +# signature: int blpapi_AbstractSession_generateManualToken(blpapi_AbstractSession_t *session,blpapi_CorrelationId_t *correlationId,const char *user,const char *manualIp,blpapi_EventQueue_t *eventQueue); +def _blpapi_AbstractSession_generateManualToken( + session, correlationId, user, manualIp, eventQueue +): + return l_blpapi_AbstractSession_generateManualToken( + session, + byref(correlationId.thestruct), + charPtrFromPyStr(user), + charPtrFromPyStr(manualIp), + eventQueue, + ) + + +# signature: int blpapi_AbstractSession_generateToken(blpapi_AbstractSession_t *session,blpapi_CorrelationId_t *correlationId,blpapi_EventQueue_t *eventQueue); +def _blpapi_AbstractSession_generateToken(session, correlationId, eventQueue): + return l_blpapi_AbstractSession_generateToken( + session, byref(correlationId.thestruct), eventQueue + ) + + +# signature: int blpapi_AbstractSession_getAuthorizedIdentity(blpapi_AbstractSession_t *session,const blpapi_CorrelationId_t *cid,blpapi_Identity_t **identity); +def _blpapi_AbstractSession_getAuthorizedIdentity(session, cid): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AbstractSession_getAuthorizedIdentity( + session, byref(cid.thestruct), outp + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AbstractSession_getService(blpapi_AbstractSession_t *session,blpapi_Service_t **service,const char *serviceIdentifier); +def _blpapi_AbstractSession_getService(session, serviceIdentifier): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AbstractSession_getService( + session, outp, charPtrFromPyStr(serviceIdentifier) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AbstractSession_openService(blpapi_AbstractSession_t *session, const char *serviceIdentifier); +def _blpapi_AbstractSession_openService(session, serviceIdentifier): + return l_blpapi_AbstractSession_openService( + session, charPtrFromPyStr(serviceIdentifier) + ) + + +# signature: int blpapi_AbstractSession_openServiceAsync(blpapi_AbstractSession_t *session,const char *serviceIdentifier,blpapi_CorrelationId_t *correlationId); +def _blpapi_AbstractSession_openServiceAsync( + session, serviceIdentifier, correlationId +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(correlationId.thestruct) + + return l_blpapi_AbstractSession_openServiceAsync( + session, charPtrFromPyStr(serviceIdentifier), cidp + ) + + +# signature: int blpapi_AbstractSession_sendAuthorizationRequest(...) +def _blpapi_AbstractSession_sendAuthorizationRequest( + session, request, identity, correlationId, eventQueue, requestLabel +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(correlationId.thestruct) + + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_AbstractSession_sendAuthorizationRequest( + session, request, identity, cidp, eventQueue, label, sz # int + ) + + +# signature: int blpapi_AbstractSession_sessionName(blpapi_AbstractSession_t *session,const char **sessionName,size_t *size); +def _blpapi_AbstractSession_sessionName(session): + out = c_char_p() + szout = c_size_t() + outp = pointer(out) + szoutp = pointer(szout) + retCode = l_blpapi_AbstractSession_sessionName(session, outp, szoutp) + return retCode, getSizedStrFromOutput(outp, szoutp, retCode) + + +# signature: int blpapi_AuthApplication_copy(blpapi_AuthApplication_t *lhs, const blpapi_AuthApplication_t *rhs); +def _blpapi_AuthApplication_copy(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthApplication_create(blpapi_AuthApplication_t **app, const char *appName); +def _blpapi_AuthApplication_create(appName): + authapphandle = c_void_p() + outp = pointer(authapphandle) + retCode = l_blpapi_AuthApplication_create(outp, charPtrFromPyStr(appName)) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: void blpapi_AuthApplication_destroy(blpapi_AuthApplication_t *app); +def _blpapi_AuthApplication_destroy(app): + l_blpapi_AuthApplication_destroy(app) + + +# signature: int blpapi_AuthApplication_duplicate(blpapi_AuthApplication_t **app, const blpapi_AuthApplication_t *dup); +def _blpapi_AuthApplication_duplicate(dup): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthOptions_copy(blpapi_AuthOptions_t *lhs, const blpapi_AuthOptions_t *rhs); +def _blpapi_AuthOptions_copy(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthOptions_create_default(blpapi_AuthOptions_t **options); +def _blpapi_AuthOptions_create_default(): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthOptions_create_default(outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthOptions_create_forAppMode(blpapi_AuthOptions_t **options, const blpapi_AuthApplication_t *app); +def _blpapi_AuthOptions_create_forAppMode(app): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthOptions_create_forAppMode(outp, app) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthOptions_create_forToken(blpapi_AuthOptions_t **options, const blpapi_AuthToken_t *token); +def _blpapi_AuthOptions_create_forToken(token): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthOptions_create_forToken(outp, token) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthOptions_create_forUserAndAppMode(blpapi_AuthOptions_t **options,const blpapi_AuthUser_t *user,const blpapi_AuthApplication_t *app); +def _blpapi_AuthOptions_create_forUserAndAppMode(user, app): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthOptions_create_forUserAndAppMode(outp, user, app) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthOptions_create_forUserMode(blpapi_AuthOptions_t **options, const blpapi_AuthUser_t *user); +def _blpapi_AuthOptions_create_forUserMode(user): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthOptions_create_forUserMode(outp, user) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: void blpapi_AuthOptions_destroy(blpapi_AuthOptions_t *options); +def _blpapi_AuthOptions_destroy(options): + l_blpapi_AuthOptions_destroy(options) + + +# signature: int blpapi_AuthOptions_duplicate(blpapi_AuthOptions_t **options, const blpapi_AuthOptions_t *dup); +def _blpapi_AuthOptions_duplicate(dup): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthToken_copy(blpapi_AuthToken_t *lhs, const blpapi_AuthToken_t *rhs); +def _blpapi_AuthToken_copy(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthToken_create(blpapi_AuthToken_t **token, const char *tokenStr); +def _blpapi_AuthToken_create(tokenStr): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthToken_create(outp, charPtrFromPyStr(tokenStr)) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: void blpapi_AuthToken_destroy(blpapi_AuthToken_t *token); +def _blpapi_AuthToken_destroy(token): + l_blpapi_AuthToken_destroy(token) + + +# signature: int blpapi_AuthToken_duplicate(blpapi_AuthToken_t **token, const blpapi_AuthToken_t *dup); +def _blpapi_AuthToken_duplicate(dup): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthUser_copy(blpapi_AuthUser_t *lhs, const blpapi_AuthUser_t *rhs); +def _blpapi_AuthUser_copy(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_AuthUser_createWithActiveDirectoryProperty(blpapi_AuthUser_t **user, const char *propertyName); +def _blpapi_AuthUser_createWithActiveDirectoryProperty(propertyName): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthUser_createWithActiveDirectoryProperty( + outp, charPtrFromPyStr(propertyName) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthUser_createWithLogonName(blpapi_AuthUser_t **user); +def _blpapi_AuthUser_createWithLogonName(): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthUser_createWithLogonName(outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_AuthUser_createWithManualOptions(blpapi_AuthUser_t **user, const char *userId, const char *ipAddress); +def _blpapi_AuthUser_createWithManualOptions(userId, ipAddress): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_AuthUser_createWithManualOptions( + outp, charPtrFromPyStr(userId), charPtrFromPyStr(ipAddress) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: void blpapi_AuthUser_destroy(blpapi_AuthUser_t *user); +def _blpapi_AuthUser_destroy(user): + l_blpapi_AuthUser_destroy(user) + + +# signature: int blpapi_AuthUser_duplicate(blpapi_AuthUser_t **user, const blpapi_AuthUser_t *dup); +def _blpapi_AuthUser_duplicate(dup): + raise NotImplementedError("not called") + + +# signature: int blpapi_ConstantList_datatype(const blpapi_ConstantList_t *constant); +def _blpapi_ConstantList_datatype(constant): + return l_blpapi_ConstantList_datatype(constant) + + +# signature: const char *blpapi_ConstantList_description(const blpapi_ConstantList_t *list); +def _blpapi_ConstantList_description(clist): + assert clist is not None and clist.value is not None + return getStrFromC(l_blpapi_ConstantList_description(clist)) + + +# signature: blpapi_Constant_t *blpapi_ConstantList_getConstant(const blpapi_ConstantList_t *constant,const char *nameString,const blpapi_Name_t *name); +def _blpapi_ConstantList_getConstant(constant, nameString, name): + value = l_blpapi_ConstantList_getConstant( + constant, charPtrFromPyStr(nameString), name + ) + return getHandleFromPtr(value) + + +# signature: blpapi_Constant_t *blpapi_ConstantList_getConstantAt(const blpapi_ConstantList_t *constant, size_t index); +def _blpapi_ConstantList_getConstantAt(constant, index): + return getHandleFromPtr( + l_blpapi_ConstantList_getConstantAt(constant, c_size_t(index)) + ) + + +# signature: +def _blpapi_ConstantList_hasConstant(slist, nameString, name): + constant = _blpapi_ConstantList_getConstant(slist, nameString, name) + return constant is not None and constant.value is not None + + +# signature: blpapi_Name_t *blpapi_ConstantList_name(const blpapi_ConstantList_t *list); +def _blpapi_ConstantList_name(clist): + return getHandleFromPtr(l_blpapi_ConstantList_name(clist)) + + +# signature: int blpapi_ConstantList_numConstants(const blpapi_ConstantList_t *list); +def _blpapi_ConstantList_numConstants(slist): + return l_blpapi_ConstantList_numConstants(slist) + + +# signature: int blpapi_ConstantList_status(const blpapi_ConstantList_t *list); +def _blpapi_ConstantList_status(slist): + return l_blpapi_ConstantList_status(slist) + + +# signature: int blpapi_Constant_datatype(const blpapi_Constant_t *constant); +def _blpapi_Constant_datatype(constant): + return l_blpapi_Constant_datatype(constant) + + +# signature: const char *blpapi_Constant_description(const blpapi_Constant_t *constant); +def _blpapi_Constant_description(constant): + return getStrFromC(l_blpapi_Constant_description(constant)) + + +# signature: int blpapi_Constant_getValueAsChar(const blpapi_Constant_t *constant, blpapi_Char_t *buffer); +def _blpapi_Constant_getValueAsChar(constant): + out = c_char() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsChar(constant, outp) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_Constant_getValueAsDatetime(const blpapi_Constant_t *constant, blpapi_Datetime_t *buffer); +def _blpapi_Constant_getValueAsDatetime(constant): + out = BDatetime() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsDatetime(constant, outp) + return retCode, out if retCode == 0 else None + + +# signature: int blpapi_Constant_getValueAsFloat32(const blpapi_Constant_t *constant, blpapi_Float32_t *buffer); +def _blpapi_Constant_getValueAsFloat32(constant): + out = c_float() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsFloat32(constant, outp) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Constant_getValueAsFloat64(const blpapi_Constant_t *constant, blpapi_Float64_t *buffer); +def _blpapi_Constant_getValueAsFloat64(constant): + out = c_double() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsFloat64(constant, outp) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Constant_getValueAsInt32(const blpapi_Constant_t *constant, blpapi_Int32_t *buffer); +def _blpapi_Constant_getValueAsInt32(constant): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsInt32(constant, outp) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Constant_getValueAsInt64(const blpapi_Constant_t *constant, blpapi_Int64_t *buffer); +def _blpapi_Constant_getValueAsInt64(constant): + out = c_int64() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsInt64(constant, outp) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Constant_getValueAsString(const blpapi_Constant_t *constant, const char **buffer); +def _blpapi_Constant_getValueAsString(constant): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_Constant_getValueAsString(constant, outp) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: blpapi_Name_t *blpapi_Constant_name(const blpapi_Constant_t *constant); +def _blpapi_Constant_name(constant): + return getHandleFromPtr(l_blpapi_Constant_name(constant)) + + +# signature: int blpapi_Constant_status(const blpapi_Constant_t *constant); +def _blpapi_Constant_status(constant): + return l_blpapi_Constant_status(constant) + + +# signature: +def _blpapi_DiagnosticsUtil_memoryInfo_wrapper(): + outp = c_void_p() + sz = l_blpapi_DiagnosticsUtil_memoryInfo(outp, c_size_t(0)) + if sz < 0: + return None + sz += 1 + outp = create_string_buffer(sz) + sz = l_blpapi_DiagnosticsUtil_memoryInfo(outp, c_size_t(sz)) + return getSizedStrFromBuffer(outp, sz) if sz >= 0 else None + + +# signature: int blpapi_Element_appendElement(blpapi_Element_t *element, blpapi_Element_t **appendedElement); +def _blpapi_Element_appendElement(element): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_appendElement(element, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_datatype(const blpapi_Element_t *element); +def _blpapi_Element_datatype(element): + return l_blpapi_Element_datatype(element) + + +# signature: blpapi_SchemaElementDefinition_t *blpapi_Element_definition(const blpapi_Element_t *element); +def _blpapi_Element_definition(element): + return getHandleFromPtr(l_blpapi_Element_definition(element)) + + +# signature: int blpapi_Element_getChoice(const blpapi_Element_t *element, blpapi_Element_t **result); +def _blpapi_Element_getChoice(element): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_getChoice(element, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getElementAt(const blpapi_Element_t *element,blpapi_Element_t **result,size_t position); +def _blpapi_Element_getElement(element, nameString, name): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_getElement( + element, outp, charPtrFromPyStr(nameString), name + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getElementAt(const blpapi_Element_t *element,blpapi_Element_t **result,size_t position); +def _blpapi_Element_getElementAt(element, position): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_getElementAt(element, outp, position) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsBool(const blpapi_Element_t *element, blpapi_Bool_t *buffer, size_t index); +def _blpapi_Element_getValueAsBool(element, index): + out = c_int() # int as boolean + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsBool(element, outp, c_size_t(index)) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsBytes(const blpapi_Element_t *element,const char **buffer,size_t *length,size_t index); +def _blpapi_Element_getValueAsBytes(element, index): + out = c_char_p() + outp = pointer(out) + szout = c_size_t() + szoutp = pointer(szout) + retCode = l_blpapi_Element_getValueAsBytes( + element, outp, szoutp, c_size_t(index) + ) + return retCode, getSizedBytesFromOutput(outp, szoutp, retCode) + + +# signature: int blpapi_Element_getValueAsChar(const blpapi_Element_t *element, blpapi_Char_t *buffer, size_t index); +def _blpapi_Element_getValueAsChar(element, index): + out = c_char() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsChar(element, outp, c_size_t(index)) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsDatetime(const blpapi_Element_t *element,blpapi_Datetime_t *buffer,size_t index); +def _blpapi_Element_getValueAsDatetime(element, index): + raise NotImplementedError("not called") + + +# signature: int blpapi_Element_getValueAsElement(const blpapi_Element_t *element,blpapi_Element_t **buffer,size_t index); +def _blpapi_Element_getValueAsElement(element, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsElement( + element, outp, c_size_t(index) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsFloat64(const blpapi_Element_t *element,blpapi_Float64_t *buffer,size_t index); +def _blpapi_Element_getValueAsFloat64(element, index): + out = c_double() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsFloat64( + element, outp, c_size_t(index) + ) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsHighPrecisionDatetime(const blpapi_Element_t *element,blpapi_HighPrecisionDatetime_t *buffer,size_t index); +def _blpapi_Element_getValueAsHighPrecisionDatetime(element, index): + out = HighPrecisionDatetime() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsHighPrecisionDatetime( + element, outp, c_size_t(index) + ) + return retCode, getStructFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsInt32(const blpapi_Element_t *element, blpapi_Int32_t *buffer, size_t index); +def _blpapi_Element_getValueAsInt32(element, index): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsInt32(element, outp, c_size_t(index)) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsInt64(const blpapi_Element_t *element, blpapi_Int64_t *buffer, size_t index); +def _blpapi_Element_getValueAsInt64(element, index): + out = c_int64() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsInt64(element, outp, c_size_t(index)) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsName(const blpapi_Element_t *element, blpapi_Name_t **buffer, size_t index); +def _blpapi_Element_getValueAsName(element, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsName(element, outp, c_size_t(index)) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_getValueAsString(const blpapi_Element_t *element, const char **buffer, size_t index); +def _blpapi_Element_getValueAsString(element, index): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_Element_getValueAsString(element, outp, c_size_t(index)) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_Element_hasElementEx(const blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,int excludeNullElements,int reserved); +def _blpapi_Element_hasElementEx( + element, nameString, name, excludeNullElements, reserved +): + return l_blpapi_Element_hasElementEx( + element, + charPtrFromPyStr(nameString), + name, + excludeNullElements, + reserved, + ) + + +# signature: int blpapi_Element_isArray(const blpapi_Element_t *element); +def _blpapi_Element_isArray(element): + return l_blpapi_Element_isArray(element) + + +# signature: int blpapi_Element_isComplexType(const blpapi_Element_t *element); +def _blpapi_Element_isComplexType(element): + return l_blpapi_Element_isComplexType(element) + + +# signature: int blpapi_Element_isNullValue(const blpapi_Element_t *element, size_t position); +def _blpapi_Element_isNull(element): + return l_blpapi_Element_isNull(element) + + +# signature: int blpapi_Element_isNullValue(const blpapi_Element_t *element, size_t position); +def _blpapi_Element_isNullValue(element, position): + return l_blpapi_Element_isNullValue(element, position) + + +# signature: int blpapi_Element_isReadOnly(const blpapi_Element_t *element); +def _blpapi_Element_isReadOnly(element): + return l_blpapi_Element_isReadOnly(element) + + +# signature: blpapi_Name_t *blpapi_Element_name(const blpapi_Element_t *element); +def _blpapi_Element_name(element): + return getHandleFromPtr(l_blpapi_Element_name(element)) + + +# signature: const char *blpapi_Element_nameString(const blpapi_Element_t *element); +def _blpapi_Element_nameString(element): + raise NotImplementedError("not called") + + +# signature: size_t blpapi_Element_numElements(const blpapi_Element_t *element); +def _blpapi_Element_numElements(element): + return l_blpapi_Element_numElements(element) + + +# signature: size_t blpapi_Element_numValues(const blpapi_Element_t *element); +def _blpapi_Element_numValues(element): + return l_blpapi_Element_numValues(element) + + +# signature: +def _blpapi_Element_printHelper(element, level, spacesPerLevel): + return any_printer(element, l_blpapi_Element_print, level, spacesPerLevel) + + +# signature: int blpapi_Element_setChoice(blpapi_Element_t *element,blpapi_Element_t **resultElement,const char *nameCstr,const blpapi_Name_t *name,size_t index); +def _blpapi_Element_setChoice(element, nameCstr, name, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Element_setChoice( + element, outp, charPtrFromPyStr(nameCstr), name, c_size_t(index) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Element_setElementBool(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,blpapi_Bool_t value); +def _blpapi_Element_setElementBool(element, nameString, name, value): + return l_blpapi_Element_setElementBool( + element, charPtrFromPyStr(nameString), name, c_int(value) + ) + + +# signature: int blpapi_Element_setElementBytes(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,const char *value,size_t length); +def _blpapi_Element_setElementBytes(element, nameString, name, value): + valuePtr, sz = charPtrWithSizeFromPyStr(value) + return l_blpapi_Element_setElementBytes( + element, charPtrFromPyStr(nameString), name, valuePtr, c_size_t(sz) + ) + + +# signature: int blpapi_Element_setElementFloat32(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,blpapi_Float32_t value); +def _blpapi_Element_setElementFloat(element, nameString, name, value): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + retCode, field = _blpapi_Element_getElement(element, nameString, name) + if retCode == 0 and (field is not None and field.value is not None): + # Able to get field, consider its datatype + if l_blpapi_Element_datatype(field) == DATATYPE_FLOAT32: + retCode = l_blpapi_Element_setElementFloat32( + element, charPtrFromPyStr(nameString), name, c_float(value) + ) + else: + retCode = l_blpapi_Element_setElementFloat64( + element, charPtrFromPyStr(nameString), name, c_double(value) + ) + return retCode + + # Unable to get field. Try to set element anyway + retCode = l_blpapi_Element_setElementFloat64( + element, charPtrFromPyStr(nameString), name, c_double(value) + ) + if retCode: + retCode = l_blpapi_Element_setElementFloat32( + element, charPtrFromPyStr(nameString), name, c_float(value) + ) + return retCode + + +# signature: int blpapi_Element_setElementFromName(blpapi_Element_t *element,const char *elementName,const blpapi_Name_t *name,const blpapi_Name_t *buffer); +def _blpapi_Element_setElementFromName(element, elementName, name, buffer): + return l_blpapi_Element_setElementFromName( + element, charPtrFromPyStr(elementName), name, buffer + ) + + +# signature: int blpapi_Element_setElementHighPrecisionDatetime(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,const blpapi_HighPrecisionDatetime_t *value); +def _blpapi_Element_setElementHighPrecisionDatetime( + element, nameString, name, value +): + return l_blpapi_Element_setElementHighPrecisionDatetime( + element, charPtrFromPyStr(nameString), name, byref(value) + ) + + +# signature: int blpapi_Element_setElementInt32(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,blpapi_Int32_t value); +def _blpapi_Element_setElementInt32(element, nameString, name, value): + return l_blpapi_Element_setElementInt32( + element, charPtrFromPyStr(nameString), name, c_int(value) + ) + + +# signature: int blpapi_Element_setElementInt64(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,blpapi_Int64_t value); +def _blpapi_Element_setElementInt64(element, nameString, name, value): + return l_blpapi_Element_setElementInt64( + element, charPtrFromPyStr(nameString), name, c_int64(value) + ) + + +# signature: int blpapi_Element_setElementString(blpapi_Element_t *element,const char *nameString,const blpapi_Name_t *name,const char *value); +def _blpapi_Element_setElementString(element, nameString, name, value): + return l_blpapi_Element_setElementString( + element, charPtrFromPyStr(nameString), name, charPtrFromPyStr(value) + ) + + +# signature: int blpapi_Element_setValueBool(blpapi_Element_t *element, blpapi_Bool_t value, size_t index); +def _blpapi_Element_setValueBool(element, value, index): + return l_blpapi_Element_setValueBool( + element, c_int(value), c_size_t(index) + ) + + +# signature: int blpapi_Element_setValueBytes(blpapi_Element_t *element,const char *value,size_t length,size_t index); +def _blpapi_Element_setValueBytes(element, value, index): + valuePtr, sz = charPtrWithSizeFromPyStr(value) + return l_blpapi_Element_setValueBytes( + element, valuePtr, c_size_t(sz), c_size_t(index) + ) + + +# signature: int blpapi_Element_setValueFloat32(blpapi_Element_t *element, blpapi_Float32_t value, size_t index); +def _blpapi_Element_setValueFloat(element, value, index): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + # Consider field datatype + if l_blpapi_Element_datatype(element) == DATATYPE_FLOAT32: + retCode = l_blpapi_Element_setValueFloat32( + element, c_float(value), c_size_t(index) + ) + else: + retCode = l_blpapi_Element_setValueFloat64( + element, c_double(value), c_size_t(index) + ) + return retCode + + +# signature: int blpapi_Element_setValueFromName(blpapi_Element_t *element, const blpapi_Name_t *value, size_t index); +def _blpapi_Element_setValueFromName(element, value, index): + return l_blpapi_Element_setValueFromName(element, value, c_size_t(index)) + + +# signature: int blpapi_Element_setValueHighPrecisionDatetime(blpapi_Element_t *element,const blpapi_HighPrecisionDatetime_t *value,size_t index); +def _blpapi_Element_setValueHighPrecisionDatetime(element, value, index): + return l_blpapi_Element_setValueHighPrecisionDatetime( + element, byref(value), c_size_t(index) + ) + + +# signature: int blpapi_Element_setValueInt32(blpapi_Element_t *element, blpapi_Int32_t value, size_t index); +def _blpapi_Element_setValueInt32(element, value, index): + return l_blpapi_Element_setValueInt32( + element, c_int(value), c_size_t(index) + ) + + +# signature: int blpapi_Element_setValueInt64(blpapi_Element_t *element, blpapi_Int64_t value, size_t index); +def _blpapi_Element_setValueInt64(element, value, index): + return l_blpapi_Element_setValueInt64( + element, c_int64(value), c_size_t(index) + ) + + +# signature: int blpapi_Element_setValueString(blpapi_Element_t *element, const char *value, size_t index); +def _blpapi_Element_setValueString(element, value, index): + return l_blpapi_Element_setValueString( + element, charPtrFromPyStr(value), c_size_t(index) + ) + + +# signature: +def _blpapi_Element_toPy(element): + return libffastcalls.blpapi_Element_toPy(element) + + +# signature: blpapi_EventDispatcher_t *blpapi_EventDispatcher_create(size_t numDispatcherThreads); +def _blpapi_EventDispatcher_create(numDispatcherThreads): + return getHandleFromPtr( + l_blpapi_EventDispatcher_create(c_size_t(numDispatcherThreads)) + ) + + +# signature: void blpapi_EventDispatcher_destroy(blpapi_EventDispatcher_t *handle); +def _blpapi_EventDispatcher_destroy(handle): + l_blpapi_EventDispatcher_destroy(handle) + + +# signature: int blpapi_EventDispatcher_start(blpapi_EventDispatcher_t *handle); +def _blpapi_EventDispatcher_start(handle): + return l_blpapi_EventDispatcher_start(handle) + + +# signature: int blpapi_EventDispatcher_stop(blpapi_EventDispatcher_t *handle, int async); +def _blpapi_EventDispatcher_stop(handle, asynch): + return l_blpapi_EventDispatcher_stop(handle, c_int(asynch)) + + +# signature: int blpapi_EventFormatter_appendElement(blpapi_EventFormatter_t *formatter); +def _blpapi_EventFormatter_appendElement(formatter): + return l_blpapi_EventFormatter_appendElement(formatter) + + +# signature: int blpapi_EventFormatter_appendFragmentedRecapMessage(blpapi_EventFormatter_t *formatter,const char *typeString,blpapi_Name_t *typeName,const blpapi_Topic_t *topic,const blpapi_CorrelationId_t *cid,int fragmentType); +def _blpapi_EventFormatter_appendFragmentedRecapMessage( + formatter, typeString, typeName, topic, cid, fragmentType +): + return l_blpapi_EventFormatter_appendFragmentedRecapMessage( + formatter, + charPtrFromPyStr(typeString), + typeName, + topic, + byref(cid.thestruct) if cid is not None else None, + fragmentType, + ) + + +# signature: int blpapi_EventFormatter_appendFragmentedRecapMessageSeq(blpapi_EventFormatter_t *formatter,const char *typeString,blpapi_Name_t *typeName,const blpapi_Topic_t *topic,int fragmentType,unsigned int sequenceNumber); +def _blpapi_EventFormatter_appendFragmentedRecapMessageSeq( + formatter, typeString, typeName, topic, fragmentType, sequenceNumber +): + return l_blpapi_EventFormatter_appendFragmentedRecapMessageSeq( + formatter, + charPtrFromPyStr(typeString), + typeName, + topic, + fragmentType, + c_uint32(sequenceNumber), + ) + + +# signature: int blpapi_EventFormatter_appendMessage(blpapi_EventFormatter_t *formatter,const char *typeString,blpapi_Name_t *typeName,const blpapi_Topic_t *topic); +def _blpapi_EventFormatter_appendMessage( + formatter, typeString, typeName, topic +): + return l_blpapi_EventFormatter_appendMessage( + formatter, charPtrFromPyStr(typeString), typeName, topic + ) + + +# signature: int blpapi_EventFormatter_appendMessageSeq(blpapi_EventFormatter_t *formatter,const char *typeString,blpapi_Name_t *typeName,const blpapi_Topic_t *topic,unsigned int sequenceNumber,unsigned int); +def _blpapi_EventFormatter_appendMessageSeq( + formatter, typeString, typeName, topic, sequenceNumber, aUIntArg +): + return l_blpapi_EventFormatter_appendMessageSeq( + formatter, + charPtrFromPyStr(typeString), + typeName, + topic, + c_uint32(sequenceNumber), + c_uint(aUIntArg), + ) + + +# signature: int blpapi_EventFormatter_appendRecapMessage(blpapi_EventFormatter_t *formatter,const blpapi_Topic_t *topic,const blpapi_CorrelationId_t *cid); +def _blpapi_EventFormatter_appendRecapMessage(formatter, topic, cid): + return l_blpapi_EventFormatter_appendRecapMessage( + formatter, + topic, + byref(cid.thestruct) if cid is not None else None, + ) + + +# signature: int blpapi_EventFormatter_appendRecapMessageSeq(blpapi_EventFormatter_t *formatter,const blpapi_Topic_t *topic,const blpapi_CorrelationId_t *cid,unsigned int sequenceNumber,unsigned int); +def _blpapi_EventFormatter_appendRecapMessageSeq( + formatter, topic, cid, sequenceNumber, aUIntArg +): + return l_blpapi_EventFormatter_appendRecapMessageSeq( + formatter, + topic, + byref(cid.thestruct) if cid is not None else None, + c_uint32(sequenceNumber), + c_uint(aUIntArg), + ) + + +# signature: int blpapi_EventFormatter_appendResponse(blpapi_EventFormatter_t *formatter,const char *typeString,blpapi_Name_t *typeName); +def _blpapi_EventFormatter_appendResponse(formatter, typeString, typeName): + return l_blpapi_EventFormatter_appendResponse( + formatter, charPtrFromPyStr(typeString), typeName + ) + + +# signature: int blpapi_EventFormatter_appendValueBool(blpapi_EventFormatter_t *formatter, blpapi_Bool_t value); +def _blpapi_EventFormatter_appendValueBool(formatter, value): + return l_blpapi_EventFormatter_appendValueBool( + formatter, c_int(value) + ) # int as boolean + + +# signature: int blpapi_EventFormatter_appendValueChar(blpapi_EventFormatter_t *formatter, char value); +def _blpapi_EventFormatter_appendValueChar(formatter, value): + return l_blpapi_EventFormatter_appendValueChar(formatter, c_char(value)) + + +# signature: int blpapi_EventFormatter_appendValueFloat32(blpapi_EventFormatter_t *formatter, blpapi_Float32_t value); +def _blpapi_EventFormatter_appendValueFloat(formatter, value): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + retCode = l_blpapi_EventFormatter_appendValueFloat64( + formatter, c_double(value) + ) + if retCode: + retCode = l_blpapi_EventFormatter_appendValueFloat32( + formatter, c_float(value) + ) + return retCode + + +# signature: int blpapi_EventFormatter_appendValueFromName(blpapi_EventFormatter_t *formatter, const blpapi_Name_t *value); +def _blpapi_EventFormatter_appendValueFromName(formatter, value): + return l_blpapi_EventFormatter_appendValueFromName(formatter, value) + + +# signature: int blpapi_EventFormatter_appendValueHighPrecisionDatetime(blpapi_EventFormatter_t *formatter,const blpapi_HighPrecisionDatetime_t *value); +def _blpapi_EventFormatter_appendValueHighPrecisionDatetime(formatter, value): + return l_blpapi_EventFormatter_appendValueHighPrecisionDatetime( + formatter, byref(value) + ) + + +# signature: int blpapi_EventFormatter_appendValueInt32(blpapi_EventFormatter_t *formatter, blpapi_Int32_t value); +def _blpapi_EventFormatter_appendValueInt32(formatter, value): + return l_blpapi_EventFormatter_appendValueInt32(formatter, c_int(value)) + + +# signature: int blpapi_EventFormatter_appendValueInt64(blpapi_EventFormatter_t *formatter, blpapi_Int64_t value); +def _blpapi_EventFormatter_appendValueInt64(formatter, value): + return l_blpapi_EventFormatter_appendValueInt64(formatter, c_int64(value)) + + +# signature: int blpapi_EventFormatter_appendValueString(blpapi_EventFormatter_t *formatter, const char *value); +def _blpapi_EventFormatter_appendValueString(formatter, value): + return l_blpapi_EventFormatter_appendValueString( + formatter, charPtrFromPyStr(value) + ) + + +# signature: blpapi_EventFormatter_t *blpapi_EventFormatter_create(blpapi_Event_t *event); +def _blpapi_EventFormatter_create(event): + return getHandleFromPtr(l_blpapi_EventFormatter_create(event)) + + +# signature: void blpapi_EventFormatter_destroy(blpapi_EventFormatter_t *victim); +def _blpapi_EventFormatter_destroy(victim): + l_blpapi_EventFormatter_destroy(victim) + + +# signature: int blpapi_EventFormatter_popElement(blpapi_EventFormatter_t *formatter); +def _blpapi_EventFormatter_popElement(formatter): + return l_blpapi_EventFormatter_popElement(formatter) + + +# signature: int blpapi_EventFormatter_pushElement(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName); +def _blpapi_EventFormatter_pushElement(formatter, typeString, typeName): + return l_blpapi_EventFormatter_pushElement( + formatter, charPtrFromPyStr(typeString), typeName + ) + + +# signature: int blpapi_EventFormatter_setValueBool(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,blpapi_Bool_t value); +def _blpapi_EventFormatter_setValueBool( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueBool( + formatter, charPtrFromPyStr(typeString), typeName, c_int(value) + ) # int as boolean + + +# signature: int blpapi_EventFormatter_setValueBytes(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,const char *value,size_t length); +def _blpapi_EventFormatter_setValueBytes( + formatter, typeString, typeName, value +): + valuePtr, sz = charPtrWithSizeFromPyStr(value) + return l_blpapi_EventFormatter_setValueBytes( + formatter, + charPtrFromPyStr(typeString), + typeName, + valuePtr, + c_size_t(sz), + ) + + +# signature: int blpapi_EventFormatter_setValueChar(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,char value); +def _blpapi_EventFormatter_setValueChar( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueChar( + formatter, + charPtrFromPyStr(typeString), + typeName, + c_char(value), + ) + + +# signature: int blpapi_EventFormatter_setValueFloat32(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,blpapi_Float32_t value); +def _blpapi_EventFormatter_setValueFloat( + formatter, typeString, typeName, value +): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + retCode = l_blpapi_EventFormatter_setValueFloat64( + formatter, charPtrFromPyStr(typeString), typeName, c_double(value) + ) + if retCode: + retCode = l_blpapi_EventFormatter_setValueFloat32( + formatter, charPtrFromPyStr(typeString), typeName, c_float(value) + ) + return retCode + + +# signature: int blpapi_EventFormatter_setValueFromName(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,const blpapi_Name_t *value); +def _blpapi_EventFormatter_setValueFromName( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueFromName( + formatter, charPtrFromPyStr(typeString), typeName, value + ) + + +# signature: int blpapi_EventFormatter_setValueHighPrecisionDatetime(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,const blpapi_HighPrecisionDatetime_t *value); +def _blpapi_EventFormatter_setValueHighPrecisionDatetime( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueHighPrecisionDatetime( + formatter, charPtrFromPyStr(typeString), typeName, byref(value) + ) + + +# signature: int blpapi_EventFormatter_setValueInt32(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,blpapi_Int32_t value); +def _blpapi_EventFormatter_setValueInt32( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueInt32( + formatter, charPtrFromPyStr(typeString), typeName, c_int(value) + ) + + +# signature: int blpapi_EventFormatter_setValueInt64(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,blpapi_Int64_t value); +def _blpapi_EventFormatter_setValueInt64( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueInt64( + formatter, charPtrFromPyStr(typeString), typeName, c_int64(value) + ) + + +# signature: int blpapi_EventFormatter_setValueNull(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName); +def _blpapi_EventFormatter_setValueNull(formatter, typeString, typeName): + return l_blpapi_EventFormatter_setValueNull( + formatter, + charPtrFromPyStr(typeString), + typeName, + ) + + +# signature: int blpapi_EventFormatter_setValueString(blpapi_EventFormatter_t *formatter,const char *typeString,const blpapi_Name_t *typeName,const char *value); +def _blpapi_EventFormatter_setValueString( + formatter, typeString, typeName, value +): + return l_blpapi_EventFormatter_setValueString( + formatter, + charPtrFromPyStr(typeString), + typeName, + charPtrFromPyStr(value), + ) + + +# signature: blpapi_EventQueue_t *blpapi_EventQueue_create(void); +def _blpapi_EventQueue_create(): + return getHandleFromPtr(l_blpapi_EventQueue_create()) + + +# signature: int blpapi_EventQueue_destroy(blpapi_EventQueue_t *eventQueue); +def _blpapi_EventQueue_destroy(eventQueue): + return l_blpapi_EventQueue_destroy(eventQueue) + + +# signature: blpapi_Event_t *blpapi_EventQueue_nextEvent(blpapi_EventQueue_t *eventQueue, int timeout); +def _blpapi_EventQueue_nextEvent(eventQueue, timeout): + return getHandleFromPtr(l_blpapi_EventQueue_nextEvent(eventQueue, timeout)) + + +# signature: int blpapi_EventQueue_purge(blpapi_EventQueue_t *eventQueue); +def _blpapi_EventQueue_purge(eventQueue): + return l_blpapi_EventQueue_purge(eventQueue) + + +# signature: int blpapi_EventQueue_tryNextEvent(blpapi_EventQueue_t *eventQueue, blpapi_Event_t **eventPointer); +def _blpapi_EventQueue_tryNextEvent(eventQueue): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_EventQueue_tryNextEvent(eventQueue, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Event_eventType(const blpapi_Event_t *event); +def _blpapi_Event_eventType(event): + return l_blpapi_Event_eventType(event) + + +# signature: int blpapi_Event_release(const blpapi_Event_t *event); +def _blpapi_Event_release(event): + return l_blpapi_Event_release(event) + + +# signature: int blpapi_HighPrecisionDatetime_compare(const blpapi_HighPrecisionDatetime_t *lhs,const blpapi_HighPrecisionDatetime_t *rhs); +def _blpapi_HighPrecisionDatetime_compare(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_HighPrecisionDatetime_fromTimePoint(blpapi_HighPrecisionDatetime_t *datetime,const blpapi_TimePoint_t *timePoint,short offset); +def _blpapi_HighPrecisionDatetime_fromTimePoint(timepoint, offset): + out = HighPrecisionDatetime() + outp = pointer(out) + retCode = l_blpapi_HighPrecisionDatetime_fromTimePoint( + outp, byref(timepoint), c_int16(offset) + ) + return retCode, getStructFromOutput(outp, retCode) + + +# signature: +def _blpapi_HighPrecisionDatetime_fromTimePoint_wrapper(timepoint): + _, result = _blpapi_HighPrecisionDatetime_fromTimePoint(timepoint, 0) + return result + + +# signature: int blpapi_HighPrecisionDatetime_print(const blpapi_HighPrecisionDatetime_t *datetime,blpapi_StreamWriter_t streamWriter,void *stream,int level,int spacesPerLevel); +def _blpapi_HighPrecisionDatetime_print( + datetime, streamWriter, stream, level, spacesPerLevel +): + raise NotImplementedError("not called") + + +# signature: int blpapi_HighResolutionClock_now(blpapi_TimePoint_t *timePoint); +def _blpapi_HighResolutionClock_now(): + out = TimePoint() + outp = pointer(out) + retCode = l_blpapi_HighResolutionClock_now(outp) + return retCode, getStructFromOutput(outp, retCode) + + +# signature: int blpapi_Identity_addRef(blpapi_Identity_t *handle); +def _blpapi_Identity_addRef(handle): + raise NotImplementedError("not called") # only needed on copy + + +# signature: int blpapi_Identity_getSeatType(const blpapi_Identity_t *handle, int *seatType); +def _blpapi_Identity_getSeatType(handle): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_Identity_getSeatType(handle, outp) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_Identity_hasEntitlements(const blpapi_Identity_t *handle,const blpapi_Service_t *service,const blpapi_Element_t *eidElement,const int *entitlementIds,size_t numEntitlements,int *failedEntitlements,int *failedEntitlementsCount); +def _blpapi_Identity_hasEntitlements( + handle, + service, + eidElement, + entitlementIds, + numEntitlements, + failedEntitlements, + failedEntitlementsCount, +): + return l_blpapi_Identity_hasEntitlements( + handle, + service, + eidElement, + c_void_p() if entitlementIds is None else byref(entitlementIds), + c_size_t(numEntitlements), + ( + c_void_p() + if failedEntitlements is None + else pointer(failedEntitlements) + ), + ( + c_void_p() + if failedEntitlementsCount is None + else pointer(failedEntitlementsCount) + ), + ) + + +# signature: int blpapi_Identity_isAuthorized(const blpapi_Identity_t *handle, const blpapi_Service_t *service); +def _blpapi_Identity_isAuthorized(handle, service): + return l_blpapi_Identity_isAuthorized(handle, service) + + +# signature: void blpapi_Identity_release(blpapi_Identity_t *handle); +def _blpapi_Identity_release(handle): + l_blpapi_Identity_release(handle) + + +# signature: void blpapi_Logging_logTestMessage(blpapi_Logging_Severity_t severity); +def _blpapi_Logging_logTestMessage(severity): + l_blpapi_Logging_logTestMessage(severity) + + +class LoggingCallbackWrapper: + # typedef void (*blpapi_Logging_Func_t)( + # blpapi_UInt64_t threadId, + # int severity, + # blpapi_Datetime_t timestamp, + # const char *category, + # const char *message); + _cftype = CFUNCTYPE(None, c_uint64, c_int, BDatetime, c_char_p, c_char_p) + + @staticmethod + def get(cb: Optional[Callable]) -> Callable: + return ( + LoggingCallbackWrapper._cftype(cb) + if cb is not None + else c_void_p(0) + ) + + +# signature: blpapi_Logging_registerCallback(logging_cb, int); +def _blpapi_Logging_registerCallback(callback, thresholdSeverity): + proxy = LoggingCallbackWrapper.get(callback) + return l_blpapi_Logging_registerCallback(proxy, thresholdSeverity), proxy + + +# signature: int blpapi_MessageFormatter_FormatMessageJson(blpapi_MessageFormatter_t *formatter, const char *message); +def _blpapi_MessageFormatter_FormatMessageJson(formatter, message): + return l_blpapi_MessageFormatter_FormatMessageJson( + formatter, charPtrFromPyStr(message) + ) + + +# signature: int blpapi_MessageFormatter_FormatMessageXml(blpapi_MessageFormatter_t *formatter, const char *message); +def _blpapi_MessageFormatter_FormatMessageXml(formatter, message): + return l_blpapi_MessageFormatter_FormatMessageXml( + formatter, charPtrFromPyStr(message) + ) + + +# signature: int blpapi_MessageFormatter_appendElement(blpapi_MessageFormatter_t *formatter); +def _blpapi_MessageFormatter_appendElement(formatter): + return l_blpapi_MessageFormatter_appendElement(formatter) + + +# signature: int blpapi_MessageFormatter_appendValueBool(blpapi_MessageFormatter_t *formatter, blpapi_Bool_t value); +def _blpapi_MessageFormatter_appendValueBool(formatter, value): + return l_blpapi_MessageFormatter_appendValueBool( + formatter, c_int(value) + ) # int as boolean + + +# signature: int blpapi_MessageFormatter_appendValueChar(blpapi_MessageFormatter_t *formatter, char value); +def _blpapi_MessageFormatter_appendValueChar(formatter, value): + return l_blpapi_MessageFormatter_appendValueChar(formatter, c_char(value)) + + +# signature: int blpapi_MessageFormatter_appendValueDatetime(blpapi_MessageFormatter_t *formatter, const blpapi_Datetime_t *value); +def _blpapi_MessageFormatter_appendValueDatetime(formatter, value): + return l_blpapi_MessageFormatter_appendValueDatetime( + formatter, byref(value) + ) + + +# signature: int blpapi_MessageFormatter_appendValueFloat32(blpapi_MessageFormatter_t *formatter, blpapi_Float32_t value); +def _blpapi_MessageFormatter_appendValueFloat(formatter, value): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + retCode = l_blpapi_MessageFormatter_appendValueFloat64( + formatter, c_double(value) + ) + if retCode: + retCode = l_blpapi_MessageFormatter_appendValueFloat32( + formatter, c_float(value) + ) + return retCode + + +# signature: int blpapi_MessageFormatter_appendValueFloat32(blpapi_MessageFormatter_t *formatter, blpapi_Float32_t value); +def _blpapi_MessageFormatter_appendValueFloat32(formatter, value): + return l_blpapi_MessageFormatter_appendValueFloat32( + formatter, c_float(value) + ) + + +# signature: int blpapi_MessageFormatter_appendValueFloat64(blpapi_MessageFormatter_t *formatter, blpapi_Float64_t value); +def _blpapi_MessageFormatter_appendValueFloat64(formatter, value): + return l_blpapi_MessageFormatter_appendValueFloat64( + formatter, c_double(value) + ) + + +# signature: int blpapi_MessageFormatter_appendValueFromName(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *value); +def _blpapi_MessageFormatter_appendValueFromName(formatter, value): + return l_blpapi_MessageFormatter_appendValueFromName(formatter, value) + + +# signature: int blpapi_MessageFormatter_appendValueHighPrecisionDatetime(blpapi_MessageFormatter_t *formatter,const blpapi_HighPrecisionDatetime_t *value); +def _blpapi_MessageFormatter_appendValueHighPrecisionDatetime( + formatter, value +): + return l_blpapi_MessageFormatter_appendValueHighPrecisionDatetime( + formatter, byref(value) + ) + + +# signature: int blpapi_MessageFormatter_appendValueInt32(blpapi_MessageFormatter_t *formatter, blpapi_Int32_t value); +def _blpapi_MessageFormatter_appendValueInt32(formatter, value): + return l_blpapi_MessageFormatter_appendValueInt32(formatter, value) + + +# signature: int blpapi_MessageFormatter_appendValueInt64(blpapi_MessageFormatter_t *formatter, blpapi_Int64_t value); +def _blpapi_MessageFormatter_appendValueInt64(formatter, value): + return l_blpapi_MessageFormatter_appendValueInt64( + formatter, c_int64(value) + ) + + +# signature: int blpapi_MessageFormatter_appendValueString(blpapi_MessageFormatter_t *formatter, const char *value); +def _blpapi_MessageFormatter_appendValueString(formatter, value): + return l_blpapi_MessageFormatter_appendValueString( + formatter, charPtrFromPyStr(value) + ) + + +# signature: int blpapi_MessageFormatter_assign(blpapi_MessageFormatter_t **lhs, const blpapi_MessageFormatter_t *rhs); +def _blpapi_MessageFormatter_assign(rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_MessageFormatter_copy(blpapi_MessageFormatter_t **formatter,const blpapi_MessageFormatter_t *original); +def _blpapi_MessageFormatter_copy(original): + raise NotImplementedError("not called") + + +# signature: int blpapi_MessageFormatter_destroy(blpapi_MessageFormatter_t *formatter); +def _blpapi_MessageFormatter_destroy(formatter): + return l_blpapi_MessageFormatter_destroy(formatter) + + +# signature: int blpapi_MessageFormatter_popElement(blpapi_MessageFormatter_t *formatter); +def _blpapi_MessageFormatter_popElement(formatter): + return l_blpapi_MessageFormatter_popElement(formatter) + + +# signature: int blpapi_MessageFormatter_pushElement(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName); +def _blpapi_MessageFormatter_pushElement(formatter, typeName): + return l_blpapi_MessageFormatter_pushElement(formatter, typeName) + + +# signature: int blpapi_MessageFormatter_setValueBool(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Bool_t value); +def _blpapi_MessageFormatter_setValueBool(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueBool( + formatter, typeName, c_int(value) + ) # int as boolean + + +# signature: int blpapi_MessageFormatter_setValueBytes(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,const char *value,size_t length); +def _blpapi_MessageFormatter_setValueBytes(formatter, typeName, value): + valuePtr, sz = charPtrWithSizeFromPyStr(value) + return l_blpapi_MessageFormatter_setValueBytes( + formatter, typeName, valuePtr, c_size_t(sz) + ) + + +# signature: int blpapi_MessageFormatter_setValueChar(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,char value); +def _blpapi_MessageFormatter_setValueChar(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueChar( + formatter, typeName, c_char(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueDatetime(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,const blpapi_Datetime_t *value); +def _blpapi_MessageFormatter_setValueDatetime(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueDatetime( + formatter, typeName, byref(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueFloat32(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Float32_t value); +def _blpapi_MessageFormatter_setValueFloat(formatter, typeName, value): + # The C interface will not silently discard precision to store a 64-bit + # float in a field whose schema type is 32-bit, however all Python floats + # are 64-bit, so we explicitly allow narrowing to 32 bits if necessary. + + retCode = l_blpapi_MessageFormatter_setValueFloat64( + formatter, typeName, c_double(value) + ) + if retCode: + retCode = l_blpapi_MessageFormatter_setValueFloat32( + formatter, typeName, c_float(value) + ) + return retCode + + +# signature: int blpapi_MessageFormatter_setValueFloat32(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Float32_t value); +def _blpapi_MessageFormatter_setValueFloat32(formatter, typeName, value): + return l_blpapi_MessageFormatter_appendValueFloat32( + formatter, typeName, c_float(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueFloat64(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Float64_t value); +def _blpapi_MessageFormatter_setValueFloat64(formatter, typeName, value): + return l_blpapi_MessageFormatter_appendValueFloat64( + formatter, typeName, c_double(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueFromName(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,const blpapi_Name_t *value); +def _blpapi_MessageFormatter_setValueFromName(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueFromName( + formatter, typeName, value + ) + + +# signature: int blpapi_MessageFormatter_setValueHighPrecisionDatetime(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,const blpapi_HighPrecisionDatetime_t *value); +def _blpapi_MessageFormatter_setValueHighPrecisionDatetime( + formatter, typeName, value +): + return l_blpapi_MessageFormatter_setValueHighPrecisionDatetime( + formatter, typeName, byref(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueInt32(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Int32_t value); +def _blpapi_MessageFormatter_setValueInt32(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueInt32(formatter, typeName, value) + + +# signature: int blpapi_MessageFormatter_setValueInt64(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,blpapi_Int64_t value); +def _blpapi_MessageFormatter_setValueInt64(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueInt64( + formatter, typeName, c_int64(value) + ) + + +# signature: int blpapi_MessageFormatter_setValueNull(blpapi_MessageFormatter_t *formatter, const blpapi_Name_t *typeName); +def _blpapi_MessageFormatter_setValueNull(formatter, typeName): + return l_blpapi_MessageFormatter_setValueNull(formatter, typeName) + + +# signature: int blpapi_MessageFormatter_setValueString(blpapi_MessageFormatter_t *formatter,const blpapi_Name_t *typeName,const char *value); +def _blpapi_MessageFormatter_setValueString(formatter, typeName, value): + return l_blpapi_MessageFormatter_setValueString( + formatter, typeName, charPtrFromPyStr(value) + ) + + +# signature: blpapi_MessageIterator_t *blpapi_MessageIterator_create(const blpapi_Event_t *event); +def _blpapi_MessageIterator_create(event): + return getHandleFromPtr(l_blpapi_MessageIterator_create(event)) + + +# signature: void blpapi_MessageIterator_destroy(blpapi_MessageIterator_t *iterator); +def _blpapi_MessageIterator_destroy(iterator): + l_blpapi_MessageIterator_destroy(iterator) + + +# signature: int blpapi_MessageIterator_next(blpapi_MessageIterator_t *iterator, blpapi_Message_t **result); +def _blpapi_MessageIterator_next(iterator): + message_pp = c_void_p() + outp = pointer(message_pp) + retCode = l_blpapi_MessageIterator_next(iterator, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_MessageProperties_assign(blpapi_MessageProperties_t *lhs,const blpapi_MessageProperties_t *rhs); +def _blpapi_MessageProperties_assign(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: int blpapi_MessageProperties_copy(blpapi_MessageProperties_t **dest,const blpapi_MessageProperties_t *src); +def _blpapi_MessageProperties_copy(src): + raise NotImplementedError("not called") + + +# signature: int blpapi_MessageProperties_create(blpapi_MessageProperties_t **messageProperties); +def _blpapi_MessageProperties_create(): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_MessageProperties_create(outp) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: void blpapi_MessageProperties_destroy(blpapi_MessageProperties_t *messageProperties); +def _blpapi_MessageProperties_destroy(messageProperties): + l_blpapi_MessageProperties_destroy(messageProperties) + + +# signature: int blpapi_MessageProperties_setCorrelationIds(blpapi_MessageProperties_t *messageProperties,const blpapi_CorrelationId_t *correlationIds,size_t numCorrelationIds); +def _blpapi_MessageProperties_setCorrelationIds( + messageProperties, correlationIds +): + szcids = len(correlationIds) + if szcids > 1: + arraytype = CidStruct * szcids + ptrs = arraytype(*[c.thestruct for c in correlationIds]) + oneptr = byref(ptrs) + elif szcids == 1: + oneptr = byref(correlationIds[0].thestruct) + else: + oneptr = c_void_p() # pass null, the C SDK will check and reject + + return l_blpapi_MessageProperties_setCorrelationIds( + messageProperties, oneptr, c_size_t(szcids) + ) + + +# signature: int blpapi_MessageProperties_setRecapType(blpapi_MessageProperties_t *messageProperties,int recap,int fragment); +def _blpapi_MessageProperties_setRecapType(messageProperties, recap, fragment): + return l_blpapi_MessageProperties_setRecapType( + messageProperties, recap, fragment + ) + + +# signature: int blpapi_MessageProperties_setRequestId(blpapi_MessageProperties_t *messageProperties, const char *requestId); +def _blpapi_MessageProperties_setRequestId(messageProperties, requestId): + return l_blpapi_MessageProperties_setRequestId( + messageProperties, charPtrFromPyStr(requestId) + ) + + +# signature: int blpapi_MessageProperties_setService(blpapi_MessageProperties_t *messageProperties,const blpapi_Service_t *service); +def _blpapi_MessageProperties_setService(messageProperties, service): + return l_blpapi_MessageProperties_setService(messageProperties, service) + + +# signature: int blpapi_MessageProperties_setTimeReceived(blpapi_MessageProperties_t *messageProperties,const blpapi_HighPrecisionDatetime_t *timestamp); +def _blpapi_MessageProperties_setTimeReceived(messageProperties, timestamp): + return l_blpapi_MessageProperties_setTimeReceived( + messageProperties, byref(timestamp) + ) + + +# signature: int blpapi_Message_addRef(const blpapi_Message_t *message); +def _blpapi_Message_addRef(message): + return l_blpapi_Message_addRef(message) + + +# signature: blpapi_CorrelationId_t blpapi_Message_correlationId(const blpapi_Message_t *message, size_t index); +def _blpapi_Message_correlationId(message, index): + # C does return ABIUtil::ptr(message)->correlationId(index).impl(); + # i.e., we need to bump the ref. -- the caller will wrap this in CorrelationId + cid = l_blpapi_Message_correlationId(message, c_size_t(index)) + return cid + + +# signature: blpapi_Element_t *blpapi_Message_elements(const blpapi_Message_t *message); +def _blpapi_Message_elements(message): + return getHandleFromPtr(l_blpapi_Message_elements(message)) + + +# signature: int blpapi_Message_fragmentType(const blpapi_Message_t *message); +def _blpapi_Message_fragmentType(message): + return l_blpapi_Message_fragmentType(message) + + +# signature: int blpapi_Message_getRequestId(const blpapi_Message_t *message, const char **requestId); +def _blpapi_Message_getRequestId(message): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_Message_getRequestId(message, outp) # int + return retCode, getStrFromOutput(outp, retCode) + + +# signature: blpapi_Name_t *blpapi_Message_messageType(const blpapi_Message_t *message); +def _blpapi_Message_messageType(message): + return getHandleFromPtr(l_blpapi_Message_messageType(message)) + + +# signature: int blpapi_Message_numCorrelationIds(const blpapi_Message_t *message); +def _blpapi_Message_numCorrelationIds(message): + return l_blpapi_Message_numCorrelationIds(message) + + +# signature: +def _blpapi_Message_printHelper(message, level, spacesPerLevel): + return any_printer(message, l_blpapi_Message_print, level, spacesPerLevel) + + +# signature: int blpapi_Message_recapType(const blpapi_Message_t *message); +def _blpapi_Message_recapType(message): + return l_blpapi_Message_recapType(message) + + +# signature: int blpapi_Message_release(const blpapi_Message_t *message); +def _blpapi_Message_release(message): + return l_blpapi_Message_release(message) + + +# signature: blpapi_Service_t *blpapi_Message_service(const blpapi_Message_t *message); +def _blpapi_Message_service(message): + service = l_blpapi_Message_service(message) + return getHandleFromPtr(service) + + +# signature: int blpapi_Message_timeReceived(const blpapi_Message_t *message, blpapi_TimePoint_t *timeReceived); +def _blpapi_Message_timeReceived(message): + out = TimePoint() + outp = pointer(out) + retCode = l_blpapi_Message_timeReceived(message, outp) + return retCode, getStructFromOutput(outp, retCode) + + +# signature: const char *blpapi_Message_topicName(const blpapi_Message_t *message); +def _blpapi_Message_topicName(message): # pylint: disable=unused-argument + return "" # that is what C does + + +# signature: blpapi_Name_t *blpapi_Name_create(const char *nameString); +def _blpapi_Name_create(nameString): + return getHandleFromPtr(l_blpapi_Name_create(charPtrFromPyStr(nameString))) + + +# signature: void blpapi_Name_destroy(blpapi_Name_t *name); +def _blpapi_Name_destroy(name): + l_blpapi_Name_destroy(name) + + +# signature: int blpapi_Name_equalsStr(const blpapi_Name_t *name, const char *string); +def _blpapi_Name_equalsStr(name, string): + return l_blpapi_Name_equalsStr(name, charPtrFromPyStr(string)) + + +# signature: blpapi_Name_t *blpapi_Name_findName(const char *nameString); +def _blpapi_Name_findName(nameString): + return getHandleFromPtr( + l_blpapi_Name_findName(charPtrFromPyStr(nameString)) + ) + + +# signature: +def _blpapi_Name_hasName(nameString): + handle = _blpapi_Name_findName(nameString) + return 0 if handle is None else 1 + + +# signature: size_t blpapi_Name_length(const blpapi_Name_t *name); +def _blpapi_Name_length(name): + return l_blpapi_Name_length(name) + + +# signature: const char *blpapi_Name_string(const blpapi_Name_t *name); +def _blpapi_Name_string(name): + # C does not check the pointer, simply reinterpret_casts it + # c_void_p().value and c_void_p(0).value are None + if name is None or name.value is None: + return None + return getStrFromC(l_blpapi_Name_string(name)) + + +# signature: const char *blpapi_Operation_description(blpapi_Operation_t *operation); +def _blpapi_Operation_description(operation): + # tests assume empty string + return getStrFromC(l_blpapi_Operation_description(operation), "") + + +# signature: const char *blpapi_Operation_name(blpapi_Operation_t *operation); +def _blpapi_Operation_name(operation): + return getStrFromC(l_blpapi_Operation_name(operation)) + + +# signature: int blpapi_Operation_numResponseDefinitions(blpapi_Operation_t *operation); +def _blpapi_Operation_numResponseDefinitions(operation): + return l_blpapi_Operation_numResponseDefinitions(operation) + + +# signature: int blpapi_Operation_requestDefinition(blpapi_Operation_t *operation,blpapi_SchemaElementDefinition_t **requestDefinition); +def _blpapi_Operation_requestDefinition(operation): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Operation_requestDefinition(operation, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Operation_responseDefinition(blpapi_Operation_t *operation,blpapi_SchemaElementDefinition_t **responseDefinition,size_t index); +def _blpapi_Operation_responseDefinition(operation, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Operation_responseDefinition( + operation, outp, c_size_t(index) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Operation_responseDefinitionFromName(blpapi_Operation_t *operation,blpapi_SchemaElementDefinition_t **responseDefinition,const blpapi_Name_t *name); +def _blpapi_Operation_responseDefinitionFromName(operation, name): + raise NotImplementedError("not called") + + +# signature: int blpapi_ProviderSession_activateSubServiceCodeRange(blpapi_ProviderSession_t *session,const char *serviceName,int begin,int end,int priority); +def _blpapi_ProviderSession_activateSubServiceCodeRange( + session, serviceName, begin, end, priority +): + return l_blpapi_ProviderSession_activateSubServiceCodeRange( + session, charPtrFromPyStr(serviceName), begin, end, priority + ) + + +# signature: int blpapi_ProviderSession_createServiceStatusTopic(blpapi_ProviderSession_t *session,const blpapi_Service_t *service,blpapi_Topic_t **topic); +def _blpapi_ProviderSession_createServiceStatusTopic(session, service): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_ProviderSession_createServiceStatusTopic( + session, service, outp + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_ProviderSession_createTopics(blpapi_ProviderSession_t *session,blpapi_TopicList_t *topicList,int resolveMode,const blpapi_Identity_t *identity); +def _blpapi_ProviderSession_createTopic(session, message): + raise NotImplementedError("not called") + + +# signature: int blpapi_ProviderSession_createTopics(blpapi_ProviderSession_t *session,blpapi_TopicList_t *topicList,int resolveMode,const blpapi_Identity_t *identity); +def _blpapi_ProviderSession_createTopics( + session, topicList, resolveMode, identity +): + return l_blpapi_ProviderSession_createTopics( + session, topicList, c_int(resolveMode), identity + ) + + +# signature: int blpapi_ProviderSession_createTopicsAsync(blpapi_ProviderSession_t *session,const blpapi_TopicList_t *topicList,int resolveMode,const blpapi_Identity_t *identity); +def _blpapi_ProviderSession_createTopicsAsync( + session, topicList, resolveMode, identity +): + return l_blpapi_ProviderSession_createTopicsAsync( + session, topicList, c_int(resolveMode), identity + ) + + +# signature: int blpapi_ProviderSession_deactivateSubServiceCodeRange(blpapi_ProviderSession_t *session,const char *serviceName,int begin,int end); +def _blpapi_ProviderSession_deactivateSubServiceCodeRange( + session, serviceName, begin, end +): + return l_blpapi_ProviderSession_deactivateSubServiceCodeRange( + session, charPtrFromPyStr(serviceName), begin, end + ) + + +# signature: int blpapi_ProviderSession_deleteTopics(blpapi_ProviderSession_t *session,const blpapi_Topic_t **topics,size_t numTopics); +def _blpapi_ProviderSession_deleteTopics(session, topics): + # topics is a python list of handles by now + sz = len(topics) + arraytpe = c_void_p * sz + topicsp = arraytpe(*topics) + return l_blpapi_ProviderSession_deleteTopics( + session, topicsp, c_size_t(sz) + ) + + +# signature: int blpapi_ProviderSession_deregisterService(blpapi_ProviderSession_t *session, const char *serviceName); +def _blpapi_ProviderSession_deregisterService(session, serviceName): + return l_blpapi_ProviderSession_deregisterService( + session, charPtrFromPyStr(serviceName) + ) + + +# signature: int blpapi_ProviderSession_flushPublishedEvents(blpapi_ProviderSession_t *session, int *allFlushed, int timeoutMsecs); +def _blpapi_ProviderSession_flushPublishedEvents(session, timeoutMsecs): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_ProviderSession_flushPublishedEvents( + session, outp, timeoutMsecs + ) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: blpapi_AbstractSession_t *blpapi_ProviderSession_getAbstractSession(blpapi_ProviderSession_t *session); +def _blpapi_ProviderSession_getAbstractSession(session): + return getHandleFromPtr( + l_blpapi_ProviderSession_getAbstractSession(session) + ) + + +# signature: int blpapi_ProviderSession_getTopic(blpapi_ProviderSession_t *session,const blpapi_Message_t *message,blpapi_Topic_t **topic); +def _blpapi_ProviderSession_getTopic(session, message): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_ProviderSession_getTopic(session, message, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_ProviderSession_nextEvent(blpapi_ProviderSession_t *session,blpapi_Event_t **eventPointer,unsigned int timeoutInMilliseconds); +def _blpapi_ProviderSession_nextEvent(session, timeoutInMilliseconds): + eventptr = c_void_p() + outp = pointer(eventptr) + retCode = l_blpapi_ProviderSession_nextEvent( + session, outp, c_uint(timeoutInMilliseconds) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_ProviderSession_publish(blpapi_ProviderSession_t *session, blpapi_Event_t *event); +def _blpapi_ProviderSession_publish(session, event): + return l_blpapi_ProviderSession_publish(session, event) + + +# signature: int blpapi_ProviderSession_registerService(blpapi_ProviderSession_t *session,const char *serviceName,const blpapi_Identity_t *identity,blpapi_ServiceRegistrationOptions_t *registrationOptions); +def _blpapi_ProviderSession_registerService( + session, serviceName, identity, registrationOptions +): + return l_blpapi_ProviderSession_registerService( + session, charPtrFromPyStr(serviceName), identity, registrationOptions + ) + + +# signature: int blpapi_ProviderSession_registerServiceAsync(blpapi_ProviderSession_t *session,const char *serviceName,const blpapi_Identity_t *identity,blpapi_CorrelationId_t *correlationId,blpapi_ServiceRegistrationOptions_t *registrationOptions); +def _blpapi_ProviderSession_registerServiceAsync( + session, serviceName, identity, correlationId, registrationOptions +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(correlationId.thestruct) + + return l_blpapi_ProviderSession_registerServiceAsync( + session, + charPtrFromPyStr(serviceName), + identity, + cidp, + registrationOptions, + ) + + +# signature: int blpapi_ProviderSession_resolve(blpapi_ProviderSession_t *session,blpapi_ResolutionList_t *resolutionList,int resolveMode,const blpapi_Identity_t *identity); +def _blpapi_ProviderSession_resolve( + session, resolutionList, resolveMode, identity +): + return l_blpapi_ProviderSession_resolve( + session, resolutionList, c_int(resolveMode), identity + ) + + +# signature: int blpapi_ProviderSession_resolveAsync(blpapi_ProviderSession_t *session,const blpapi_ResolutionList_t *resolutionList,int resolveMode,const blpapi_Identity_t *identity); +def _blpapi_ProviderSession_resolveAsync( + session, resolutionList, resolveMode, identity +): + return l_blpapi_ProviderSession_resolveAsync( + session, resolutionList, c_int(resolveMode), identity + ) + + +# signature: int blpapi_ProviderSession_sendResponse(blpapi_ProviderSession_t *session,blpapi_Event_t *event,int isPartialResponse); +def _blpapi_ProviderSession_sendResponse(session, event, isPartialResponse): + return l_blpapi_ProviderSession_sendResponse( + session, event, c_int(isPartialResponse) + ) + + +# signature: int blpapi_ProviderSession_start(blpapi_ProviderSession_t *session); +def _blpapi_ProviderSession_start(session): + return l_blpapi_ProviderSession_start(session) + + +# signature: int blpapi_ProviderSession_startAsync(blpapi_ProviderSession_t *session); +def _blpapi_ProviderSession_startAsync(session): + return l_blpapi_ProviderSession_startAsync(session) + + +# signature: int blpapi_ProviderSession_stop(blpapi_ProviderSession_t *session); +def _blpapi_ProviderSession_stop(session): + return l_blpapi_ProviderSession_stop(session) + + +# signature: int blpapi_ProviderSession_stopAsync(blpapi_ProviderSession_t *session); +def _blpapi_ProviderSession_stopAsync(session): + return l_blpapi_ProviderSession_stopAsync(session) + + +def _blpapi_ProviderSession_terminateSubscriptionsOnTopic( + session, topic, message +): + return _blpapi_ProviderSession_terminateSubscriptionsOnTopics( + session, [topic], message + ) + + +# signature: int blpapi_ProviderSession_terminateSubscriptionsOnTopics(blpapi_ProviderSession_t *session,const blpapi_Topic_t **topics,size_t numTopics,const char *message); +def _blpapi_ProviderSession_terminateSubscriptionsOnTopics( + session, topics, message +): + # we put handles in providersession inside topics + sz = len(topics) + arraytype = c_void_p * sz + topicsp = arraytype(*topics) + return l_blpapi_ProviderSession_terminateSubscriptionsOnTopics( + session, topicsp, c_size_t(sz), charPtrFromPyStr(message) + ) + + +# signature: int blpapi_ProviderSession_tryNextEvent(blpapi_ProviderSession_t *session, blpapi_Event_t **eventPointer); +def _blpapi_ProviderSession_tryNextEvent(session): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_ProviderSession_tryNextEvent(session, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_RequestTemplate_release(const blpapi_RequestTemplate_t *requestTemplate); +def _blpapi_RequestTemplate_release(requestTemplate): + return l_blpapi_RequestTemplate_release(requestTemplate) + + +# signature: void blpapi_Request_destroy(blpapi_Request_t *request); +def _blpapi_Request_destroy(request): + l_blpapi_Request_destroy(request) + + +# signature: blpapi_Element_t *blpapi_Request_elements(blpapi_Request_t *request); +def _blpapi_Request_elements(request): + return getHandleFromPtr(l_blpapi_Request_elements(request)) + + +# signature: int blpapi_Request_getRequestId(const blpapi_Request_t *request, const char **requestId); +def _blpapi_Request_getRequestId(request): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_Request_getRequestId(request, outp) + if retCode != 0: + return retCode, None + return (retCode, getStrFromOutput(outp, retCode)) + + +# signature: void blpapi_Request_setPreferredRoute(blpapi_Request_t *request, blpapi_CorrelationId_t *correlationId); +def _blpapi_Request_setPreferredRoute(request, correlationId): + raise NotImplementedError("not called") + + +# signature: int blpapi_ResolutionList_add(blpapi_ResolutionList_t *list,const char *topic,const blpapi_CorrelationId_t *correlationId); +def _blpapi_ResolutionList_add(resolution_list, topic, correlationId): + return l_blpapi_ResolutionList_add( + resolution_list, + charPtrFromPyStr(topic), + byref(correlationId.thestruct), + ) + + +# signature: int blpapi_ResolutionList_addAttribute(blpapi_ResolutionList_t *list, const blpapi_Name_t *name); +def _blpapi_ResolutionList_addAttribute(resolution_list, name): + return l_blpapi_ResolutionList_addAttribute(resolution_list, name) + + +# signature: int blpapi_ResolutionList_addFromMessage(blpapi_ResolutionList_t *list,const blpapi_Message_t *topic,const blpapi_CorrelationId_t *correlationId); +def _blpapi_ResolutionList_addFromMessage(resolution_list, topic, cid): + return l_blpapi_ResolutionList_addFromMessage( + resolution_list, + topic, + byref(cid.thestruct), + ) + + +# signature: int blpapi_ResolutionList_attribute(const blpapi_ResolutionList_t *list,blpapi_Element_t **element,const blpapi_Name_t *attribute,const blpapi_CorrelationId_t *id); +def _blpapi_ResolutionList_attribute(resolution_list, attribute, cid): + out = c_void_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_attribute( + resolution_list, + outp, + attribute, + byref(cid.thestruct), + ) + + return rc, getHandleFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_attributeAt(const blpapi_ResolutionList_t *list,blpapi_Element_t **element,const blpapi_Name_t *attribute,size_t index); +def _blpapi_ResolutionList_attributeAt(resolution_list, attribute, index): + out = c_void_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_attributeAt( + resolution_list, outp, attribute, c_size_t(index) + ) + + return rc, getHandleFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_correlationIdAt(const blpapi_ResolutionList_t *list,blpapi_CorrelationId_t *result,size_t index); +def _blpapi_ResolutionList_correlationIdAt(resolution_list, index): + cid = CidStruct() + cid_p = pointer(cid) + rc = l_blpapi_ResolutionList_correlationIdAt( + resolution_list, cid_p, c_size_t(index) + ) + if rc == 0: + # C will do: *result = rlImpl->correlationId(index).impl(), + # i.e., we need to bump the reference + # the caller will wrap this in CorrelationId + return rc, cid + return rc, None + + +# signature: blpapi_ResolutionList_t *blpapi_ResolutionList_create(blpapi_ResolutionList_t *from); +def _blpapi_ResolutionList_create(_from): + from_p = c_void_p() if _from is None else _from + return getHandleFromPtr(l_blpapi_ResolutionList_create(from_p)) + + +# signature: void blpapi_ResolutionList_destroy(blpapi_ResolutionList_t *list); +def _blpapi_ResolutionList_destroy(resolution_list): + l_blpapi_ResolutionList_destroy(resolution_list) + + +# signature: blpapi_Element_t *blpapi_ResolutionList_extractAttributeFromResolutionSuccess(const blpapi_Message_t *message, const blpapi_Name_t *attribute); +def _blpapi_ResolutionList_extractAttributeFromResolutionSuccess( + message, attribute +): + raise DeprecationWarning() + + +# signature: int blpapi_ResolutionList_message(const blpapi_ResolutionList_t *list,blpapi_Message_t **element,const blpapi_CorrelationId_t *id); +def _blpapi_ResolutionList_message(resolution_list, cid): + out = c_void_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_message( + resolution_list, outp, byref(cid.thestruct) + ) + return rc, getHandleFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_messageAt(const blpapi_ResolutionList_t *list,blpapi_Message_t **element,size_t index); +def _blpapi_ResolutionList_messageAt(resolution_list, index): + out = c_void_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_messageAt( + resolution_list, outp, c_size_t(index) + ) + return rc, getHandleFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_size(const blpapi_ResolutionList_t *list); +def _blpapi_ResolutionList_size(resolution_list): + return l_blpapi_ResolutionList_size(resolution_list) + + +# signature: int blpapi_ResolutionList_status(const blpapi_ResolutionList_t *list,int *status,const blpapi_CorrelationId_t *id); +def _blpapi_ResolutionList_status(resolution_list, cid): + out = c_int() + outp = pointer(out) + rc = l_blpapi_ResolutionList_status( + resolution_list, outp, byref(cid.thestruct) + ) + + return rc, getPODFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_statusAt(const blpapi_ResolutionList_t *list, int *status, size_t index); +def _blpapi_ResolutionList_statusAt(resolution_list, index): + out = c_int() + outp = pointer(out) + rc = l_blpapi_ResolutionList_statusAt(resolution_list, outp, index) + + return rc, out.value + + +# signature: int blpapi_ResolutionList_topicString(const blpapi_ResolutionList_t *list,const char **topic,const blpapi_CorrelationId_t *id); +def _blpapi_ResolutionList_topicString(resolution_list, cid): + out = c_char_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_topicString( + resolution_list, outp, byref(cid.thestruct) + ) + return rc, getStrFromOutput(outp, rc) + + +# signature: int blpapi_ResolutionList_topicStringAt(const blpapi_ResolutionList_t *list, const char **topic, size_t index); +def _blpapi_ResolutionList_topicStringAt(resolution_list, index): + out = c_char_p() + outp = pointer(out) + rc = l_blpapi_ResolutionList_topicStringAt(resolution_list, outp, index) + return rc, getStrFromOutput(outp, rc) + + +# signature: const char *blpapi_SchemaElementDefinition_description(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_description(field): + ds = l_blpapi_SchemaElementDefinition_description(field) + return getStrFromC(ds) + + +# signature: blpapi_Name_t *blpapi_SchemaElementDefinition_getAlternateName(const blpapi_SchemaElementDefinition_t *field, size_t index); +def _blpapi_SchemaElementDefinition_getAlternateName(field, index): + return getHandleFromPtr( + l_blpapi_SchemaElementDefinition_getAlternateName( + field, c_size_t(index) + ) + ) + + +# signature: size_t blpapi_SchemaElementDefinition_maxValues(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_maxValues(field): + return l_blpapi_SchemaElementDefinition_maxValues(field) + + +# signature: size_t blpapi_SchemaElementDefinition_minValues(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_minValues(field): + return l_blpapi_SchemaElementDefinition_minValues(field) + + +# signature: blpapi_Name_t *blpapi_SchemaElementDefinition_name(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_name(field): + return getHandleFromPtr(l_blpapi_SchemaElementDefinition_name(field)) + + +# signature: size_t blpapi_SchemaElementDefinition_numAlternateNames(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_numAlternateNames(field): + return l_blpapi_SchemaElementDefinition_numAlternateNames(field) + + +# signature: +def _blpapi_SchemaElementDefinition_printHelper(item, level, spacesPerLevel): + return any_printer( + item, l_blpapi_SchemaElementDefinition_print, level, spacesPerLevel + ) + + +# signature: int blpapi_SchemaElementDefinition_status(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_status(field): + return l_blpapi_SchemaElementDefinition_status(field) + + +# signature: blpapi_SchemaTypeDefinition_t *blpapi_SchemaElementDefinition_type(const blpapi_SchemaElementDefinition_t *field); +def _blpapi_SchemaElementDefinition_type(field): + return getHandleFromPtr(l_blpapi_SchemaElementDefinition_type(field)) + + +# signature: int blpapi_SchemaTypeDefinition_datatype(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_datatype(stype): + return l_blpapi_SchemaTypeDefinition_datatype(stype) + + +# signature: const char *blpapi_SchemaTypeDefinition_description(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_description(stype): + ds = l_blpapi_SchemaTypeDefinition_description(stype) + return getStrFromC(ds) + + +# signature: blpapi_ConstantList_t *blpapi_SchemaTypeDefinition_enumeration(const blpapi_SchemaTypeDefinition_t *element); +def _blpapi_SchemaTypeDefinition_enumeration(element): + return getHandleFromPtr(l_blpapi_SchemaTypeDefinition_enumeration(element)) + + +# signature: blpapi_SchemaTypeDefinition_getElementDefinition(const blpapi_SchemaTypeDefinition_t *type,const char *nameString,const blpapi_Name_t *name); +def _blpapi_SchemaTypeDefinition_getElementDefinition(stype, nameString, name): + return getHandleFromPtr( + l_blpapi_SchemaTypeDefinition_getElementDefinition( + stype, charPtrFromPyStr(nameString), name + ) + ) + + +# signature: blpapi_SchemaTypeDefinition_getElementDefinitionAt(const blpapi_SchemaTypeDefinition_t *type, size_t index); +def _blpapi_SchemaTypeDefinition_getElementDefinitionAt(stype, index): + return getHandleFromPtr( + l_blpapi_SchemaTypeDefinition_getElementDefinitionAt( + stype, c_size_t(index) + ) + ) + + +# signature: +def _blpapi_SchemaTypeDefinition_hasElementDefinition(stype, nameString, name): + return l_blpapi_SchemaTypeDefinition_getElementDefinition( + stype, charPtrFromPyStr(nameString), name + ) + + +# signature: int blpapi_SchemaTypeDefinition_isComplexType(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_isComplexType(stype): + return l_blpapi_SchemaTypeDefinition_isComplexType(stype) + + +# signature: int blpapi_SchemaTypeDefinition_isEnumerationType(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_isEnumerationType(stype): + return l_blpapi_SchemaTypeDefinition_isEnumerationType(stype) + + +# signature: int blpapi_SchemaTypeDefinition_isSimpleType(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_isSimpleType(stype): + return l_blpapi_SchemaTypeDefinition_isSimpleType(stype) + + +# signature: blpapi_Name_t *blpapi_SchemaTypeDefinition_name(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_name(stype): + return getHandleFromPtr(l_blpapi_SchemaTypeDefinition_name(stype)) + + +# signature: size_t blpapi_SchemaTypeDefinition_numElementDefinitions(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_numElementDefinitions(stype): + return l_blpapi_SchemaTypeDefinition_numElementDefinitions(stype) + + +# signature: +def _blpapi_SchemaTypeDefinition_printHelper(item, level, spacesPerLevel): + return any_printer( + item, l_blpapi_SchemaTypeDefinition_print, level, spacesPerLevel + ) + + +# signature: int blpapi_SchemaTypeDefinition_status(const blpapi_SchemaTypeDefinition_t *type); +def _blpapi_SchemaTypeDefinition_status(stype): + return l_blpapi_SchemaTypeDefinition_status(stype) + + +# signature: int blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange(blpapi_ServiceRegistrationOptions_t *parameters,int start,int end,int priority); +def _blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange( + parameters, start, end, priority +): + return l_blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange( + parameters, start, end, priority + ) # all ints + + +# signature: void blpapi_ServiceRegistrationOptions_copy(blpapi_ServiceRegistrationOptions_t *lhs,const blpapi_ServiceRegistrationOptions_t *rhs); +def _blpapi_ServiceRegistrationOptions_copy(lhs, rhs): + raise NotImplementedError("not called") + + +# signature: blpapi_ServiceRegistrationOptions_t *blpapi_ServiceRegistrationOptions_create(void); +def _blpapi_ServiceRegistrationOptions_create(): + return getHandleFromPtr(l_blpapi_ServiceRegistrationOptions_create()) + + +# signature: void blpapi_ServiceRegistrationOptions_destroy(blpapi_ServiceRegistrationOptions_t *parameters); +def _blpapi_ServiceRegistrationOptions_destroy(parameters): + l_blpapi_ServiceRegistrationOptions_destroy(parameters) + + +# signature: blpapi_ServiceRegistrationOptions_duplicate(const blpapi_ServiceRegistrationOptions_t *parameters); +def _blpapi_ServiceRegistrationOptions_duplicate(parameters): + raise NotImplementedError("not called") + + +BLPAPI_MAX_GROUP_ID_SIZE = 64 + + +# signature: int blpapi_ServiceRegistrationOptions_getGroupId(blpapi_ServiceRegistrationOptions_t *parameters,char *groupdIdBuffer,int *groupIdLength); +def _blpapi_ServiceRegistrationOptions_getGroupId(parameters): + outp = create_string_buffer(BLPAPI_MAX_GROUP_ID_SIZE) + sz = c_int() + szp = pointer(sz) + retCode = l_blpapi_ServiceRegistrationOptions_getGroupId( + parameters, outp, szp + ) + if retCode != 0: + return None + return retCode, getSizedStrFromBuffer(outp, sz.value) + + +# signature: int blpapi_ServiceRegistrationOptions_getPartsToRegister(blpapi_ServiceRegistrationOptions_t *parameters); +def _blpapi_ServiceRegistrationOptions_getPartsToRegister(parameters): + return l_blpapi_ServiceRegistrationOptions_getPartsToRegister(parameters) + + +# signature: int blpapi_ServiceRegistrationOptions_getServicePriority(blpapi_ServiceRegistrationOptions_t *parameters); +def _blpapi_ServiceRegistrationOptions_getServicePriority(parameters): + return l_blpapi_ServiceRegistrationOptions_getServicePriority(parameters) + + +# signature: void blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges(blpapi_ServiceRegistrationOptions_t *parameters); +def _blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges( + parameters, +): + l_blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges( + parameters + ) + + +# signature: void blpapi_ServiceRegistrationOptions_setGroupId(blpapi_ServiceRegistrationOptions_t *parameters,const char *groupId,unsigned int groupIdLength); +def _blpapi_ServiceRegistrationOptions_setGroupId(parameters, groupId): + gid, sz = charPtrWithSizeFromPyStr(groupId) + l_blpapi_ServiceRegistrationOptions_setGroupId(parameters, gid, c_uint(sz)) + + +# signature: void blpapi_ServiceRegistrationOptions_setPartsToRegister(blpapi_ServiceRegistrationOptions_t *parameters, int parts); +def _blpapi_ServiceRegistrationOptions_setPartsToRegister(parameters, parts): + l_blpapi_ServiceRegistrationOptions_setPartsToRegister(parameters, parts) + + +# signature: int blpapi_ServiceRegistrationOptions_setServicePriority(blpapi_ServiceRegistrationOptions_t *parameters, int priority); +def _blpapi_ServiceRegistrationOptions_setServicePriority( + parameters, priority +): + return l_blpapi_ServiceRegistrationOptions_setServicePriority( + parameters, priority + ) + + +# signature: int blpapi_Service_addRef(blpapi_Service_t *service); +def _blpapi_Service_addRef(service): + return l_blpapi_Service_addRef(service) + + +# signature: const char *blpapi_Service_authorizationServiceName(blpapi_Service_t *service); +def _blpapi_Service_authorizationServiceName(service): + return getStrFromC(l_blpapi_Service_authorizationServiceName(service)) + + +# signature: int blpapi_Service_createAdminEvent(blpapi_Service_t *service, blpapi_Event_t **event); +def _blpapi_Service_createAdminEvent(service): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_createAdminEvent(service, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_createAuthorizationRequest(blpapi_Service_t *service,blpapi_Request_t **request,const char *operation); +def _blpapi_Service_createAuthorizationRequest(service, operation): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_createAuthorizationRequest( + service, outp, charPtrFromPyStr(operation) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_createPublishEvent(blpapi_Service_t *service, blpapi_Event_t **event); +def _blpapi_Service_createPublishEvent(service): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_createPublishEvent(service, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_createRequest(blpapi_Service_t *service,blpapi_Request_t **request,const char *operation); +def _blpapi_Service_createRequest(service, operation): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_createRequest( + service, outp, charPtrFromPyStr(operation) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_createResponseEvent(blpapi_Service_t *service,const blpapi_CorrelationId_t *correlationId,blpapi_Event_t **event); +def _blpapi_Service_createResponseEvent(service, correlationId): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_createResponseEvent( + service, byref(correlationId.thestruct), outp + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: const char *blpapi_Service_description(blpapi_Service_t *service); +def _blpapi_Service_description(service): + return getStrFromC(l_blpapi_Service_description(service)) + + +# signature: int blpapi_Service_getEventDefinition(blpapi_Service_t *service,blpapi_SchemaElementDefinition_t **result,const char *nameString,const blpapi_Name_t *name); +def _blpapi_Service_getEventDefinition(service, nameString, name): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_getEventDefinition( + service, outp, charPtrFromPyStr(nameString), name + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_getEventDefinitionAt(blpapi_Service_t *service,blpapi_SchemaElementDefinition_t **result,size_t index); +def _blpapi_Service_getEventDefinitionAt(service, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_getEventDefinitionAt( + service, outp, c_size_t(index) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_getOperation(blpapi_Service_t *service,blpapi_Operation_t **operation,const char *nameString,const blpapi_Name_t *name); +def _blpapi_Service_getOperation(service, nameString, name): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_getOperation( + service, outp, charPtrFromPyStr(nameString), name + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Service_getOperationAt(blpapi_Service_t *service,blpapi_Operation_t **operation,size_t index); +def _blpapi_Service_getOperationAt(service, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_Service_getOperationAt(service, outp, index) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: +def _blpapi_Service_hasEventDefinition(service, nameString, name): + return ( + 0 == _blpapi_Service_getEventDefinition(service, nameString, name)[0] + ) + + +# signature: +def _blpapi_Service_hasOperation(service, nameString, name): + return 0 == _blpapi_Service_getOperation(service, nameString, name)[0] + + +# signature: const char *blpapi_Service_name(blpapi_Service_t *service); +def _blpapi_Service_name(service): + return getStrFromC(l_blpapi_Service_name(service)) + + +# signature: int blpapi_Service_numEventDefinitions(blpapi_Service_t *service); +def _blpapi_Service_numEventDefinitions(service): + return l_blpapi_Service_numEventDefinitions(service) + + +# signature: int blpapi_Service_numOperations(blpapi_Service_t *service); +def _blpapi_Service_numOperations(service): + return l_blpapi_Service_numOperations(service) + + +# signature: +def _blpapi_Service_printHelper(service, level, spacesPerLevel): + return any_printer(service, l_blpapi_Service_print, level, spacesPerLevel) + + +# signature: void blpapi_Service_release(blpapi_Service_t *service); +def _blpapi_Service_release(service): + l_blpapi_Service_release(service) + + +# signature: int blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(parameters): + return l_blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg(parameters) + + +# signature: int blpapi_SessionOptions_applicationIdentityKey(const char **applicationIdentityKey,size_t *size,blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_applicationIdentityKey(parameters): + out = c_char_p() + outp = pointer(out) + szout = c_size_t() + szoutp = pointer(szout) + retCode = l_blpapi_SessionOptions_applicationIdentityKey( + outp, szoutp, parameters + ) + return retCode, getSizedStrFromOutput(outp, szoutp, retCode) + + +# signature: const char *blpapi_SessionOptions_authenticationOptions(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_authenticationOptions(parameters): + return getStrFromC( + l_blpapi_SessionOptions_authenticationOptions(parameters) + ) + + +# signature: int blpapi_SessionOptions_autoRestartOnDisconnection(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_autoRestartOnDisconnection(parameters): + return l_blpapi_SessionOptions_autoRestartOnDisconnection(parameters) + + +# signature: int blpapi_SessionOptions_bandwidthSaveModeDisabled(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_bandwidthSaveModeDisabled(parameters): + return l_blpapi_SessionOptions_bandwidthSaveModeDisabled(parameters) + + +# signature: int blpapi_SessionOptions_clientMode(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_clientMode(parameters): + return l_blpapi_SessionOptions_clientMode(parameters) + + +# signature: unsigned int blpapi_SessionOptions_connectTimeout(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_connectTimeout(parameters): + return l_blpapi_SessionOptions_connectTimeout(parameters) + + +# signature: blpapi_SessionOptions_t *blpapi_SessionOptions_create(void); +def _blpapi_SessionOptions_create(): + return getHandleFromPtr(l_blpapi_SessionOptions_create()) + + +# signature: int blpapi_SessionOptions_defaultKeepAliveInactivityTime(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_defaultKeepAliveInactivityTime(parameters): + return l_blpapi_SessionOptions_defaultKeepAliveInactivityTime(parameters) + + +# signature: int blpapi_SessionOptions_defaultKeepAliveResponseTimeout(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_defaultKeepAliveResponseTimeout(parameters): + return l_blpapi_SessionOptions_defaultKeepAliveResponseTimeout(parameters) + + +# signature: const char *blpapi_SessionOptions_defaultServices(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_defaultServices(parameters): + return getStrFromC(l_blpapi_SessionOptions_defaultServices(parameters)) + + +# signature: const char *blpapi_SessionOptions_defaultSubscriptionService(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_defaultSubscriptionService(parameters): + return getStrFromC( + l_blpapi_SessionOptions_defaultSubscriptionService(parameters) + ) + + +# signature: const char *blpapi_SessionOptions_defaultTopicPrefix(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_defaultTopicPrefix(parameters): + return getStrFromC(l_blpapi_SessionOptions_defaultTopicPrefix(parameters)) + + +# signature: void blpapi_SessionOptions_destroy(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_destroy(parameters): + l_blpapi_SessionOptions_destroy(parameters) + + +# signature: int blpapi_SessionOptions_flushPublishedEventsTimeout(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_flushPublishedEventsTimeout(parameters): + return l_blpapi_SessionOptions_flushPublishedEventsTimeout(parameters) + + +# signature: int blpapi_SessionOptions_getServerAddressWithProxy(blpapi_SessionOptions_t *parameters,const char **serverHost,unsigned short *serverPort,const char **socks5Host,unsigned short *sock5Port,size_t index); +def _blpapi_SessionOptions_getServerAddressWithProxy(parameters, index): + hostout = c_char_p() + hostoutp = pointer(hostout) + portout = c_uint16() + portoutp = pointer(portout) + s5hostout = c_char_p() + s5hostoutp = pointer(s5hostout) + s5portout = c_uint16() + s5portoutp = pointer(s5portout) + retCode = l_blpapi_SessionOptions_getServerAddressWithProxy( + parameters, hostoutp, portoutp, s5hostoutp, s5portoutp, c_size_t(index) + ) + return ( + retCode, + getStrFromOutput(hostoutp, retCode), + getPODFromOutput(portoutp, retCode), + getStrFromOutput(s5hostoutp, retCode), + getPODFromOutput(s5portoutp, retCode), + ) + + +# signature: int blpapi_SessionOptions_keepAliveEnabled(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_keepAliveEnabled(parameters): + return l_blpapi_SessionOptions_keepAliveEnabled(parameters) + + +# signature: size_t blpapi_SessionOptions_maxEventQueueSize(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_maxEventQueueSize(parameters): + return l_blpapi_SessionOptions_maxEventQueueSize(parameters) + + +# signature: int blpapi_SessionOptions_maxPendingRequests(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_maxPendingRequests(parameters): + return l_blpapi_SessionOptions_maxPendingRequests(parameters) + + +# signature: int blpapi_SessionOptions_numServerAddresses(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_numServerAddresses(parameters): + return l_blpapi_SessionOptions_numServerAddresses(parameters) + + +# signature: int blpapi_SessionOptions_numStartAttempts(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_numStartAttempts(parameters): + return l_blpapi_SessionOptions_numStartAttempts(parameters) + + +# signature: +def _blpapi_SessionOptions_printHelper(sessionOptions, level, spacesPerLevel): + return any_printer( + sessionOptions, l_blpapi_SessionOptions_print, level, spacesPerLevel + ) + + +# signature: int blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_recordSubscriptionDataReceiveTimes(parameters): + return l_blpapi_SessionOptions_recordSubscriptionDataReceiveTimes( + parameters + ) + + +# signature: int blpapi_SessionOptions_removeServerAddress(blpapi_SessionOptions_t *parameters, size_t index); +def _blpapi_SessionOptions_removeServerAddress(parameters, index): + return l_blpapi_SessionOptions_removeServerAddress( + parameters, c_size_t(index) + ) + + +# signature: const char *blpapi_SessionOptions_serverHost(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_serverHost(parameters): + return getStrFromC(l_blpapi_SessionOptions_serverHost(parameters)) + + +# signature: unsigned int blpapi_SessionOptions_serverPort(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_serverPort(parameters): + return l_blpapi_SessionOptions_serverPort(parameters) + + +# signature: int blpapi_SessionOptions_serviceCheckTimeout(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_serviceCheckTimeout(parameters): + return l_blpapi_SessionOptions_serviceCheckTimeout(parameters) + + +# signature: int blpapi_SessionOptions_serviceDownloadTimeout(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_serviceDownloadTimeout(parameters): + return l_blpapi_SessionOptions_serviceDownloadTimeout(parameters) + + +# signature: int blpapi_SessionOptions_sessionName(const char **sessionName,size_t *size,blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_sessionName(parameters): + out = c_char_p() + outp = pointer(out) + szout = c_size_t() + szoutp = pointer(szout) + retCode = l_blpapi_SessionOptions_sessionName(outp, szoutp, parameters) + return retCode, getSizedStrFromOutput(outp, szoutp, retCode) + + +# signature: void blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg(blpapi_SessionOptions_t *parameters,int allowMultipleCorrelatorsPerMsg); +def _blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg( + parameters, allowMultipleCorrelatorsPerMsg +): + l_blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg( + parameters, allowMultipleCorrelatorsPerMsg + ) + + +# signature: int blpapi_SessionOptions_setApplicationIdentityKey(blpapi_SessionOptions_t *parameters,const char *applicationIdentityKey,size_t size); +def _blpapi_SessionOptions_setApplicationIdentityKey( + parameters, applicationIdentityKey +): + aik, sz = charPtrWithSizeFromPyStr(applicationIdentityKey) + return l_blpapi_SessionOptions_setApplicationIdentityKey( + parameters, + aik, + c_size_t(sz), + ) + + +# signature: void blpapi_SessionOptions_setAuthenticationOptions(blpapi_SessionOptions_t *parameters, const char *authOptions); +def _blpapi_SessionOptions_setAuthenticationOptions(parameters, authOptions): + l_blpapi_SessionOptions_setAuthenticationOptions( + parameters, charPtrFromPyStr(authOptions) + ) + + +# signature: void blpapi_SessionOptions_setAutoRestartOnDisconnection(blpapi_SessionOptions_t *parameters, int autoRestart); +def _blpapi_SessionOptions_setAutoRestartOnDisconnection( + parameters, autoRestart +): + l_blpapi_SessionOptions_setAutoRestartOnDisconnection( + parameters, autoRestart + ) + + +# signature: int blpapi_SessionOptions_setBandwidthSaveModeDisabled(blpapi_SessionOptions_t *parameters, int disableBandwidthSaveMode); +def _blpapi_SessionOptions_setBandwidthSaveModeDisabled( + parameters, disableBandwidthSaveMode +): + return l_blpapi_SessionOptions_setBandwidthSaveModeDisabled( + parameters, disableBandwidthSaveMode + ) + + +# signature: void blpapi_SessionOptions_setClientMode(blpapi_SessionOptions_t *parameters, int clientMode); +def _blpapi_SessionOptions_setClientMode(parameters, clientMode): + l_blpapi_SessionOptions_setClientMode(parameters, clientMode) + + +# signature: int blpapi_SessionOptions_setConnectTimeout(blpapi_SessionOptions_t *parameters,unsigned int timeoutInMilliseconds); +def _blpapi_SessionOptions_setConnectTimeout( + parameters, timeoutInMilliseconds +): + return l_blpapi_SessionOptions_setConnectTimeout( + parameters, c_uint32(timeoutInMilliseconds) + ) + + +# signature: int blpapi_SessionOptions_setDefaultKeepAliveInactivityTime(blpapi_SessionOptions_t *parameters, int inactivityMsecs); +def _blpapi_SessionOptions_setDefaultKeepAliveInactivityTime( + parameters, inactivityMsecs +): + return l_blpapi_SessionOptions_setDefaultKeepAliveInactivityTime( + parameters, inactivityMsecs + ) + + +# signature: int blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout(blpapi_SessionOptions_t *parameters, int timeoutMsecs); +def _blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout( + parameters, timeoutMsecs +): + return l_blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout( + parameters, timeoutMsecs + ) + + +# signature: int blpapi_SessionOptions_setDefaultServices(blpapi_SessionOptions_t *parameters, const char *defaultServices); +def _blpapi_SessionOptions_setDefaultServices(parameters, defaultServices): + return l_blpapi_SessionOptions_setDefaultServices( + parameters, charPtrFromPyStr(defaultServices) + ) + + +# signature: int blpapi_SessionOptions_setDefaultSubscriptionService(blpapi_SessionOptions_t *parameters, const char *serviceIdentifier); +def _blpapi_SessionOptions_setDefaultSubscriptionService( + parameters, serviceIdentifier +): + return l_blpapi_SessionOptions_setDefaultSubscriptionService( + parameters, charPtrFromPyStr(serviceIdentifier) + ) + + +# signature: void blpapi_SessionOptions_setDefaultTopicPrefix(blpapi_SessionOptions_t *parameters, const char *prefix); +def _blpapi_SessionOptions_setDefaultTopicPrefix(parameters, topicPrefix): + l_blpapi_SessionOptions_setDefaultTopicPrefix( + parameters, charPtrFromPyStr(topicPrefix) + ) + + +# signature: int blpapi_SessionOptions_setFlushPublishedEventsTimeout(blpapi_SessionOptions_t *paramaters, int timeoutMsecs); +def _blpapi_SessionOptions_setFlushPublishedEventsTimeout( + paramaters, timeoutMsecs +): + return l_blpapi_SessionOptions_setFlushPublishedEventsTimeout( + paramaters, timeoutMsecs + ) + + +# signature: int blpapi_SessionOptions_setKeepAliveEnabled(blpapi_SessionOptions_t *parameters, int isEnabled); +def _blpapi_SessionOptions_setKeepAliveEnabled(parameters, isEnabled): + return l_blpapi_SessionOptions_setKeepAliveEnabled(parameters, isEnabled) + + +# signature: void blpapi_SessionOptions_setMaxEventQueueSize(blpapi_SessionOptions_t *parameters, size_t maxEventQueueSize); +def _blpapi_SessionOptions_setMaxEventQueueSize(parameters, maxEventQueueSize): + l_blpapi_SessionOptions_setMaxEventQueueSize( + parameters, c_size_t(maxEventQueueSize) + ) + + +# signature: void blpapi_SessionOptions_setMaxPendingRequests(blpapi_SessionOptions_t *parameters, int maxPendingRequests); +def _blpapi_SessionOptions_setMaxPendingRequests( + parameters, maxPendingRequests +): + l_blpapi_SessionOptions_setMaxPendingRequests( + parameters, maxPendingRequests + ) + + +# signature: void blpapi_SessionOptions_setNumStartAttempts(blpapi_SessionOptions_t *parameters, int numStartAttempts); +def _blpapi_SessionOptions_setNumStartAttempts(parameters, numStartAttempts): + l_blpapi_SessionOptions_setNumStartAttempts(parameters, numStartAttempts) + + +# signature: void blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes(blpapi_SessionOptions_t *parameters, int shouldRecord); +def _blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes( + parameters, shouldRecord +): + l_blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes( + parameters, shouldRecord + ) + + +# signature: int blpapi_SessionOptions_setServerAddress(blpapi_SessionOptions_t *parameters,const char *serverHost,unsigned short serverPort,size_t index); +def _blpapi_SessionOptions_setServerAddress( + parameters, serverHost, serverPort, index +): + return l_blpapi_SessionOptions_setServerAddress( + parameters, + charPtrFromPyStr(serverHost), + c_uint16(serverPort), + c_size_t(index), + ) + + +# signature: int blpapi_SessionOptions_setServerAddressWithProxy(blpapi_SessionOptions_t *parameters,const char *serverHost,unsigned short serverPort,const blpapi_Socks5Config_t *socks5Config,size_t index); +def _blpapi_SessionOptions_setServerAddressWithProxy( + parameters, serverHost, serverPort, socks5Config, index +): + # parameters is the handle to SessionOptions + # socks5Config if any would be a handle to Socks5Config + return l_blpapi_SessionOptions_setServerAddressWithProxy( + parameters, + charPtrFromPyStr(serverHost), + c_uint16(serverPort), + socks5Config, + c_size_t(index), + ) + + +# signature: int blpapi_SessionOptions_setServerHost(blpapi_SessionOptions_t *parameters, const char *serverHost); +def _blpapi_SessionOptions_setServerHost(parameters, serverHost): + return l_blpapi_SessionOptions_setServerHost( + parameters, charPtrFromPyStr(serverHost) + ) + + +# signature: int blpapi_SessionOptions_setServerPort(blpapi_SessionOptions_t *parameters, unsigned short serverPort); +def _blpapi_SessionOptions_setServerPort(parameters, serverPort): + return l_blpapi_SessionOptions_setServerPort( + parameters, c_uint16(serverPort) + ) + + +# signature: int blpapi_SessionOptions_setServiceCheckTimeout(blpapi_SessionOptions_t *paramaters, int timeoutMsecs); +def _blpapi_SessionOptions_setServiceCheckTimeout(paramaters, timeoutMsecs): + return l_blpapi_SessionOptions_setServiceCheckTimeout( + paramaters, timeoutMsecs + ) + + +# signature: int blpapi_SessionOptions_setServiceDownloadTimeout(blpapi_SessionOptions_t *paramaters, int timeoutMsecs); +def _blpapi_SessionOptions_setServiceDownloadTimeout(paramaters, timeoutMsecs): + return l_blpapi_SessionOptions_setServiceDownloadTimeout( + paramaters, timeoutMsecs + ) + + +# signature: int blpapi_SessionOptions_setSessionIdentityOptions(blpapi_SessionOptions_t *parameters,const blpapi_AuthOptions_t *authOptions,blpapi_CorrelationId_t *cid); +def _blpapi_SessionOptions_setSessionIdentityOptions( + parameters, authOptions, cid +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(cid.thestruct) + retCode = l_blpapi_SessionOptions_setSessionIdentityOptions( + parameters, authOptions, cidp + ) + return retCode, cid if retCode == 0 else None + + +# signature: int blpapi_SessionOptions_setSessionName(blpapi_SessionOptions_t *parameters,const char *sessionName,size_t size); +def _blpapi_SessionOptions_setSessionName(parameters, sessionName): + sn, sz = charPtrWithSizeFromPyStr(sessionName) + return l_blpapi_SessionOptions_setSessionName( + parameters, + sn, + c_size_t(sz), + ) + + +# signature: int blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark(blpapi_SessionOptions_t *parameters, float hiWaterMark); +def _blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark( + parameters, hiWaterMark +): + return l_blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark( + parameters, c_float(hiWaterMark) + ) + + +# signature: int blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark(blpapi_SessionOptions_t *parameters, float loWaterMark); +def _blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark( + parameters, loWaterMark +): + return l_blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark( + parameters, c_float(loWaterMark) + ) + + +# signature: void blpapi_SessionOptions_setTlsOptions(blpapi_SessionOptions_t *paramaters,const blpapi_TlsOptions_t *tlsOptions); +def _blpapi_SessionOptions_setTlsOptions(paramaters, tlsOptions): + l_blpapi_SessionOptions_setTlsOptions(paramaters, tlsOptions) + + +# signature: float blpapi_SessionOptions_slowConsumerWarningHiWaterMark(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_slowConsumerWarningHiWaterMark(parameters): + return l_blpapi_SessionOptions_slowConsumerWarningHiWaterMark(parameters) + + +# signature: float blpapi_SessionOptions_slowConsumerWarningLoWaterMark(blpapi_SessionOptions_t *parameters); +def _blpapi_SessionOptions_slowConsumerWarningLoWaterMark(parameters): + return l_blpapi_SessionOptions_slowConsumerWarningLoWaterMark(parameters) + + +# signature: int blpapi_Session_createSnapshotRequestTemplate(blpapi_RequestTemplate_t **requestTemplate,blpapi_Session_t *session,const char *subscriptionString,const blpapi_Identity_t *identity,blpapi_CorrelationId_t *correlationId); +def _blpapi_Session_createSnapshotRequestTemplate( + session, subscriptionString, identity, correlationId +): + # the C layer will OVERWRITE cid with autogen for unset + out = c_void_p() + outp = pointer(out) + idp = c_void_p() if identity is None else identity + + cidp = pointer(correlationId.thestruct) + + retCode = l_blpapi_Session_createSnapshotRequestTemplate( + outp, + session, + charPtrFromPyStr(subscriptionString), + idp, + cidp, + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: blpapi_AbstractSession_t *blpapi_Session_getAbstractSession(blpapi_Session_t *session); +def _blpapi_Session_getAbstractSession(session): + return getHandleFromPtr(l_blpapi_Session_getAbstractSession(session)) + + +# signature: int blpapi_Session_nextEvent(blpapi_Session_t *session,blpapi_Event_t **eventPointer,unsigned int timeoutInMilliseconds); +def _blpapi_Session_nextEvent(session, timeoutInMilliseconds): + eventptr = c_void_p() + outp = pointer(eventptr) + retCode = l_blpapi_Session_nextEvent( + session, outp, c_uint(timeoutInMilliseconds) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Session_resubscribe(blpapi_Session_t *session,const blpapi_SubscriptionList_t *resubscriptionList,const char *requestLabel,int requestLabelLen); +def _blpapi_Session_resubscribe(session, resubscriptionList, requestLabel): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_resubscribe(session, resubscriptionList, label, sz) + + +# signature: int blpapi_Session_resubscribeEx(blpapi_Session_t *session,const blpapi_SubscriptionList_t *resubscriptionList,const char *requestLabel,int requestLabelLen,blpapi_SubscriptionPreprocessErrorHandler_t errorHandler,void *userData); +def _blpapi_Session_resubscribeEx( + session, resubscriptionList, requestLabel, errorHandler, userData +): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_resubscribeEx( + session, resubscriptionList, label, c_int(sz), errorHandler, userData + ) + + +# signature: +def _blpapi_Session_resubscribeEx_helper( + session, resubscriptionList, requestLabel, errorAppenderCb +): + proxy = anySessionSubErrorHandlerWrapper.get() + userdata = voidFromPyFunction(errorAppenderCb) + return _blpapi_Session_resubscribeEx( + session, resubscriptionList, requestLabel, proxy, userdata + ) + + +# signature: int blpapi_Session_resubscribeWithId(blpapi_Session_t *session,const blpapi_SubscriptionList_t *resubscriptionList,int resubscriptionId,const char *requestLabel,int requestLabelLen); +def _blpapi_Session_resubscribeWithId( + session, resubscriptionList, resubscriptionId, requestLabel +): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_resubscribeWithId( + session, + resubscriptionList, + resubscriptionId, # int + label, + sz, + ) + + +# signature: int blpapi_Session_resubscribeWithIdEx(blpapi_Session_t *session,const blpapi_SubscriptionList_t *resubscriptionList,int resubscriptionId,const char *requestLabel,int requestLabelLen,blpapi_SubscriptionPreprocessErrorHandler_t errorHandler,void *userData); +def _blpapi_Session_resubscribeWithIdEx( + session, + resubscriptionList, + resubscriptionId, + requestLabel, + errorHandler, + userdata, +): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_resubscribeWithIdEx( + session, + resubscriptionList, + c_int(resubscriptionId), + label, + c_int(sz), + errorHandler, + userdata, + ) + + +# signature: +def _blpapi_Session_resubscribeWithIdEx_helper( + session, + resubscriptionList, + resubscriptionId, + requestLabel, + errorAppenderCb, +): + proxy = anySessionSubErrorHandlerWrapper.get() + userdata = voidFromPyFunction(errorAppenderCb) + return _blpapi_Session_resubscribeWithIdEx( + session, + resubscriptionList, + resubscriptionId, + requestLabel, + proxy, + userdata, + ) + + +# signature: int blpapi_Session_sendRequest(blpapi_Session_t *session,const blpapi_Request_t *request,blpapi_CorrelationId_t *correlationId,blpapi_Identity_t *identity,blpapi_EventQueue_t *eventQueue,const char *requestLabel,int requestLabelLen); +def _blpapi_Session_sendRequest( + session, request, correlationId, identity, eventQueue, requestLabel +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(correlationId.thestruct) + + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_sendRequest( + session, + request, + cidp, + identity, + eventQueue, + label, + sz, # int + ) + + +# signature: int blpapi_Session_sendRequestTemplate(blpapi_Session_t *session,const blpapi_RequestTemplate_t *requestTemplate,blpapi_CorrelationId_t *correlationId); +def _blpapi_Session_sendRequestTemplate( + session, requestTemplate, correlationId +): + # the C layer will OVERWRITE cid with autogen for unset + cidp = pointer(correlationId.thestruct) + + return l_blpapi_Session_sendRequestTemplate( + session, + requestTemplate, + cidp, + ) + + +# signature: int blpapi_Session_setStatusCorrelationId(blpapi_Session_t *session,const blpapi_Service_t *service,const blpapi_Identity_t *identity,const blpapi_CorrelationId_t *correlationId); +def _blpapi_Session_setStatusCorrelationId( + session, service, identity, correlationId +): + return l_blpapi_Session_setStatusCorrelationId( + session, service, identity, byref(correlationId.thestruct) + ) + + +# signature: int blpapi_Session_start(blpapi_Session_t *session); +def _blpapi_Session_start(session): + return l_blpapi_Session_start(session) + + +# signature: int blpapi_Session_startAsync(blpapi_Session_t *session); +def _blpapi_Session_startAsync(session): + return l_blpapi_Session_startAsync(session) + + +# signature: int blpapi_Session_stop(blpapi_Session_t *session); +def _blpapi_Session_stop(session): + return l_blpapi_Session_stop(session) + + +# signature: int blpapi_Session_stopAsync(blpapi_Session_t *session); +def _blpapi_Session_stopAsync(session): + return l_blpapi_Session_stopAsync(session) + + +# signature: int blpapi_Session_subscribe(blpapi_Session_t *session,const blpapi_SubscriptionList_t *subscriptionList,const blpapi_Identity_t *handle,const char *requestLabel,int requestLabelLen); +def _blpapi_Session_subscribe(session, subscriptionList, handle, requestLabel): + # handle is identity + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_subscribe( + session, subscriptionList, handle, label, sz # int + ) + + +# signature: int blpapi_Session_subscribeEx(blpapi_Session_t *session,const blpapi_SubscriptionList_t *subscriptionList,const blpapi_Identity_t *handle,const char *requestLabel,int requestLabelLen,blpapi_SubscriptionPreprocessErrorHandler_t errorHandler,void *userData); +def _blpapi_Session_subscribeEx( + session, subscriptionList, handle, requestLabel, errorHandler, userData +): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_subscribeEx( + session, + subscriptionList, + handle, + label, + c_int(sz), + errorHandler, + userData, + ) + + +# signature: +def _blpapi_Session_subscribeEx_helper( + session, subscriptionList, identity, requestLabel, errorAppenderCb +): + proxy = anySessionSubErrorHandlerWrapper.get() + userdata = voidFromPyFunction(errorAppenderCb) + return _blpapi_Session_subscribeEx( + session, subscriptionList, identity, requestLabel, proxy, userdata + ) + + +# signature: int blpapi_Session_tryNextEvent(blpapi_Session_t *session, blpapi_Event_t **eventPointer); +def _blpapi_Session_tryNextEvent(session): + eventptr = c_void_p() + outp = pointer(eventptr) + retCode = l_blpapi_Session_tryNextEvent(session, outp) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_Session_unsubscribe(blpapi_Session_t *session,const blpapi_SubscriptionList_t *unsubscriptionList,const char *requestLabel,int requestLabelLen); +def _blpapi_Session_unsubscribe(session, unsubscriptionList, requestLabel): + label, sz = charPtrWithSizeFromPyStr(requestLabel) + return l_blpapi_Session_unsubscribe( + session, unsubscriptionList, label, sz # sz is int + ) + + +# signature: blpapi_Socks5Config_t *blpapi_Socks5Config_create(const char *hostname, size_t hostname_size, unsigned short port); +def _blpapi_Socks5Config_create(hostname, port): + hn, sz = charPtrWithSizeFromPyStr(hostname) + return getHandleFromPtr( + l_blpapi_Socks5Config_create(hn, c_size_t(sz), c_uint16(port)) + ) + + +# signature: void blpapi_Socks5Config_destroy(blpapi_Socks5Config_t *socks5Config); +def _blpapi_Socks5Config_destroy(socks5Config): + l_blpapi_Socks5Config_destroy(socks5Config) + + +# signature: +def _blpapi_Socks5Config_printHelper(socks5Config, level, spacesPerLevel): + return any_printer( + socks5Config, l_blpapi_Socks5Config_print, level, spacesPerLevel + ) + + +# signature: +def _blpapi_SubscriptionList_addHelper(slist, topic, correlationId): + return l_blpapi_SubscriptionList_add( + slist, + charPtrFromPyStr(topic), + byref(correlationId.thestruct), + None, + None, + 0, + 0, + ) + + +# signature: int blpapi_SubscriptionList_addResolved(blpapi_SubscriptionList_t *list,const char *subscriptionString,const blpapi_CorrelationId_t *correlationId); +def _blpapi_SubscriptionList_addResolved( + slist, subscriptionString, correlationId +): + return l_blpapi_SubscriptionList_addResolved( + slist, + charPtrFromPyStr(subscriptionString), + byref(correlationId.thestruct), + ) + + +# signature: int blpapi_SubscriptionList_append(blpapi_SubscriptionList_t *dest, const blpapi_SubscriptionList_t *src); +def _blpapi_SubscriptionList_append(dest, src): + return l_blpapi_SubscriptionList_append(dest, src) + + +# signature: int blpapi_SubscriptionList_clear(blpapi_SubscriptionList_t *list); +def _blpapi_SubscriptionList_clear(slist): + return l_blpapi_SubscriptionList_clear(slist) + + +# signature: int blpapi_SubscriptionList_correlationIdAt(const blpapi_SubscriptionList_t *list,blpapi_CorrelationId_t *result,size_t index); +def _blpapi_SubscriptionList_correlationIdAt(slist, index): + cid = CidStruct() + cidp = pointer(cid) + retCode = l_blpapi_SubscriptionList_correlationIdAt( + slist, cidp, c_size_t(index) + ) + if retCode == 0: + # C doese *result = list->d_impl.subscription(index).d_correlationId.impl(); + # i.e., we need to bump ref + # the caller will wrap this in CorrelationId + return retCode, cid + return retCode, None + + +# signature: blpapi_SubscriptionList_t *blpapi_SubscriptionList_create(void); +def _blpapi_SubscriptionList_create(): + return getHandleFromPtr(l_blpapi_SubscriptionList_create()) + + +# signature: void blpapi_SubscriptionList_destroy(blpapi_SubscriptionList_t *list); +def _blpapi_SubscriptionList_destroy(slist): + l_blpapi_SubscriptionList_destroy(slist) + + +# signature: int blpapi_SubscriptionList_isResolvedAt(blpapi_SubscriptionList_t *list, int *result, size_t index); +def _blpapi_SubscriptionList_isResolvedAt(slist, index): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_SubscriptionList_isResolvedAt( + slist, outp, c_size_t(index) + ) + return retCode, getPODFromOutput(outp, retCode) != 0 + + +# signature: int blpapi_SubscriptionList_size(const blpapi_SubscriptionList_t *list); +def _blpapi_SubscriptionList_size(slist): + return l_blpapi_SubscriptionList_size(slist) # int + + +# signature: int blpapi_SubscriptionList_topicStringAt(blpapi_SubscriptionList_t *list, const char **result, size_t index); +def _blpapi_SubscriptionList_topicStringAt(slist, index): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_SubscriptionList_topicStringAt( + slist, outp, c_size_t(index) + ) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_TestUtil_appendMessage(blpapi_MessageFormatter_t **formatter,blpapi_Event_t *event,const blpapi_SchemaElementDefinition_t *messageType,const blpapi_MessageProperties_t *properties); +def _blpapi_TestUtil_appendMessage(event, messageType, properties): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TestUtil_appendMessage( + outp, event, messageType, properties + ) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TestUtil_createEvent(blpapi_Event_t **event, int eventType); +def _blpapi_TestUtil_createEvent(eventType): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TestUtil_createEvent(outp, eventType) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TestUtil_createTopic(blpapi_Topic_t **topic, const blpapi_Service_t *service, int isActive); +def _blpapi_TestUtil_createTopic(service, isActive): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TestUtil_createTopic(outp, service, isActive) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TestUtil_deserializeService(const char *schema, size_t schemaLength, blpapi_Service_t **service); +def _blpapi_TestUtil_deserializeService( + schema, schemaLength +): # pylint: disable=unused-argument + out = c_void_p() + outp = pointer(out) + schemac, sz = charPtrWithSizeFromPyStr(schema) + retCode = l_blpapi_TestUtil_deserializeService( + schemac, c_size_t(sz), outp + ) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TestUtil_getAdminMessageDefinition(blpapi_SchemaElementDefinition_t **definition,blpapi_Name_t *messageName); +def _blpapi_TestUtil_getAdminMessageDefinition(messageName): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TestUtil_getAdminMessageDefinition( + outp, messageName + ) # int + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: +def _blpapi_TestUtil_serializeServiceHelper(service): + out = StringIO() + writer = StreamWrapper() + outparam = voidFromPyObject(out) + retCode = l_blpapi_TestUtil_serializeService( + writer.get(), outparam, service + ) + if retCode: + return None + out.seek(0) + return out.read() + + +# signature: long long blpapi_TimePointUtil_nanosecondsBetween(const blpapi_TimePoint_t *start, const blpapi_TimePoint_t *end); +def _blpapi_TimePointUtil_nanosecondsBetween(start, end): + raise NotImplementedError("not called") + + +# signature: blpapi_TlsOptions_t *blpapi_TlsOptions_createFromBlobs(const char *clientCredentialsRawData,int clientCredentialsRawDataLength,const char *clientCredentialsPassword,const char *trustedCertificatesRawData,int trustedCertificatesRawDataLength); +def _blpapi_TlsOptions_createFromBlobs( + clientCredentialsRawData, + clientCredentialsPassword, + trustedCertificatesRawData, +): + cc, ccsz = charPtrWithSizeFromPyStr(clientCredentialsRawData) + tc, tcsz = charPtrWithSizeFromPyStr(trustedCertificatesRawData) + return getHandleFromPtr( + l_blpapi_TlsOptions_createFromBlobs( + cc, ccsz, charPtrFromPyStr(clientCredentialsPassword), tc, tcsz + ) + ) + + +# signature: blpapi_TlsOptions_t *blpapi_TlsOptions_createFromFiles(const char *clientCredentialsFileName,const char *clientCredentialsPassword,const char *trustedCertificatesFileName); +def _blpapi_TlsOptions_createFromFiles( + clientCredentialsFileName, + clientCredentialsPassword, + trustedCertificatesFileName, +): + return getHandleFromPtr( + l_blpapi_TlsOptions_createFromFiles( + charPtrFromPyStr(clientCredentialsFileName), + charPtrFromPyStr(clientCredentialsPassword), + charPtrFromPyStr(trustedCertificatesFileName), + ) + ) + + +# signature: void blpapi_TlsOptions_destroy(blpapi_TlsOptions_t *parameters); +def _blpapi_TlsOptions_destroy(parameters): + l_blpapi_TlsOptions_destroy(parameters) + + +# signature: void blpapi_TlsOptions_setCrlFetchTimeoutMs(blpapi_TlsOptions_t *paramaters, int crlFetchTimeoutMs); +def _blpapi_TlsOptions_setCrlFetchTimeoutMs(paramaters, crlFetchTimeoutMs): + l_blpapi_TlsOptions_setCrlFetchTimeoutMs(paramaters, crlFetchTimeoutMs) + + +# signature: void blpapi_TlsOptions_setTlsHandshakeTimeoutMs(blpapi_TlsOptions_t *paramaters, int tlsHandshakeTimeoutMs); +def _blpapi_TlsOptions_setTlsHandshakeTimeoutMs( + paramaters, tlsHandshakeTimeoutMs +): + l_blpapi_TlsOptions_setTlsHandshakeTimeoutMs( + paramaters, tlsHandshakeTimeoutMs + ) + + +# signature: int blpapi_TopicList_add(blpapi_TopicList_t *list,const char *topic,const blpapi_CorrelationId_t *correlationId); +def _blpapi_TopicList_add(topic_list, topic, correlationId): + return l_blpapi_TopicList_add( + topic_list, + charPtrFromPyStr(topic), + byref(correlationId.thestruct), + ) + + +# signature: int blpapi_TopicList_addFromMessage(blpapi_TopicList_t *list,const blpapi_Message_t *topic,const blpapi_CorrelationId_t *correlationId); +def _blpapi_TopicList_addFromMessage(topic_list, message, correlationId): + return l_blpapi_TopicList_addFromMessage( + topic_list, message, byref(correlationId.thestruct) + ) + + +# signature: int blpapi_TopicList_correlationIdAt(const blpapi_TopicList_t *list,blpapi_CorrelationId_t *result,size_t index); +def _blpapi_TopicList_correlationIdAt(topic_list, index): + cid = CidStruct() + cidp = pointer(cid) + retCode = l_blpapi_TopicList_correlationIdAt( + topic_list, cidp, c_size_t(index) + ) + if retCode == 0: + # C does *result = rlImpl->correlationId(index).impl(); + # i.e, we need to bump ref. + # the caller will wrap this in CorrelationId + return retCode, cid + return retCode, None + + +# signature: blpapi_TopicList_t *blpapi_TopicList_create(blpapi_TopicList_t *from); +def _blpapi_TopicList_create(_from): + fromp = c_void_p() if _from is None else _from + return getHandleFromPtr(l_blpapi_TopicList_create(fromp)) + + +# signature: +def _blpapi_TopicList_createFromResolutionList(_from): + return getHandleFromPtr(l_blpapi_TopicList_create(_from)) + + +# signature: void blpapi_TopicList_destroy(blpapi_TopicList_t *list); +def _blpapi_TopicList_destroy(topic_list): + l_blpapi_TopicList_destroy(topic_list) + + +# signature: int blpapi_TopicList_message(const blpapi_TopicList_t *list,blpapi_Message_t **element,const blpapi_CorrelationId_t *id); +def _blpapi_TopicList_message(topic_list, cid): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TopicList_message( + topic_list, outp, byref(cid.thestruct) + ) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TopicList_messageAt(const blpapi_TopicList_t *list,blpapi_Message_t **element,size_t index); +def _blpapi_TopicList_messageAt(topic_list, index): + out = c_void_p() + outp = pointer(out) + retCode = l_blpapi_TopicList_messageAt(topic_list, outp, index) + return retCode, getHandleFromOutput(outp, retCode) + + +# signature: int blpapi_TopicList_size(const blpapi_TopicList_t *list); +def _blpapi_TopicList_size(topic_list): + return l_blpapi_TopicList_size(topic_list) # int + + +# signature: int blpapi_TopicList_status(const blpapi_TopicList_t *list,int *status,const blpapi_CorrelationId_t *id); +def _blpapi_TopicList_status(topic_list, cid): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_TopicList_status(topic_list, outp, byref(cid.thestruct)) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_TopicList_statusAt(const blpapi_TopicList_t *list, int *status, size_t index); +def _blpapi_TopicList_statusAt(topic_list, index): + out = c_int() + outp = pointer(out) + retCode = l_blpapi_TopicList_statusAt(topic_list, outp, index) + return retCode, getPODFromOutput(outp, retCode) + + +# signature: int blpapi_TopicList_topicString(const blpapi_TopicList_t *list,const char **topic,const blpapi_CorrelationId_t *id); +def _blpapi_TopicList_topicString(topic_list, cid): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_TopicList_topicString( + topic_list, outp, byref(cid.thestruct) + ) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_TopicList_topicStringAt(const blpapi_TopicList_t *list, const char **topic, size_t index); +def _blpapi_TopicList_topicStringAt(topic_list, index): + out = c_char_p() + outp = pointer(out) + retCode = l_blpapi_TopicList_topicStringAt(topic_list, outp, index) + return retCode, getStrFromOutput(outp, retCode) + + +# signature: int blpapi_Topic_compare(const blpapi_Topic_t *lhs, const blpapi_Topic_t *rhs); +def _blpapi_Topic_compare(lhs, rhs): + return l_blpapi_Topic_compare(lhs, rhs) + + +# signature: blpapi_Topic_t *blpapi_Topic_create(blpapi_Topic_t *from); +def _blpapi_Topic_create(_from): + raise NotImplementedError("not called") + + +# signature: void blpapi_Topic_destroy(blpapi_Topic_t *victim); +def _blpapi_Topic_destroy(victim): + l_blpapi_Topic_destroy(victim) + + +# signature: int blpapi_Topic_isActive(const blpapi_Topic_t *topic); +def _blpapi_Topic_isActive(topic): + return l_blpapi_Topic_isActive(topic) != 0 + + +# signature: blpapi_Service_t *blpapi_Topic_service(const blpapi_Topic_t *topic); +def _blpapi_Topic_service(topic): + return getHandleFromPtr(l_blpapi_Topic_service(topic)) + + +# signature: int blpapi_ZfpUtil_getOptionsForLeasedLines(blpapi_SessionOptions_t *sessionOptions,const blpapi_TlsOptions_t *tlsOptions,int remote); +def _blpapi_ZfpUtil_getOptionsForLeasedLines( + sessionOptions, tlsOptions, remote +): + return l_blpapi_ZfpUtil_getOptionsForLeasedLines( + sessionOptions, tlsOptions, remote + ) + + +# signature: const char *blpapi_getLastErrorDescription(int resultCode); +def _blpapi_getLastErrorDescription(resultCode): + return getStrFromC(l_blpapi_getLastErrorDescription(resultCode)) + + +def _blpapi_getVersionInfo(): + major = c_int() + majorp = pointer(major) + minor = c_int() + minorp = pointer(minor) + patch = c_int() + patchp = pointer(patch) + build = c_int() + buildp = pointer(build) + + l_blpapi_getVersionInfo(majorp, minorp, patchp, buildp) + + return ".".join( + [ + str(major.value), + str(minor.value), + str(patch.value), + str(build.value), + ] + ) + + +def _ProviderSession_createHelper(parameters, eventHandlerFunc, dispatcher): + # parameters is a handle to SessionOptions + # eventHandlerFunc is python callback + # dispatcher is a handle to dispatcher, which we honestly hope to be None! + # returns handle to Session + hasHandler = eventHandlerFunc is not None + if hasHandler: + handlerparam = anySessionEventHandlerWrapper.get() + userdata = voidFromPyFunction(eventHandlerFunc) + else: + handlerparam = c_void_p(0) + userdata = c_void_p(0) + handle = l_blpapi_ProviderSession_create( + parameters, + handlerparam, + dispatcher, + userdata, + ) + return getHandleFromPtr(handle) + + +def _ProviderSession_destroyHelper(sessionHandle, _eventHandlerFunc): + l_blpapi_ProviderSession_destroy(sessionHandle) + + +def _Session_createHelper(parameters, eventHandlerFunc, dispatcher): + # parameters is a handle to SessionOptions + # eventHandlerFunc is python callback + # dispatcher is a handle to dispatcher, which we honestly hope to be None! + # returns handle to Session + hasHandler = eventHandlerFunc is not None + if hasHandler: + handlerparam = anySessionEventHandlerWrapper.get() + userdata = voidFromPyFunction(eventHandlerFunc) + else: + handlerparam = c_void_p(0) + userdata = c_void_p(0) + + handle = l_blpapi_Session_create( + parameters, + handlerparam, + dispatcher, + userdata, + ) + # returns address of control block of shared_ptr + return getHandleFromPtr(handle) + + +def _Session_destroyHelper(sessionHandle, _eventHandlerFunc): + l_blpapi_Session_destroy(sessionHandle) + + +blpapi_AbstractSession_cancel = _blpapi_AbstractSession_cancel +blpapi_AbstractSession_createIdentity = _blpapi_AbstractSession_createIdentity +blpapi_AbstractSession_generateAuthorizedIdentityAsync = ( + _blpapi_AbstractSession_generateAuthorizedIdentityAsync +) +blpapi_AbstractSession_generateManualToken = ( + _blpapi_AbstractSession_generateManualToken +) +blpapi_AbstractSession_generateToken = _blpapi_AbstractSession_generateToken +blpapi_AbstractSession_getAuthorizedIdentity = ( + _blpapi_AbstractSession_getAuthorizedIdentity +) +blpapi_AbstractSession_getService = _blpapi_AbstractSession_getService +blpapi_AbstractSession_openService = _blpapi_AbstractSession_openService +blpapi_AbstractSession_openServiceAsync = ( + _blpapi_AbstractSession_openServiceAsync +) +blpapi_AbstractSession_sendAuthorizationRequest = ( + _blpapi_AbstractSession_sendAuthorizationRequest +) +blpapi_AbstractSession_sessionName = _blpapi_AbstractSession_sessionName +blpapi_AuthApplication_copy = _blpapi_AuthApplication_copy +blpapi_AuthApplication_create = _blpapi_AuthApplication_create +blpapi_AuthApplication_destroy = _blpapi_AuthApplication_destroy +blpapi_AuthApplication_duplicate = _blpapi_AuthApplication_duplicate +blpapi_AuthOptions_copy = _blpapi_AuthOptions_copy +blpapi_AuthOptions_create_default = _blpapi_AuthOptions_create_default +blpapi_AuthOptions_create_forAppMode = _blpapi_AuthOptions_create_forAppMode +blpapi_AuthOptions_create_forToken = _blpapi_AuthOptions_create_forToken +blpapi_AuthOptions_create_forUserAndAppMode = ( + _blpapi_AuthOptions_create_forUserAndAppMode +) +blpapi_AuthOptions_create_forUserMode = _blpapi_AuthOptions_create_forUserMode +blpapi_AuthOptions_destroy = _blpapi_AuthOptions_destroy +blpapi_AuthOptions_duplicate = _blpapi_AuthOptions_duplicate +blpapi_AuthToken_copy = _blpapi_AuthToken_copy +blpapi_AuthToken_create = _blpapi_AuthToken_create +blpapi_AuthToken_destroy = _blpapi_AuthToken_destroy +blpapi_AuthToken_duplicate = _blpapi_AuthToken_duplicate +blpapi_AuthUser_copy = _blpapi_AuthUser_copy +blpapi_AuthUser_createWithActiveDirectoryProperty = ( + _blpapi_AuthUser_createWithActiveDirectoryProperty +) +blpapi_AuthUser_createWithLogonName = _blpapi_AuthUser_createWithLogonName +blpapi_AuthUser_createWithManualOptions = ( + _blpapi_AuthUser_createWithManualOptions +) +blpapi_AuthUser_destroy = _blpapi_AuthUser_destroy +blpapi_AuthUser_duplicate = _blpapi_AuthUser_duplicate +blpapi_ConstantList_datatype = _blpapi_ConstantList_datatype +blpapi_ConstantList_description = _blpapi_ConstantList_description +blpapi_ConstantList_getConstant = _blpapi_ConstantList_getConstant +blpapi_ConstantList_getConstantAt = _blpapi_ConstantList_getConstantAt +blpapi_ConstantList_hasConstant = _blpapi_ConstantList_hasConstant +blpapi_ConstantList_name = _blpapi_ConstantList_name +blpapi_ConstantList_numConstants = _blpapi_ConstantList_numConstants +blpapi_ConstantList_status = _blpapi_ConstantList_status +blpapi_Constant_datatype = _blpapi_Constant_datatype +blpapi_Constant_description = _blpapi_Constant_description +blpapi_Constant_getValueAsChar = _blpapi_Constant_getValueAsChar +blpapi_Constant_getValueAsDatetime = _blpapi_Constant_getValueAsDatetime +blpapi_Constant_getValueAsFloat32 = _blpapi_Constant_getValueAsFloat32 +blpapi_Constant_getValueAsFloat64 = _blpapi_Constant_getValueAsFloat64 +blpapi_Constant_getValueAsInt32 = _blpapi_Constant_getValueAsInt32 +blpapi_Constant_getValueAsInt64 = _blpapi_Constant_getValueAsInt64 +blpapi_Constant_getValueAsString = _blpapi_Constant_getValueAsString +blpapi_Constant_name = _blpapi_Constant_name +blpapi_Constant_status = _blpapi_Constant_status +blpapi_Datetime_tag = BDatetime +blpapi_DiagnosticsUtil_memoryInfo_wrapper = ( + _blpapi_DiagnosticsUtil_memoryInfo_wrapper +) +blpapi_Element_appendElement = _blpapi_Element_appendElement +blpapi_Element_datatype = _blpapi_Element_datatype +blpapi_Element_definition = _blpapi_Element_definition +blpapi_Element_getChoice = _blpapi_Element_getChoice +blpapi_Element_getElement = _blpapi_Element_getElement +blpapi_Element_getElementAt = _blpapi_Element_getElementAt +blpapi_Element_getValueAsBool = _blpapi_Element_getValueAsBool +blpapi_Element_getValueAsBytes = _blpapi_Element_getValueAsBytes +blpapi_Element_getValueAsChar = _blpapi_Element_getValueAsChar +blpapi_Element_getValueAsDatetime = _blpapi_Element_getValueAsDatetime +blpapi_Element_getValueAsElement = _blpapi_Element_getValueAsElement +blpapi_Element_getValueAsFloat64 = _blpapi_Element_getValueAsFloat64 +blpapi_Element_getValueAsHighPrecisionDatetime = ( + _blpapi_Element_getValueAsHighPrecisionDatetime +) +blpapi_Element_getValueAsInt32 = _blpapi_Element_getValueAsInt32 +blpapi_Element_getValueAsInt64 = _blpapi_Element_getValueAsInt64 +blpapi_Element_getValueAsName = _blpapi_Element_getValueAsName +blpapi_Element_getValueAsString = _blpapi_Element_getValueAsString +blpapi_Element_hasElementEx = _blpapi_Element_hasElementEx +blpapi_Element_isArray = _blpapi_Element_isArray +blpapi_Element_isComplexType = _blpapi_Element_isComplexType +blpapi_Element_isNull = _blpapi_Element_isNull +blpapi_Element_isNullValue = _blpapi_Element_isNullValue +blpapi_Element_isReadOnly = _blpapi_Element_isReadOnly +blpapi_Element_name = _blpapi_Element_name +blpapi_Element_nameString = _blpapi_Element_nameString +blpapi_Element_numElements = _blpapi_Element_numElements +blpapi_Element_numValues = _blpapi_Element_numValues +blpapi_Element_printHelper = _blpapi_Element_printHelper +blpapi_Element_setChoice = _blpapi_Element_setChoice +blpapi_Element_setElementBool = _blpapi_Element_setElementBool +blpapi_Element_setElementBytes = _blpapi_Element_setElementBytes +blpapi_Element_setElementFloat = _blpapi_Element_setElementFloat +blpapi_Element_setElementFromName = _blpapi_Element_setElementFromName +blpapi_Element_setElementHighPrecisionDatetime = ( + _blpapi_Element_setElementHighPrecisionDatetime +) +blpapi_Element_setElementInt32 = _blpapi_Element_setElementInt32 +blpapi_Element_setElementInt64 = _blpapi_Element_setElementInt64 +blpapi_Element_setElementString = _blpapi_Element_setElementString +blpapi_Element_setValueBool = _blpapi_Element_setValueBool +blpapi_Element_setValueBytes = _blpapi_Element_setValueBytes +blpapi_Element_setValueFloat = _blpapi_Element_setValueFloat +blpapi_Element_setValueFromName = _blpapi_Element_setValueFromName +blpapi_Element_setValueHighPrecisionDatetime = ( + _blpapi_Element_setValueHighPrecisionDatetime +) +blpapi_Element_setValueInt32 = _blpapi_Element_setValueInt32 +blpapi_Element_setValueInt64 = _blpapi_Element_setValueInt64 +blpapi_Element_setValueString = _blpapi_Element_setValueString +blpapi_Element_toPy = _blpapi_Element_toPy +blpapi_EventDispatcher_create = _blpapi_EventDispatcher_create +blpapi_EventDispatcher_destroy = _blpapi_EventDispatcher_destroy +blpapi_EventDispatcher_start = _blpapi_EventDispatcher_start +blpapi_EventDispatcher_stop = _blpapi_EventDispatcher_stop +blpapi_EventFormatter_appendElement = _blpapi_EventFormatter_appendElement +blpapi_EventFormatter_appendFragmentedRecapMessage = ( + _blpapi_EventFormatter_appendFragmentedRecapMessage +) +blpapi_EventFormatter_appendFragmentedRecapMessageSeq = ( + _blpapi_EventFormatter_appendFragmentedRecapMessageSeq +) +blpapi_EventFormatter_appendMessage = _blpapi_EventFormatter_appendMessage +blpapi_EventFormatter_appendMessageSeq = ( + _blpapi_EventFormatter_appendMessageSeq +) +blpapi_EventFormatter_appendRecapMessage = ( + _blpapi_EventFormatter_appendRecapMessage +) +blpapi_EventFormatter_appendRecapMessageSeq = ( + _blpapi_EventFormatter_appendRecapMessageSeq +) +blpapi_EventFormatter_appendResponse = _blpapi_EventFormatter_appendResponse +blpapi_EventFormatter_appendValueBool = _blpapi_EventFormatter_appendValueBool +blpapi_EventFormatter_appendValueChar = _blpapi_EventFormatter_appendValueChar +blpapi_EventFormatter_appendValueFloat = ( + _blpapi_EventFormatter_appendValueFloat +) +blpapi_EventFormatter_appendValueFromName = ( + _blpapi_EventFormatter_appendValueFromName +) +blpapi_EventFormatter_appendValueHighPrecisionDatetime = ( + _blpapi_EventFormatter_appendValueHighPrecisionDatetime +) +blpapi_EventFormatter_appendValueInt32 = ( + _blpapi_EventFormatter_appendValueInt32 +) +blpapi_EventFormatter_appendValueInt64 = ( + _blpapi_EventFormatter_appendValueInt64 +) +blpapi_EventFormatter_appendValueString = ( + _blpapi_EventFormatter_appendValueString +) +blpapi_EventFormatter_create = _blpapi_EventFormatter_create +blpapi_EventFormatter_destroy = _blpapi_EventFormatter_destroy +blpapi_EventFormatter_popElement = _blpapi_EventFormatter_popElement +blpapi_EventFormatter_pushElement = _blpapi_EventFormatter_pushElement +blpapi_EventFormatter_setValueBool = _blpapi_EventFormatter_setValueBool +blpapi_EventFormatter_setValueBytes = _blpapi_EventFormatter_setValueBytes +blpapi_EventFormatter_setValueChar = _blpapi_EventFormatter_setValueChar +blpapi_EventFormatter_setValueFloat = _blpapi_EventFormatter_setValueFloat +blpapi_EventFormatter_setValueFromName = ( + _blpapi_EventFormatter_setValueFromName +) +blpapi_EventFormatter_setValueHighPrecisionDatetime = ( + _blpapi_EventFormatter_setValueHighPrecisionDatetime +) +blpapi_EventFormatter_setValueInt32 = _blpapi_EventFormatter_setValueInt32 +blpapi_EventFormatter_setValueInt64 = _blpapi_EventFormatter_setValueInt64 +blpapi_EventFormatter_setValueNull = _blpapi_EventFormatter_setValueNull +blpapi_EventFormatter_setValueString = _blpapi_EventFormatter_setValueString +blpapi_EventQueue_create = _blpapi_EventQueue_create +blpapi_EventQueue_destroy = _blpapi_EventQueue_destroy +blpapi_EventQueue_nextEvent = _blpapi_EventQueue_nextEvent +blpapi_EventQueue_purge = _blpapi_EventQueue_purge +blpapi_EventQueue_tryNextEvent = _blpapi_EventQueue_tryNextEvent +blpapi_Event_eventType = _blpapi_Event_eventType +blpapi_Event_release = _blpapi_Event_release +blpapi_HighPrecisionDatetime_compare = _blpapi_HighPrecisionDatetime_compare +blpapi_HighPrecisionDatetime_fromTimePoint = ( + _blpapi_HighPrecisionDatetime_fromTimePoint +) +blpapi_HighPrecisionDatetime_fromTimePoint_wrapper = ( + _blpapi_HighPrecisionDatetime_fromTimePoint_wrapper +) +blpapi_HighPrecisionDatetime_print = _blpapi_HighPrecisionDatetime_print +blpapi_HighPrecisionDatetime_tag = HighPrecisionDatetime +blpapi_HighResolutionClock_now = _blpapi_HighResolutionClock_now +blpapi_Identity_addRef = _blpapi_Identity_addRef +blpapi_Identity_getSeatType = _blpapi_Identity_getSeatType +blpapi_Identity_hasEntitlements = _blpapi_Identity_hasEntitlements +blpapi_Identity_isAuthorized = _blpapi_Identity_isAuthorized +blpapi_Identity_release = _blpapi_Identity_release +blpapi_Logging_logTestMessage = _blpapi_Logging_logTestMessage +blpapi_Logging_registerCallback = _blpapi_Logging_registerCallback +blpapi_MessageFormatter_FormatMessageJson = ( + _blpapi_MessageFormatter_FormatMessageJson +) +blpapi_MessageFormatter_FormatMessageXml = ( + _blpapi_MessageFormatter_FormatMessageXml +) +blpapi_MessageFormatter_appendElement = _blpapi_MessageFormatter_appendElement +blpapi_MessageFormatter_appendValueBool = ( + _blpapi_MessageFormatter_appendValueBool +) +blpapi_MessageFormatter_appendValueChar = ( + _blpapi_MessageFormatter_appendValueChar +) +blpapi_MessageFormatter_appendValueDatetime = ( + _blpapi_MessageFormatter_appendValueDatetime +) +blpapi_MessageFormatter_appendValueFloat = ( + _blpapi_MessageFormatter_appendValueFloat +) +blpapi_MessageFormatter_appendValueFloat32 = ( + _blpapi_MessageFormatter_appendValueFloat32 +) +blpapi_MessageFormatter_appendValueFloat64 = ( + _blpapi_MessageFormatter_appendValueFloat64 +) +blpapi_MessageFormatter_appendValueFromName = ( + _blpapi_MessageFormatter_appendValueFromName +) +blpapi_MessageFormatter_appendValueHighPrecisionDatetime = ( + _blpapi_MessageFormatter_appendValueHighPrecisionDatetime +) +blpapi_MessageFormatter_appendValueInt32 = ( + _blpapi_MessageFormatter_appendValueInt32 +) +blpapi_MessageFormatter_appendValueInt64 = ( + _blpapi_MessageFormatter_appendValueInt64 +) +blpapi_MessageFormatter_appendValueString = ( + _blpapi_MessageFormatter_appendValueString +) +blpapi_MessageFormatter_assign = _blpapi_MessageFormatter_assign +blpapi_MessageFormatter_copy = _blpapi_MessageFormatter_copy +blpapi_MessageFormatter_destroy = _blpapi_MessageFormatter_destroy +blpapi_MessageFormatter_popElement = _blpapi_MessageFormatter_popElement +blpapi_MessageFormatter_pushElement = _blpapi_MessageFormatter_pushElement +blpapi_MessageFormatter_setValueBool = _blpapi_MessageFormatter_setValueBool +blpapi_MessageFormatter_setValueBytes = _blpapi_MessageFormatter_setValueBytes +blpapi_MessageFormatter_setValueChar = _blpapi_MessageFormatter_setValueChar +blpapi_MessageFormatter_setValueDatetime = ( + _blpapi_MessageFormatter_setValueDatetime +) +blpapi_MessageFormatter_setValueFloat = _blpapi_MessageFormatter_setValueFloat +blpapi_MessageFormatter_setValueFloat32 = ( + _blpapi_MessageFormatter_setValueFloat32 +) +blpapi_MessageFormatter_setValueFloat64 = ( + _blpapi_MessageFormatter_setValueFloat64 +) +blpapi_MessageFormatter_setValueFromName = ( + _blpapi_MessageFormatter_setValueFromName +) +blpapi_MessageFormatter_setValueHighPrecisionDatetime = ( + _blpapi_MessageFormatter_setValueHighPrecisionDatetime +) +blpapi_MessageFormatter_setValueInt32 = _blpapi_MessageFormatter_setValueInt32 +blpapi_MessageFormatter_setValueInt64 = _blpapi_MessageFormatter_setValueInt64 +blpapi_MessageFormatter_setValueNull = _blpapi_MessageFormatter_setValueNull +blpapi_MessageFormatter_setValueString = ( + _blpapi_MessageFormatter_setValueString +) +blpapi_MessageIterator_create = _blpapi_MessageIterator_create +blpapi_MessageIterator_destroy = _blpapi_MessageIterator_destroy +blpapi_MessageIterator_next = _blpapi_MessageIterator_next +blpapi_MessageProperties_assign = _blpapi_MessageProperties_assign +blpapi_MessageProperties_copy = _blpapi_MessageProperties_copy +blpapi_MessageProperties_create = _blpapi_MessageProperties_create +blpapi_MessageProperties_destroy = _blpapi_MessageProperties_destroy +blpapi_MessageProperties_setCorrelationIds = ( + _blpapi_MessageProperties_setCorrelationIds +) +blpapi_MessageProperties_setRecapType = _blpapi_MessageProperties_setRecapType +blpapi_MessageProperties_setRequestId = _blpapi_MessageProperties_setRequestId +blpapi_MessageProperties_setService = _blpapi_MessageProperties_setService +blpapi_MessageProperties_setTimeReceived = ( + _blpapi_MessageProperties_setTimeReceived +) +blpapi_Message_addRef = _blpapi_Message_addRef +blpapi_Message_correlationId = _blpapi_Message_correlationId +blpapi_Message_elements = _blpapi_Message_elements +blpapi_Message_fragmentType = _blpapi_Message_fragmentType +blpapi_Message_getRequestId = _blpapi_Message_getRequestId +blpapi_Message_messageType = _blpapi_Message_messageType +blpapi_Message_numCorrelationIds = _blpapi_Message_numCorrelationIds +blpapi_Message_printHelper = _blpapi_Message_printHelper +blpapi_Message_recapType = _blpapi_Message_recapType +blpapi_Message_release = _blpapi_Message_release +blpapi_Message_service = _blpapi_Message_service +blpapi_Message_timeReceived = _blpapi_Message_timeReceived +blpapi_Message_topicName = _blpapi_Message_topicName +blpapi_Name_create = _blpapi_Name_create +blpapi_Name_destroy = _blpapi_Name_destroy +blpapi_Name_equalsStr = _blpapi_Name_equalsStr +blpapi_Name_findName = _blpapi_Name_findName +blpapi_Name_hasName = _blpapi_Name_hasName +blpapi_Name_length = _blpapi_Name_length +blpapi_Name_string = _blpapi_Name_string +blpapi_Operation_description = _blpapi_Operation_description +blpapi_Operation_name = _blpapi_Operation_name +blpapi_Operation_numResponseDefinitions = ( + _blpapi_Operation_numResponseDefinitions +) +blpapi_Operation_requestDefinition = _blpapi_Operation_requestDefinition +blpapi_Operation_responseDefinition = _blpapi_Operation_responseDefinition +blpapi_Operation_responseDefinitionFromName = ( + _blpapi_Operation_responseDefinitionFromName +) +blpapi_ProviderSession_activateSubServiceCodeRange = ( + _blpapi_ProviderSession_activateSubServiceCodeRange +) +blpapi_ProviderSession_createServiceStatusTopic = ( + _blpapi_ProviderSession_createServiceStatusTopic +) +blpapi_ProviderSession_createTopic = _blpapi_ProviderSession_createTopic +blpapi_ProviderSession_createTopics = _blpapi_ProviderSession_createTopics +blpapi_ProviderSession_createTopicsAsync = ( + _blpapi_ProviderSession_createTopicsAsync +) +blpapi_ProviderSession_deactivateSubServiceCodeRange = ( + _blpapi_ProviderSession_deactivateSubServiceCodeRange +) +blpapi_ProviderSession_deleteTopics = _blpapi_ProviderSession_deleteTopics +blpapi_ProviderSession_deregisterService = ( + _blpapi_ProviderSession_deregisterService +) +blpapi_ProviderSession_flushPublishedEvents = ( + _blpapi_ProviderSession_flushPublishedEvents +) +blpapi_ProviderSession_getAbstractSession = ( + _blpapi_ProviderSession_getAbstractSession +) +blpapi_ProviderSession_getTopic = _blpapi_ProviderSession_getTopic +blpapi_ProviderSession_nextEvent = _blpapi_ProviderSession_nextEvent +blpapi_ProviderSession_publish = _blpapi_ProviderSession_publish +blpapi_ProviderSession_registerService = ( + _blpapi_ProviderSession_registerService +) +blpapi_ProviderSession_registerServiceAsync = ( + _blpapi_ProviderSession_registerServiceAsync +) +blpapi_ProviderSession_resolve = _blpapi_ProviderSession_resolve +blpapi_ProviderSession_resolveAsync = _blpapi_ProviderSession_resolveAsync +blpapi_ProviderSession_sendResponse = _blpapi_ProviderSession_sendResponse +blpapi_ProviderSession_start = _blpapi_ProviderSession_start +blpapi_ProviderSession_startAsync = _blpapi_ProviderSession_startAsync +blpapi_ProviderSession_stop = _blpapi_ProviderSession_stop +blpapi_ProviderSession_stopAsync = _blpapi_ProviderSession_stopAsync +ProviderSession_terminateSubscriptionsOnTopic = ( + _blpapi_ProviderSession_terminateSubscriptionsOnTopic +) +blpapi_ProviderSession_terminateSubscriptionsOnTopics = ( + _blpapi_ProviderSession_terminateSubscriptionsOnTopics +) +blpapi_ProviderSession_tryNextEvent = _blpapi_ProviderSession_tryNextEvent +blpapi_RequestTemplate_release = _blpapi_RequestTemplate_release +blpapi_Request_destroy = _blpapi_Request_destroy +blpapi_Request_elements = _blpapi_Request_elements +blpapi_Request_getRequestId = _blpapi_Request_getRequestId +blpapi_Request_setPreferredRoute = _blpapi_Request_setPreferredRoute +blpapi_ResolutionList_add = _blpapi_ResolutionList_add +blpapi_ResolutionList_addAttribute = _blpapi_ResolutionList_addAttribute +blpapi_ResolutionList_addFromMessage = _blpapi_ResolutionList_addFromMessage +blpapi_ResolutionList_attribute = _blpapi_ResolutionList_attribute +blpapi_ResolutionList_attributeAt = _blpapi_ResolutionList_attributeAt +blpapi_ResolutionList_correlationIdAt = _blpapi_ResolutionList_correlationIdAt +blpapi_ResolutionList_create = _blpapi_ResolutionList_create +blpapi_ResolutionList_destroy = _blpapi_ResolutionList_destroy +blpapi_ResolutionList_extractAttributeFromResolutionSuccess = ( + _blpapi_ResolutionList_extractAttributeFromResolutionSuccess +) +blpapi_ResolutionList_message = _blpapi_ResolutionList_message +blpapi_ResolutionList_messageAt = _blpapi_ResolutionList_messageAt +blpapi_ResolutionList_size = _blpapi_ResolutionList_size +blpapi_ResolutionList_status = _blpapi_ResolutionList_status +blpapi_ResolutionList_statusAt = _blpapi_ResolutionList_statusAt +blpapi_ResolutionList_topicString = _blpapi_ResolutionList_topicString +blpapi_ResolutionList_topicStringAt = _blpapi_ResolutionList_topicStringAt +blpapi_SchemaElementDefinition_description = ( + _blpapi_SchemaElementDefinition_description +) +blpapi_SchemaElementDefinition_getAlternateName = ( + _blpapi_SchemaElementDefinition_getAlternateName +) +blpapi_SchemaElementDefinition_maxValues = ( + _blpapi_SchemaElementDefinition_maxValues +) +blpapi_SchemaElementDefinition_minValues = ( + _blpapi_SchemaElementDefinition_minValues +) +blpapi_SchemaElementDefinition_name = _blpapi_SchemaElementDefinition_name +blpapi_SchemaElementDefinition_numAlternateNames = ( + _blpapi_SchemaElementDefinition_numAlternateNames +) +blpapi_SchemaElementDefinition_printHelper = ( + _blpapi_SchemaElementDefinition_printHelper +) +blpapi_SchemaElementDefinition_status = _blpapi_SchemaElementDefinition_status +blpapi_SchemaElementDefinition_type = _blpapi_SchemaElementDefinition_type +blpapi_SchemaTypeDefinition_datatype = _blpapi_SchemaTypeDefinition_datatype +blpapi_SchemaTypeDefinition_description = ( + _blpapi_SchemaTypeDefinition_description +) +blpapi_SchemaTypeDefinition_enumeration = ( + _blpapi_SchemaTypeDefinition_enumeration +) +blpapi_SchemaTypeDefinition_getElementDefinition = ( + _blpapi_SchemaTypeDefinition_getElementDefinition +) +blpapi_SchemaTypeDefinition_getElementDefinitionAt = ( + _blpapi_SchemaTypeDefinition_getElementDefinitionAt +) +blpapi_SchemaTypeDefinition_hasElementDefinition = ( + _blpapi_SchemaTypeDefinition_hasElementDefinition +) +blpapi_SchemaTypeDefinition_isComplexType = ( + _blpapi_SchemaTypeDefinition_isComplexType +) +blpapi_SchemaTypeDefinition_isEnumerationType = ( + _blpapi_SchemaTypeDefinition_isEnumerationType +) +blpapi_SchemaTypeDefinition_isSimpleType = ( + _blpapi_SchemaTypeDefinition_isSimpleType +) +blpapi_SchemaTypeDefinition_name = _blpapi_SchemaTypeDefinition_name +blpapi_SchemaTypeDefinition_numElementDefinitions = ( + _blpapi_SchemaTypeDefinition_numElementDefinitions +) +blpapi_SchemaTypeDefinition_printHelper = ( + _blpapi_SchemaTypeDefinition_printHelper +) +blpapi_SchemaTypeDefinition_status = _blpapi_SchemaTypeDefinition_status +blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange = ( + _blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange +) +blpapi_ServiceRegistrationOptions_copy = ( + _blpapi_ServiceRegistrationOptions_copy +) +blpapi_ServiceRegistrationOptions_create = ( + _blpapi_ServiceRegistrationOptions_create +) +blpapi_ServiceRegistrationOptions_destroy = ( + _blpapi_ServiceRegistrationOptions_destroy +) +blpapi_ServiceRegistrationOptions_duplicate = ( + _blpapi_ServiceRegistrationOptions_duplicate +) +blpapi_ServiceRegistrationOptions_getGroupId = ( + _blpapi_ServiceRegistrationOptions_getGroupId +) +blpapi_ServiceRegistrationOptions_getPartsToRegister = ( + _blpapi_ServiceRegistrationOptions_getPartsToRegister +) +blpapi_ServiceRegistrationOptions_getServicePriority = ( + _blpapi_ServiceRegistrationOptions_getServicePriority +) +blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges = ( + _blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges +) +blpapi_ServiceRegistrationOptions_setGroupId = ( + _blpapi_ServiceRegistrationOptions_setGroupId +) +blpapi_ServiceRegistrationOptions_setPartsToRegister = ( + _blpapi_ServiceRegistrationOptions_setPartsToRegister +) +blpapi_ServiceRegistrationOptions_setServicePriority = ( + _blpapi_ServiceRegistrationOptions_setServicePriority +) +blpapi_Service_addRef = _blpapi_Service_addRef +blpapi_Service_authorizationServiceName = ( + _blpapi_Service_authorizationServiceName +) +blpapi_Service_createAdminEvent = _blpapi_Service_createAdminEvent +blpapi_Service_createAuthorizationRequest = ( + _blpapi_Service_createAuthorizationRequest +) +blpapi_Service_createPublishEvent = _blpapi_Service_createPublishEvent +blpapi_Service_createRequest = _blpapi_Service_createRequest +blpapi_Service_createResponseEvent = _blpapi_Service_createResponseEvent +blpapi_Service_description = _blpapi_Service_description +blpapi_Service_getEventDefinition = _blpapi_Service_getEventDefinition +blpapi_Service_getEventDefinitionAt = _blpapi_Service_getEventDefinitionAt +blpapi_Service_getOperation = _blpapi_Service_getOperation +blpapi_Service_getOperationAt = _blpapi_Service_getOperationAt +blpapi_Service_hasEventDefinition = _blpapi_Service_hasEventDefinition +blpapi_Service_hasOperation = _blpapi_Service_hasOperation +blpapi_Service_name = _blpapi_Service_name +blpapi_Service_numEventDefinitions = _blpapi_Service_numEventDefinitions +blpapi_Service_numOperations = _blpapi_Service_numOperations +blpapi_Service_printHelper = _blpapi_Service_printHelper +blpapi_Service_release = _blpapi_Service_release +blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg = ( + _blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg +) +blpapi_SessionOptions_applicationIdentityKey = ( + _blpapi_SessionOptions_applicationIdentityKey +) +blpapi_SessionOptions_authenticationOptions = ( + _blpapi_SessionOptions_authenticationOptions +) +blpapi_SessionOptions_autoRestartOnDisconnection = ( + _blpapi_SessionOptions_autoRestartOnDisconnection +) +blpapi_SessionOptions_bandwidthSaveModeDisabled = ( + _blpapi_SessionOptions_bandwidthSaveModeDisabled +) +blpapi_SessionOptions_clientMode = _blpapi_SessionOptions_clientMode +blpapi_SessionOptions_connectTimeout = _blpapi_SessionOptions_connectTimeout +blpapi_SessionOptions_create = _blpapi_SessionOptions_create +blpapi_SessionOptions_defaultKeepAliveInactivityTime = ( + _blpapi_SessionOptions_defaultKeepAliveInactivityTime +) +blpapi_SessionOptions_defaultKeepAliveResponseTimeout = ( + _blpapi_SessionOptions_defaultKeepAliveResponseTimeout +) +blpapi_SessionOptions_defaultServices = _blpapi_SessionOptions_defaultServices +blpapi_SessionOptions_defaultSubscriptionService = ( + _blpapi_SessionOptions_defaultSubscriptionService +) +blpapi_SessionOptions_defaultTopicPrefix = ( + _blpapi_SessionOptions_defaultTopicPrefix +) +blpapi_SessionOptions_destroy = _blpapi_SessionOptions_destroy +blpapi_SessionOptions_flushPublishedEventsTimeout = ( + _blpapi_SessionOptions_flushPublishedEventsTimeout +) +blpapi_SessionOptions_getServerAddressWithProxy = ( + _blpapi_SessionOptions_getServerAddressWithProxy +) +blpapi_SessionOptions_keepAliveEnabled = ( + _blpapi_SessionOptions_keepAliveEnabled +) +blpapi_SessionOptions_maxEventQueueSize = ( + _blpapi_SessionOptions_maxEventQueueSize +) +blpapi_SessionOptions_maxPendingRequests = ( + _blpapi_SessionOptions_maxPendingRequests +) +blpapi_SessionOptions_numServerAddresses = ( + _blpapi_SessionOptions_numServerAddresses +) +blpapi_SessionOptions_numStartAttempts = ( + _blpapi_SessionOptions_numStartAttempts +) +blpapi_SessionOptions_printHelper = _blpapi_SessionOptions_printHelper +blpapi_SessionOptions_recordSubscriptionDataReceiveTimes = ( + _blpapi_SessionOptions_recordSubscriptionDataReceiveTimes +) +blpapi_SessionOptions_removeServerAddress = ( + _blpapi_SessionOptions_removeServerAddress +) +blpapi_SessionOptions_serverHost = _blpapi_SessionOptions_serverHost +blpapi_SessionOptions_serverPort = _blpapi_SessionOptions_serverPort +blpapi_SessionOptions_serviceCheckTimeout = ( + _blpapi_SessionOptions_serviceCheckTimeout +) +blpapi_SessionOptions_serviceDownloadTimeout = ( + _blpapi_SessionOptions_serviceDownloadTimeout +) +blpapi_SessionOptions_sessionName = _blpapi_SessionOptions_sessionName +blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg = ( + _blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg +) +blpapi_SessionOptions_setApplicationIdentityKey = ( + _blpapi_SessionOptions_setApplicationIdentityKey +) +blpapi_SessionOptions_setAuthenticationOptions = ( + _blpapi_SessionOptions_setAuthenticationOptions +) +blpapi_SessionOptions_setAutoRestartOnDisconnection = ( + _blpapi_SessionOptions_setAutoRestartOnDisconnection +) +blpapi_SessionOptions_setBandwidthSaveModeDisabled = ( + _blpapi_SessionOptions_setBandwidthSaveModeDisabled +) +blpapi_SessionOptions_setClientMode = _blpapi_SessionOptions_setClientMode +blpapi_SessionOptions_setConnectTimeout = ( + _blpapi_SessionOptions_setConnectTimeout +) +blpapi_SessionOptions_setDefaultKeepAliveInactivityTime = ( + _blpapi_SessionOptions_setDefaultKeepAliveInactivityTime +) +blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout = ( + _blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout +) +blpapi_SessionOptions_setDefaultServices = ( + _blpapi_SessionOptions_setDefaultServices +) +blpapi_SessionOptions_setDefaultSubscriptionService = ( + _blpapi_SessionOptions_setDefaultSubscriptionService +) +blpapi_SessionOptions_setDefaultTopicPrefix = ( + _blpapi_SessionOptions_setDefaultTopicPrefix +) +blpapi_SessionOptions_setFlushPublishedEventsTimeout = ( + _blpapi_SessionOptions_setFlushPublishedEventsTimeout +) +blpapi_SessionOptions_setKeepAliveEnabled = ( + _blpapi_SessionOptions_setKeepAliveEnabled +) +blpapi_SessionOptions_setMaxEventQueueSize = ( + _blpapi_SessionOptions_setMaxEventQueueSize +) +blpapi_SessionOptions_setMaxPendingRequests = ( + _blpapi_SessionOptions_setMaxPendingRequests +) +blpapi_SessionOptions_setNumStartAttempts = ( + _blpapi_SessionOptions_setNumStartAttempts +) +blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes = ( + _blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes +) +blpapi_SessionOptions_setServerAddress = ( + _blpapi_SessionOptions_setServerAddress +) +blpapi_SessionOptions_setServerAddressWithProxy = ( + _blpapi_SessionOptions_setServerAddressWithProxy +) +blpapi_SessionOptions_setServerHost = _blpapi_SessionOptions_setServerHost +blpapi_SessionOptions_setServerPort = _blpapi_SessionOptions_setServerPort +blpapi_SessionOptions_setServiceCheckTimeout = ( + _blpapi_SessionOptions_setServiceCheckTimeout +) +blpapi_SessionOptions_setServiceDownloadTimeout = ( + _blpapi_SessionOptions_setServiceDownloadTimeout +) +blpapi_SessionOptions_setSessionIdentityOptions = ( + _blpapi_SessionOptions_setSessionIdentityOptions +) +blpapi_SessionOptions_setSessionName = _blpapi_SessionOptions_setSessionName +blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark = ( + _blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark +) +blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark = ( + _blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark +) +blpapi_SessionOptions_setTlsOptions = _blpapi_SessionOptions_setTlsOptions +blpapi_SessionOptions_slowConsumerWarningHiWaterMark = ( + _blpapi_SessionOptions_slowConsumerWarningHiWaterMark +) +blpapi_SessionOptions_slowConsumerWarningLoWaterMark = ( + _blpapi_SessionOptions_slowConsumerWarningLoWaterMark +) +blpapi_Session_createSnapshotRequestTemplate = ( + _blpapi_Session_createSnapshotRequestTemplate +) +blpapi_Session_getAbstractSession = _blpapi_Session_getAbstractSession +blpapi_Session_nextEvent = _blpapi_Session_nextEvent +blpapi_Session_resubscribe = _blpapi_Session_resubscribe +blpapi_Session_resubscribeEx = _blpapi_Session_resubscribeEx +blpapi_Session_resubscribeEx_helper = _blpapi_Session_resubscribeEx_helper +blpapi_Session_resubscribeWithId = _blpapi_Session_resubscribeWithId +blpapi_Session_resubscribeWithIdEx = _blpapi_Session_resubscribeWithIdEx +blpapi_Session_resubscribeWithIdEx_helper = ( + _blpapi_Session_resubscribeWithIdEx_helper +) +blpapi_Session_sendRequest = _blpapi_Session_sendRequest +blpapi_Session_sendRequestTemplate = _blpapi_Session_sendRequestTemplate +blpapi_Session_setStatusCorrelationId = _blpapi_Session_setStatusCorrelationId +blpapi_Session_start = _blpapi_Session_start +blpapi_Session_startAsync = _blpapi_Session_startAsync +blpapi_Session_stop = _blpapi_Session_stop +blpapi_Session_stopAsync = _blpapi_Session_stopAsync +blpapi_Session_subscribe = _blpapi_Session_subscribe +blpapi_Session_subscribeEx = _blpapi_Session_subscribeEx +blpapi_Session_subscribeEx_helper = _blpapi_Session_subscribeEx_helper +blpapi_Session_tryNextEvent = _blpapi_Session_tryNextEvent +blpapi_Session_unsubscribe = _blpapi_Session_unsubscribe +blpapi_Socks5Config_create = _blpapi_Socks5Config_create +blpapi_Socks5Config_destroy = _blpapi_Socks5Config_destroy +blpapi_Socks5Config_printHelper = _blpapi_Socks5Config_printHelper +blpapi_SubscriptionList_addHelper = _blpapi_SubscriptionList_addHelper +blpapi_SubscriptionList_addResolved = _blpapi_SubscriptionList_addResolved +blpapi_SubscriptionList_append = _blpapi_SubscriptionList_append +blpapi_SubscriptionList_clear = _blpapi_SubscriptionList_clear +blpapi_SubscriptionList_correlationIdAt = ( + _blpapi_SubscriptionList_correlationIdAt +) +blpapi_SubscriptionList_create = _blpapi_SubscriptionList_create +blpapi_SubscriptionList_destroy = _blpapi_SubscriptionList_destroy +blpapi_SubscriptionList_isResolvedAt = _blpapi_SubscriptionList_isResolvedAt +blpapi_SubscriptionList_size = _blpapi_SubscriptionList_size +blpapi_SubscriptionList_topicStringAt = _blpapi_SubscriptionList_topicStringAt +blpapi_TestUtil_appendMessage = _blpapi_TestUtil_appendMessage +blpapi_TestUtil_createEvent = _blpapi_TestUtil_createEvent +blpapi_TestUtil_createTopic = _blpapi_TestUtil_createTopic +blpapi_TestUtil_deserializeService = _blpapi_TestUtil_deserializeService +blpapi_TestUtil_getAdminMessageDefinition = ( + _blpapi_TestUtil_getAdminMessageDefinition +) +blpapi_TestUtil_serializeServiceHelper = ( + _blpapi_TestUtil_serializeServiceHelper +) +blpapi_TimePoint = TimePoint +blpapi_TimePointUtil_nanosecondsBetween = ( + _blpapi_TimePointUtil_nanosecondsBetween +) +blpapi_TlsOptions_createFromBlobs = _blpapi_TlsOptions_createFromBlobs +blpapi_TlsOptions_createFromFiles = _blpapi_TlsOptions_createFromFiles +blpapi_TlsOptions_destroy = _blpapi_TlsOptions_destroy +blpapi_TlsOptions_setCrlFetchTimeoutMs = ( + _blpapi_TlsOptions_setCrlFetchTimeoutMs +) +blpapi_TlsOptions_setTlsHandshakeTimeoutMs = ( + _blpapi_TlsOptions_setTlsHandshakeTimeoutMs +) +blpapi_TopicList_add = _blpapi_TopicList_add +blpapi_TopicList_addFromMessage = _blpapi_TopicList_addFromMessage +blpapi_TopicList_correlationIdAt = _blpapi_TopicList_correlationIdAt +blpapi_TopicList_create = _blpapi_TopicList_create +blpapi_TopicList_createFromResolutionList = ( + _blpapi_TopicList_createFromResolutionList +) +blpapi_TopicList_destroy = _blpapi_TopicList_destroy +blpapi_TopicList_message = _blpapi_TopicList_message +blpapi_TopicList_messageAt = _blpapi_TopicList_messageAt +blpapi_TopicList_size = _blpapi_TopicList_size +blpapi_TopicList_status = _blpapi_TopicList_status +blpapi_TopicList_statusAt = _blpapi_TopicList_statusAt +blpapi_TopicList_topicString = _blpapi_TopicList_topicString +blpapi_TopicList_topicStringAt = _blpapi_TopicList_topicStringAt +blpapi_Topic_compare = _blpapi_Topic_compare +blpapi_Topic_create = _blpapi_Topic_create +blpapi_Topic_destroy = _blpapi_Topic_destroy +blpapi_Topic_isActive = _blpapi_Topic_isActive +blpapi_Topic_service = _blpapi_Topic_service +blpapi_ZfpUtil_getOptionsForLeasedLines = ( + _blpapi_ZfpUtil_getOptionsForLeasedLines +) +blpapi_getLastErrorDescription = _blpapi_getLastErrorDescription +blpapi_getVersionInfo = _blpapi_getVersionInfo +ProviderSession_createHelper = _ProviderSession_createHelper +ProviderSession_destroyHelper = _ProviderSession_destroyHelper +Session_createHelper = _Session_createHelper +Session_destroyHelper = _Session_destroyHelper + + +def _test_function_signatures(): + _C_TO_PY = { + "char": c_char, + "double": c_double, + "float": c_float, + "int": c_int, + "int*": POINTER(c_int), + "size_t": c_size_t, + "unsigned int": c_uint, + "blpapi_CorrelationId_t": CidStruct, + } + + def c_type_to_ctypes(ctype: str): + pt = _C_TO_PY.get(ctype, None) + if pt is not None: + return pt + if "char" in ctype: + return c_char_p + elif "*" in ctype: + return c_void_p + return None + + def verify_ctypes(fnc, ret: str, args: List[str]): + f = globals().get("l_" + fnc, None) # find in local module + if f is None: + # this if fine, not yet impl + return + + if f.restype != c_type_to_ctypes(ret): + raise ImportError( + f"Return type for '{fnc}' is '{ret}', but restype set to '{f.restype}'" + ) + + if f.argtypes is None: + # OK, for now, not all have it + return + + assert len(f.argtypes) == len(args) + for pyarg, carg in zip(f.argtypes, args): + if pyarg != c_type_to_ctypes(carg): + raise ImportError( + f"Argument type for '{fnc}' is '{carg}' but set to '{pyarg}'" + ) + + verify_ctypes( + fnc="blpapi_AbstractSession_cancel", + ret="int", + args=[ + "blpapi_AbstractSession_t*", + "blpapi_CorrelationId_t*", + "size_t", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_createIdentity", + ret="blpapi_Identity_t *", + args=["blpapi_AbstractSession_t*"], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_generateAuthorizedIdentityAsync", + ret="int", + args=[ + "blpapi_AbstractSession_t*", + "blpapi_AuthOptions_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_generateManualToken", + ret="int", + args=[ + "blpapi_AbstractSession_t*", + "blpapi_CorrelationId_t*", + "char*", + "char*", + "blpapi_EventQueue_t*", + ], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_generateToken", + ret="int", + args=[ + "blpapi_AbstractSession_t*", + "blpapi_CorrelationId_t*", + "blpapi_EventQueue_t*", + ], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_getAuthorizedIdentity", + ret="int", + args=[ + "blpapi_AbstractSession_t*", + "blpapi_CorrelationId_t*", + "blpapi_Identity_t**", + ], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_getService", + ret="int", + args=["blpapi_AbstractSession_t*", "blpapi_Service_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_openService", + ret="int", + args=["blpapi_AbstractSession_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_openServiceAsync", + ret="int", + args=["blpapi_AbstractSession_t*", "char*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_AbstractSession_sessionName", + ret="int", + args=["blpapi_AbstractSession_t*", "char**", "size_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthApplication_copy", + ret="int", + args=["blpapi_AuthApplication_t*", "blpapi_AuthApplication_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthApplication_create", + ret="int", + args=["blpapi_AuthApplication_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_AuthApplication_destroy", + ret="void", + args=["blpapi_AuthApplication_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthApplication_duplicate", + ret="int", + args=["blpapi_AuthApplication_t**", "blpapi_AuthApplication_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_copy", + ret="int", + args=["blpapi_AuthOptions_t*", "blpapi_AuthOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_create_default", + ret="int", + args=["blpapi_AuthOptions_t**"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_create_forAppMode", + ret="int", + args=["blpapi_AuthOptions_t**", "blpapi_AuthApplication_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_create_forToken", + ret="int", + args=["blpapi_AuthOptions_t**", "blpapi_AuthToken_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_create_forUserAndAppMode", + ret="int", + args=[ + "blpapi_AuthOptions_t**", + "blpapi_AuthUser_t*", + "blpapi_AuthApplication_t*", + ], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_create_forUserMode", + ret="int", + args=["blpapi_AuthOptions_t**", "blpapi_AuthUser_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_destroy", + ret="void", + args=["blpapi_AuthOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthOptions_duplicate", + ret="int", + args=["blpapi_AuthOptions_t**", "blpapi_AuthOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthToken_copy", + ret="int", + args=["blpapi_AuthToken_t*", "blpapi_AuthToken_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthToken_create", + ret="int", + args=["blpapi_AuthToken_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_AuthToken_destroy", + ret="void", + args=["blpapi_AuthToken_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthToken_duplicate", + ret="int", + args=["blpapi_AuthToken_t**", "blpapi_AuthToken_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthUser_copy", + ret="int", + args=["blpapi_AuthUser_t*", "blpapi_AuthUser_t*"], + ) + verify_ctypes( + fnc="blpapi_AuthUser_createWithActiveDirectoryProperty", + ret="int", + args=["blpapi_AuthUser_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_AuthUser_createWithLogonName", + ret="int", + args=["blpapi_AuthUser_t**"], + ) + verify_ctypes( + fnc="blpapi_AuthUser_createWithManualOptions", + ret="int", + args=["blpapi_AuthUser_t**", "char*", "char*"], + ) + verify_ctypes( + fnc="blpapi_AuthUser_destroy", ret="void", args=["blpapi_AuthUser_t*"] + ) + verify_ctypes( + fnc="blpapi_AuthUser_duplicate", + ret="int", + args=["blpapi_AuthUser_t**", "blpapi_AuthUser_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_datatype", + ret="int", + args=["blpapi_ConstantList_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_description", + ret="char *", + args=["blpapi_ConstantList_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_getConstant", + ret="blpapi_Constant_t *", + args=["blpapi_ConstantList_t*", "char*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_getConstantAt", + ret="blpapi_Constant_t *", + args=["blpapi_ConstantList_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_name", + ret="blpapi_Name_t *", + args=["blpapi_ConstantList_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_numConstants", + ret="int", + args=["blpapi_ConstantList_t*"], + ) + verify_ctypes( + fnc="blpapi_ConstantList_status", + ret="int", + args=["blpapi_ConstantList_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_datatype", ret="int", args=["blpapi_Constant_t*"] + ) + verify_ctypes( + fnc="blpapi_Constant_description", + ret="char *", + args=["blpapi_Constant_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsChar", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Char_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsDatetime", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Datetime_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsFloat32", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Float32_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsFloat64", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Float64_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsInt32", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Int32_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsInt64", + ret="int", + args=["blpapi_Constant_t*", "blpapi_Int64_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_getValueAsString", + ret="int", + args=["blpapi_Constant_t*", "char**"], + ) + verify_ctypes( + fnc="blpapi_Constant_name", + ret="blpapi_Name_t *", + args=["blpapi_Constant_t*"], + ) + verify_ctypes( + fnc="blpapi_Constant_status", ret="int", args=["blpapi_Constant_t*"] + ) + verify_ctypes( + fnc="blpapi_Element_appendElement", + ret="int", + args=["blpapi_Element_t*", "blpapi_Element_t**"], + ) + verify_ctypes( + fnc="blpapi_Element_datatype", ret="int", args=["blpapi_Element_t*"] + ) + verify_ctypes( + fnc="blpapi_Element_definition", + ret="blpapi_SchemaElementDefinition_t *", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_getChoice", + ret="int", + args=["blpapi_Element_t*", "blpapi_Element_t**"], + ) + verify_ctypes( + fnc="blpapi_Element_getElement", + ret="int", + args=["blpapi_Element_t*", "blpapi_Element_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getElementAt", + ret="int", + args=["blpapi_Element_t*", "blpapi_Element_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsBool", + ret="int", + args=["blpapi_Element_t*", "blpapi_Bool_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsBytes", + ret="int", + args=["blpapi_Element_t*", "char**", "size_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsChar", + ret="int", + args=["blpapi_Element_t*", "blpapi_Char_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsDatetime", + ret="int", + args=["blpapi_Element_t*", "blpapi_Datetime_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsElement", + ret="int", + args=["blpapi_Element_t*", "blpapi_Element_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsFloat64", + ret="int", + args=["blpapi_Element_t*", "blpapi_Float64_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsHighPrecisionDatetime", + ret="int", + args=[ + "blpapi_Element_t*", + "blpapi_HighPrecisionDatetime_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsInt32", + ret="int", + args=["blpapi_Element_t*", "blpapi_Int32_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsInt64", + ret="int", + args=["blpapi_Element_t*", "blpapi_Int64_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsName", + ret="int", + args=["blpapi_Element_t*", "blpapi_Name_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_getValueAsString", + ret="int", + args=["blpapi_Element_t*", "char**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_hasElementEx", + ret="int", + args=["blpapi_Element_t*", "char*", "blpapi_Name_t*", "int", "int"], + ) + verify_ctypes( + fnc="blpapi_Element_isArray", ret="int", args=["blpapi_Element_t*"] + ) + verify_ctypes( + fnc="blpapi_Element_isComplexType", + ret="int", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_isNull", + ret="int", + args=["blpapi_Element_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_isNullValue", + ret="int", + args=["blpapi_Element_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_isReadOnly", ret="int", args=["blpapi_Element_t*"] + ) + verify_ctypes( + fnc="blpapi_Element_name", + ret="blpapi_Name_t *", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_nameString", + ret="char *", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_numElements", + ret="size_t", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_numValues", + ret="size_t", + args=["blpapi_Element_t*"], + ) + verify_ctypes( + fnc="blpapi_Element_setChoice", + ret="int", + args=[ + "blpapi_Element_t*", + "blpapi_Element_t**", + "char*", + "blpapi_Name_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementBool", + ret="int", + args=["blpapi_Element_t*", "char*", "blpapi_Name_t*", "blpapi_Bool_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setElementBytes", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "char*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementFloat", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Float32_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementFromName", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementHighPrecisionDatetime", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "blpapi_HighPrecisionDatetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementInt32", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Int32_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementInt64", + ret="int", + args=[ + "blpapi_Element_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Int64_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setElementString", + ret="int", + args=["blpapi_Element_t*", "char*", "blpapi_Name_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueBool", + ret="int", + args=["blpapi_Element_t*", "blpapi_Bool_t", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueBytes", + ret="int", + args=["blpapi_Element_t*", "char*", "size_t", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueFloat", + ret="int", + args=["blpapi_Element_t*", "blpapi_Float32_t", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueFromName", + ret="int", + args=["blpapi_Element_t*", "blpapi_Name_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueHighPrecisionDatetime", + ret="int", + args=[ + "blpapi_Element_t*", + "blpapi_HighPrecisionDatetime_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Element_setValueInt32", + ret="int", + args=["blpapi_Element_t*", "blpapi_Int32_t", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueInt64", + ret="int", + args=["blpapi_Element_t*", "blpapi_Int64_t", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Element_setValueString", + ret="int", + args=["blpapi_Element_t*", "char*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_EventDispatcher_create", + ret="blpapi_EventDispatcher_t *", + args=["size_t"], + ) + verify_ctypes( + fnc="blpapi_EventDispatcher_destroy", + ret="void", + args=["blpapi_EventDispatcher_t*"], + ) + verify_ctypes( + fnc="blpapi_EventDispatcher_start", + ret="int", + args=["blpapi_EventDispatcher_t*"], + ) + verify_ctypes( + fnc="blpapi_EventDispatcher_stop", + ret="int", + args=["blpapi_EventDispatcher_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendElement", + ret="int", + args=["blpapi_EventFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendFragmentedRecapMessage", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Topic_t*", + "blpapi_CorrelationId_t*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendFragmentedRecapMessageSeq", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Topic_t*", + "int", + "unsigned int", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendMessage", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Topic_t*", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendMessageSeq", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Topic_t*", + "unsigned int", + "unsigned", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendRecapMessage", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "blpapi_Topic_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendRecapMessageSeq", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "blpapi_Topic_t*", + "blpapi_CorrelationId_t*", + "unsigned int", + "unsigned", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendResponse", + ret="int", + args=["blpapi_EventFormatter_t*", "char*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueBool", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_Bool_t"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueChar", + ret="int", + args=["blpapi_EventFormatter_t*", "char"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueFloat", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_Float32_t"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueFromName", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueHighPrecisionDatetime", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_HighPrecisionDatetime_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueInt32", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_Int32_t"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueInt64", + ret="int", + args=["blpapi_EventFormatter_t*", "blpapi_Int64_t"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_appendValueString", + ret="int", + args=["blpapi_EventFormatter_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_create", + ret="blpapi_EventFormatter_t *", + args=["blpapi_Event_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_destroy", + ret="void", + args=["blpapi_EventFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_popElement", + ret="int", + args=["blpapi_EventFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_pushElement", + ret="int", + args=["blpapi_EventFormatter_t*", "char*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueBool", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Bool_t", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueBytes", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "char*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueChar", + ret="int", + args=["blpapi_EventFormatter_t*", "char*", "blpapi_Name_t*", "char"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueFloat", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Float32_t", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueFromName", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueHighPrecisionDatetime", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_HighPrecisionDatetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueInt32", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Int32_t", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueInt64", + ret="int", + args=[ + "blpapi_EventFormatter_t*", + "char*", + "blpapi_Name_t*", + "blpapi_Int64_t", + ], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueNull", + ret="int", + args=["blpapi_EventFormatter_t*", "char*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_EventFormatter_setValueString", + ret="int", + args=["blpapi_EventFormatter_t*", "char*", "blpapi_Name_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_EventQueue_create", ret="blpapi_EventQueue_t *", args=[""] + ) + verify_ctypes( + fnc="blpapi_EventQueue_destroy", + ret="int", + args=["blpapi_EventQueue_t*"], + ) + verify_ctypes( + fnc="blpapi_EventQueue_nextEvent", + ret="blpapi_Event_t *", + args=["blpapi_EventQueue_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_EventQueue_purge", ret="int", args=["blpapi_EventQueue_t*"] + ) + verify_ctypes( + fnc="blpapi_EventQueue_tryNextEvent", + ret="int", + args=["blpapi_EventQueue_t*", "blpapi_Event_t**"], + ) + verify_ctypes( + fnc="blpapi_Event_eventType", ret="int", args=["blpapi_Event_t*"] + ) + verify_ctypes( + fnc="blpapi_Event_release", ret="int", args=["blpapi_Event_t*"] + ) + verify_ctypes( + fnc="blpapi_HighPrecisionDatetime_compare", + ret="int", + args=[ + "blpapi_HighPrecisionDatetime_t*", + "blpapi_HighPrecisionDatetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_HighPrecisionDatetime_fromTimePoint", + ret="int", + args=[ + "blpapi_HighPrecisionDatetime_t*", + "blpapi_TimePoint_t*", + "short", + ], + ) + verify_ctypes( + fnc="blpapi_HighPrecisionDatetime_print", + ret="int", + args=[ + "blpapi_HighPrecisionDatetime_t*", + "blpapi_StreamWriter_t", + "void*", + "int", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_HighResolutionClock_now", + ret="int", + args=["blpapi_TimePoint_t*"], + ) + verify_ctypes( + fnc="blpapi_Identity_addRef", ret="int", args=["blpapi_Identity_t*"] + ) + verify_ctypes( + fnc="blpapi_Identity_getSeatType", + ret="int", + args=["blpapi_Identity_t*", "int*"], + ) + verify_ctypes( + fnc="blpapi_Identity_hasEntitlements", + ret="int", + args=[ + "blpapi_Identity_t*", + "blpapi_Service_t*", + "blpapi_Element_t*", + "int*", + "size_t", + "int*", + "int*", + ], + ) + verify_ctypes( + fnc="blpapi_Identity_isAuthorized", + ret="int", + args=["blpapi_Identity_t*", "blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_Identity_release", ret="void", args=["blpapi_Identity_t*"] + ) + verify_ctypes( + fnc="blpapi_Logging_logTestMessage", + ret="void", + args=["blpapi_Logging_Severity_t"], + ) + verify_ctypes( + fnc="blpapi_Logging_registerCallback", + ret="int", + args=["funct", "blpapi_Logging_Severity_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_FormatMessageJson", + ret="int", + args=["blpapi_MessageFormatter_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_FormatMessageXml", + ret="int", + args=["blpapi_MessageFormatter_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendElement", + ret="int", + args=["blpapi_MessageFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueBool", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Bool_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueChar", + ret="int", + args=["blpapi_MessageFormatter_t*", "char"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueDatetime", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Datetime_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueFloat", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Float32_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueFloat32", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Float32_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueFloat64", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Float64_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueFromName", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueHighPrecisionDatetime", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_HighPrecisionDatetime_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueInt32", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Int32_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueInt64", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Int64_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_appendValueString", + ret="int", + args=["blpapi_MessageFormatter_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_assign", + ret="int", + args=["blpapi_MessageFormatter_t**", "blpapi_MessageFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_copy", + ret="int", + args=["blpapi_MessageFormatter_t**", "blpapi_MessageFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_destroy", + ret="int", + args=["blpapi_MessageFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_popElement", + ret="int", + args=["blpapi_MessageFormatter_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_pushElement", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueBool", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*", "blpapi_Bool_t"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueBytes", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "char*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueChar", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*", "char"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueDatetime", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Datetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueFloat", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Float32_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueFloat32", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Float32_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueFloat64", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Float64_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueFromName", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueHighPrecisionDatetime", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_HighPrecisionDatetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueInt32", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Int32_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueInt64", + ret="int", + args=[ + "blpapi_MessageFormatter_t*", + "blpapi_Name_t*", + "blpapi_Int64_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueNull", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageFormatter_setValueString", + ret="int", + args=["blpapi_MessageFormatter_t*", "blpapi_Name_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_MessageIterator_create", + ret="blpapi_MessageIterator_t *", + args=["blpapi_Event_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageIterator_destroy", + ret="void", + args=["blpapi_MessageIterator_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageIterator_next", + ret="int", + args=["blpapi_MessageIterator_t*", "blpapi_Message_t**"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_assign", + ret="int", + args=["blpapi_MessageProperties_t*", "blpapi_MessageProperties_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_copy", + ret="int", + args=["blpapi_MessageProperties_t**", "blpapi_MessageProperties_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_create", + ret="int", + args=["blpapi_MessageProperties_t**"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_destroy", + ret="void", + args=["blpapi_MessageProperties_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_setCorrelationIds", + ret="int", + args=[ + "blpapi_MessageProperties_t*", + "blpapi_CorrelationId_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_setRecapType", + ret="int", + args=["blpapi_MessageProperties_t*", "int", "int"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_setRequestId", + ret="int", + args=["blpapi_MessageProperties_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_setService", + ret="int", + args=["blpapi_MessageProperties_t*", "blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_MessageProperties_setTimeReceived", + ret="int", + args=[ + "blpapi_MessageProperties_t*", + "blpapi_HighPrecisionDatetime_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Message_addRef", ret="int", args=["blpapi_Message_t*"] + ) + verify_ctypes( + fnc="blpapi_Message_correlationId", + ret="blpapi_CorrelationId_t", + args=["blpapi_Message_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Message_elements", + ret="blpapi_Element_t *", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_fragmentType", + ret="int", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_getRequestId", + ret="int", + args=["blpapi_Message_t*", "char**"], + ) + verify_ctypes( + fnc="blpapi_Message_messageType", + ret="blpapi_Name_t *", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_numCorrelationIds", + ret="int", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_recapType", ret="int", args=["blpapi_Message_t*"] + ) + verify_ctypes( + fnc="blpapi_Message_release", ret="int", args=["blpapi_Message_t*"] + ) + verify_ctypes( + fnc="blpapi_Message_service", + ret="blpapi_Service_t *", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_timeReceived", + ret="int", + args=["blpapi_Message_t*", "blpapi_TimePoint_t*"], + ) + verify_ctypes( + fnc="blpapi_Message_topicName", + ret="char *", + args=["blpapi_Message_t*"], + ) + verify_ctypes( + fnc="blpapi_Name_create", ret="blpapi_Name_t *", args=["char*"] + ) + verify_ctypes( + fnc="blpapi_Name_destroy", ret="void", args=["blpapi_Name_t*"] + ) + verify_ctypes( + fnc="blpapi_Name_equalsStr", + ret="int", + args=["blpapi_Name_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_Name_findName", ret="blpapi_Name_t *", args=["char*"] + ) + verify_ctypes( + fnc="blpapi_Name_length", ret="size_t", args=["blpapi_Name_t*"] + ) + verify_ctypes( + fnc="blpapi_Name_string", ret="char *", args=["blpapi_Name_t*"] + ) + verify_ctypes( + fnc="blpapi_Operation_description", + ret="char *", + args=["blpapi_Operation_t*"], + ) + verify_ctypes( + fnc="blpapi_Operation_name", ret="char *", args=["blpapi_Operation_t*"] + ) + verify_ctypes( + fnc="blpapi_Operation_numResponseDefinitions", + ret="int", + args=["blpapi_Operation_t*"], + ) + verify_ctypes( + fnc="blpapi_Operation_requestDefinition", + ret="int", + args=["blpapi_Operation_t*", "blpapi_SchemaElementDefinition_t**"], + ) + verify_ctypes( + fnc="blpapi_Operation_responseDefinition", + ret="int", + args=[ + "blpapi_Operation_t*", + "blpapi_SchemaElementDefinition_t**", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Operation_responseDefinitionFromName", + ret="int", + args=[ + "blpapi_Operation_t*", + "blpapi_SchemaElementDefinition_t**", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_activateSubServiceCodeRange", + ret="int", + args=["blpapi_ProviderSession_t*", "char*", "int", "int", "int"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_createServiceStatusTopic", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_Service_t*", + "blpapi_Topic_t**", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_createTopic", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_TopicList_t*", + "int", + "blpapi_Identity_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_createTopics", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_TopicList_t*", + "int", + "blpapi_Identity_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_createTopicsAsync", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_TopicList_t*", + "int", + "blpapi_Identity_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_deactivateSubServiceCodeRange", + ret="int", + args=["blpapi_ProviderSession_t*", "char*", "int", "int"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_deleteTopics", + ret="int", + args=["blpapi_ProviderSession_t*", "blpapi_Topic_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_deregisterService", + ret="int", + args=["blpapi_ProviderSession_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_flushPublishedEvents", + ret="int", + args=["blpapi_ProviderSession_t*", "int*", "int"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_getAbstractSession", + ret="blpapi_AbstractSession_t *", + args=["blpapi_ProviderSession_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_getTopic", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_Message_t*", + "blpapi_Topic_t**", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_nextEvent", + ret="int", + args=["blpapi_ProviderSession_t*", "blpapi_Event_t**", "unsigned int"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_publish", + ret="int", + args=["blpapi_ProviderSession_t*", "blpapi_Event_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_registerService", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "char*", + "blpapi_Identity_t*", + "blpapi_ServiceRegistrationOptions_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_registerServiceAsync", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "char*", + "blpapi_Identity_t*", + "blpapi_CorrelationId_t*", + "blpapi_ServiceRegistrationOptions_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_resolve", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_ResolutionList_t*", + "int", + "blpapi_Identity_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_resolveAsync", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_ResolutionList_t*", + "int", + "blpapi_Identity_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_sendResponse", + ret="int", + args=["blpapi_ProviderSession_t*", "blpapi_Event_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_start", + ret="int", + args=["blpapi_ProviderSession_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_startAsync", + ret="int", + args=["blpapi_ProviderSession_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_stop", + ret="int", + args=["blpapi_ProviderSession_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_stopAsync", + ret="int", + args=["blpapi_ProviderSession_t*"], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_terminateSubscriptionsOnTopics", + ret="int", + args=[ + "blpapi_ProviderSession_t*", + "blpapi_Topic_t**", + "size_t", + "char*", + ], + ) + verify_ctypes( + fnc="blpapi_ProviderSession_tryNextEvent", + ret="int", + args=["blpapi_ProviderSession_t*", "blpapi_Event_t**"], + ) + verify_ctypes( + fnc="blpapi_RequestTemplate_release", + ret="int", + args=["blpapi_RequestTemplate_t*"], + ) + verify_ctypes( + fnc="blpapi_Request_destroy", ret="void", args=["blpapi_Request_t*"] + ) + verify_ctypes( + fnc="blpapi_Request_elements", + ret="blpapi_Element_t *", + args=["blpapi_Request_t*"], + ) + verify_ctypes( + fnc="blpapi_Request_getRequestId", + ret="int", + args=["blpapi_Request_t*", "char**"], + ) + verify_ctypes( + fnc="blpapi_Request_setPreferredRoute", + ret="void", + args=["blpapi_Request_t*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_add", + ret="int", + args=["blpapi_ResolutionList_t*", "char*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_addAttribute", + ret="int", + args=["blpapi_ResolutionList_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_addFromMessage", + ret="int", + args=[ + "blpapi_ResolutionList_t*", + "blpapi_Message_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_attribute", + ret="int", + args=[ + "blpapi_ResolutionList_t*", + "blpapi_Element_t**", + "blpapi_Name_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_attributeAt", + ret="int", + args=[ + "blpapi_ResolutionList_t*", + "blpapi_Element_t**", + "blpapi_Name_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_correlationIdAt", + ret="int", + args=["blpapi_ResolutionList_t*", "blpapi_CorrelationId_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_create", + ret="blpapi_ResolutionList_t *", + args=["blpapi_ResolutionList_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_destroy", + ret="void", + args=["blpapi_ResolutionList_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_extractAttributeFromResolutionSuccess", + ret="blpapi_Element_t *", + args=["blpapi_Message_t*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_message", + ret="int", + args=[ + "blpapi_ResolutionList_t*", + "blpapi_Message_t**", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_messageAt", + ret="int", + args=["blpapi_ResolutionList_t*", "blpapi_Message_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_size", + ret="int", + args=["blpapi_ResolutionList_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_status", + ret="int", + args=["blpapi_ResolutionList_t*", "int*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_statusAt", + ret="int", + args=["blpapi_ResolutionList_t*", "int*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_topicString", + ret="int", + args=["blpapi_ResolutionList_t*", "char**", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_ResolutionList_topicStringAt", + ret="int", + args=["blpapi_ResolutionList_t*", "char**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_description", + ret="char *", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_getAlternateName", + ret="blpapi_Name_t *", + args=["blpapi_SchemaElementDefinition_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_maxValues", + ret="size_t", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_minValues", + ret="size_t", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_name", + ret="blpapi_Name_t *", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_numAlternateNames", + ret="size_t", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_status", + ret="int", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaElementDefinition_type", + ret="blpapi_SchemaTypeDefinition_t *", + args=["blpapi_SchemaElementDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_datatype", + ret="int", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_description", + ret="char *", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_enumeration", + ret="blpapi_ConstantList_t *", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_getElementDefinition", + ret="void*", + args=["blpapi_SchemaTypeDefinition_t*", "char*", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_getElementDefinitionAt", + ret="void*", + args=["blpapi_SchemaTypeDefinition_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_isComplexType", + ret="int", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_isEnumerationType", + ret="int", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_isSimpleType", + ret="int", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_name", + ret="blpapi_Name_t *", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_numElementDefinitions", + ret="size_t", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_SchemaTypeDefinition_status", + ret="int", + args=["blpapi_SchemaTypeDefinition_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange", + ret="int", + args=["blpapi_ServiceRegistrationOptions_t*", "int", "int", "int"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_copy", + ret="void", + args=[ + "blpapi_ServiceRegistrationOptions_t*", + "blpapi_ServiceRegistrationOptions_t*", + ], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_create", + ret="blpapi_ServiceRegistrationOptions_t *", + args=[""], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_destroy", + ret="void", + args=["blpapi_ServiceRegistrationOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_duplicate", + ret="void*", + args=["blpapi_ServiceRegistrationOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_getGroupId", + ret="int", + args=["blpapi_ServiceRegistrationOptions_t*", "char*", "int*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_getPartsToRegister", + ret="int", + args=["blpapi_ServiceRegistrationOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_getServicePriority", + ret="int", + args=["blpapi_ServiceRegistrationOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges", + ret="void", + args=["blpapi_ServiceRegistrationOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_setGroupId", + ret="void", + args=["blpapi_ServiceRegistrationOptions_t*", "char*", "unsigned int"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_setPartsToRegister", + ret="void", + args=["blpapi_ServiceRegistrationOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_ServiceRegistrationOptions_setServicePriority", + ret="int", + args=["blpapi_ServiceRegistrationOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_Service_addRef", ret="int", args=["blpapi_Service_t*"] + ) + verify_ctypes( + fnc="blpapi_Service_authorizationServiceName", + ret="char *", + args=["blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_Service_createAdminEvent", + ret="int", + args=["blpapi_Service_t*", "blpapi_Event_t**"], + ) + verify_ctypes( + fnc="blpapi_Service_createAuthorizationRequest", + ret="int", + args=["blpapi_Service_t*", "blpapi_Request_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_Service_createPublishEvent", + ret="int", + args=["blpapi_Service_t*", "blpapi_Event_t**"], + ) + verify_ctypes( + fnc="blpapi_Service_createRequest", + ret="int", + args=["blpapi_Service_t*", "blpapi_Request_t**", "char*"], + ) + verify_ctypes( + fnc="blpapi_Service_createResponseEvent", + ret="int", + args=[ + "blpapi_Service_t*", + "blpapi_CorrelationId_t*", + "blpapi_Event_t**", + ], + ) + verify_ctypes( + fnc="blpapi_Service_description", + ret="char *", + args=["blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_Service_getEventDefinition", + ret="int", + args=[ + "blpapi_Service_t*", + "blpapi_SchemaElementDefinition_t**", + "char*", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Service_getEventDefinitionAt", + ret="int", + args=[ + "blpapi_Service_t*", + "blpapi_SchemaElementDefinition_t**", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_Service_getOperation", + ret="int", + args=[ + "blpapi_Service_t*", + "blpapi_Operation_t**", + "char*", + "blpapi_Name_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Service_getOperationAt", + ret="int", + args=["blpapi_Service_t*", "blpapi_Operation_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Service_name", ret="char *", args=["blpapi_Service_t*"] + ) + verify_ctypes( + fnc="blpapi_Service_numEventDefinitions", + ret="int", + args=["blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_Service_numOperations", + ret="int", + args=["blpapi_Service_t*"], + ) + verify_ctypes( + fnc="blpapi_Service_release", ret="void", args=["blpapi_Service_t*"] + ) + verify_ctypes( + fnc="blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_applicationIdentityKey", + ret="int", + args=["char**", "size_t*", "blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_authenticationOptions", + ret="char *", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_autoRestartOnDisconnection", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_bandwidthSaveModeDisabled", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_clientMode", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_connectTimeout", + ret="unsigned int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_create", + ret="blpapi_SessionOptions_t *", + args=[""], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_defaultKeepAliveInactivityTime", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_defaultKeepAliveResponseTimeout", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_defaultServices", + ret="char *", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_defaultSubscriptionService", + ret="char *", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_defaultTopicPrefix", + ret="char *", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_destroy", + ret="void", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_flushPublishedEventsTimeout", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_getServerAddressWithProxy", + ret="int", + args=[ + "blpapi_SessionOptions_t*", + "char**", + "unsigned short*", + "char**", + "unsigned short*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_keepAliveEnabled", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_maxEventQueueSize", + ret="size_t", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_maxPendingRequests", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_numServerAddresses", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_numStartAttempts", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_recordSubscriptionDataReceiveTimes", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_removeServerAddress", + ret="int", + args=["blpapi_SessionOptions_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_serverHost", + ret="char *", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_serverPort", + ret="unsigned int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_serviceCheckTimeout", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_serviceDownloadTimeout", + ret="int", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_sessionName", + ret="int", + args=["char**", "size_t*", "blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setApplicationIdentityKey", + ret="int", + args=["blpapi_SessionOptions_t*", "char*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setAuthenticationOptions", + ret="void", + args=["blpapi_SessionOptions_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setAutoRestartOnDisconnection", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setBandwidthSaveModeDisabled", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setClientMode", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setConnectTimeout", + ret="int", + args=["blpapi_SessionOptions_t*", "unsigned int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setDefaultKeepAliveInactivityTime", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setDefaultServices", + ret="int", + args=["blpapi_SessionOptions_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setDefaultSubscriptionService", + ret="int", + args=["blpapi_SessionOptions_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setDefaultTopicPrefix", + ret="void", + args=["blpapi_SessionOptions_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setFlushPublishedEventsTimeout", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setKeepAliveEnabled", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setMaxEventQueueSize", + ret="void", + args=["blpapi_SessionOptions_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setMaxPendingRequests", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setNumStartAttempts", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes", + ret="void", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServerAddress", + ret="int", + args=["blpapi_SessionOptions_t*", "char*", "unsigned short", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServerAddressWithProxy", + ret="int", + args=[ + "blpapi_SessionOptions_t*", + "char*", + "unsigned short", + "blpapi_Socks5Config_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServerHost", + ret="int", + args=["blpapi_SessionOptions_t*", "char*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServerPort", + ret="int", + args=["blpapi_SessionOptions_t*", "unsigned short"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServiceCheckTimeout", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setServiceDownloadTimeout", + ret="int", + args=["blpapi_SessionOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setSessionIdentityOptions", + ret="int", + args=[ + "blpapi_SessionOptions_t*", + "blpapi_AuthOptions_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setSessionName", + ret="int", + args=["blpapi_SessionOptions_t*", "char*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark", + ret="int", + args=["blpapi_SessionOptions_t*", "float"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark", + ret="int", + args=["blpapi_SessionOptions_t*", "float"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_setTlsOptions", + ret="void", + args=["blpapi_SessionOptions_t*", "blpapi_TlsOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_slowConsumerWarningHiWaterMark", + ret="float", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_SessionOptions_slowConsumerWarningLoWaterMark", + ret="float", + args=["blpapi_SessionOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_Session_createSnapshotRequestTemplate", + ret="int", + args=[ + "blpapi_RequestTemplate_t**", + "blpapi_Session_t*", + "char*", + "blpapi_Identity_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Session_getAbstractSession", + ret="blpapi_AbstractSession_t *", + args=["blpapi_Session_t*"], + ) + verify_ctypes( + fnc="blpapi_Session_nextEvent", + ret="int", + args=["blpapi_Session_t*", "blpapi_Event_t**", "unsigned int"], + ) + verify_ctypes( + fnc="blpapi_Session_resubscribe", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_Session_resubscribeEx", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "char*", + "int", + "blpapi_SubscriptionPreprocessErrorHandler_t", + "void*", + ], + ) + verify_ctypes( + fnc="blpapi_Session_resubscribeWithId", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "int", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_Session_resubscribeWithIdEx", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "int", + "char*", + "int", + "blpapi_SubscriptionPreprocessErrorHandler_t", + "void*", + ], + ) + verify_ctypes( + fnc="blpapi_Session_sendRequest", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_Request_t*", + "blpapi_CorrelationId_t*", + "blpapi_Identity_t*", + "blpapi_EventQueue_t*", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_Session_sendRequestTemplate", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_RequestTemplate_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Session_setStatusCorrelationId", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_Service_t*", + "blpapi_Identity_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_Session_start", ret="int", args=["blpapi_Session_t*"] + ) + verify_ctypes( + fnc="blpapi_Session_startAsync", ret="int", args=["blpapi_Session_t*"] + ) + verify_ctypes( + fnc="blpapi_Session_stop", ret="int", args=["blpapi_Session_t*"] + ) + verify_ctypes( + fnc="blpapi_Session_stopAsync", ret="int", args=["blpapi_Session_t*"] + ) + verify_ctypes( + fnc="blpapi_Session_subscribe", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "blpapi_Identity_t*", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_Session_tryNextEvent", + ret="int", + args=["blpapi_Session_t*", "blpapi_Event_t**"], + ) + verify_ctypes( + fnc="blpapi_Session_unsubscribe", + ret="int", + args=[ + "blpapi_Session_t*", + "blpapi_SubscriptionList_t*", + "char*", + "int", + ], + ) + verify_ctypes( + fnc="blpapi_Socks5Config_create", + ret="blpapi_Socks5Config_t *", + args=["char*", "size_t", "unsigned short"], + ) + verify_ctypes( + fnc="blpapi_Socks5Config_destroy", + ret="void", + args=["blpapi_Socks5Config_t*"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_addResolved", + ret="int", + args=[ + "blpapi_SubscriptionList_t*", + "char*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_append", + ret="int", + args=["blpapi_SubscriptionList_t*", "blpapi_SubscriptionList_t*"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_clear", + ret="int", + args=["blpapi_SubscriptionList_t*"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_correlationIdAt", + ret="int", + args=[ + "blpapi_SubscriptionList_t*", + "blpapi_CorrelationId_t*", + "size_t", + ], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_create", + ret="blpapi_SubscriptionList_t *", + args=[""], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_destroy", + ret="void", + args=["blpapi_SubscriptionList_t*"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_isResolvedAt", + ret="int", + args=["blpapi_SubscriptionList_t*", "int*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_size", + ret="int", + args=["blpapi_SubscriptionList_t*"], + ) + verify_ctypes( + fnc="blpapi_SubscriptionList_topicStringAt", + ret="int", + args=["blpapi_SubscriptionList_t*", "char**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_TestUtil_appendMessage", + ret="int", + args=[ + "blpapi_MessageFormatter_t**", + "blpapi_Event_t*", + "blpapi_SchemaElementDefinition_t*", + "blpapi_MessageProperties_t*", + ], + ) + verify_ctypes( + fnc="blpapi_TestUtil_createEvent", + ret="int", + args=["blpapi_Event_t**", "int"], + ) + verify_ctypes( + fnc="blpapi_TestUtil_createTopic", + ret="int", + args=["blpapi_Topic_t**", "blpapi_Service_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_TestUtil_deserializeService", + ret="int", + args=["char*", "size_t", "blpapi_Service_t**"], + ) + verify_ctypes( + fnc="blpapi_TestUtil_getAdminMessageDefinition", + ret="int", + args=["blpapi_SchemaElementDefinition_t**", "blpapi_Name_t*"], + ) + verify_ctypes( + fnc="blpapi_TimePointUtil_nanosecondsBetween", + ret="long long", + args=["blpapi_TimePoint_t*", "blpapi_TimePoint_t*"], + ) + verify_ctypes( + fnc="blpapi_TlsOptions_createFromBlobs", + ret="blpapi_TlsOptions_t *", + args=["char*", "int", "char*", "char*", "int"], + ) + verify_ctypes( + fnc="blpapi_TlsOptions_createFromFiles", + ret="blpapi_TlsOptions_t *", + args=["char*", "char*", "char*"], + ) + verify_ctypes( + fnc="blpapi_TlsOptions_destroy", + ret="void", + args=["blpapi_TlsOptions_t*"], + ) + verify_ctypes( + fnc="blpapi_TlsOptions_setCrlFetchTimeoutMs", + ret="void", + args=["blpapi_TlsOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_TlsOptions_setTlsHandshakeTimeoutMs", + ret="void", + args=["blpapi_TlsOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_TopicList_add", + ret="int", + args=["blpapi_TopicList_t*", "char*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_TopicList_addFromMessage", + ret="int", + args=[ + "blpapi_TopicList_t*", + "blpapi_Message_t*", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_TopicList_correlationIdAt", + ret="int", + args=["blpapi_TopicList_t*", "blpapi_CorrelationId_t*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_TopicList_create", + ret="blpapi_TopicList_t *", + args=["blpapi_TopicList_t*"], + ) + verify_ctypes( + fnc="blpapi_TopicList_destroy", + ret="void", + args=["blpapi_TopicList_t*"], + ) + verify_ctypes( + fnc="blpapi_TopicList_message", + ret="int", + args=[ + "blpapi_TopicList_t*", + "blpapi_Message_t**", + "blpapi_CorrelationId_t*", + ], + ) + verify_ctypes( + fnc="blpapi_TopicList_messageAt", + ret="int", + args=["blpapi_TopicList_t*", "blpapi_Message_t**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_TopicList_size", ret="int", args=["blpapi_TopicList_t*"] + ) + verify_ctypes( + fnc="blpapi_TopicList_status", + ret="int", + args=["blpapi_TopicList_t*", "int*", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_TopicList_statusAt", + ret="int", + args=["blpapi_TopicList_t*", "int*", "size_t"], + ) + verify_ctypes( + fnc="blpapi_TopicList_topicString", + ret="int", + args=["blpapi_TopicList_t*", "char**", "blpapi_CorrelationId_t*"], + ) + verify_ctypes( + fnc="blpapi_TopicList_topicStringAt", + ret="int", + args=["blpapi_TopicList_t*", "char**", "size_t"], + ) + verify_ctypes( + fnc="blpapi_Topic_compare", + ret="int", + args=["blpapi_Topic_t*", "blpapi_Topic_t*"], + ) + verify_ctypes( + fnc="blpapi_Topic_create", + ret="blpapi_Topic_t *", + args=["blpapi_Topic_t*"], + ) + verify_ctypes( + fnc="blpapi_Topic_destroy", ret="void", args=["blpapi_Topic_t*"] + ) + verify_ctypes( + fnc="blpapi_Topic_isActive", ret="int", args=["blpapi_Topic_t*"] + ) + verify_ctypes( + fnc="blpapi_Topic_service", + ret="blpapi_Service_t *", + args=["blpapi_Topic_t*"], + ) + verify_ctypes( + fnc="blpapi_ZfpUtil_getOptionsForLeasedLines", + ret="int", + args=["blpapi_SessionOptions_t*", "blpapi_TlsOptions_t*", "int"], + ) + verify_ctypes( + fnc="blpapi_getLastErrorDescription", ret="char *", args=["int"] + ) diff --git a/src/blpapi/logging.py b/src/blpapi/logging.py new file mode 100644 index 0000000..d3f1763 --- /dev/null +++ b/src/blpapi/logging.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +"""@PURPOSE: Provide a C call to register a call back for logging + +@DESCRIPTION: This component provides a function that is used to + register a callback for logging""" + +from typing import Callable, List, Optional, Tuple +from blpapi import internals +from datetime import datetime +from . import utils +from .datetime import _DatetimeUtil +from .typehints import AnyPythonDatetime +from inspect import signature + + +class Logger(metaclass=utils.MetaClassForClassesWithEnums): + """This utility class provides a namespace for functions to test the + logging configuration.""" + + # Different logging levels + SEVERITY_OFF = internals.blpapi_Logging_SEVERITY_OFF + SEVERITY_FATAL = internals.blpapi_Logging_SEVERITY_FATAL + SEVERITY_ERROR = internals.blpapi_Logging_SEVERITY_ERROR + SEVERITY_WARN = internals.blpapi_Logging_SEVERITY_WARN + SEVERITY_INFO = internals.blpapi_Logging_SEVERITY_INFO + SEVERITY_DEBUG = internals.blpapi_Logging_SEVERITY_DEBUG + SEVERITY_TRACE = internals.blpapi_Logging_SEVERITY_TRACE + + # needed for temp. ref. holding + loggerCallbacksLocal: List[Tuple[Callable, Callable]] = [] + + @staticmethod + def registerCallback( + callback: Optional[ + Callable[[int, int, AnyPythonDatetime, str, str], None] + ], + thresholdSeverity: int = SEVERITY_INFO, + ) -> None: + """Register the specified 'callback' that will be called for all log + messages with severity greater than or equal to the specified + 'thresholdSeverity'. The callback needs to be registered before the + start of all sessions. If this function is called multiple times, only + the last registered callback will take effect. An exception of type + 'RuntimeError' will be thrown if 'callback' cannot be registered. + If callback is None, any existing callback shall be removed.""" + + callbackRef = None + if callback is not None: + sign = signature(callback) + # we expect 5 named parameters + if len(sign.parameters) < 5: + raise TypeError("Wrong type of callback for logging") + + def callbackWrapper( + threadId: int, + severity: int, + ts: datetime, + category: bytes, + message: bytes, + ) -> None: + dt = _DatetimeUtil.convertToNativeNotHighPrecision(ts) + callback( + threadId, severity, dt, category.decode(), message.decode() + ) + + callbackRef = callbackWrapper + + err_code, proxy = internals.blpapi_Logging_registerCallback( + callbackRef, thresholdSeverity + ) + + if err_code == -1: + raise ValueError("parameter must be a function") + if err_code == -2: + raise RuntimeError("unable to register callback") + + # we store a reference to callbackWrapper (that binds callback) + # for as long as it may be needed, i.e. until gc or re-register + if callbackRef is not None: + Logger.loggerCallbacksLocal.append((callbackRef, proxy)) + + if len(Logger.loggerCallbacksLocal) > 1: + # we have a new cb now, let the previous one go + Logger.loggerCallbacksLocal.pop(0) + + @staticmethod + def logTestMessage(severity: int) -> None: + """Log a test message at the specified 'severity'. + Note that this function is intended for testing + of the logging configuration only.""" + internals.blpapi_Logging_logTestMessage(severity) diff --git a/src/blpapi/message.py b/src/blpapi/message.py new file mode 100644 index 0000000..57ded33 --- /dev/null +++ b/src/blpapi/message.py @@ -0,0 +1,468 @@ +# message.py + +"""Defines a message containing elements. + +This file defines a class 'Message' which represents an individual message +inside an event and containing elements. + +""" + + +from __future__ import absolute_import +import sys +import weakref +import datetime +from typing import Set, Optional, Any, List +from blpapi.datetime import _DatetimeUtil, UTC +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiNameOrIndex +from .typehints import BlpapiMessageHandle, AnyPythonDatetime +from .typehints import SupportedElementTypes +from typing import Iterator as IteratorType +from .element import Element +from .exception import _ExceptionUtil +from .name import Name +from . import internals +from .utils import deprecated, MetaClassForClassesWithEnums +from .chandle import CHandle +from .correlationid import CorrelationId + +# Handling a circular dependency between modules: +# service->event->message->service +service = sys.modules.get("blpapi.service") +if service is None: + from . import service + + +# pylint: disable=protected-access +class Message(CHandle, metaclass=MetaClassForClassesWithEnums): + """A handle to a single message. + + :class:`Message` objects are obtained by iterating an :class:`Event`. Each + :class:`Message` is associated with a :class:`Service` and with one or more + :class:`CorrelationId` values. The :class:`Message` contents are + represented as an :class:`Element` and all :class:`Element`'s accessors + could be used to access the data. + + The possible fragment types are: + + - :attr:`FRAGMENT_NONE` + - :attr:`FRAGMENT_START` + - :attr:`FRAGMENT_INTERMEDIATE` + - :attr:`FRAGMENT_END` + + The possible recap types are: + + - :attr:`RECAPTYPE_NONE` + - :attr:`RECAPTYPE_SOLICITED` + - :attr:`RECAPTYPE_UNSOLICITED` + + :class:`Message` objects are always created by the API, never directly by + the application. + """ + + FRAGMENT_NONE = internals.MESSAGE_FRAGMENT_NONE + """Unfragmented message""" + FRAGMENT_START = internals.MESSAGE_FRAGMENT_START + """Start of a fragmented message""" + FRAGMENT_INTERMEDIATE = internals.MESSAGE_FRAGMENT_INTERMEDIATE + """Intermediate fragment""" + FRAGMENT_END = internals.MESSAGE_FRAGMENT_END + """Final part of a fragmented message""" + + RECAPTYPE_NONE = internals.MESSAGE_RECAPTYPE_NONE + """Normal data tick""" + RECAPTYPE_SOLICITED = internals.MESSAGE_RECAPTYPE_SOLICITED + """Generated on request by subscriber""" + RECAPTYPE_UNSOLICITED = internals.MESSAGE_RECAPTYPE_UNSOLICITED + """Generated by the service""" + + def __init__( + self, + handle: BlpapiMessageHandle, + event: Optional["typehints.Event"] = None, + sessions: Optional[Set["typehints.AbstractSession"]] = None, + ) -> None: + """ + Args: + handle: Handle to the internal implementation + event: Event that this message belongs to + sessions: Sessions that this object is associated with + """ + + if handle is None: + raise ValueError("Handle should not be None") + + internals.blpapi_Message_addRef(handle) + super(Message, self).__init__(handle, internals.blpapi_Message_release) + self.__handle = handle + self.__sessions: Set["typehints.AbstractSession"] = set() + if event is None: + if sessions is not None: + self.__sessions = sessions + else: + self.__sessions = event._sessions() + + self.__element: Optional[weakref.ReferenceType] = None + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this Message. Call of str(message) + is equivalent to message.toString() called with default parameters. + + """ + + return self.toString() + + def __getitem__(self, name: BlpapiNameOrIndex) -> Any: + """Equivalent to + :meth:`asElement().__getitem__()`. + """ + return self.asElement()[name] + + def __iter__(self) -> IteratorType: + """Equivalent to + :meth:`asElement().__iter__()`. + """ + return self.asElement().__iter__() + + def __contains__(self, item: SupportedElementTypes) -> bool: + """Equivalent to + :meth:`asElement().__contains__()`. + """ + return self.asElement().__contains__(item) + + def __len__(self) -> int: + """Equivalent to + :meth:`asElement().__len__()`. + """ + return self.asElement().__len__() + + def messageType(self) -> Name: + """ + Returns: + Type of this message. + """ + return Name._createInternally( + internals.blpapi_Message_messageType(self.__handle) + ) + + def fragmentType(self) -> int: + """ + Returns: + Fragment type of this message. + + Fragment types are listed in the class docstring. + """ + return internals.blpapi_Message_fragmentType(self.__handle) + + def recapType(self) -> int: + """ + Returns: + Recap type of this message. + + Recap types are listed in the class docstring. + """ + return internals.blpapi_Message_recapType(self.__handle) + + @deprecated + def topicName(self) -> str: + """ + Returns: + Topic string of this message. If there is no topic associated + with the message, empty string is returned. + + **DEPRECATED** + + This function has been deprecated because messages could contain + multiple payloads with different correlation ids, and each of these + correlation ids may map to different topic strings. + + In such a scenario, it would be incorrect to choose one out of the + multiple topics (for the various correlation id's in the message) as + the topic name for the message. Trying to make this correct would + result in extra look up costs. + + For correctness, users are encouraged to maintain a data structure in + their application to help retrieve the topic name associated with the + cid's present in the delivered message. + """ + return internals.blpapi_Message_topicName(self.__handle) + + def service(self) -> Optional["typehints.Service"]: + """ + Returns: + Service that this :class:`Message` is associated with. + """ + svcHandle = internals.blpapi_Message_service(self.__handle) + return ( + None + if svcHandle is None + else service.Service(svcHandle, self.__sessions) # type: ignore + ) + + def correlationId(self) -> Optional["typehints.CorrelationId"]: + """ + Returns: + The single correlation id or the first correlation + id associated with the message, or None if the message is not + associated with any correlation ids. + + Note: + See :meth:`correlationIds` for more details. + + If ``allowMultipleCorrelatorsPerMsg`` is enabled, + :meth:`correlationIds` should be used. + """ + numCorrelations = internals.blpapi_Message_numCorrelationIds( + self.__handle + ) + if numCorrelations == 0: + return None + + return CorrelationId( + internals.blpapi_Message_correlationId(self.__handle, 0) + ) + + def correlationIds(self) -> List["typehints.CorrelationId"]: + r""" + Returns: + Correlation ids associated with this message. + + Note: + A subscription data :class:`Message` has exactly one + :class:`CorrelationId` unless the + ``allowMultipleCorrelatorsPerMsg`` option is enabled for the + :class:`Session`. + + When ``allowMultipleCorrelatorsPerMsg`` is disabled (the default), + multiple active subscriptions of the same topic result in the same + :class:`Message` being delivered multiple times (without making + physical copies), with a single :class:`CorrelationId` from each + active subscription. + + Otherwise, only one :class:`Message` is delivered with all the + :class:`CorrelationId`\s from the active subscriptions. + """ + + res = [] + for i in range( + internals.blpapi_Message_numCorrelationIds(self.__handle) + ): + res.append( + CorrelationId( + internals.blpapi_Message_correlationId(self.__handle, i) + ) + ) + return res + + def hasElement( + self, name: Name, excludeNullElements: bool = False + ) -> bool: + """Equivalent to asElement().hasElement(name, excludeNullElements). + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().hasElement(name, excludeNullElements) + + def numElements(self) -> int: + """Equivalent to :meth:`asElement().numElements() + `.""" + return self.asElement().numElements() + + def getElement(self, name: BlpapiNameOrIndex) -> Element: + """Equivalent to :meth:`asElement().getElement(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElement(name) + + def getElementAsBool(self, name: Name) -> bool: + """Equivalent to :meth:`asElement().getElementAsBool(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElementAsBool(name) + + def getElementAsString(self, name: Name) -> str: + """Equivalent to :meth:`asElement().getElementAsString(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElementAsString(name) + + def getElementAsBytes(self, name: Name) -> bytes: + """Equivalent to :meth:`asElement().getElementAsBytes(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElementAsBytes(name) + + def getElementAsInteger(self, name: Name) -> int: + """Equivalent to :meth:`asElement().getElementAsInteger(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElementAsInteger(name) + + def getElementAsFloat(self, name: Name) -> float: + """Equivalent to :meth:`asElement().getElementAsFloat(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElementAsFloat(name) + + def getElementAsDatetime(self, name: Name) -> AnyPythonDatetime: + """Equivalent to :meth:`asElement().getElementAsDatetime(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost.""" + return self.asElement().getElementAsDatetime(name) + + def getRequestId(self) -> Optional[str]: + """Return the message's request id if one exists, otherwise return + ``None``. + + When present, the request id can be reported to Bloomberg to + troubleshoot the cause of failure messages, or issues with the data + contained in the message. + + Note that request id is not the same as correlation id and should + not be used for correlation purposes. + + Returns: + The request id of the message. + """ + rc, requestId = internals.blpapi_Message_getRequestId(self.__handle) + _ExceptionUtil.raiseOnError(rc) + return requestId + + def asElement(self) -> Element: + """ + Returns: + Element: The content of this :class:`Message` as an + :class:`Element`. + """ + el = None + if self.__element: + el = self.__element() + if el is None: + el = Element( + internals.blpapi_Message_elements(self.__handle), self + ) + self.__element = weakref.ref(el) + return el + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Format this :class:`Message` to the string at the specified + indentation level. + + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This element formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + return internals.blpapi_Message_printHelper( + self.__handle, level, spacesPerLevel + ) + + def toPy(self) -> dict: + """Equivalent to :meth:`asElement().toPy()`.""" + return self.asElement().toPy() # type: ignore + + def timeReceived(self, tzinfo: datetime.tzinfo = UTC) -> AnyPythonDatetime: + """Get the time when the message was received by the SDK. + + Args: + tzinfo: Timezone info + + Returns: + datetime.datetime or datetime.date or datetime.time: Time when the + message was received by the SDK. + + Raises: + ValueError: If this information was not recorded for this message. + See :meth:`SessionOptions.recordSubscriptionDataReceiveTimes` + for information on configuring this recording. + + The resulting datetime will be represented using the specified + ``tzinfo`` value, and will be measured using a high-resolution clock + internal to the SDK. + """ + err_code, time_point = internals.blpapi_Message_timeReceived( + self.__handle + ) + if err_code != 0: + raise ValueError("Message has no timestamp") + original = ( + internals.blpapi_HighPrecisionDatetime_fromTimePoint_wrapper( + time_point + ) + ) + + native = _DatetimeUtil.convertToNative(original) + return native.astimezone(tzinfo) # type: ignore + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this Message related to. For internal use.""" + return self.__sessions + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/name.py b/src/blpapi/name.py new file mode 100644 index 0000000..84d965f --- /dev/null +++ b/src/blpapi/name.py @@ -0,0 +1,188 @@ +# name.py + +"""Provide a representation of a string for efficient comparison. + +This file defines a class 'Name' which represents a string in a +form for efficient string comparison. + +""" +from __future__ import annotations +from typing import Any, Optional, Tuple, Union +from . import internals +from .utils import conv2str, get_handle, isstr +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiNameHandle + + +# pylint: disable=broad-except +class Name(CHandle): + """:class:`Name` represents a string in a form which is efficient for hashing and + comparison, thus providing efficient lookup when used as a key in either + ordered or hash-based containers. + + :class:`Name` objects are used to identify and access the classes which + define the schema - :class:`SchemaTypeDefinition`, + :class:`SchemaElementDefinition`, :class:`Constant`, :class:`ConstantList`. + They are also used to access the values in :class:`Element` objects and + :class:`Message` objects. + + The :class:`Name` class is an efficient substitute for a string when used + as a key, providing constant time comparison and ordering operations. Two + :class:`Name` objects constructed from equal strings will always compare + equally. + + :class:`Name` objects should be initialized once and then + reused. Creating a :class:`Name` object involves a search in a container + requiring multiple string comparison operations. + + Note: + Each :class:`Name` instance refers to an entry in a global static + table. :class:`Name` instances for identical strings will refer to the + same data. There is no provision for removing entries from the static + table so :class:`Name` objects should only be used when the set of + input strings is bounded. + + For example, creating a :class:`Name` for every possible field name and + type in a data model is reasonable (in fact, the API will do this + whenever it receives schema information). However converting sequence + numbers on incoming messages to strings and creating a :class:`Name` + from each one of those strings will cause the static table to grow in + an unbounded manner. + """ + + @staticmethod + def findName(nameString: str) -> Optional[Name]: + """ + Args: + nameString: String represented by an existing :class:`Name` + + Returns: + An existing :class:`Name` object representing ``nameString``. + If no such object exists, ``None`` is returned. + """ + nameHandle = internals.blpapi_Name_findName(nameString) + return ( + None if nameHandle is None else Name._createInternally(nameHandle) + ) + + @staticmethod + def hasName(nameString: str) -> bool: + """ + Args: + nameString: String represented by an existing :class:`Name` + + Returns: + ``True`` if a :class:`Name` object representing + ``nameString`` exists + """ + return bool(internals.blpapi_Name_hasName(nameString)) + + @staticmethod + def _createInternally(handle: BlpapiNameHandle) -> Name: + return Name(None, handle) + + def __init__( + self, + nameString: Optional[str], + internalHandle: Optional[BlpapiNameHandle] = None, + ) -> None: + selfhandle = internalHandle + if selfhandle is None: + selfhandle = internals.blpapi_Name_create(nameString) + super(Name, self).__init__(selfhandle, internals.blpapi_Name_destroy) + self.__handle = selfhandle + + def __len__(self) -> int: + """Return the length of the string that this Name represents.""" + + return internals.blpapi_Name_length(self.__handle) + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string that this Name represents. + + """ + + return internals.blpapi_Name_string(self.__handle) + + def __repr__(self) -> str: + """ + + Return a string that this Name represents. + Container's __str__ uses contained objects' __repr__ + + """ + return f"blpapi.Name('{self}')" + + def __eq__(self, other: Any) -> bool: + """x.__eq__(y) <==> x==y""" + if not isstr(other): + if other is None: + return False + return self.__handle.value == get_handle(other).value # type: ignore + + s = conv2str(other) + p = internals.blpapi_Name_equalsStr(self.__handle, s) + return p != 0 + + def __ne__(self, other: Any) -> bool: + """x.__ne__(y) <==> x!=y""" + return not self.__eq__(other) + + def __hash__(self) -> int: + """x.__hash__() <==> hash(x)""" + return int(self.__handle.value) # type: ignore + + +def getNamePair( + name: Union[Name, str], +) -> Union[Tuple[None, BlpapiNameHandle], Tuple[str, None]]: + """Create a tuple that contains a name string and blpapi_Name_t*. + + Args: + name: A :class:`Name` or a string instance + + Returns: + ``(None, name._handle())`` if ``name`` is a :class:`Name` instance, or + ``(name, None)`` if ``name`` is a string. In other cases raise + TypeError exception. + + Raises: + TypeError: If ``name`` is neither a :class:`Name` nor a string + + For internal use only. + + Note: + :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + if isinstance(name, Name): + return (None, get_handle(name)) + if isstr(name): + return (conv2str(name), None) + raise TypeError("name should be an instance of a string or blpapi.Name") + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/names.py b/src/blpapi/names.py new file mode 100644 index 0000000..b2ed1ed --- /dev/null +++ b/src/blpapi/names.py @@ -0,0 +1,77 @@ +""" +Provides 'Name' constants for common message types. +""" + +from .name import Name + + +class Names: + """ + Provides 'Name' constants for common message types. + """ + + SLOW_CONSUMER_WARNING = Name("SlowConsumerWarning") + SLOW_CONSUMER_WARNING_CLEARED = Name("SlowConsumerWarningCleared") + DATA_LOSS = Name("DataLoss") + REQUEST_TEMPLATE_AVAILABLE = Name("RequestTemplateAvailable") + REQUEST_TEMPLATE_PENDING = Name("RequestTemplatePending") + REQUEST_TEMPLATE_TERMINATED = Name("RequestTemplateTerminated") + SUBSCRIPTION_TERMINATED = Name("SubscriptionTerminated") + SUBSCRIPTION_STARTED = Name("SubscriptionStarted") + SUBSCRIPTION_FAILURE = Name("SubscriptionFailure") + SUBSCRIPTION_STREAMS_ACTIVATED = Name("SubscriptionStreamsActivated") + SUBSCRIPTION_STREAMS_DEACTIVATED = Name("SubscriptionStreamsDeactivated") + REQUEST_FAILURE = Name("RequestFailure") + TOKEN_GENERATION_SUCCESS = Name("TokenGenerationSuccess") + TOKEN_GENERATION_FAILURE = Name("TokenGenerationFailure") + SESSION_STARTED = Name("SessionStarted") + SESSION_TERMINATED = Name("SessionTerminated") + SESSION_STARTUP_FAILURE = Name("SessionStartupFailure") + SESSION_CONNECTION_UP = Name("SessionConnectionUp") + SESSION_CONNECTION_DOWN = Name("SessionConnectionDown") + SERVICE_OPENED = Name("ServiceOpened") + SERVICE_OPEN_FAILURE = Name("ServiceOpenFailure") + SERVICE_REGISTERED = Name("ServiceRegistered") + SERVICE_REGISTER_FAILURE = Name("ServiceRegisterFailure") + SERVICE_DEREGISTERED = Name("ServiceDeregistered") + SERVICE_UP = Name("ServiceUp") + SERVICE_DOWN = Name("ServiceDown") + SERVICE_AVAILABILITY_INFO = Name("ServiceAvailabilityInfo") + RESOLUTION_SUCCESS = Name("ResolutionSuccess") + RESOLUTION_FAILURE = Name("ResolutionFailure") + TOPIC_SUBSCRIBED = Name("TopicSubscribed") + TOPIC_UNSUBSCRIBED = Name("TopicUnsubscribed") + TOPIC_RECAP = Name("TopicRecap") + TOPIC_ACTIVATED = Name("TopicActivated") + TOPIC_DEACTIVATED = Name("TopicDeactivated") + TOPIC_CREATED = Name("TopicCreated") + TOPIC_CREATE_FAILURE = Name("TopicCreateFailure") + TOPIC_DELETED = Name("TopicDeleted") + TOPIC_RESUBSCRIBED = Name("TopicResubscribed") + PERMISSION_REQUEST = Name("PermissionRequest") + PERMISSION_RESPONSE = Name("PermissionResponse") + AUTHORIZATION_SUCCESS = Name("AuthorizationSuccess") + AUTHORIZATION_FAILURE = Name("AuthorizationFailure") + AUTHORIZATION_REVOKED = Name("AuthorizationRevoked") + + +__copyright__ = """ +Copyright 2021. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/providersession.py b/src/blpapi/providersession.py new file mode 100644 index 0000000..3e59fbb --- /dev/null +++ b/src/blpapi/providersession.py @@ -0,0 +1,1078 @@ +# providersession.py + +"""Provide a session that can be used for providing services. + +ProviderSession inherits from AbstractSession. In addition to AbstractSession +functionality, ProviderSession provides functions that are needed to support +publishing like 'registerService', 'createTopics' and 'publish'. + +Topic Life Cycle +---------------- +A provider wishing to publish subscription data must explicitly open each topic +on which they publish using 'ProviderSession.createTopics' (or +'ProviderSession.createTopicsAsync'). Creating a topic prepares the +distribution and caching infrastructure for new data associated with the +topic's resolved identifier. (Note that several different topics could resolve +to the same ID.) Independent of a topic's creation status is its subscription +status, i.e. whether there are subscribers ready to receive the data published. +A topic that is both created and subscribed is *activated*. + +There are two models for managing topic creation: broadcast and interactive. +Broadcast publishers proactively call 'ProviderSession.createTopic*' for each +topic on which they intend to publish, while interactive publishers wait to +receive a 'TopicSubscribed' message (within an 'Event' of type +'Event.TOPIC_STATUS') before calling 'ProviderSession.createTopic*' in +response. Topics are resolved before they are created---it is possible that +multiple different topic strings will map to the same underlying topic. See +below for the behavior of the SDK when the same topic is created multiple +times. + +After 'ProviderSession.createTopic*' is called, the publisher will receive a +'TopicCreated' message (within an 'Event.TOPIC_STATUS' event), and when there +is at least one subscriber to the topic the publisher will then receive a +'TopicActivated' message (also within an 'Event.TOPIC_STATUS' event). As +subscribers come and go, additional 'TopicSubscribed', 'TopicActivated', +'TopicUnsubscribed', and 'TopicDeactivated' messages may be received by the +publisher. A 'Topic' object can be retrieved from each of these messages using +the 'ProviderSession.getTopic' method, and this object can be used for +subsequent calls to 'EventFormatter.appendMessage' and +'ProviderSession.deleteTopic'. In the case that the same resolved topic is +created multiple times by a publisher using different names, it is unspecified +which of those names will be returned by 'Message.topicName' for these (or +other) messages. + +If a publisher no longer intends to publish data on a topic, it can call +'ProviderSession.deleteTopic*' to free the internal caching and distribution +resources associated with the topic. When a resolved topic has been deleted the +same number of times that it has been created, a 'TopicDeleted' message will be +delivered, preceded by 'TopicUnsubscribed' and 'TopicDeactivated' messages if +the topic was still subscribed (and activated). No further messages can be +published on a deleted topic. + +Deregistering a service deletes all topics associated with that service. + +Note that 'TopicActivated' and 'TopicDeactivated' messages are entirely +redundant with 'TopicCreated', 'TopicSubscribed', 'TopicDeleted', and +'TopicUnsubscribed' messages, and are provided only for the convenience of +publishers that do not maintain per-topic state. +""" + +from __future__ import annotations +from weakref import ref, ReferenceType # pylint: disable=unused-import +from typing import Optional, Callable, Sequence, Any +import sys +import traceback +import os +import functools +import atexit +from .abstractsession import AbstractSession +from .event import Event +from . import exception +from .exception import _ExceptionUtil +from . import internals +from .correlationid import CorrelationId +from .sessionoptions import SessionOptions +from .topic import Topic +from . import utils +from .utils import get_handle +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiEventHandle + + +# pylint: disable=line-too-long,too-many-lines +# pylint: disable=protected-access,too-many-public-methods,bare-except,too-many-function-args +class ServiceRegistrationOptions( + CHandle, metaclass=utils.MetaClassForClassesWithEnums +): + """Contains the options which can be specified when registering a service. + + To use non-default options to :meth:`~ProviderSession.registerService()`, + create a :class:`ServiceRegistrationOptions` instance and set the required + options and then supply it when using the + :meth:`~ProviderSession.registerService()` interface. + + The following attributes represent service registration priorities: + + - :attr:`PRIORITY_LOW` + - :attr:`PRIORITY_MEDIUM` + - :attr:`PRIORITY_HIGH` + + The following attributes represent the registration parts: + + - :attr:`PART_PUBLISHING` + - :attr:`PART_OPERATIONS` + - :attr:`PART_SUBSCRIBER_RESOLUTION` + - :attr:`PART_PUBLISHER_RESOLUTION` + - :attr:`PART_DEFAULT` + """ + + PRIORITY_LOW = internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW + PRIORITY_MEDIUM = internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM + PRIORITY_HIGH = internals.SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH + + # Constants for specifying which part(s) of a service should be registered: + + PART_PUBLISHING = internals.REGISTRATIONPARTS_PUBLISHING + """Register to receive subscribe and unsubscribe messages""" + + PART_OPERATIONS = internals.REGISTRATIONPARTS_OPERATIONS + """Register to receive the request types corresponding to each "operation" + defined in the service metadata""" + + PART_SUBSCRIBER_RESOLUTION = ( + internals.REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION + ) + """Register to receive resolution requests (with message type + ``PermissionRequest``) from subscribers""" + + PART_PUBLISHER_RESOLUTION = ( + internals.REGISTRATIONPARTS_PUBLISHER_RESOLUTION + ) + """Register to receive resolution requests (with message type + ``PermissionRequest``) from publishers (via + :meth:`ProviderSession.createTopics()`)""" + + PART_DEFAULT = internals.REGISTRATIONPARTS_DEFAULT + """Register the parts of the service implied by options specified in the + service metadata""" + + def __init__(self) -> None: + """Create :class:`ServiceRegistrationOptions` with default options.""" + selfhandle = internals.blpapi_ServiceRegistrationOptions_create() + super(ServiceRegistrationOptions, self).__init__( + selfhandle, internals.blpapi_ServiceRegistrationOptions_destroy + ) + self.__handle = selfhandle + + def setGroupId(self, groupId: str) -> None: + """Set the Group ID for the service to be registered. + + Args: + groupId: The group ID for the service to be registered + + Set the Group ID for the service to be registered to the specified + ``groupId`` string. If ``groupId`` length is greater than + ``MAX_GROUP_ID_SIZE`` (=64) only the first ``MAX_GROUP_ID_SIZE`` chars + are considered as Group Id. + """ + + if groupId is None: + raise ValueError("groupId must not be None") + + internals.blpapi_ServiceRegistrationOptions_setGroupId( + self.__handle, groupId + ) + + def setServicePriority(self, priority: int) -> int: + """Set the priority with which a subscription service will be + registered. + + Args: + priority: The service priority + + Set the priority with which a subscription service will be registered + to the specified ``priority``, where numerically greater values of + ``priority`` indicate higher priorities. The behavior is undefined + unless ``priority`` is non-negative. Note that while the values + pre-defined in ``ServiceRegistrationOptions`` are suitable for use + here, any non-negative ``priority`` is acceptable. + + By default, a service will be registered with priority + :attr:`PRIORITY_HIGH`. + + Note this has no effect for resolution services. + """ + return internals.blpapi_ServiceRegistrationOptions_setServicePriority( + self.__handle, priority + ) + + def getGroupId(self) -> str: + """ + Returns: + The value of the service Group Id in this instance. + """ + _, groupId = internals.blpapi_ServiceRegistrationOptions_getGroupId( + self.__handle + ) + return groupId + + def getServicePriority(self) -> int: + """ + Returns: + The value of the priority for subscription services + in this instance. + """ + priority = ( + internals.blpapi_ServiceRegistrationOptions_getServicePriority( + self.__handle + ) + ) + return priority + + def addActiveSubServiceCodeRange( + self, begin: int, end: int, priority: int + ) -> None: + """ + Args: + begin: Start of sub-service code range + end: End of sub-service code range + priority: Priority with which to receive subscriptions + + Advertise the service to be registered to receive, with the + specified ``priority``, subscriptions that the resolver has mapped to a + service code between the specified ``begin`` and the specified ``end`` + values, inclusive. Numerically greater values of ``priority`` indicate + higher priorities. + + Note: + The behavior of this function is undefined unless ``0 <= begin <= + end < (1 << 24)``, and ``priority`` is non-negative. + """ + err = internals.blpapi_ServiceRegistrationOptions_addActiveSubServiceCodeRange( + self.__handle, begin, end, priority + ) + _ExceptionUtil.raiseOnError(err) + + def removeAllActiveSubServiceCodeRanges(self) -> None: + """Remove all previously added sub-service code ranges.""" + internals.blpapi_ServiceRegistrationOptions_removeAllActiveSubServiceCodeRanges( + self.__handle + ) + + def setPartsToRegister(self, parts: int) -> None: + """Set the parts of the service to be registered. + + Args: + parts: Parts of the service to be registered. + + Set the parts of the service to be registered to the specified + ``parts``, which must be a bitwise-or of the options provided in + "registration parts" options (enumerated in the class docstring). This + option defaults to :attr:`PART_DEFAULT`. + """ + internals.blpapi_ServiceRegistrationOptions_setPartsToRegister( + self.__handle, parts + ) + + def getPartsToRegister(self) -> int: + """ + Returns: + The parts of the service to be registered. + + Registration parts are enumerated in the class docstring. + """ + return internals.blpapi_ServiceRegistrationOptions_getPartsToRegister( + self.__handle + ) + + +class ProviderSession( + AbstractSession, metaclass=utils.MetaClassForClassesWithEnums +): + """This class provides a session that can be used for providing services. + + It inherits from :class:`AbstractSession`. In addition to the + :class:`AbstractSession` functionality a :class:`ProviderSession` provides + the following functions to applications. + + A provider can register to provide services using + :meth:`registerService()`. Before registering to provide a + service the provider must have established its identity. Then the provider + can create topics and publish events on topics. It also can get requests + from the event queue and send back responses. + + After users have registered a service they will start receiving + subscription requests (``TopicSubscribed`` message in + :attr:`~Event.TOPIC_STATUS`) for topics which belong to the service. If the + resolver has specified ``subServiceCode`` for topics in + ``PermissionResponse``, then only providers who have activated the + ``subServiceCode`` will get the subscription request. Where multiple + providers have registered the same service and sub-service code (if any), + the provider that registered the highest priority for the sub-service code + will receive subscription requests; if multiple providers have registered + the same sub-service code with the same priority (or the resolver did not + set a sub-service code for the subscription), the subscription request will + be routed to one of the providers with the highest service priority. + """ + + AUTO_REGISTER_SERVICES = internals.RESOLVEMODE_AUTO_REGISTER_SERVICES + + DONT_REGISTER_SERVICES = internals.RESOLVEMODE_DONT_REGISTER_SERVICES + + __handle = None # pylint: disable=unused-private-member + __handlerProxy = None # pylint: disable=unused-private-member + + @staticmethod + def __dispatchEvent( + sessionRef: "ReferenceType[ProviderSession]", + eventHandle: BlpapiEventHandle, + ) -> None: # pragma: no cover + """Use sessions ref to dispatch an event""" + try: + session = sessionRef() + if session is not None: + event = Event(eventHandle, {session}) + session.__handler(event, session) + except: + print("Exception in event handler:", file=sys.stderr) + traceback.print_exc(file=sys.stderr) + os._exit(1) + + def __init__( + self, + options: Optional[SessionOptions] = None, + eventHandler: Optional[ + Callable[[Event, ProviderSession], None] + ] = None, + eventDispatcher: Optional["typehints.EventDispatcher"] = None, + ) -> None: + """Constructor. + + Args: + options: Options used to construct the sessions + eventHandler: Handler for the events generated by this session + eventDispatcher: Dispatcher for the events generated by this session + Raises: + InvalidArgumentException: If ``eventHandler`` is ``None`` and the + ``eventDispatcher`` is not ``None`` + + Construct a Session using the optionally specified 'options', the + optionally specified 'eventHandler' and the optionally specified + 'eventDispatcher'. + See :class:`SessionOptions` for details on what can be specified in + the ``options``. + + + If ``eventHandler`` is not ``None`` then this Session will operate in + asynchronous mode, otherwise the Session will operate in synchronous + mode. + If supplied, ``eventHandler`` is a callable object that takes two + arguments: received event and related session. + + If ``eventDispatcher`` is ``None`` then the Session will create a + default :class:`EventDispatcher` for this Session which will use a + single thread for dispatching events. For more control over event + dispatching a specific instance of :class:`EventDispatcher` can be + supplied. This can be used to share a single :class:`EventDispatcher` + amongst multiple Session objects. + + If an ``eventDispatcher`` is supplied which uses more than one thread + the Session will ensure that events which should be ordered are passed + to callbacks in a correct order. For example, partial response to a + request or updates to a single subscription. + + Each :class:`EventDispatcher` uses its own thread or pool of threads so + if you want to ensure that a session which receives very large messages + and takes a long time to process them does not delay a session that + receives small messages and processes each one very quickly then give + each one a separate :class:`EventDispatcher`. + """ + if (eventHandler is None) and (eventDispatcher is not None): + raise exception.InvalidArgumentException( + "eventDispatcher is specified but eventHandler is None", 0 + ) + if options is None: + options = SessionOptions() + if eventHandler is not None: + # pylint: disable=unused-private-member + self.__handler = eventHandler + self.__handlerProxy = functools.partial( + ProviderSession.__dispatchEvent, ref(self) + ) + + self.__handle = internals.ProviderSession_createHelper( + get_handle(options), + self.__handlerProxy, + get_handle(eventDispatcher), + ) + + def _dtor(handle: Any) -> None: + atexit.unregister(self.stop) + internals.ProviderSession_destroyHelper( + handle, self.__handlerProxy + ) + + atexit.register(self.stop) # we must stop session before shutdown + AbstractSession.__init__( + self, + self.__handle, + internals.blpapi_ProviderSession_getAbstractSession(self.__handle), + _dtor, + ) + + def _session_handle(self) -> Any: + """This is for internal implementation only""" + # `_handle()` returns `blpapi_AbstractSession_t *`, but there are times + # when we need `blpapi_ProviderSession_t *` instead. + return self.__handle + + def start(self) -> bool: + """Start this :class:`Session` in synchronous mode. + + Returns: + ``True`` if the :class:`Session` started successfully, + ``False`` otherwise. + + Attempt to start this :class:`Session` and block until the + :class:`Session` has started or failed to start. Before + :meth:`start()` returns a :attr:`~Event.SESSION_STATUS` :class:`Event` + is generated. A :class:`Session` may only be started once. + """ + return internals.blpapi_ProviderSession_start(self.__handle) == 0 + + def startAsync(self) -> bool: + """Start this :class:`Session` in asynchronous mode. + + Returns: + ``True`` if the process to start a :class:`Session` began + successfully, ``False`` otherwise. + + Attempt to begin the process to start this :class:`Session`. The + application must monitor events for a :attr:`~Event.SESSION_STATUS` + :class:`Event` which will be generated once the :class:`Session` has + started or if it fails to start. The :attr:`~Event.SESSION_STATUS` + :class:`Event` may be processed by the registered ``eventHandler`` + before :meth:`startAsync()` has returned. A :class:`Session` may only + be started once. + """ + return internals.blpapi_ProviderSession_startAsync(self.__handle) == 0 + + def flushPublishedEvents(self, timeoutMsecs: int) -> bool: + """Wait at most ``timeoutMsecs`` milliseconds for all the published + events to be sent through the underlying channel. + + Args: + timeoutMsecs: Timeout threshold in milliseconds + + Returns: + ``True`` if all the published events have been sent, + ``False`` otherwise + + The method returns either as soon as all the published events have been + sent out or when it has waited ``timeoutMsecs`` milliseconds. The behavior + is undefined unless the specified ``timeoutMsecs`` is a non-negative + value. When ``timeoutMsecs`` is ``0``, the method checks if all the published + events have been sent and returns without waiting. + """ + + ( + err_code, + allFlushed, + ) = internals.blpapi_ProviderSession_flushPublishedEvents( + self.__handle, timeoutMsecs + ) + if err_code != 0: + raise RuntimeError("Flush published events failed") + + return allFlushed != 0 + + def stop(self) -> bool: + """Stop operation of this :class:`Session` and wait until it stops. + + Returns: + ``True`` if the :class:`Session` stopped successfully, + ``False`` otherwise. + + Stop operation of this :class:`Session` and block until all callbacks + to ``eventHandler`` objects relating to this :class:`Session` which are + currently in progress have completed (including the callback to handle + the :class:`~Event.SESSION_STATUS` :class:`Event` this call generates). + Once this returns no further callbacks to ``eventHandlers`` will occur. + If :meth:`stop()` is called from within an ``eventHandler`` callback it + is silently converted to a :meth:`stopAsync()` in order to prevent + deadlock. Once a :class:`Session` has been stopped it can only be + destroyed. + """ + atexit.unregister(self.stop) + return internals.blpapi_ProviderSession_stop(self.__handle) == 0 + + def stopAsync(self) -> bool: + """Begin the process to stop this Session and return immediately. + + Returns: + ``True`` if the process to stop a :class:`Session` began + successfully, ``False`` otherwise. + + The application must monitor events for a :attr:`~Event.SESSION_STATUS` + :class:`Event` which will be generated once the :class:`Session` has + been stopped. After this :attr:`~Event.SESSION_STATUS` :class:`Event` + no further callbacks to ``eventHandlers`` will occur. Once a + :class:`Session` has been stopped it can only be destroyed. + """ + return internals.blpapi_ProviderSession_stopAsync(self.__handle) == 0 + + def nextEvent(self, timeout: int = 0) -> Event: + """ + Args: + timeout: Timeout threshold in milliseconds + + Returns: + Next available event for this session + + Raises: + InvalidStateException: If invoked on a session created in + asynchronous mode + + If there is no :class:`Event` available this will block for up to the + specified ``timeout`` milliseconds for an :class:`Event` to arrive. A + value of ``0`` for ``timeout`` (the default) indicates + :meth:`nextEvent()` should not timeout and will not return until the + next :class:`Event` is available. + + If :meth:`nextEvent()` returns due to a timeout it will return an event + of type :attr:`~Event.TIMEOUT`. + """ + retCode, event = internals.blpapi_ProviderSession_nextEvent( + self.__handle, timeout + ) + + _ExceptionUtil.raiseOnError(retCode) + + return Event(event, {self}) + + def tryNextEvent(self) -> Optional[Event]: + r""" + Returns: + Next available event for this session + + If there are :class:`Event`\s available for the session, return the + next :class:`Event` If there is no event available for the + :class:`Session`, return ``None``. This method never blocks. + """ + retCode, event = internals.blpapi_ProviderSession_tryNextEvent( + self.__handle + ) + if retCode: + return None + return Event(event, {self}) + + def registerService( + self, + uri: str, + identity: Optional["typehints.Identity"] = None, + options: Optional[ServiceRegistrationOptions] = None, + ) -> bool: + """Attempt to register the service and block until it is done. + + Args: + uri: Name of the service + identity: Identity used to verify permissions to provide + the service being registered + options: Options used to register the service + + Returns: + ``True`` if the service registered successfully, else ``False`` + + Attempt to register the service identified by the specified ``uri`` and + block until the service is either registered successfully or has failed + to be registered. The optionally specified ``identity`` is used to verify + permissions to provide the service being registered. The optionally + specified ``options`` is used to specify the group ID and service + priority of the service being registered. + + The ``uri`` must begin with a full qualified service name. That is it + must begin with ``///[/]``. Any portion of the + ``uri`` after the service name is ignored. + + Before :meth:`registerService()` returns a + :attr:`~Event.SERVICE_STATUS` :class:`Event` is generated. If this is + an asynchronous :class:`ProviderSession` then this :class:`Event` may + be processed by the registered :class:`Event` before + :meth:`registerService()` has returned. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + if options is None: + options = ServiceRegistrationOptions() + if ( + internals.blpapi_ProviderSession_registerService( + self.__handle, uri, get_handle(identity), get_handle(options) + ) + == 0 + ): + return True + return False + + def registerServiceAsync( + self, + uri: str, + identity: Optional["typehints.Identity"] = None, + correlationId: Optional[CorrelationId] = None, + options: Optional[ServiceRegistrationOptions] = None, + ) -> CorrelationId: + r"""Begin the process of registering the service immediately. + + Args: + uri: Name of the service + identity: Identity used to verify permissions to provide + the service being registered + correlationId: Correlation id to associate with this operation + options: Options used to register the service + + Returns: + Correlation id associated with events generated by this operation + + Begin the process of registering the service identified by the + specified ``uri`` and return immediately. The optionally specified + ``identity`` is used to verify permissions to provide the service being + registered. The optionally specified ``correlationId`` is used to track + :class:`Event`\s generated as a result of this call. The actual ``correlationId`` + that will identify :class:`Event`\s generated as a result of this call is + returned. The optionally specified ``options`` is used to specify the + group ID and service priority of the service being registered. + + The ``uri`` must begin with a full qualified service name. That is it + must begin with ``///[/]``. Any portion of the + ``uri`` after the service name is ignored. + + The application must monitor events for a + :class:`~Event.SERVICE_STATUS` :class:`Event` which will be generated + once the service has been successfully registered or registration has + failed. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + if correlationId is None: + correlationId = CorrelationId() + if options is None: + options = ServiceRegistrationOptions() + + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_registerServiceAsync( + self.__handle, + uri, + get_handle(identity), + correlationId, + get_handle(options), + ) + ) + + return correlationId + + def resolve( + self, + resolutionList: "typehints.ResolutionList", + resolveMode: int = DONT_REGISTER_SERVICES, + identity: Optional["typehints.Identity"] = None, + ) -> None: + r"""Resolve the topics in the specified ``resolutionList``. + + Args: + resolutionList: List of topics to resolve + resolveMode: Mode to resolve in + identity: Identity used for authorization + + Resolve the topics in the specified ``resolutionList``, which must be + an object of type :class:`ResolutionList`, and update the + ``resolutionList`` with the results of the resolution process. If the + specified ``resolveMode`` is :attr:`DONT_REGISTER_SERVICES` (the + default) then all the services referenced in the topics in the + ``resolutionList`` must already have been registered using + :meth:`registerService()`. If ``resolveMode`` is + :attr:`AUTO_REGISTER_SERVICES` then the specified ``identity`` should + be supplied and :class:`ProviderSession` will automatically attempt to + register any services reference in the topics in the ``resolutionList`` + that have not already been registered. Once :meth:`resolve()` returns + each entry in the ``resolutionList`` will have been updated with a new + status. + + Before :meth:`resolve()` returns one or more + :attr:`~Event.RESOLUTION_STATUS` events and, if ``resolveMode`` is + :attr:`AUTO_REGISTER_SERVICES`, zero or more + :attr:`~Event.SERVICE_STATUS` events are generated. If this is an + asynchronous :class:`ProviderSession` then these :class:`Event`\s may + be processed by the registered ``eventHandler`` before + :meth:`resolve()` has returned. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + resolutionList._addSession(self) + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_resolve( + self.__handle, + get_handle(resolutionList), + resolveMode, + get_handle(identity), + ) + ) + + def resolveAsync( + self, + resolutionList: "typehints.ResolutionList", + resolveMode: int = DONT_REGISTER_SERVICES, + identity: Optional["typehints.Identity"] = None, + ) -> None: + """Begin the resolution of the topics in the specified list. + + Args: + resolutionList: List of topics to resolve + resolveMode: Mode to resolve in + identity: Identity used for authorization + + Begin the resolution of the topics in the specified ``resolutionList``, + which must be an object of type :class:`ResolutionList`. If the + specified ``resolveMode`` is :attr:`DONT_REGISTER_SERVICES` (the + default) then all the services referenced in the topics in the + ``resolutionList`` must already have been registered using + :meth:`registerService()`. If ``resolveMode`` is + :attr:`AUTO_REGISTER_SERVICES` then the specified ``identity`` should + be supplied and :class:`ProviderSession` will automatically attempt to + register any services reference in the topics in the ``resolutionList`` + that have not already been registered. + + One or more :attr:`~Event.RESOLUTION_STATUS` events will be delivered + with the results of the resolution. These events may be generated + before or after :meth:`resolveAsync()` returns. If + :attr:`AUTO_REGISTER_SERVICES` is specified :attr:`~Event.SERVICE_STATUS` + events may also be generated before or after :meth:`resolveAsync()` + returns. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + resolutionList._addSession(self) + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_resolveAsync( + self.__handle, + get_handle(resolutionList), + resolveMode, + get_handle(identity), + ) + ) + + def getTopic(self, message: "typehints.Message") -> Topic: + """Find a previously created :class:`Topic` based on the ``message``. + + Args: + message: Message to get the topic from + + Returns: + The topic the message was published on + + The ``message`` must be one of the following types: ``TopicCreated``, + ``TopicActivated``, ``TopicDeactivated``, ``TopicSubscribed``, + ``TopicUnsubscribed``, ``TopicRecap``. If the ``message`` is not valid + then invoking :meth:`~Topic.isValid()` on the returned :class:`Topic` + will return ``False``. + """ + errorCode, topicHandle = internals.blpapi_ProviderSession_getTopic( + self.__handle, get_handle(message) + ) + _ExceptionUtil.raiseOnError(errorCode) + return Topic(topicHandle, {self}) + + def createServiceStatusTopic(self, service: "typehints.Service") -> Topic: + """Create a :class:`Service` Status :class:`Topic` which is to be used + to provide service status. + + Args: + service: Service for which to create the topic + + Returns: + A service status topic + + On success invoking :meth:`~Topic.isValid()` on the returned + :class:`Topic` will return ``False``. + """ + ( + errorCode, + topicHandle, + ) = internals.blpapi_ProviderSession_createServiceStatusTopic( + self.__handle, get_handle(service) + ) + _ExceptionUtil.raiseOnError(errorCode) + return Topic(topicHandle, {self}) + + def publish(self, event: Event) -> None: + """Publish the specified ``event``. + + Args: + event: Event to publish + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_publish( + self.__handle, get_handle(event) + ) + ) + + def sendResponse( + self, event: Event, isPartialResponse: bool = False + ) -> None: + """Send the response event for previously received request. + + Args: + event: Response event to send + isPartialResponse: Whether the response is partial or not + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_sendResponse( + self.__handle, get_handle(event), isPartialResponse + ) + ) + + def createTopics( + self, + topicList: "typehints.TopicList", + resolveMode: int = DONT_REGISTER_SERVICES, + identity: Optional["typehints.Identity"] = None, + ) -> None: + r"""Create the topics in the specified ``topicList``. + + Args: + topicList: List of topics to create + resolveMode: Mode to use for topic resolution + identity: Identity to use for authorization + + Create the topics in the specified ``topicList``, which must be an object + of type :class:`TopicList`, and update ``topicList`` with the results of the + creation process. If service needs to be registered, ``identity`` should + be supplied. Once a call to this function returns, each entry in the + ``topicList`` will have been updated with a new topic creation status. + + Before :meth:`createTopics()` returns one or more + :attr:`~Event.RESOLUTION_STATUS` events, zero or more + :attr:`~Event.SERVICE_STATUS` events and one or more + :attr:`~Event.TOPIC_STATUS` events are generated. If this is an + asynchronous :class:`ProviderSession` then these :class:`Event`\s may + be processed by the registered ``eventHandler`` before + :meth:`createTopics()` has returned. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + topicList._addSession(self) + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_createTopics( + self.__handle, + get_handle(topicList), + resolveMode, + get_handle(identity), + ) + ) + + def createTopicsAsync( + self, + topicList: "typehints.TopicList", + resolveMode: int = DONT_REGISTER_SERVICES, + identity: Optional["typehints.Identity"] = None, + ) -> None: + r"""Create the topics in the specified ``topicList``. + + Args: + topicList: List of topics to create + resolveMode: Mode to use for topic resolution + identity: Identity to use for authorization + + Create the topics in the specified ``topicList``, which must be an object + of type :class:`TopicList`, and update ``topicList`` with the results of the + creation process. If service needs to be registered, ``identity`` should + be supplied. Once a call to this function returns, each entry in the + ``topicList`` will have been updated with a new topic creation status. + + Before :meth:`createTopics()` returns one or more + :attr:`~Event.RESOLUTION_STATUS` events, zero or more + :attr:`~Event.SERVICE_STATUS` events and one or more + :attr:`~Event.TOPIC_STATUS` events are generated. If this is an + asynchronous :class:`ProviderSession` then these :class:`Event`\s may + be processed by the registered ``eventHandler`` before + :meth:`createTopics()` has returned. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + topicList._addSession(self) + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_createTopicsAsync( + self.__handle, + get_handle(topicList), + resolveMode, + get_handle(identity), + ) + ) + + def activateSubServiceCodeRange( + self, serviceName: str, begin: int, end: int, priority: int + ) -> None: + """ + Args: + serviceName: Name of the service + begin: Start of sub-service code range + end: End of sub-service code range + priority: Priority with which to receive subscriptions + + Register to receive, with the specified ``priority``, subscriptions for + the specified ``service`` that the resolver has mapped to a service + code between the specified ``begin`` and the specified ``end`` values, + inclusive. Numerically greater values of ``priority`` indicate higher + priorities. + + Note: + The behavior of this function is undefined unless ``service`` has + already been successfully registered, ``0 <= begin <= end < (1 << + 24)``, and ``priority`` is non-negative. + """ + err = internals.blpapi_ProviderSession_activateSubServiceCodeRange( + self.__handle, serviceName, begin, end, priority + ) + _ExceptionUtil.raiseOnError(err) + + def deactivateSubServiceCodeRange( + self, serviceName: str, begin: int, end: int + ) -> None: + """ + Args: + serviceName: Name of the service + begin: Start of sub-service code range + end: End of sub-service code range + + De-register to receive subscriptions for the specified ``service`` + that the resolver has mapped to a service code between the specified + ``begin`` and the specified ``end`` values, inclusive. + + Note: + The behavior of this function is undefined unless ``service`` has + already been successfully registered and ``0 <= begin <= end < (1 << + 24)``. + """ + err = internals.blpapi_ProviderSession_deactivateSubServiceCodeRange( + self.__handle, serviceName, begin, end + ) + _ExceptionUtil.raiseOnError(err) + + def deregisterService(self, serviceName: str) -> bool: + """De-register the service, including all registered parts. + + Args: + serviceName: Service to de-register + + Returns: + ``False`` if the service is not registered nor in pending + registration, ``True`` otherwise. + + The identity in the service registration is reused to verify + permissions for deregistration. If the service is in pending + registration, cancel the pending registration. If the service is + registered, send a deregistration request; generate + :class:`~Event.TOPIC_STATUS` events containing a ``TopicUnsubscribed`` + message for each subscribed topic, a ``TopicDeactivated`` message for + each active topic and a ``TopicDeleted`` for each created topic; + generate ``~Event.REQUEST_STATUS`` events containing a + ``RequestFailure`` message for each pending incoming request; and + generate a :class:`~Event.SERVICE_STATUS` event containing a + ``ServiceDeregistered`` message. All published events on topics created + on this service will be ignored after this method returns. + """ + res = internals.blpapi_ProviderSession_deregisterService( + self.__handle, serviceName + ) + return res == 0 + + def terminateSubscriptionsOnTopic( + self, topic: Topic, message: Optional["typehints.Message"] = None + ) -> None: + """Delete the specified ``topic`` (See :meth:`deleteTopic()` for + additional details). + + Args: + topic: Topic to delete + message: Message to convey additional information to + subscribers regarding the termination + + Furthermore, proactively terminate all current subscriptions on + ``topic``. The optionally specified ``message`` can be used to convey + additional information to subscribers regarding the termination. This + message is contained in the ``description`` of ``reason`` in a + ``SubscriptionTerminated`` message. + """ + if not topic: + return + _ExceptionUtil.raiseOnError( + internals.ProviderSession_terminateSubscriptionsOnTopic( + self.__handle, get_handle(topic), message + ) + ) + + def terminateSubscriptionsOnTopics( + self, + topics: Sequence[Topic], + message: Optional["typehints.Message"] = None, + ) -> None: + """Terminate subscriptions on the specified ``topics``. + + Args: + topics: Topics to delete + message: Message to convey additional information to + subscribers regarding the termination + + See :meth:`terminateSubscriptionsOnTopic()` for additional details. + """ + if not topics: + return + + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_terminateSubscriptionsOnTopics( + self.__handle, [get_handle(t) for t in topics], message + ) + ) + + def deleteTopic(self, topic: Topic) -> None: + """Remove one reference from the specified 'topic'. + + Args: + topic: Topic to remove the reference from + + If this function has been called the same number of times that + ``topic`` was created by ``createTopics``, then ``topic`` is deleted: a + ``TopicDeleted`` message is delivered, preceded by + ``TopicUnsubscribed`` and ``TopicDeactivated`` if ``topic`` was + subscribed. + + Note: + The behavior of this function is undefined if ``topic`` has already + been deleted the same number of times that it has been created. + Further, the behavior is undefined if a provider attempts to + publish a message on a deleted topic. + """ + self.deleteTopics((topic,)) + + def deleteTopics(self, topics: Sequence[Topic]) -> None: + """Delete each topic in the specified ``topics`` container. + + Args: + deleteTopics: Topics to delete + + See :meth:`deleteTopic()` above for additional details.""" + if not topics: + return + + _ExceptionUtil.raiseOnError( + internals.blpapi_ProviderSession_deleteTopics( + self.__handle, [get_handle(t) for t in topics] + ) + ) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/py.typed b/src/blpapi/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/blpapi/pycbhelpers.py b/src/blpapi/pycbhelpers.py new file mode 100644 index 0000000..54bf310 --- /dev/null +++ b/src/blpapi/pycbhelpers.py @@ -0,0 +1,108 @@ +from ctypes import ( + CFUNCTYPE, + c_int, + c_char_p, + c_void_p, +) + +from typing import Any, Callable +from io import StringIO + +from .ctypesutils import pyObjectFromVoid, voidFromPyObject + +# ============== General disclaimer ============== +# All python callback wrappers currently use the same approach, +# namely, the pointer to py object is given as void* userdata, +# converted back to py object and a proper call is made on it. +# The benefit of this approach is that we can have one instance +# of a proxy to serve all needs. +# The other approach would be to bind the pythonic callback +# and pass null as userdata. That way we need to keep fewer things alive, +# but would have to create per call proxy object (and keep that alive) + + +def default_print_helper(data: bytes, sz: int, out: Any) -> int: + if sz > 0: + pyout = pyObjectFromVoid(out) + getattr(pyout, "write")(data[:sz].decode()) + return 0 + + +class StreamWrapper: + _cftype = CFUNCTYPE(c_int, c_char_p, c_int, c_void_p) + + def __init__(self, cb: Callable = default_print_helper) -> None: + self._cb = self._cftype(cb) + + def get(self) -> Callable: + return self._cb + + +def any_printer( + handle: c_void_p, cfun: Callable, level: int, spacesPerLevel: int +) -> str: + out = StringIO() + writer = StreamWrapper() + outparam = voidFromPyObject(out) + cfun(handle, writer.get(), outparam, level, spacesPerLevel) + out.seek(0) + return out.read() + + +def _dispatchEventProxy(event: Any, _session: Any, pycb: Any) -> None: + pyout = pyObjectFromVoid(pycb) + getattr(pyout, "__call__")(c_void_p(event)) + + +class EventHandleWrapper: + # blpapi_Event_t *event, blpapi_Session_t *session, void *userData + _cftype = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p) + + def __init__(self) -> None: + self._cb = self._cftype(_dispatchEventProxy) + + def get(self) -> Callable: + return self._cb + + +anySessionEventHandlerWrapper = EventHandleWrapper() + + +def _subscriptionPreprocessProxy( + cid: int, subString: bytes, errorCode: int, errorDesc: bytes, pycb: int +) -> None: + # ^ the typehints are representation of + # c_void_p, c_char_p, c_int, c_char_p, c_void_p + pyout = pyObjectFromVoid(c_void_p(pycb)) + + # The handler is given &correlationId.impl() + # by ProxySubscriptionPreprocessErrorHandler::handleError + # i.e., it does not bump the ref. for us + correlationId = correlationIdWrapper(cid) + getattr(pyout, "__call__")( + correlationId, subString.decode(), errorCode, errorDesc.decode() + ) + + +class SubscriptionPreprocessHandlerWrapper: + # void (*blpapi_SubscriptionPreprocessErrorHandler_t)( + # const blpapi_CorrelationId_t *correlationId, + # const char *subscriptionString, + # int errorCode, + # const char *errorDescription, + # void *userData) + _cftype = CFUNCTYPE(None, c_void_p, c_char_p, c_int, c_char_p, c_void_p) + + def __init__(self) -> None: + self._cb = self._cftype(_subscriptionPreprocessProxy) + + def get(self) -> Callable: + return self._cb + + +anySessionSubErrorHandlerWrapper = SubscriptionPreprocessHandlerWrapper() + + +# will be overridden in correlationid.py +def correlationIdWrapper(ptr: int) -> Any: + raise Exception("Invalid cid wrapper called with", ptr) diff --git a/src/blpapi/request.py b/src/blpapi/request.py new file mode 100644 index 0000000..f016c55 --- /dev/null +++ b/src/blpapi/request.py @@ -0,0 +1,191 @@ +# request.py + +"""Defines a request which can be sent for a service. + +This file defines a class 'Request' which represents a request sent through the +Session. + +""" + +import weakref +from typing import Any, Mapping, Optional, Set +from .typehints import BlpapiRequestHandle +from .element import Element +from .exception import _ExceptionUtil +from . import internals +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + + +class Request(CHandle): + """A single request to a single service. + + :class:`Request` objects are created using :meth:`Service.createRequest()` + or :meth:`Service.createAuthorizationRequest()`. They are used with + :meth:`Session.sendRequest()` or + :meth:`Session.sendAuthorizationRequest()`. + + The :class:`Request` object contains the parameters for a single request to + a single service. Once a :class:`Request` has been created its fields can + be populated directly using the functions provided by :class:`Element` or + using the :class:`Element` interface on the :class:`Element` returned by + :meth:`asElement()`. + + The schema for the :class:`Request` can be queried using the + :class:`Element` interface. + """ + + def __init__( + self, + handle: BlpapiRequestHandle, + sessions: Set["typehints.AbstractSession"], + ) -> None: + super(Request, self).__init__(handle, internals.blpapi_Request_destroy) + self.__handle = handle + self.__sessions = sessions + self.__element: Optional[weakref.ReferenceType] = None + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this Request. Call of str(request) is + equivalent to request.toString() called with default parameters. + + """ + + return self.toString() + + def __getitem__(self, name: "typehints.Name") -> Any: + """Equivalent to :meth:`asElement().__getitem__(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement()[name] + + def __setitem__(self, name: "typehints.Name", value: Any) -> None: + """Equivalent to :meth:`asElement().__setitem__(name, value) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + self.asElement()[name] = value + + def set(self, name: "typehints.Name", value: Any) -> None: + """Equivalent to :meth:`asElement().setElement(name, value) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + self.asElement().setElement(name, value) + + def append(self, name: "typehints.Name", value: Any) -> None: + """Equivalent to :meth:`getElement(name).appendValue(value) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + self.getElement(name).appendValue(value) + + def fromPy(self, requestDict: Mapping) -> None: + """Equivalent to :meth:`asElement().fromPy(requestDict) + `. + + Args: + requestDict (collections.abc.Mapping): used to format this + :class:`Request`. See :meth:`Element.fromPy` for more details. + + Note: + Using :meth:`fromPy` to format a :class:`Request` that has already + been formatted is not supported. To further format a + :class:`Request`, use :meth:`set` / :meth:`append` or the + ``*Element()`` methods. + """ + self.asElement().fromPy(requestDict) + + def asElement(self) -> Element: + """ + Returns: + Element: The content of this :class:`Request` as an + :class:`Element`. + """ + el = None + if self.__element: + el = self.__element() + if el is None: + el = Element( + internals.blpapi_Request_elements(self.__handle), self + ) + self.__element = weakref.ref(el) + return el + + def getElement(self, name: "typehints.Name") -> Element: + """Equivalent to :meth:`asElement().getElement(name) + `. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + return self.asElement().getElement(name) + + def getRequestId(self) -> str: + """ + Return the request's id if one exists, otherwise return ``None``. + + If there are issues with this request, the request id + can be reported to Bloomberg for troubleshooting purposes. + + Note that request id is not the same as correlation + id and should not be used for correlation purposes. + + Returns: + The request id of the request. + """ + rc, requestId = internals.blpapi_Request_getRequestId(self.__handle) + _ExceptionUtil.raiseOnError(rc) + return requestId + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Equivalent to :meth:`asElement().toString(level, spacesPerLevel) + `.""" + return self.asElement().toString(level, spacesPerLevel) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this Request related to. For internal use.""" + return self.__sessions + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/requesttemplate.py b/src/blpapi/requesttemplate.py new file mode 100644 index 0000000..f5bd60d --- /dev/null +++ b/src/blpapi/requesttemplate.py @@ -0,0 +1,55 @@ +# requesttemplate.py + +""" +This component provides a class, RequestTemplate, that can be used to obtain +snapshots from subscription data without having to handle the ticks on an +actual subscription. + +Request templates are obtained from a Session and should be always used with +the session that creates the template. When a session is terminated, any +request templates associated with that session become invalid. Results of +sending or canceling of invalid request templates is undefined. + +In order to send a request represented by a template, +'blpapi.Session.sendRequestTemplate' method should be called. + +Check 'blpapi.Session.createSnapshotRequestTemplate' for details about creation +and management of snapshot request templates. +""" + +from . import internals +from .chandle import CHandle +from .typehints import BlpapiRequestTemplateHandle + + +class RequestTemplate(CHandle): + """Request templates cache the necessary information to make a request and + eliminate the need to create new requests for snapshot services. + """ + + def __init__(self, handle: BlpapiRequestTemplateHandle) -> None: + super(RequestTemplate, self).__init__( + handle, internals.blpapi_RequestTemplate_release + ) + + +__copyright__ = """ +Copyright 2018. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/resolutionlist.py b/src/blpapi/resolutionlist.py new file mode 100644 index 0000000..d22dd1e --- /dev/null +++ b/src/blpapi/resolutionlist.py @@ -0,0 +1,333 @@ +# resolutionlist.py + +"""Provide a representation of a list of topics. + +This component implements a list of topics that require resolution. +""" +from typing import Optional, Set, Union + +from .exception import _ExceptionUtil +from .message import Message +from . import internals +from . import utils +from .utils import deprecated, get_handle +from .correlationid import CorrelationId +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + + +class ResolutionList(CHandle, metaclass=utils.MetaClassForClassesWithEnums): + """Contains a list of topics that require resolution. + + Created from topic strings or from ``SUBSCRIPTION_STARTED`` messages. This + is passed to a :meth:`~ProviderSession.resolve()` call or + :meth:`ProviderSession.resolveAsync()` call on a :class:`ProviderSession`. + It is updated and returned by the :meth:`~ProviderSession.resolve()` call. + + The class attributes represent the states in which entries of a + :class:`ResolutionList` can be. + """ + + UNRESOLVED = internals.RESOLUTIONLIST_UNRESOLVED + RESOLVED = internals.RESOLUTIONLIST_RESOLVED + RESOLUTION_FAILURE_BAD_SERVICE = ( + internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_SERVICE + ) + RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED = ( + internals.RESOLUTIONLIST_RESOLUTION_FAILURE_SERVICE_AUTHORIZATION_FAILED + ) + RESOLUTION_FAILURE_BAD_TOPIC = ( + internals.RESOLUTIONLIST_RESOLUTION_FAILURE_BAD_TOPIC + ) + RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED = ( + internals.RESOLUTIONLIST_RESOLUTION_FAILURE_TOPIC_AUTHORIZATION_FAILED + ) + + @staticmethod + @deprecated("attributes are no longer supported.") + # pylint: disable=unused-argument,no-self-use + def extractAttributeFromResolutionSuccess(message, attribute): # type: ignore + """ + Raises: + UnsupportedOperationException: Unconditionally. + + **DEPRECATED** + Attributes are no longer supported. + """ + _ExceptionUtil.raiseOnError(internals.ERROR_UNSUPPORTED_OPERATION) + + def __init__(self) -> None: + """Create an empty :class:`ResolutionList`.""" + selfhandle = internals.blpapi_ResolutionList_create(None) + super(ResolutionList, self).__init__( + selfhandle, internals.blpapi_ResolutionList_destroy + ) + self.__handle = selfhandle + self.__sessions: Set["typehints.AbstractSession"] = set() + + def add( + self, + topicOrMessage: Union[str, Message], + correlationId: Optional[CorrelationId] = None, + ) -> int: + """Add the specified topic or topic from message to this list. + + Args: + topicOrMessage: Topic or message to add + correlationId: CorrelationId to associate with this + operation + + Returns: + ``0`` on success, negative number on failure + + Raises: + TypeError: If ``correlationId`` is not an instance of + :class:`CorrelationId` + + If ``topicOrMessage`` is of string type, add the specified + ``topicOrMessage`` to this list, optionally specifying a + ``correlationId``. After a successful call to :meth:`add()` the status + for this entry is ``UNRESOLVED_TOPIC``. + + If ``topicOrMessage`` is of :class:`Message` type, add the topic + contained in the specified ``topicOrMessage`` to this list, optionally + specifying a ``correlationId``. After a successful call to + :meth:`add()` the status for this entry is ``UNRESOLVED_TOPIC``. + """ + if correlationId is None: + correlationId = CorrelationId() + if not isinstance(correlationId, CorrelationId): + raise TypeError( + "correlationId should be an instance of 'CorrelationId'" + ) + if isinstance(topicOrMessage, Message): + return internals.blpapi_ResolutionList_addFromMessage( + self.__handle, get_handle(topicOrMessage), correlationId + ) + return internals.blpapi_ResolutionList_add( + self.__handle, topicOrMessage, correlationId + ) + + @deprecated("attributes are no longer supported.") + # pylint: disable=unused-argument,no-self-use + def addAttribute(self, attribute): # type: ignore + """ + Raises: + UnsupportedOperationException: Unconditionally. + + **DEPRECATED** + Attributes are no longer supported. + """ + _ExceptionUtil.raiseOnError(internals.ERROR_UNSUPPORTED_OPERATION) + + def correlationIdAt(self, index: int) -> CorrelationId: + """ + Args: + index: Index of the correlation id + + Returns: + CorrelationId: CorrelationId at the specified ``index``. + + Raises: + IndexOutOfRangeException: If ``index >= size()``. + """ + errorCode, cid = internals.blpapi_ResolutionList_correlationIdAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return CorrelationId(cid) + + def topicString(self, correlationId: CorrelationId) -> str: + """Return the topic of the entry identified by ``correlationId``. + + Args: + correlationId: Correlation id that identifies the + topic + + Returns: + Topic string of the entry identified by ``correlationId``. + + Raises: + Exception: If ``correlationId`` does not identify an entry in this + :class:`ResolutionList`. + """ + errorCode, topic = internals.blpapi_ResolutionList_topicString( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return topic + + def topicStringAt(self, index: int) -> str: + """ + Args: + index: Index of the topic string + + Returns: + Topic string at the specified ``index``. + + Raises: + IndexOutOfRangeException: If ``index >= size()``. + """ + errorCode, topic = internals.blpapi_ResolutionList_topicStringAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return topic + + def status(self, correlationId: CorrelationId) -> int: + """ + Args: + correlationId: Correlation id that identifies the + entry + + Returns: + status of the entry in this :class:`ResolutionList`. + + Raises: + Exception: If the ``correlationId`` does not identify an entry in + this :class:`ResolutionList`. + + The possible statuses are represented by the class attributes of + :class:`ResolutionList`. + """ + errorCode, status = internals.blpapi_ResolutionList_status( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return status + + def statusAt(self, index: int) -> int: + """ + Args: + index: Index of the Correlation id + + Returns: + int: status of the entry in this :class:`ResolutionList`. + + Raises: + IndexOutOfRangeException: If ``index >= size()``. + + The possible statuses are represented by the class attributes of + :class:`ResolutionList`. + """ + errorCode, status = internals.blpapi_ResolutionList_statusAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return status + + @deprecated("attributes are no longer supported") + # pylint: disable=unused-argument,no-self-use + def attribute(self, attribute, correlationId): # type: ignore + """ + Raises: + UnsupportedOperationException: Unconditionally. + + **DEPRECATED** + Attributes are no longer supported. + """ + + # pylint no-self-use + _ExceptionUtil.raiseOnError(internals.ERROR_UNSUPPORTED_OPERATION) + + @deprecated("attributes are no longer supported") + # pylint: disable=unused-argument,no-self-use + def attributeAt(self, attribute, index): # type: ignore + """ + Raises: + UnsupportedOperationException: Unconditionally. + + **DEPRECATED** + Attributes are no longer supported. + """ + _ExceptionUtil.raiseOnError(internals.ERROR_UNSUPPORTED_OPERATION) + + def message(self, correlationId: CorrelationId) -> Message: + """ + Args: + correlationId: Correlation id that identifies an + entry in this list + + Returns: + Message received during resolution of the topic + identified by the specified ``correlationId``. + + Raises: + Exception: If ``correlationId`` does not identify an entry in this + :class:`ResolutionList` or if the status of the entry identify + by ``correlationId`` is not ``RESOLVED`` an exception is + raised. + + Note: + The :class:`Message` returned can be used when creating an instance + of :class:`Topic`. + """ + errorCode, message = internals.blpapi_ResolutionList_message( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return Message(message, sessions=self._sessions()) + + def messageAt(self, index: int) -> Message: + r""" + Args: + index: Index of an entry in this list + + Returns: + Message received during resolution of the topic + specified ``index``\th entry in this :class:`ResolutionList`. + + Raises: + Exception: If ``index >= size()`` or if the status of the + ``index``\th entry is not ``RESOLVED`` an exception is raised. + + Note: + The :class:`Message` returned can be used when creating an instance + of :class:`Topic`. + """ + errorCode, message = internals.blpapi_ResolutionList_messageAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return Message(message, sessions=self._sessions()) + + def size(self) -> int: + """ + Returns: + Number of entries in this :class:`ResolutionList`. + """ + return internals.blpapi_ResolutionList_size(self.__handle) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) that this 'ResolutionList' is related to. + + For internal use.""" + return self.__sessions + + def _addSession(self, session: "typehints.AbstractSession") -> None: + """Add a new session to this 'ResolutionList'. + + For internal use.""" + self.__sessions.add(session) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/schema.py b/src/blpapi/schema.py new file mode 100644 index 0000000..df2af07 --- /dev/null +++ b/src/blpapi/schema.py @@ -0,0 +1,484 @@ +# schema.py + +"""Provide a representation of a schema describing structured messages. + +This file defines these classes: + + 'SchemaStatus' - the version status of a schema + 'SchemaTypeDefinition' - definitions of schema types + 'SchemaElementDefinition' - definitions of message elements + +This component provides types for representing schemata which describe +structured messages. Such schemata consist of two distinct kinds of +definitions: "type" definitions (represented by 'SchemaTypeDefinition' objects) +declare types that can be used within other definitions (of both kinds); an +"element" definition defines a specific field by associating a field identifier +with a particular type, as well as the number of values of that type that are +permitted to be associated with that identifier. + +""" +from __future__ import annotations +from typing import Sequence, Set, Optional +from typing import Iterator as IteratorType +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiNameOrIndex +from .typehints import BlpapiSchemaElementDefinitionHandle +from .typehints import BlpapiSchemaTypeDefinitionHandle +from .exception import NotFoundException, IndexOutOfRangeException +from .name import Name, getNamePair +from .constant import ConstantList +from . import utils +from . import internals + + +# pylint: disable=protected-access,too-few-public-methods +class SchemaStatus(metaclass=utils.MetaClassForClassesWithEnums): + """The possible deprecation statuses of a schema element or type.""" + + ACTIVE = internals.STATUS_ACTIVE + """This item is current and may appear in Messages""" + DEPRECATED = internals.STATUS_DEPRECATED + """This item is current and may appear in Messages but will be removed in + due course""" + INACTIVE = internals.STATUS_INACTIVE + """This item is not current and will not appear in Messages""" + PENDING_DEPRECATION = internals.STATUS_PENDING_DEPRECATION + """This item is expected to be deprecated in the future; clients are + advised to migrate away from use of this item.""" + + +class SchemaElementDefinition(metaclass=utils.MetaClassForClassesWithEnums): + """The definition of an individual field within a schema type. + + This class implements the definition of an individual field within a schema + type. An element is defined by an identifer/name, a type, and the number of + values of that type that may be associated with the identifier/name. In + addition, this class offers access to metadata providing a description and + deprecation status for the field. + + :class:`SchemaElementDefinition` objects are returned by :class:`Service` + and :class:`Operation` objects to define the content of requests, replies + and events. The :class:`SchemaTypeDefinition` returned by + :meth:`typeDefinition()` may itself provide access to + :class:`SchemaElementDefinition` objects when the schema contains nested + elements. (See the :class:`SchemaTypeDefinition` documentation for more + information on complex types.) + + An optional element has ``minValues() == 0``. + + A mandatory element has ``minValues() >= 1``. + + An element that must contain a single value has + ``minValues() == maxValues() == 1``. + + An element containing an array has ``maxValues() > 1``. + + An element with no upper limit on the number of values has + ``maxValues() == UNBOUNDED``. + + :class:`SchemaElementDefinition` objects are read-only. + + Application clients need never create :class:`SchemaElementDefinition` + objects directly; applications will typically work with objects returned by + other blpapi components. + """ + + UNBOUNDED = internals.ELEMENTDEFINITION_UNBOUNDED + """Indicates an array has an unbounded number of values.""" + + def __init__( + self, + handle: BlpapiSchemaElementDefinitionHandle, + sessions: Set["typehints.AbstractSession"], + ) -> None: + self.__handle = handle + self.__sessions = sessions + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this item. It is equivalent to + toString() with default parameters. + + """ + + return self.toString() + + def name(self) -> Name: + """ + Returns: + The name identifying this element within its containing + structure/type. + """ + + return Name._createInternally( + internals.blpapi_SchemaElementDefinition_name(self.__handle) + ) + + def description(self) -> str: + """ + Returns: + Human readable description of this element. + """ + return internals.blpapi_SchemaElementDefinition_description( + self.__handle + ) + + def status(self) -> int: + """ + Returns: + The deprecation status of this element. + + The possible return values are enumerated in :class:`SchemaStatus`. + """ + + return internals.blpapi_SchemaElementDefinition_status(self.__handle) + + def typeDefinition(self) -> SchemaTypeDefinition: + """ + Returns: + The type of values contained in this element. + """ + return SchemaTypeDefinition( + internals.blpapi_SchemaElementDefinition_type(self.__handle), + self.__sessions, + ) + + def minValues(self) -> int: + """ + Returns: + The minimum number of occurrences of this element. + + This value is always greater than or equal to zero. + """ + + return internals.blpapi_SchemaElementDefinition_minValues( + self.__handle + ) + + def maxValues(self) -> int: + """ + Returns: + The maximum number of occurrences of this element. + + This value is always greater than or equal to one. + + Return value is equal to :attr:`UNBOUNDED` if this item is an unbounded + array. + """ + + return internals.blpapi_SchemaElementDefinition_maxValues( + self.__handle + ) + + def alternateNames(self) -> Sequence[Name]: + """ + Returns: + The list of alternate names for this element. + """ + + res = [] + numAlternateNames = ( + internals.blpapi_SchemaElementDefinition_numAlternateNames( + self.__handle + ) + ) + for i in range(numAlternateNames): + res.append( + Name._createInternally( + internals.blpapi_SchemaElementDefinition_getAlternateName( + self.__handle, i + ) + ) + ) + return res + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """ + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This object formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + + return internals.blpapi_SchemaElementDefinition_printHelper( + self.__handle, level, spacesPerLevel + ) + + def _handle(self) -> typehints.BlpapiSchemaElementDefinitionHandle: + """Return the internal implementation.""" + return self.__handle + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +class SchemaTypeDefinition: + """Representation of a "type" that can be used within a schema. + + This class implements a representation of a "type" that can be used within + a schema, including both plain types (integers, dates, strings, etc.) + and "complex" types. The latter may be a "sequence" or a "choice" allowing + either all or one of the named elements respectively. Those elements + in turn are each described by a type. In addition to accessors + for the type's structure, this class also offers access to metadata + providing a description and deprecation status for the type. + + Each :class:`SchemaElementDefinition` object is associated with a single + :class:`SchemaTypeDefinition`; one :class:`SchemaTypeDefinition` may be + used by zero, one, or many :class:`SchemaElementDefinition` objects. + + :class:`SchemaTypeDefinition` objects are read-only. + + Application clients need never create :class:`SchemaTypeDefinition` + objects directly; applications will typically work with objects returned by + other blpapi components. + """ + + def __init__( + self, + handle: BlpapiSchemaTypeDefinitionHandle, + sessions: Set["typehints.AbstractSession"], + ) -> None: + self.__handle = handle + self.__sessions = sessions + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this 'SchemaTypeDefinition'. It is + equivalent to call of toString() with default parameters. + + """ + + return self.toString() + + def datatype(self) -> int: + """ + Returns: + The data type of this :class:`SchemaTypeDefinition`. + + The possible return values are enumerated in :class:`DataType`. + """ + + return internals.blpapi_SchemaTypeDefinition_datatype(self.__handle) + + def name(self) -> Name: + """ + Returns: + The name of this :class:`SchemaTypeDefinition`. + """ + return Name._createInternally( + internals.blpapi_SchemaTypeDefinition_name(self.__handle) + ) + + def description(self) -> str: + """ + Returns: + Human readable description of this :class:`SchemaTypeDefinition`. + """ + return internals.blpapi_SchemaTypeDefinition_description(self.__handle) + + def status(self) -> int: + """ + Returns: + The deprecation status of this :class:`SchemaTypeDefinition`. + + The possible return values are enumerated in :class:`SchemaStatus`. + """ + + return internals.blpapi_SchemaTypeDefinition_status(self.__handle) + + def numElementDefinitions(self) -> int: + """ + Returns: + The number of :class:`SchemaElementDefinition` objects. + + If this :class:`SchemaTypeDefinition` is neither a choice nor a + sequence this will return ``0``. + """ + + return internals.blpapi_SchemaTypeDefinition_numElementDefinitions( + self.__handle + ) + + def isComplexType(self) -> bool: + """ + Returns: + ``True`` if this :class:`SchemaTypeDefinition` represents a + sequence or choice type. + """ + + return bool( + internals.blpapi_SchemaTypeDefinition_isComplexType(self.__handle) + ) + + def isSimpleType(self) -> bool: + """ + Returns: + ``True`` if this :class:`SchemaTypeDefinition` represents neither + a sequence nor a choice type. + """ + + return bool( + internals.blpapi_SchemaTypeDefinition_isSimpleType(self.__handle) + ) + + def isEnumerationType(self) -> bool: + """ + Returns: + ``True`` if this :class:`SchemaTypeDefinition` represents an + enumeration type, ``False`` otherwise. + """ + + return bool( + internals.blpapi_SchemaTypeDefinition_isEnumerationType( + self.__handle + ) + ) + + def hasElementDefinition(self, name: Name) -> bool: + """ + Args: + name: Item identifier + + Returns: + ``True`` if this object contains an item with the + specified ``name``, ``False`` otherwise + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + namepair = getNamePair(name) + return bool( + internals.blpapi_SchemaTypeDefinition_hasElementDefinition( + self.__handle, namepair[0], namepair[1] + ) + ) + + def getElementDefinition( + self, nameOrIndex: BlpapiNameOrIndex + ) -> SchemaElementDefinition: + """ + Args: + nameOrIndex: Name or index of the element + + Returns: + The definition of a specified element. + + Raises: + NotFoundException: If ``nameOrIndex`` is a string and + ``hasElement(nameOrIndex) != True``. + IndexOutOfRangeException: If ``nameOrIndex`` is an integer and + ``nameOrIndex >= numElementDefinitions()`` + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``nameOrIndex``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + if not isinstance(nameOrIndex, int): + name = nameOrIndex + names = getNamePair(name) + res = internals.blpapi_SchemaTypeDefinition_getElementDefinition( + self.__handle, names[0], names[1] + ) + if res is None: + errMessage = ( + f"Name '{name!s}' not a sub-element of element " + f" '{self.name()!s}'." + ) + raise NotFoundException(errMessage, 0) + return SchemaElementDefinition(res, self.__sessions) + position = nameOrIndex + res = internals.blpapi_SchemaTypeDefinition_getElementDefinitionAt( + self.__handle, position + ) + if res is None: + errMessage = f"Index '{position}' out of bounds." + raise IndexOutOfRangeException(errMessage, 0) + return SchemaElementDefinition(res, self.__sessions) + + def elementDefinitions(self) -> IteratorType[SchemaElementDefinition]: + r""" + Returns: + Iterator over :class:`SchemaElementDefinition`\s defined by this + :class:`SchemaTypeDefinition`. + """ + + return utils.Iterator( + self, + SchemaTypeDefinition.numElementDefinitions, + SchemaTypeDefinition.getElementDefinition, + ) + + def enumeration(self) -> Optional["typehints.ConstantList"]: + """ + Returns: + All possible values of the enumeration defined by this type. + ``None`` in case this :class:`SchemaTypeDefinition` is + not a enumeration. + """ + + res = internals.blpapi_SchemaTypeDefinition_enumeration(self.__handle) + return None if res is None else ConstantList(res, self.__sessions) + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """ + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This object formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + + return internals.blpapi_SchemaTypeDefinition_printHelper( + self.__handle, level, spacesPerLevel + ) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/service.py b/src/blpapi/service.py new file mode 100644 index 0000000..74a118f --- /dev/null +++ b/src/blpapi/service.py @@ -0,0 +1,484 @@ +# service.py + +"""A service which provides access to API data (provide or consume). + +All API data is associated with a 'Service'. A service object is obtained +from a Session and contains zero or more 'Operations'. A service can be a +provider service (can generate API data) or a consumer service. + +""" +import warnings +from typing import Optional, Set +from typing import Iterator as IteratorType +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiNameOrIndex +from .typehints import BlpapiServiceHandle, BlpapiOperationHandle +from .event import Event +from .name import getNamePair +from .request import Request +from .schema import SchemaElementDefinition +from .exception import _ExceptionUtil +from . import utils +from . import internals +from .chandle import CHandle + + +class Operation: + """Defines an operation which can be performed by a :class:`Service`. + + Operation objects are obtained from a :class:`Service` object. They provide + read-only access to the schema of the Operations Request and the schema of + the possible response. + """ + + def __init__( + self, + handle: BlpapiOperationHandle, + sessions: Set["typehints.AbstractSession"], + ): + self.__handle = handle + self.__sessions = sessions + + def name(self) -> str: + """ + Returns: + The name of this :class:`Operation`. + """ + return internals.blpapi_Operation_name(self.__handle) + + def description(self) -> str: + """ + Returns: + A human readable description of this Operation. + """ + return internals.blpapi_Operation_description(self.__handle) + + def requestDefinition(self) -> Optional[SchemaElementDefinition]: + """ + Returns: + Object which defines the schema for this :class:`Operation`. + """ + + errCode, definition = internals.blpapi_Operation_requestDefinition( + self.__handle + ) + return ( + None + if errCode != 0 + else SchemaElementDefinition(definition, self.__sessions) + ) + + def numResponseDefinitions(self) -> int: + """ + Returns: + The number of the response types that can be returned by this + :class:`Operation`. + + """ + + return internals.blpapi_Operation_numResponseDefinitions(self.__handle) + + def getResponseDefinitionAt( + self, position: int + ) -> SchemaElementDefinition: + """ + Args: + position: Index of the response type + + Returns: + Object which defines the schema for the + response that this :class:`Operation` delivers. + + Raises: + Exception: If ``position >= numResponseDefinitions()``. + """ + + errCode, definition = internals.blpapi_Operation_responseDefinition( + self.__handle, position + ) + _ExceptionUtil.raiseOnError(errCode) + return SchemaElementDefinition(definition, self.__sessions) + + def responseDefinitions(self) -> IteratorType[SchemaElementDefinition]: + """ + Returns: + Iterator over response types that can be returned by this + :class:`Operation`. + + Response type is defined by :class:`SchemaElementDefinition`. + """ + + return utils.Iterator( + self, + Operation.numResponseDefinitions, + Operation.getResponseDefinitionAt, + ) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +class Service(CHandle): + r"""Defines a service which provides access to API data. + + A :class:`Service` object is obtained from a :class:`Session` and contains + the :class:`Operation`\s (each of which contains its own schema) and the + schema for :class:`Event`\s which this :class:`Service` may produce. A + :class:`Service` object is also used to create :class:`Request` objects + used with a :class:`Session` to issue requests. + + Provider services are created to generate API data and must be registered + before use. + + The :class:`Service` object is a handle to the underlying data which is + owned by the :class:`Session`. Once a :class:`Service` has been succesfully + opened in a :class:`Session` it remains accessible until the + :class:`Session` is terminated. + """ + + def __init__( + self, + handle: BlpapiServiceHandle, + sessions: Set["typehints.AbstractSession"], + isRealService: bool = True, + ) -> None: + super(Service, self).__init__(handle, internals.blpapi_Service_release) + self.__handle = handle + self.__sessions = sessions + if isRealService: # as opposed to deserialized + # see blpapi-cpp/src/blpapi_testutil.cpp#L270 + internals.blpapi_Service_addRef(self.__handle) + + def __str__(self) -> str: + """Convert the service schema to a string.""" + return self.toString() + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Convert this :class:`Service` schema to a string. + + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This object formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + + return internals.blpapi_Service_printHelper( + self.__handle, level, spacesPerLevel + ) + + def createPublishEvent(self) -> Event: + r""" + Returns: + :class:`Event` suitable for publishing to this + :class:`Service` + + Use an :class:`EventFormatter` to add :class:`Message`\s to the + :class:`Event` and set fields. + """ + + errCode, event = internals.blpapi_Service_createPublishEvent( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return Event(event, self.__sessions) + + def createAdminEvent(self) -> Event: + r""" + Returns: + An :attr:`~Event.ADMIN` :class:`Event` suitable for + publishing to this :class:`Service` + + Use an :class:`EventFormatter` to add :class:`Message`\s to the + :class:`Event` and set fields. + + **DEPRECATED** + Use :meth:`Service.createPublishEvent()`. + + """ + + warnings.warn( + "This method is deprecated, see docstring for details", + DeprecationWarning, + ) + errCode, event = internals.blpapi_Service_createAdminEvent( + self.__handle + ) + _ExceptionUtil.raiseOnError(errCode) + return Event(event, self.__sessions) + + def createResponseEvent( + self, correlationId: "typehints.CorrelationId" + ) -> Event: + r"""Create a :attr:`~Event.RESPONSE` :class:`Event` to answer the + request. + + Args: + correlationId: Correlation id to associate with the + created event + + Returns: + The created response event. + + Use an :class:`EventFormatter` to add :class:`Message`\s to the + :class:`Event` and set fields. + """ + + errCode, event = internals.blpapi_Service_createResponseEvent( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errCode) + return Event(event, self.__sessions) + + def name(self) -> str: + """ + Returns: + Name of this service. + """ + return internals.blpapi_Service_name(self.__handle) + + def description(self) -> str: + """ + Returns: + str: Human-readable description of this service. + """ + return internals.blpapi_Service_description(self.__handle) + + def hasOperation(self, name: "typehints.Name") -> bool: + """ + Returns: + ``True`` if the specified ``name`` is a valid + :class:`Operation` in this :class:`Service`. + """ + + names = getNamePair(name) + return bool( + internals.blpapi_Service_hasOperation( + self.__handle, names[0], names[1] + ) + ) + + def getOperation(self, nameOrIndex: BlpapiNameOrIndex) -> Operation: + """ + Args: + nameOrIndex: Name or index of the operation + + Returns: + The specified operation. + + Raises: + Exception: If ``nameOrIndex`` is a string or a :class:`Name` and + ``hasOperation(nameOrIndex) != True``, or if ``nameOrIndex`` is + an integer and ``nameOrIndex >= numOperations()``. + + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``nameOrIndex``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + if not isinstance(nameOrIndex, int): + names = getNamePair(nameOrIndex) + errCode, operation = internals.blpapi_Service_getOperation( + self.__handle, names[0], names[1] + ) + _ExceptionUtil.raiseOnError(errCode) + return Operation(operation, self.__sessions) + errCode, operation = internals.blpapi_Service_getOperationAt( + self.__handle, nameOrIndex + ) + _ExceptionUtil.raiseOnError(errCode) + return Operation(operation, self.__sessions) + + def numOperations(self) -> int: + r""" + Returns: + The number of :class:`Operation`\s defined by this + :class:`Service`. + """ + return internals.blpapi_Service_numOperations(self.__handle) + + def operations(self) -> IteratorType[Operation]: + r""" + Returns: + Iterator over :class:`Operation`\s defined by this :class:`Service` + """ + return utils.Iterator( + self, Service.numOperations, Service.getOperation + ) + + def hasEventDefinition(self, name: "typehints.Name") -> bool: + """ + Args: + name: Event identifier + + Returns: + ``True`` if the specified ``name`` identifies a valid event + in this :class:`Service`, ``False`` otherwise. + + Raises: + Exception: If ``name`` is neither a :class:`Name` nor a string. + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``name``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + names = getNamePair(name) + return bool( + internals.blpapi_Service_hasEventDefinition( + self.__handle, names[0], names[1] + ) + ) + + def getEventDefinition( + self, nameOrIndex: BlpapiNameOrIndex + ) -> SchemaElementDefinition: + """Get the definition of a specified event. + + Args: + nameOrIndex: Name or index of the event + + Returns: + Object describing the element identified + by the specified ``nameOrIndex``. + + Raises: + NotFoundException: If ``nameOrIndex`` is a string and + ``hasEventDefinition(nameOrIndex) != True`` + IndexOutOfRangeException: If ``nameOrIndex`` is an integer and + ``nameOrIndex >= numEventDefinitions()`` + + Note: + **Please use** :class:`Name` **over** :class:`str` **where possible for** + ``nameOrIndex``. :class:`Name` **objects should be initialized + once and then reused** in order to minimize lookup cost. + """ + + if not isinstance(nameOrIndex, int): + names = getNamePair(nameOrIndex) + errCode, definition = internals.blpapi_Service_getEventDefinition( + self.__handle, names[0], names[1] + ) + _ExceptionUtil.raiseOnError(errCode) + return SchemaElementDefinition(definition, self.__sessions) + errCode, definition = internals.blpapi_Service_getEventDefinitionAt( + self.__handle, nameOrIndex + ) + _ExceptionUtil.raiseOnError(errCode) + return SchemaElementDefinition(definition, self.__sessions) + + def numEventDefinitions(self) -> int: + """ + Returns: + The number of unsolicited events defined by this :class:`Service`. + """ + return internals.blpapi_Service_numEventDefinitions(self.__handle) + + def eventDefinitions(self) -> IteratorType[SchemaElementDefinition]: + """ + Returns: + An iterator over unsolicited events defined by this + :class:`Service`. + """ + + return utils.Iterator( + self, Service.numEventDefinitions, Service.getEventDefinition + ) + + def authorizationServiceName(self) -> str: + """Get the authorization service name. + + Returns: + The name of the :class:`Service` which must be used in order + to authorize access to restricted operations on this + :class:`Service`. If no authorization is required to access + operations on this service an empty string is returned. + + Authorization services never require authorization to use. + """ + return internals.blpapi_Service_authorizationServiceName(self.__handle) + + def createRequest(self, operation: str) -> Request: + """Create an empty Request object for the specified ``operation``. + + Args: + operation: A valid operation on this service + + Returns: + An empty request for the specified ``operation``. + + Raises: + Exception: If ``operation`` does not identify a valid operation in + the :class:`Service` + + An application must populate the :class:`Request` before issuing it + using :meth:`Session.sendRequest()`. + """ + + errCode, request = internals.blpapi_Service_createRequest( + self.__handle, operation + ) + _ExceptionUtil.raiseOnError(errCode) + return Request(request, self.__sessions) + + def createAuthorizationRequest( + self, authorizationOperation: Optional[str] = None + ) -> Request: + """Create an empty :class:`Request` object for + ``authorizationOperation``. + + Args: + authorizationOperation: A valid operation on this service + + Returns: + An empty request for the specified ``authorizationOperation``. + + Raises: + Exception: If ``authorizationOperation`` does not identify a valid + operation in the :class:`Service` + + An application must populate the :class:`Request` before issuing it + using :meth:`Session.sendAuthorizationRequest()`. + """ + + errCode, request = internals.blpapi_Service_createAuthorizationRequest( + self.__handle, authorizationOperation + ) + _ExceptionUtil.raiseOnError(errCode) + return Request(request, self.__sessions) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) this object is related to. For internal use.""" + return self.__sessions + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/session.py b/src/blpapi/session.py new file mode 100644 index 0000000..11dbba4 --- /dev/null +++ b/src/blpapi/session.py @@ -0,0 +1,850 @@ +# session.py + +"""Provide consumer session to get Bloomberg Service. + +This component implements a consumer session for getting services. +""" + +from __future__ import annotations +from weakref import ref, ReferenceType # pylint: disable=unused-import +from typing import Optional, Callable, Any, List +import sys +import traceback +import os +import functools +import atexit +from enum import Enum +from .abstractsession import AbstractSession +from .event import Event +from . import exception +from .exception import _ExceptionUtil +from . import internals +from .correlationid import CorrelationId +from .sessionoptions import SessionOptions +from .requesttemplate import RequestTemplate +from .utils import get_handle, MetaClassForClassesWithEnums +from . import typehints # pylint: disable=unused-import +from .typehints import BlpapiEventHandle + + +# pylint: disable=too-many-arguments,protected-access,bare-except +class SubscriptionPreprocessMode(Enum): + """The modes that can be used for the :meth:`Session.subscribe()` and + :meth:`Session.resubscribe()` operations.""" + + FAIL_ON_FIRST_ERROR = 1 + """In this mode, an exception is raised on the first invalid entry in the + :class:`SubscriptionList`, and the entire batch will be considered failed. + Otherwise, all the subscriptions will move forward and the method returns + ``None``.""" + + RETURN_INDIVIDUAL_ERRORS = 2 + """In this mode, instead of raising exceptions, a list of + :class:`SubscriptionPreprocessError` is returned, each representing an + error due to an invalid subscription in the :class:`SubscriptionList`. The + valid subscriptions will move forward.""" + + +class Session(AbstractSession, metaclass=MetaClassForClassesWithEnums): + r"""Consumer session for making requests for Bloomberg services. + + This class provides a consumer session for making requests for Bloomberg + services. For information on generic session operations, see the parent + class: :class:`AbstractSession`. + + Sessions manage access to services either by requests and responses or + subscriptions. A Session can dispatch events and replies in either a + synchronous or asynchronous mode. The mode of a Session is determined when + it is constructed and cannot be changed subsequently. + + A Session is asynchronous if an ``eventHandler`` argument is supplied when + it is constructed. The ``nextEvent()`` method may not be called. All + incoming events are delivered to the ``eventHandler`` supplied on + construction. + + If supplied, ``eventHandler`` must be a callable object that takes two + arguments: received :class:`Event` and related session. + + A Session is synchronous if an ``eventHandler`` argument is not supplied + when it is constructed. The :meth:`nextEvent()` method must be called to + read incoming events. + + Several methods in Session take a :class:`CorrelationId` parameter. The + application may choose to supply its own :class:`CorrelationId` values or + allow the Session to create values. If the application supplies its own + :class:`CorrelationId` values it must manage their lifetime such that the + same value is not reused for more than one operation at a time. The + lifetime of a :class:`CorrelationId` begins when it is supplied in a method + invoked on a Session and ends either when it is explicitly cancelled using + :meth:`cancel()` or :meth:`unsubscribe()`, when a :attr:`~Event.RESPONSE` + :class:`Event` (not a :attr:`~Event.PARTIAL_RESPONSE`) containing it is + received or when a :attr:`~Event.SUBSCRIPTION_STATUS` :class:`Event` which + indicates that the subscription it refers to has been terminated is + received. + + When using an asynchronous Session, the application must be aware that + because the callbacks are generated from another thread, they may be + processed before the call which generates them has returned. For example, + the :attr:`~Event.SESSION_STATUS` :class:`Event` generated by a + :meth:`startAsync()` may be processed before :meth:`startAsync()` has + returned (even though :meth:`startAsync()` itself will not block). + + This becomes more significant when Session generated + :class:`CorrelationId`\s are in use. For example, if a call to + :meth:`subscribe()` which returns a Session generated + :class:`CorrelationId` has not completed before the first :class:`Event`\s + which contain that :class:`CorrelationId` arrive the application may not be + able to interpret those events correctly. For this reason, it is preferable + to use user generated :class:`CorrelationId`\s when using asynchronous + Sessions. This issue does not arise when using a synchronous Session as + long as the calls to :meth:`subscribe()` etc. are made on the same thread + as the calls to :meth:`nextEvent()`. + + The class attributes represent the states in which a subscription can be. + """ + + UNSUBSCRIBED = internals.SUBSCRIPTIONSTATUS_UNSUBSCRIBED + """No longer active, terminated by API.""" + SUBSCRIBING = internals.SUBSCRIPTIONSTATUS_SUBSCRIBING + """Initiated but no updates received.""" + SUBSCRIBED = internals.SUBSCRIPTIONSTATUS_SUBSCRIBED + """Updates are flowing.""" + CANCELLED = internals.SUBSCRIPTIONSTATUS_CANCELLED + """No longer active, terminated by Application.""" + PENDING_CANCELLATION = internals.SUBSCRIPTIONSTATUS_PENDING_CANCELLATION + """No longer active, terminated by Application.""" + + @staticmethod + def __dispatchEvent( + sessionRef: "ReferenceType[Session]", eventHandle: BlpapiEventHandle + ) -> None: # pragma: no cover + """event dispatcher""" + try: + session = sessionRef() + if session is not None: + event = Event(eventHandle, {session}) + session.__handler(event, session) + except: + print("Exception in event handler:", file=sys.stderr) + traceback.print_exc(file=sys.stderr) + os._exit(1) + + def __init__( + self, + options: Optional[SessionOptions] = None, + eventHandler: Optional[Callable[[Event, Session], None]] = None, + eventDispatcher: Optional["typehints.EventDispatcher"] = None, + ) -> None: + """Create a consumer :class:`Session`. + + Args: + options: Options to construct the session with + eventHandler: Handler for events + generated by the session. Takes two arguments - received event + and related session + eventDispatcher: An optional dispatcher for events. + + Raises: + InvalidArgumentException: If ``eventHandler`` is ``None`` and and + the ``eventDispatcher`` is not ``None`` + + If ``eventHandler`` is not ``None`` then this :class:`Session` will + operate in asynchronous mode, otherwise the :class:`Session` will + operate in synchronous mode. + + If ``eventDispatcher`` is ``None`` then the :class:`Session` will + create a default :class:`EventDispatcher` for this :class:`Session` + which will use a single thread for dispatching events. For more control + over event dispatching a specific instance of :class:`EventDispatcher` + can be supplied. This can be used to share a single + :class:`EventDispatcher` amongst multiple :class:`Session` objects. + + If an ``eventDispatcher`` is supplied which uses more than one thread + the :class:`Session` will ensure that events which should be ordered + are passed to callbacks in a correct order. For example, partial + response to a request or updates to a single subscription. + + Each ``eventDispatcher`` uses it's own thread or pool of threads so if + you want to ensure that a session which receives very large messages + and takes a long time to process them does not delay a session that + receives small messages and processes each one very quickly then give + each one a separate ``eventDispatcher``. + + Note: + In case of unhandled exception in ``eventHandler``, the exception + traceback will be printed to ``sys.stderr`` and application will be + terminated with nonzero exit code. + """ + if (eventHandler is None) and (eventDispatcher is not None): + raise exception.InvalidArgumentException( + "eventDispatcher is specified but eventHandler is None", 0 + ) + if options is None: + options = SessionOptions() + self.__handlerProxy = None + if eventHandler is not None: + # pylint: disable=unused-private-member + self.__handler = eventHandler + self.__handlerProxy = functools.partial( + Session.__dispatchEvent, ref(self) + ) + + # Note __handle in Session is not the __handle + # in/of AbstractSession base class + self.__handle = internals.Session_createHelper( + get_handle(options), + self.__handlerProxy, + get_handle(eventDispatcher), + ) + + def _dtor(handle: Any) -> None: + atexit.unregister(self.stop) + internals.Session_destroyHelper(handle, self.__handlerProxy) + + atexit.register(self.stop) # we must stop session before shutdown + + AbstractSession.__init__( + self, + self.__handle, + internals.blpapi_Session_getAbstractSession(self.__handle), + _dtor, + ) + + def _session_handle(self) -> Any: + """This is for internal implementation only""" + # `_handle()` returns `blpapi_AbstractSession_t *`, but there are times + # when we need `blpapi_Session_t *` instead. + return self.__handle + + def start(self) -> bool: + """Start this :class:`Session` in synchronous mode. + + Returns: + ``True`` if the :class:`Session` started successfully, + ``False`` otherwise. + + Attempt to start this :class:`Session` and block until the + :class:`Session` has started or failed to start. Before + :meth:`start()` returns a :attr:`~Event.SESSION_STATUS` :class:`Event` + is generated. A :class:`Session` may only be started once. + """ + return internals.blpapi_Session_start(self.__handle) == 0 + + def startAsync(self) -> bool: + """Start this :class:`Session` in asynchronous mode. + + Returns: + ``True`` if the process to start a :class:`Session` began + successfully, ``False`` otherwise. + + Attempt to begin the process to start this :class:`Session`. The + application must monitor events for a :attr:`~Event.SESSION_STATUS` + :class:`Event` which will be generated once the :class:`Session` has + started or if it fails to start. The :attr:`~Event.SESSION_STATUS` + :class:`Event` may be processed by the registered ``eventHandler`` + before :meth:`startAsync()` has returned. A :class:`Session` may only + be started once. + """ + return internals.blpapi_Session_startAsync(self.__handle) == 0 + + def stop(self) -> bool: + """Stop operation of this :class:`Session` and wait until it stops. + + Returns: + ``True`` if the :class:`Session` stopped successfully, + ``False`` otherwise. + + Stop operation of this :class:`Session` and block until all callbacks + to ``eventHandler`` objects relating to this :class:`Session` which are + currently in progress have completed (including the callback to handle + the :class:`~Event.SESSION_STATUS` :class:`Event` this call generates). + Once this returns no further callbacks to ``eventHandlers`` will occur. + If :meth:`stop()` is called from within an ``eventHandler`` callback it + is silently converted to a :meth:`stopAsync()` in order to prevent + deadlock. Once a :class:`Session` has been stopped it can only be + destroyed. + """ + atexit.unregister(self.stop) + return internals.blpapi_Session_stop(self.__handle) == 0 + + def stopAsync(self) -> bool: + """Begin the process to stop this Session and return immediately. + + Returns: + ``True`` if the process to stop a :class:`Session` began + successfully, ``False`` otherwise. + + The application must monitor events for a :attr:`~Event.SESSION_STATUS` + :class:`Event` which will be generated once the :class:`Session` has + been stopped. After this :attr:`~Event.SESSION_STATUS` :class:`Event` + no further callbacks to ``eventHandlers`` will occur. Once a + :class:`Session` has been stopped it can only be destroyed. + """ + return internals.blpapi_Session_stopAsync(self.__handle) == 0 + + def nextEvent(self, timeout: int = 0) -> Event: + """ + Args: + timeout: Timeout threshold in milliseconds + + Returns: + Event: Next available event for this session + + Raises: + InvalidStateException: If invoked on a session created in + asynchronous mode + + If there is no :class:`Event` available this will block for up to the + specified ``timeout`` milliseconds for an :class:`Event` to arrive. A + value of ``0`` for ``timeout`` (the default) indicates + :meth:`nextEvent()` should not timeout and will not return until the + next :class:`Event` is available. + + If :meth:`nextEvent()` returns due to a timeout it will return an event + of type :attr:`~Event.TIMEOUT`. + """ + retCode, event = internals.blpapi_Session_nextEvent( + self.__handle, timeout + ) + + _ExceptionUtil.raiseOnError(retCode) + + return Event(event, {self}) + + def tryNextEvent(self) -> Optional[Event]: + r""" + Returns: + Event: Next available event for this session + + If there are :class:`Event`\s available for the session, return the + next :class:`Event` If there is no event available for the + :class:`Session`, return ``None``. This method never blocks. + """ + retCode, event = internals.blpapi_Session_tryNextEvent(self.__handle) + if retCode: + return None + return Event(event, {self}) + + @staticmethod + def _createErrorAppender( + errorList: List[SubscriptionPreprocessError], + ) -> Callable: + def errorAppender( + correlationId: CorrelationId, + subscriptionString: str, + errorCode: int, + description: str, + ) -> None: + errorList.append( + SubscriptionPreprocessError( + correlationId, + subscriptionString, + SubscriptionPreprocessError.ErrorCode(errorCode), + description, + ) + ) + + return errorAppender + + def subscribe( + self, + subscriptionList: "typehints.SubscriptionList", + identity: Optional["typehints.Identity"] = None, + requestLabel: Optional[str] = None, + mode: SubscriptionPreprocessMode = SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR, + ) -> Optional[List[SubscriptionPreprocessError]]: + """Begin subscriptions for each entry in the specified list. + + Args: + subscriptionList: List of subscriptions to begin + identity: Identity used for authorization + requestLabel: String which will be recorded along with any + diagnostics for this operation + mode: Mode to use for this operation. + See :class:`SubscriptionPreprocessMode` for an explanation of + the available modes. + + Returns: + If mode is :attr:`~SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR`, + then ``None`` is returned. If mode is + :attr:`~SubscriptionPreprocessMode.RETURN_INDIVIDUAL_ERRORS`, + then a list of :class:`SubscriptionPreprocessError` is + returned. + + Begin subscriptions for each entry in the specified + ``subscriptionList``, which must be an object of type + :class:`SubscriptionList`, optionally using the specified ``identity`` + for authorization. If no ``identity`` is specified, the default + authorization information is used. If the optional ``requestLabel`` is + provided it defines a string which will be recorded along with any + diagnostics for this operation. + + A :attr:`~Event.SUBSCRIPTION_STATUS` :class:`Event` will be generated + for each entry in the ``subscriptionList``. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + subMode = SubscriptionPreprocessMode(mode) + + if subMode == SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR: + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_subscribe( + self.__handle, + get_handle(subscriptionList), + get_handle(identity), + requestLabel, + ) + ) + elif subMode == SubscriptionPreprocessMode.RETURN_INDIVIDUAL_ERRORS: + errorList: List[SubscriptionPreprocessError] = [] + errorAppender = Session._createErrorAppender(errorList) + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_subscribeEx_helper( + self.__handle, + get_handle(subscriptionList), + get_handle(identity), + requestLabel, + errorAppender, + ) + ) + + return errorList + else: + raise exception.InvalidArgumentException( + "Unsupported SubscriptionPreprocessMode: '{}'".format(mode), 0 + ) + return None + + def unsubscribe( + self, subscriptionList: "typehints.SubscriptionList" + ) -> None: + """Cancel subscriptions from the specified ``subscriptionList``. + + Args: + subscriptionList: List of subscriptions to cancel + + Cancel each of the current subscriptions identified by the specified + ``subscriptionList``, which must be an object of type + :class:`SubscriptionList`. If the correlation ID of any entry in the + ``subscriptionList`` does not identify a current subscription then that + entry is ignored. All entries which have valid correlation IDs will be + cancelled. + + Once this call returns the correlation ids in the ``subscriptionList`` + will not be seen in any subsequent :class:`Message` obtained from a + ``MessageIterator`` by calling ``next()`` However, any :class:`Message` + currently pointed to by a ``MessageIterator`` when + :meth:`unsubscribe()` is called is not affected even if it has one of + the correlation IDs in the ``subscriptionList``. Also any + :class:`Message` where a reference has been retained by the application + may still contain a correlation ID from the ``subscriptionList``. For + these reasons, although technically an application is free to re-use + the correlation IDs as soon as this method returns it is preferable not + to aggressively re-use correlation IDs, particularly with an + asynchronous :class:`Session`. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_unsubscribe( + self.__handle, get_handle(subscriptionList), None + ) + ) + + def resubscribe( + self, + subscriptionList: "typehints.SubscriptionList", + requestLabel: Optional[str] = None, + resubscriptionId: Optional[int] = None, + mode: SubscriptionPreprocessMode = SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR, + ) -> Optional[List[SubscriptionPreprocessError]]: + """Modify subscriptions in ``subscriptionList``. + + Args: + subscriptionList: List of subscriptions to modify + requestLabel: String which will be recorded along with any + diagnostics for this operation + resubscriptionId: An id that will be included in the event + generated from this operation + mode: Mode to use for this operation. + See :class:`SubscriptionPreprocessMode` for an explanation of + the available modes. + + Returns: + If mode is :attr:`~SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR`, + then ``None`` is returned. If mode is + :attr:`~SubscriptionPreprocessMode.RETURN_INDIVIDUAL_ERRORS`, + then a list of :class:`SubscriptionPreprocessError` is + returned. + + Modify each subscription in the specified ``subscriptionList``, which + must be an object of type :class:`SubscriptionList`, to reflect the + modified options specified for it. If the optional ``requestLabel`` is + provided it defines a string which will be recorded along with any + diagnostics for this operation. + + For each entry in the ``subscriptionList`` which has a correlation ID + which identifies a current subscription the modified options replace + the current options for the subscription and a + :attr:`~Event.SUBSCRIPTION_STATUS` :class:`Event` (containing the + ``resubscriptionId`` if specified) will be generated in the event + stream before the first update based on the new options. If the + correlation ID of an entry in the ``subscriptionList`` does not + identify a current subscription then that entry is ignored. + """ + subMode = SubscriptionPreprocessMode(mode) + + if subMode == SubscriptionPreprocessMode.FAIL_ON_FIRST_ERROR: + if resubscriptionId is None: + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_resubscribe( + self.__handle, + get_handle(subscriptionList), + requestLabel, + ) + ) + else: + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_resubscribeWithId( + self.__handle, + get_handle(subscriptionList), + resubscriptionId, # an int, not a cid + requestLabel, + ) + ) + elif subMode == SubscriptionPreprocessMode.RETURN_INDIVIDUAL_ERRORS: + errorList: List[SubscriptionPreprocessError] = [] + errorAppender = Session._createErrorAppender(errorList) + + if resubscriptionId is None: + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_resubscribeEx_helper( + self.__handle, + get_handle(subscriptionList), + requestLabel, + errorAppender, + ) + ) + else: + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_resubscribeWithIdEx_helper( + self.__handle, + get_handle(subscriptionList), + resubscriptionId, # an int, not a cid + requestLabel, + errorAppender, + ) + ) + + return errorList + else: + raise exception.InvalidArgumentException( + "Unsupported SubscriptionPreprocessMode: '{}'".format(mode), 0 + ) + return None + + def setStatusCorrelationId( + self, + service: "typehints.Service", + correlationId: CorrelationId, + identity: Optional["typehints.Identity"] = None, + ) -> None: + """Set the Correlation id on which service status messages will be + received. + + Args: + service: The service from which the status messages + are received + correlationId: Correlation id to associate with the + service status messages + identity: Identity used for authorization + + Note: + No service status messages are received prior to this call + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_Session_setStatusCorrelationId( + self.__handle, + get_handle(service), + get_handle(identity), + correlationId, + ) + ) + + def sendRequest( + self, + request: "typehints.Request", + identity: Optional["typehints.Identity"] = None, + correlationId: Optional[CorrelationId] = None, + eventQueue: Optional["typehints.EventQueue"] = None, + requestLabel: Optional[str] = None, + ) -> CorrelationId: + r"""Send the specified ``request``. + + Args: + request: Request to send + identity: Identity used for authorization + correlationId: Correlation id to associate with the + request + eventQueue: Event queue on which the events related to + this operation will arrive + requestLabel: String which will be recorded along with any + diagnostics for this operation + + Returns: + CorrelationId: The actual correlation id associated with the + request + + Send the specified ``request`` using the optionally specified + ``identity`` for authorization. If ``identity`` is not provided, then + the request will be sent using the session identity. If the optionally + specified ``correlationId`` is supplied use it, otherwise create a + :class:`CorrelationId`. The actual :class:`CorrelationId` used is + returned. If the optionally specified ``eventQueue`` is supplied all + events relating to this :class:`Request` will arrive on that + :class:`EventQueue`. If the optional ``requestLabel`` is provided it + defines a string which will be recorded along with any diagnostics for + this operation. + + A successful request will generate zero or more + :class:`~Event.PARTIAL_RESPONSE` :class:`Message`\s followed by + exactly one :class:`~Event.RESPONSE` :class:`Message`. Once the final + :class:`~Event.RESPONSE` :class:`Message` has been received the + :class:`CorrelationId` associated with this request may be re-used. If + the request fails at any stage a :class:`~Event.REQUEST_STATUS` will be + generated after which the :class:`CorrelationId` associated with the + request may be re-used. + + When ``identity`` is not provided, the session identity will be used if + it has been authorized. + """ + if correlationId is None: + correlationId = CorrelationId() + res = internals.blpapi_Session_sendRequest( + self.__handle, + get_handle(request), + correlationId, + get_handle(identity), + get_handle(eventQueue), + requestLabel, + ) + _ExceptionUtil.raiseOnError(res) + if eventQueue is not None: + eventQueue._registerSession(self) + return correlationId + + def sendRequestTemplate( + self, + requestTemplate: RequestTemplate, + correlationId: Optional[CorrelationId] = None, + ) -> CorrelationId: + """Send a request defined by the specified ``requestTemplate``. + + Args: + requestTemplate: Template that defines the + request + correlationId: Correlation id to associate with the + request + + Returns: + CorrelationId: The actual correlation id used for the request is + returned. + + If the optionally specified ``correlationId`` is supplied, use it + otherwise create a new :class:`CorrelationId`. The actual + :class:`CorrelationId` used is returned. + + A successful request will generate zero or more + :attr:`~Event.PARTIAL_RESPONSE` events followed by exactly one + :attr:`~Event.RESPONSE` event. Once the final :attr:`~Event.RESPONSE` + event has been received the ``CorrelationId`` associated with this + request may be re-used. If the request fails at any stage a + :attr:`~Event.REQUEST_STATUS` will be generated after which the + ``CorrelationId`` associated with the request may be re-used. + """ + if correlationId is None: + correlationId = CorrelationId() + res = internals.blpapi_Session_sendRequestTemplate( + self.__handle, get_handle(requestTemplate), correlationId + ) + _ExceptionUtil.raiseOnError(res) + return correlationId + + def createSnapshotRequestTemplate( + self, + subscriptionString: str, + correlationId: CorrelationId, + identity: Optional["typehints.Identity"] = None, + ) -> RequestTemplate: + """Create a snapshot request template for getting subscription data + specified by the ``subscriptionString`` using the specified + ``identity``. + + Args: + subscriptionString: String that specifies the subscription + correlationId: Correlation id to associate with + events generated by this operation + identity: Optional. Identity used for authorization. + + Returns: + RequestTemplate: Created request template + + Raises: + Exception: If one or more of the following conditions is not met: + the session is established, ``subscriptionString`` is a valid + subscription string and ``correlationId`` is not used in this + session. + + The provided ``correlationId`` will be used for status updates about + the created request template state and an implied subscription + associated with it delivered by :attr:`~Event.SUBSCRIPTION_STATUS` + events. + + The benefit of the snapshot request templates is that these requests + may be serviced from a cache and the user may expect to see + significantly lower response time. + + There are 3 possible states for a created request template: + ``Pending``, ``Available``, and ``Terminated``. Right after creation a + request template is in the ``Pending`` state. + + If a state is ``Pending``, the user may send a request using this + template but there are no guarantees about response time since cache + is not available yet. Request template may transition into ``Pending`` + state only from the ``Available`` state. In this case the + ``RequestTemplatePending`` message is generated. + + If state is ``Available``, all requests will be serviced from a cache + and the user may expect to see significantly reduced latency. Note, + that a snapshot request template can transition out of the + ``Available`` state concurrently with requests being sent, so no + guarantee of service from the cache can be provided. Request + template may transition into ``Available`` state only from the + ``Pending`` state. In this case the ``RequestTemplateAvailable`` message + is generated. This message will also contain information about + currently used connection in the ``boundTo`` field. Note that it is + possible to get the ``RequestTemplateAvailable`` message with a new + connection information, even if a request template is already in the + ``Available`` state. + + If state is ``Terminated``, sending request will always result in a + failure response. Request template may transition into this state from + any other state. This is a final state and it is guaranteed that the + last message associated with the provided ``correlationId`` will be the + ``RequestTemplateTerminated`` message which is generated when a request + template transitions into this state. If a request template transitions + into this state, all outstanding requests will be failed and + appropriate messages will be generated for each request. After + receiving the ``RequestTemplateTerminated`` message, ``correlationId`` + may be reused. + + Note that resources used by a snapshot request template are released + only when request template transitions into the ``Terminated`` state + or when session is destroyed. In order to release resources when + request template is not needed anymore, user should call the + :meth:`cancel()` method unless the ``RequestTemplateTerminated`` + message was already received due to some problems. When the last + copy of a ``RequestTemplate`` object goes out of scope and there are + no outstanding requests left, the snapshot request template will be + destroyed automatically. If the last copy of a ``RequestTemplate`` + object goes out of scope while there are still some outstanding + requests left, snapshot service request template will be destroyed + automatically when the last request gets a final response. + + When ``identity`` is ``None``, the session identity will be used if it + has been authorized. + """ + + # We changed the order of last two arguments, but + # old clients may have them swapped at call site. + # This detects the swap and calls the method correctly. + # It causes mypy to complain about an unreachable statement + # so we add # type: ignore to suppress it + + # Note: cid may never be None, only identity is allowed None + # Hence, in the swapped case identity must be of type CorrelationId + if isinstance(correlationId, CorrelationId): + ( + rc, + template, + ) = internals.blpapi_Session_createSnapshotRequestTemplate( + self.__handle, + subscriptionString, + get_handle(identity), + correlationId, + ) + elif isinstance(identity, CorrelationId): # type: ignore + ( + rc, + template, + ) = internals.blpapi_Session_createSnapshotRequestTemplate( + self.__handle, + subscriptionString, + get_handle(correlationId), + identity, + ) + else: + raise exception.InvalidArgumentException( + "Invalid CorrelationId", 0 + ) + _ExceptionUtil.raiseOnError(rc) + reqTemplate = RequestTemplate(template) + return reqTemplate + + +class SubscriptionPreprocessError: + """Class representing an error due to an invalid subscription.""" + + class ErrorCode(Enum): + """The error codes used by :class:`SubscriptionPreprocessError`.""" + + SUBSCRIPTIONPREPROCESS_INVALID_SUBSCRIPTION_STRING = ( + internals.SUBSCRIPTIONPREPROCESS_INVALID_SUBSCRIPTION_STRING + ) + """Error due to an invalid subscription string.""" + + SUBSCRIPTIONPREPROCESS_CORRELATIONID_ERROR = ( + internals.SUBSCRIPTIONPREPROCESS_CORRELATIONID_ERROR + ) + """Error due to misuse of correlation id, such as using a duplicate.""" + + def __init__( + self, + correlationId: CorrelationId, + subscriptionString: str, + errorCode: SubscriptionPreprocessError.ErrorCode, + description: str, + ) -> None: + self.correlationId = correlationId + self.subscriptionString = subscriptionString + self.errorCode = errorCode + self.description = description + + def __str__(self) -> str: + return ( + f"{{correlationId: {self.correlationId}" + f", subscriptionString: {self.subscriptionString}" + f", code: {self.errorCode}" + f", description: {self.description}}}" + ) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/sessionoptions.py b/src/blpapi/sessionoptions.py new file mode 100644 index 0000000..ace2ba3 --- /dev/null +++ b/src/blpapi/sessionoptions.py @@ -0,0 +1,1107 @@ +# sessionoptions.py + +"""A common interface shared between publish and consumer sessions. + +This file defines a 'SessionOptions' class which is used to specify various +options during session creation. + +Usage +----- + +The following snippet shows how to use the SessionOptions when creating a +'Session'. + + sessionOptions = blpapi.SessionOptions() + sessionOptions.setServerHost(options.host) + sessionOptions.setServerPort(options.port) + session = blpapi.Session(sessionOptions) + if not session.start(): + raise Exception("Can't start session.") + +""" + +from __future__ import annotations +from typing import Iterator, Optional, Sequence, Tuple, Union +from .typehints import BlpapiTlsOptionsHandle +from .exception import _ExceptionUtil +from . import AuthOptions +from . import CorrelationId +from . import internals +from . import utils +from .utils import get_handle +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + + +class Socks5Config(CHandle): + """Configuration to be used to specify a SOCKS5 proxy""" + + def __init__(self, hostname: str, port: int) -> None: + """ + Args: + hostname: hostname of the SOCKS5 proxy + port: port of the SOCKS5 proxy. Must be between 1 and 65535 + + Creates an object that defines a SOCKS5 proxy. + """ + SessionOptions._validatePort(port) + + self.__handle = internals.blpapi_Socks5Config_create(hostname, port) + super(Socks5Config, self).__init__( + self.__handle, internals.blpapi_Socks5Config_destroy + ) + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Returns a string representation of this :class:`Socks5Config`. Calling + 'str(socks5Config)' is equivalent to calling 'socks5Config.toString()' + with default parameters. + + """ + return self.toString() + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Formats this :class:`Socks5Config` to the string. + + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This object formatted as a string + + If ``level`` is negative, suppresses indentation of the first line. If + ``spacesPerLevel`` is negative, formats the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + return internals.blpapi_Socks5Config_printHelper( + self.__handle, level, spacesPerLevel + ) + + +# pylint: disable=too-many-public-methods +class SessionOptions(CHandle, metaclass=utils.MetaClassForClassesWithEnums): + """Options which the user can specify when creating a session. + + To use non-default options on a :class:`Session`, create a + :class:`SessionOptions` instance and set the required options and then + supply it when creating a :class:`Session`. + + The class attributes represent the possible options for how to connect to + the API. + """ + + AUTO = internals.CLIENTMODE_AUTO + """Automatic (desktop if available otherwise server)""" + DAPI = internals.CLIENTMODE_DAPI + """Always connect to the desktop API""" + SAPI = internals.CLIENTMODE_SAPI + """Always connect to the server API""" + + def __init__(self) -> None: + """Create a :class:`SessionOptions` with all options set to the + defaults""" + selfhandle = internals.blpapi_SessionOptions_create() + super(SessionOptions, self).__init__( + selfhandle, internals.blpapi_SessionOptions_destroy + ) + self.__handle = selfhandle + + def __str__(self) -> str: + """x.__str__() <==> str(x) + + Return a string representation of this SessionOptions. Call of + 'str(options)' is equivalent to 'options.toString()' called with + default parameters. + + """ + return self.toString() + + def setServerHost(self, serverHost: str) -> None: + """Set the API server host to connect to when using the server API. + + Args: + serverHost: Server host + + Set the API server host to connect to when using the server API to the + specified ``serverHost``. The server host is either a hostname or an + IPv4 address (that is, ``a.b.c.d``). The default is ``127.0.0.1``. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setServerHost( + self.__handle, serverHost + ) + ) + + def setServerPort(self, serverPort: int) -> None: + """Set the port to connect to when using the server API. + + Args: + serverPort: Server port. Must be between 1 and 65535 + + Set the port to connect to when using the server API to the specified + ``serverPort``. The default is ``8194``. + """ + SessionOptions._validatePort(serverPort) + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setServerPort( + self.__handle, serverPort + ) + ) + + def setServerAddress( + self, + serverHost: str, + serverPort: int, + index: int, + socks5Config: Optional[Socks5Config] = None, + ) -> None: + """Set the server address at the specified ``index``. + + Args: + serverHost: Server host + serverPort: Server port. Must be between 1 and 65535 + index: Index to set the address at + socks5Config: Optional. SOCKS5 proxy configuration + + Set the server address at the specified ``index`` using the specified + ``serverHost`` and ``serverPort``. + """ + SessionOptions._validatePort(serverPort) + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setServerAddressWithProxy( + self.__handle, + serverHost, + serverPort, + get_handle(socks5Config), + index, + ) + ) + + def removeServerAddress(self, index: int) -> None: + """Remove the server address at the specified ``index``. + + Args: + index: Index to remove the address at + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_removeServerAddress( + self.__handle, index + ) + ) + + def setConnectTimeout(self, timeoutMilliSeconds: int) -> None: + """Set the connection timeout in milliseconds. + + Args: + timeoutMilliSeconds: Timeout threshold in milliseconds + + Set the connection timeout in milliseconds when connecting to the API. + The default is ``5000`` milliseconds. Behavior is not defined unless + the specified ``timeoutMilliSeconds`` is in range of ``[1 .. 120000]`` + milliseconds. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setConnectTimeout( + self.__handle, timeoutMilliSeconds + ) + ) + + def setDefaultServices(self, defaultServices: Sequence[str]) -> None: + """Set the default service for the session. + + Args: + defaultServices: The default services + + **DEPRECATED** + + Set the default service for the session. This function is deprecated; + see :meth:`setDefaultSubscriptionService()`. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setDefaultServices( + self.__handle, defaultServices + ) + ) + + def setDefaultSubscriptionService( + self, defaultSubscriptionService: str + ) -> None: + """Set the default service for subscriptions. + + Args: + defaultSubscriptionService: Identifier for the service to be + used as default + + Set the default service for subscriptions which do not specify a + subscription server to the specified ``defaultSubscriptionService``. + The behavior is undefined unless ``defaultSubscriptionService`` matches + the regular expression ``^//[-_.a-zA-Z0-9]+/[-_.a-zA-Z0-9]+$``. The + default is ``//blp/mktdata``. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setDefaultSubscriptionService( + self.__handle, defaultSubscriptionService + ) + ) + + def setDefaultTopicPrefix(self, prefix: str) -> None: + """Set the default topic prefix. + + Args: + prefix: The topic prefix to set + + Set the default topic prefix to be used when a subscription does not + specify a prefix to the specified ``prefix``. The default is + ``/ticker/``. + """ + + internals.blpapi_SessionOptions_setDefaultTopicPrefix( + self.__handle, prefix + ) + + def setAllowMultipleCorrelatorsPerMsg( + self, allowMultipleCorrelatorsPerMsg: bool + ) -> None: + """Associate more than one :class:`CorrelationId` with a + :class:`Message`. + + Args: + allowMultipleCorrelatorsPerMsg: Value to set the option to + + Set whether the :class:`Session` is allowed to associate more than one + :class:`CorrelationId` with a :class:`Message` to the specified + ``allowMultipleCorrelatorsPerMsg``. The default is ``False``. This + means that if you have multiple subscriptions which overlap (that is a + particular :class:`Message` is relevant to all of them) you will be + presented with the same message multiple times when you use the + ``MessageIterator``, each time with a different :class:`CorrelationId`. + If you specify ``True`` for this then a :class:`Message` may be + presented with multiple :class:`CorrelationId`'s. + """ + + internals.blpapi_SessionOptions_setAllowMultipleCorrelatorsPerMsg( + self.__handle, allowMultipleCorrelatorsPerMsg + ) + + def setClientMode(self, clientMode: int) -> None: + """Set how to connect to the API. The default is :attr:`AUTO`. + + Args: + clientMode: The client mode + + Set how to connect to the API. The default is :attr:`AUTO` which will + try to connect to the desktop API but fall back to the server API if + the desktop is not available. :attr:`DAPI` always connects to the + desktop API and will fail if it is not available. :attr:`SAPI` always + connects to the server API and will fail if it is not available. + """ + + internals.blpapi_SessionOptions_setClientMode( + self.__handle, clientMode + ) + + def setMaxPendingRequests(self, maxPendingRequests: int) -> None: + """Set the maximum number of requests which can be pending. + + Args: + maxPendingRequests: Maximum number of pending requests + + Set the maximum number of requests which can be pending to the + specified ``maxPendingRequests``. The default is ``1024``. + """ + + internals.blpapi_SessionOptions_setMaxPendingRequests( + self.__handle, maxPendingRequests + ) + + def setSessionIdentityOptions( + self, + authOptions: Optional[AuthOptions], + correlationId: Optional[CorrelationId] = None, + ) -> CorrelationId: + """Sets the specified ``authOptions`` as the :class:`AuthOptions` for + the session identity, enabling automatic authorization of the session + identity during startup. + + Args: + authOptions: the authorization options to use for the + session identity. + correlationId: Optional. Used to identify the + messages associated with the session identity. + + Returns: + CorrelationId: The actual :class:`CorrelationId` that identifies + the messages associated with the session identity. + + The session identity lifetime is tied to the session's lifetime, so it + is guaranteed that the session identity will remain authorized during + the entire duration of the session. The identity will be authorized + before the session starts. The session will terminate if the identity + fails to authorize or is revoked. + + The session identity is used to send requests and make subscriptions if + no other identity is provided. + + By default the session identity is not authorized. + + It is possible to pass ``None`` as ``authOptions``, to reset this value + to its default state. + """ + if correlationId is None: + correlationId = CorrelationId() + + if authOptions is None: + # Use an 'empty' authoptions instance to reset the value + ( + retcode, + authOptions_handle, + ) = internals.blpapi_AuthOptions_create_default() + _ExceptionUtil.raiseOnError(retcode) + authOptions = AuthOptions(authOptions_handle) + + ( + retcode, + actualcid, + ) = internals.blpapi_SessionOptions_setSessionIdentityOptions( + self._handle(), get_handle(authOptions), correlationId + ) + _ExceptionUtil.raiseOnError(retcode) + return actualcid + + def setAuthenticationOptions(self, authOptions: str) -> None: + """Set the specified ``authOptions`` as the authentication options. + + Args: + authOptions: The options used during authentication. + """ + internals.blpapi_SessionOptions_setAuthenticationOptions( + self.__handle, authOptions + ) + + def setNumStartAttempts(self, numStartAttempts: int) -> None: + """Set the maximum number of attempts to start a session. + + Set the maximum number of attempts to start a session by connecting a + server. + """ + internals.blpapi_SessionOptions_setNumStartAttempts( + self.__handle, numStartAttempts + ) + + def setAutoRestartOnDisconnection(self, autoRestart: bool) -> None: + """Set whether automatically restarting connection if disconnected. + + Args: + autoRestart (bool): Whether to automatically restart if + disconnected + """ + internals.blpapi_SessionOptions_setAutoRestartOnDisconnection( + self.__handle, autoRestart + ) + + def setSlowConsumerWarningHiWaterMark(self, hiWaterMark: float) -> None: + """Set the point at which "slow consumer" events will be generated. + + Args: + hiWaterMark: Fraction of :meth:`maxEventQueueSize()` + + Set the point at which "slow consumer" events will be generated, using + the specified ``hiWaterMark`` as a fraction of + :meth:`maxEventQueueSize()`; the default value is ``0.75``. A warning + event will be generated when the number of outstanding undelivered + events passes above ``hiWaterMark * maxEventQueueSize()``. The + behavior of the function is undefined unless ``0.0 < hiWaterMark <= + 1.0``. Further, at the time that :meth:`Session.start()` is called, it + must be the case that ``slowConsumerWarningLoWaterMark() * + maxEventQueueSize()`` < ``slowConsumerWarningHiWaterMark() * + maxEventQueueSize()``. + """ + err = ( + internals.blpapi_SessionOptions_setSlowConsumerWarningHiWaterMark( + self.__handle, hiWaterMark + ) + ) + _ExceptionUtil.raiseOnError(err) + + def setSlowConsumerWarningLoWaterMark(self, loWaterMark: float) -> None: + """Set the point at which "slow consumer cleared" events will be + generated + + Args: + loWaterMark: Fraction of :meth:`maxEventQueueSize()` + + Set the point at which "slow consumer cleared" events will be + generated, using the specified ``loWaterMark`` as a fraction of + :meth:`maxEventQueueSize()`; the default value is ``0.5``. A warning + cleared event will be generated when the number of outstanding + undelivered events drops below ``loWaterMark * maxEventQueueSize``. + The behavior of the function is undefined unless ``0.0 <= loWaterMark < + 1.0``. Further, at the time that :meth:`Session.start()` is called, it + must be the case that ``slowConsumerWarningLoWaterMark() * + maxEventQueueSize()`` < ``slowConsumerWarningHiWaterMark() * + maxEventQueueSize()``. + """ + err = ( + internals.blpapi_SessionOptions_setSlowConsumerWarningLoWaterMark( + self.__handle, loWaterMark + ) + ) + _ExceptionUtil.raiseOnError(err) + + def setMaxEventQueueSize(self, eventQueueSize: int) -> None: + """Set the maximum number of outstanding undelivered events per + session. + + Args: + eventQueueSize: Maximum number of outstanding undelivered + events + + Set the maximum number of outstanding undelivered events per session to + the specified ``eventQueueSize``. All subsequent events delivered over + the network will be dropped by the session if the number of outstanding + undelivered events is ``eventQueueSize``, the specified threshold. The + default value is ``10000``. + """ + internals.blpapi_SessionOptions_setMaxEventQueueSize( + self.__handle, eventQueueSize + ) + + def setKeepAliveEnabled(self, isEnabled: bool) -> None: + """Set whether to enable keep-alive pings. + + Args: + isEnabled: Whether to enable keep-alive pings + + If the specified ``isEnabled`` is ``False``, then disable all + keep-alive mechanisms, both from the client to the server and from the + server to the client; otherwise enable keep-alive pings both from the + client to the server (as configured by + :meth:`setDefaultKeepAliveInactivityTime()` and + :meth:`setDefaultKeepAliveResponseTimeout()` if the connection supports + ping-based keep-alives), and from the server to the client as specified + by the server configuration. + """ + keepAliveValue = 1 if isEnabled else 0 + err = internals.blpapi_SessionOptions_setKeepAliveEnabled( + self.__handle, keepAliveValue + ) + _ExceptionUtil.raiseOnError(err) + + def setDefaultKeepAliveInactivityTime(self, inactivityMsecs: int) -> None: + """Set the amount of time that no traffic can be received before the + keep-alive mechanism is triggered. + + Args: + inactivityMsecs (int): Amount of time in milliseconds + + Set to the specified ``inactivityMsecs`` the amount of time that no + traffic can be received on a connection before the ping-based + keep-alive mechanism is triggered; if no traffic is received for this + duration then a keep-alive ping is sent to the remote end to solicit a + response. If ``inactivityMsecs == 0``, then no keep-alive pings will + be sent. The behavior of this function is undefined unless + ``inactivityMsecs`` is a non-negative value. The default value is + ``20,000`` milliseconds. + + Note: + Not all back-end connections provide ping-based keep-alives; + this option is ignored by such connections. + """ + err = ( + internals.blpapi_SessionOptions_setDefaultKeepAliveInactivityTime( + self.__handle, inactivityMsecs + ) + ) + _ExceptionUtil.raiseOnError(err) + + def setDefaultKeepAliveResponseTimeout(self, timeoutMsecs: int) -> None: + """Set the timeout for terminating the connection due to inactivity. + + Args: + timeoutMsecs: Timeout threshold in milliseconds + + When a keep-alive ping is sent, wait for the specified ``timeoutMsecs`` + to receive traffic (of any kind) before terminating the connection due + to inactivity. If ``timeoutMsecs == 0``, then connections are never + terminated due to the absence of traffic after a keep-alive ping. The + behavior of this function is undefined unless ``timeoutMsecs`` is a + non-negative value. The default value is ``5,000`` milliseconds. + + Note: + that not all back-end connections provide support for ping-based + keep-alives; this option is ignored by such connections. + """ + err = ( + internals.blpapi_SessionOptions_setDefaultKeepAliveResponseTimeout( + self.__handle, timeoutMsecs + ) + ) + _ExceptionUtil.raiseOnError(err) + + def setFlushPublishedEventsTimeout(self, timeoutMsecs: int) -> None: + """ + Args: + timeoutMsecs: Timeout threshold in milliseconds + + Set the timeout, in milliseconds, for :class:`ProviderSession` to flush + published events before stopping. The behavior is not defined unless + the specified ``timeoutMsecs`` is a positive value. The default value + is ``2000``. + """ + internals.blpapi_SessionOptions_setFlushPublishedEventsTimeout( + self.__handle, timeoutMsecs + ) + + def setRecordSubscriptionDataReceiveTimes( + self, shouldRecord: bool + ) -> None: + """ + Args: + shouldRecord: Whether to record the receipt time + + Set whether the receipt time (accessed via + :meth:`.Message.timeReceived()`) should be recorded for subscription + data messages. By default, the receipt time for these messages is not + recorded. + """ + internals.blpapi_SessionOptions_setRecordSubscriptionDataReceiveTimes( + self.__handle, shouldRecord + ) + + def setServiceCheckTimeout(self, timeoutMsecs: int) -> None: + """ + Args: + timeoutMsecs: Timeout threshold in milliseconds + + Set the timeout, in milliseconds, when opening a service for checking + what version of the schema should be downloaded. The behavior is not + defined unless ``timeoutMsecs`` is a positive value. The default + timeout is ``60,000`` milliseconds. + """ + err = internals.blpapi_SessionOptions_setServiceCheckTimeout( + self.__handle, timeoutMsecs + ) + _ExceptionUtil.raiseOnError(err) + + def setServiceDownloadTimeout(self, timeoutMsecs: int) -> None: + """ + Args: + timeoutMsecs: Timeout threshold in milliseconds + + Set the timeout, in milliseconds, when opening a service for + downloading the service schema. The behavior is not defined unless the + specified ``timeoutMsecs`` is a positive value. The default timeout is + ``120,000`` milliseconds. + """ + err = internals.blpapi_SessionOptions_setServiceDownloadTimeout( + self.__handle, timeoutMsecs + ) + _ExceptionUtil.raiseOnError(err) + + def setTlsOptions(self, tlsOptions: TlsOptions) -> None: + """Set the TLS options + + Args: + tlsOptions: The TLS options + """ + internals.blpapi_SessionOptions_setTlsOptions( + self.__handle, get_handle(tlsOptions) + ) + + def setBandwidthSaveModeDisabled(self, isDisabled: bool) -> None: + """Specify whether to disable bandwidth saving measures. + + Args: + isDisabled: Whether to disable bandwidth saving measures. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setBandwidthSaveModeDisabled( + self.__handle, isDisabled + ) + ) + + def setApplicationIdentityKey(self, applicationIdentityKey: str) -> None: + """Sets the application identity key (AIK) which uniquely identifies + this application for this session. + + Args: + applicationIdentityKey: The application identity key to set. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setApplicationIdentityKey( + self.__handle, applicationIdentityKey + ) + ) + + def applicationIdentityKey(self) -> str: + """ + Returns: + The application identity key (AIK) which uniquely identifies + this application for this session. + """ + + ( + result, + aik, + ) = internals.blpapi_SessionOptions_applicationIdentityKey( + self.__handle + ) + + _ExceptionUtil.raiseOnError(result) + return aik + + def setSessionName(self, sessionName: str) -> None: + """Set the session name which can be used to identify the log + lines pertaining to the session. + + Args: + sessionName: The session name to set. + """ + + _ExceptionUtil.raiseOnError( + internals.blpapi_SessionOptions_setSessionName( + self.__handle, sessionName + ) + ) + + def sessionName(self) -> str: + """ + Returns: + The session name. + """ + (result, sessionName) = internals.blpapi_SessionOptions_sessionName( + self.__handle + ) + + _ExceptionUtil.raiseOnError(result) + return sessionName + + def serverHost(self) -> str: + """ + Returns: + The server host option in this :class:`SessionOptions` instance. + """ + + return internals.blpapi_SessionOptions_serverHost(self.__handle) + + def serverPort(self) -> int: + """ + Returns: + The server port that this session connects to. + """ + + return internals.blpapi_SessionOptions_serverPort(self.__handle) + + def numServerAddresses(self) -> int: + """ + Returns: + The number of server addresses. + """ + + return internals.blpapi_SessionOptions_numServerAddresses( + self.__handle + ) + + def getServerAddress( + self, index: int + ) -> Tuple[str, int, Optional[Socks5Config]]: + """ + Returns: + Server name, port and optional SOCKS5 proxy configuration indexed + by ``index``. + """ + + ( + errorCode, + host, + port, + socks5Host, + socks5Port, + ) = internals.blpapi_SessionOptions_getServerAddressWithProxy( + self.__handle, index + ) + + _ExceptionUtil.raiseOnError(errorCode) + + return ( + host, + port, + Socks5Config(socks5Host, socks5Port) if socks5Host else None, + ) + + def serverAddresses(self) -> Iterator: + """ + Returns: + Iterator over server addresses for this :class:`SessionOptions`. + """ + + return utils.Iterator( + self, + SessionOptions.numServerAddresses, + SessionOptions.getServerAddress, + ) + + def connectTimeout(self) -> int: + """ + Returns: + The value of the connection timeout option. + """ + + return internals.blpapi_SessionOptions_connectTimeout(self.__handle) + + def defaultServices(self) -> str: + """ + Returns: + All default services in one string, separated by `;`. + """ + return internals.blpapi_SessionOptions_defaultServices(self.__handle) + + def defaultSubscriptionService(self) -> str: + """ + Returns: + The default subscription service. + """ + + return internals.blpapi_SessionOptions_defaultSubscriptionService( + self.__handle + ) + + def defaultTopicPrefix(self) -> str: + """ + Returns: + The default topic prefix. + """ + + return internals.blpapi_SessionOptions_defaultTopicPrefix( + self.__handle + ) + + def allowMultipleCorrelatorsPerMsg(self) -> bool: + """ + Returns: + The value of the allow multiple correlators per message + option. + """ + + return ( + internals.blpapi_SessionOptions_allowMultipleCorrelatorsPerMsg( + self.__handle + ) + != 0 + ) + + def clientMode(self) -> int: + """ + Returns: + The value of the client mode option. + """ + + return internals.blpapi_SessionOptions_clientMode(self.__handle) + + def maxPendingRequests(self) -> int: + """ + Returns: + The value of the maximum pending request option. + """ + + return internals.blpapi_SessionOptions_maxPendingRequests( + self.__handle + ) + + def autoRestartOnDisconnection(self) -> bool: + """ + Returns: + Whether automatically restart connection if disconnected. + """ + return ( + internals.blpapi_SessionOptions_autoRestartOnDisconnection( + self.__handle + ) + != 0 + ) + + def authenticationOptions(self) -> str: + """ + Returns: + Authentication options in a string. + """ + return internals.blpapi_SessionOptions_authenticationOptions( + self.__handle + ) + + def numStartAttempts(self) -> int: + """ + Returns: + The maximum number of attempts to start a session. + """ + return internals.blpapi_SessionOptions_numStartAttempts(self.__handle) + + def recordSubscriptionDataReceiveTimes(self) -> bool: + """ + Returns: + Whether the receipt time (accessed via + :meth:`Message.timeReceived()`) should be recorded for subscription + data messages. + """ + return bool( + internals.blpapi_SessionOptions_recordSubscriptionDataReceiveTimes( + self.__handle + ) + ) + + def slowConsumerWarningHiWaterMark(self) -> float: + """ + Returns: + The fraction of :meth:`maxEventQueueSize()` at which "slow + consumer" event will be generated. + """ + return internals.blpapi_SessionOptions_slowConsumerWarningHiWaterMark( + self.__handle + ) + + def slowConsumerWarningLoWaterMark(self) -> float: + """ + Returns: + The fraction of :meth:`maxEventQueueSize()` at which "slow + consumer cleared" event will be generated. + """ + return internals.blpapi_SessionOptions_slowConsumerWarningLoWaterMark( + self.__handle + ) + + def maxEventQueueSize(self) -> int: + """ + Returns: + The value of maximum outstanding undelivered events that the + session is configured with. + """ + return internals.blpapi_SessionOptions_maxEventQueueSize(self.__handle) + + def defaultKeepAliveInactivityTime(self) -> int: + """ + Returns: + The interval (in milliseconds) a connection has to remain + inactive (receive no data) before a keep alive probe will be sent. + """ + return internals.blpapi_SessionOptions_defaultKeepAliveInactivityTime( + self.__handle + ) + + def defaultKeepAliveResponseTimeout(self) -> int: + """ + Returns: + The time (in milliseconds) the library will wait for response + to a keep alive probe before declaring it lost. + """ + return internals.blpapi_SessionOptions_defaultKeepAliveResponseTimeout( + self.__handle + ) + + def flushPublishedEventsTimeout(self) -> int: + """ + Returns: + The timeout, in milliseconds, for :class:`ProviderSession` to + flush published events before stopping. The default value is + ``2000``. + """ + return internals.blpapi_SessionOptions_flushPublishedEventsTimeout( + self.__handle + ) + + def keepAliveEnabled(self) -> bool: + """ + Returns: + ``True`` if the keep-alive mechanism is enabled; otherwise + return ``False``. + """ + return bool( + internals.blpapi_SessionOptions_keepAliveEnabled(self.__handle) + ) + + def serviceCheckTimeout(self) -> int: + """ + Returns: + The value of the service check timeout option in this + :class:`SessionOptions` instance in milliseconds. + """ + return internals.blpapi_SessionOptions_serviceCheckTimeout( + self.__handle + ) + + def serviceDownloadTimeout(self) -> int: + """ + Returns: + The value of the service download timeout option in this + :class:`SessionOptions` instance in milliseconds. + """ + return internals.blpapi_SessionOptions_serviceDownloadTimeout( + self.__handle + ) + + def bandwidthSaveModeDisabled(self) -> bool: + """ + Returns: + Whether bandwidth saving measures are disabled. + """ + return bool( + internals.blpapi_SessionOptions_bandwidthSaveModeDisabled( + self.__handle + ) + ) + + def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str: + """Format this :class:`SessionOptions` to the string. + + Args: + level: Indentation level + spacesPerLevel: Number of spaces per indentation level for + this and all nested objects + + Returns: + This object formatted as a string + + If ``level`` is negative, suppress indentation of the first line. If + ``spacesPerLevel`` is negative, format the entire output on one line, + suppressing all but the initial indentation (as governed by ``level``). + """ + return internals.blpapi_SessionOptions_printHelper( + self.__handle, level, spacesPerLevel + ) + + @staticmethod + def _validatePort(port: int) -> None: + if port < 1 or port > 65535: + raise ValueError( + f"port out of range:{port}. Must be beetween 1 and 65535" + ) + + +class TlsOptions(CHandle): + """SSL configuration options + + :class:`TlsOptions` instances maintain client credentials and trust + material used by a session to establish secure mutually authenticated + connections to endpoints. + + The client credentials comprise an encrypted private key with a client + certificate. The trust material comprises one or more certificates. + + :class:`TlsOptions` objects are created using :meth:`createFromFiles()` or + :meth:`createFromBlobs()` accepting the DER encoded client credentials in + PKCS#12 format and the DER encoded trusted material in PKCS#7 format. + """ + + def __init__(self, handle: BlpapiTlsOptionsHandle) -> None: + super(TlsOptions, self).__init__( + handle, internals.blpapi_TlsOptions_destroy + ) + self.__handle = handle + + def setTlsHandshakeTimeoutMs(self, timeoutMs: int) -> None: + """ + Args: + timeoutMs: Timeout threshold in milliseconds + + Set the TLS handshake timeout to the specified ``timeoutMs``. The + default is ``10,000`` milliseconds. The TLS handshake timeout will be + set to the default if the specified ``timeoutMs`` is not positive. + """ + internals.blpapi_TlsOptions_setTlsHandshakeTimeoutMs( + self.__handle, timeoutMs + ) + + def setCrlFetchTimeoutMs(self, timeoutMs: int) -> None: + """ + Args: + timeoutMs: Timeout threshold in milliseconds + + Set the CRL fetch timeout to the specified ``timeoutMs``. The default + is ``20,000`` milliseconds. The TLS handshake timeout will be set to + the default if the specified ``timeoutMs`` is not positive. + """ + internals.blpapi_TlsOptions_setCrlFetchTimeoutMs( + self.__handle, timeoutMs + ) + + @staticmethod + def createFromFiles( + clientCredentialsFilename: str, + clientCredentialsPassword: str, + trustedCertificatesFilename: str, + ) -> TlsOptions: + """ + Args: + clientCredentialsFilename: Path to the file with the client + credentials + clientCredentialsPassword: Password for the credentials + trustedCertificatesFilename: Path to the file with the + trusted certificates + + Creates a :class:`TlsOptions` using a DER encoded client credentials in + PKCS#12 format and DER encoded trust material in PKCS#7 format from the + specified files. + """ + handle = internals.blpapi_TlsOptions_createFromFiles( + clientCredentialsFilename, + clientCredentialsPassword, + trustedCertificatesFilename, + ) + return TlsOptions(handle) + + @staticmethod + def createFromBlobs( + clientCredentials: Union[bytes, bytearray], + clientCredentialsPassword: str, + trustedCertificates: Union[bytes, bytearray], + ) -> TlsOptions: + """ + Args: + clientCredentials: Blob with the client + credentials + clientCredentialsPassword: Password for the credentials + trustedCertificates: Blob with the trusted + certificates + + Creates a :class:`TlsOptions` using a DER encoded client credentials in + PKCS#12 format and DER encoded trust material in PKCS#7 format from the + given raw data. + """ + credentials = bytes(clientCredentials) + certs = bytes(trustedCertificates) + handle = internals.blpapi_TlsOptions_createFromBlobs( + credentials, clientCredentialsPassword, certs + ) + return TlsOptions(handle) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/subscriptionlist.py b/src/blpapi/subscriptionlist.py new file mode 100644 index 0000000..6801618 --- /dev/null +++ b/src/blpapi/subscriptionlist.py @@ -0,0 +1,332 @@ +# subscriptionlist.py + +"""Provide a list of subscriptions. + +This component provides a class to hold the data used (and returned) by the +'Session.subscribe', 'Session.resubscribe', and 'Session.unsubscribe' +methods. This class comprises a list in which each list entry contains two +primary fields: a 'CorrelationId' associated with the subscription, and a +string, called a *subscription* *string*, describing the data to be delivered +as a part of the subscription. + +STRUCTURE OF SUBSCRIPTION STRING +--------------------------------- +The simplest form of a subscription string is a *fully* *qualified* +subscription string, which has the following structure: + +"//blp/mktdata/ticker/IBM US Equity?fields=BID,ASK&interval=2" + \\-----------/\\------/\\-----------/\\------------------------/ + | | | | + Service Prefix Instrument Suffix + +Such a fully-qualified string is composed of: +: Service Identifier: a string matching the expression +: '^//[-_.a-zA-Z0-9]+/[-_.a-zA-Z0-9]+$', e.g. //blp/mktdata. See +: 'blpapi_abstractsession' for further details. +: +: Prefix: a string matching the expression '/([-_.a-zA-Z0-9]+/)?', often used +: as a symbology identifier. Common examples include '/ticker/' and +: '/cusip/'. Not all services make use of prefices. Note than an "empty" +: topic prefix consists of the string "/", so the topic prefix always +: separates the service string from the instrument string. +: +: Instrument: a non-empty string that does not contain the character '?' +: (i.e. a string matching '[^?]+') e.g. "IBM US Equity", or "SPX Index". +: The service, prefix, and instrument together uniquely identify a source +: for subscription data. +: +: Suffix: a suffix contains a question mark followed by a list of options +: which can affect the content delivery. The format of these options is +: service specific, but they generally follow URI query string conventions: +: a sequence of "key=value" pairs separated by "&" characters. Further, +: many common services follow the convention that the value given for the +: 'fields' key is formatted as a comma-separated list of field names. +: BLPAPI provides several convenience functions to assist in formatting +: subscription strings for services that make use of these conventions; +: see the 'SubscriptionList.add' methods for details. + +Subscription strings need not be fully qualified: BLPAPI allows the service and +prefix to be omitted from subscription strings, and automatically qualifies +these strings using information stored in a 'Session' object. + +QUALIFYING SUBSCRIPTION STRINGS +------------------------------- +The subscription strings passed to 'Session.subscribe' and +'Session.resubscribe' are automatically qualified if the service identifier is +missing (i.e. if the subscription string does not start with "//"). The +subscription parameters (i.e. the optional part after instrument identifier) +are never modified. + +The rules for qualifying the subscription string are: + +: o If the subscription string begins with "//" then it is assumed to be a +: a fully qualified subscription string including service identifier, +: prefix, and instrument. In this case the string will not be modified and +: session options defaults have no affect on the subscription. +: +: o If the subscription string begins with a '/' and the second character is +: not '/', then the string is assumed to begin with the topic prefix, but +: no service identifier. In this case the string is qualified by prepending +: the 'SessionOptions.defaultSubscriptionService()' to the specified +: string. +: +: o If the subscription string does not begin with a '/' it is assumed to +: begin with an instrument identifier. In this case the string is +: qualified by prepending the +: 'SessionOptions.defaultSubscriptionService()' followed by +: 'SessionOptions.defaultTopicPrefix()' to the specified string. +: If the 'defaultTopicPrefix' is empty or null, then the prefix used is +: '/'. Otherwise (in the case of a nontrivial prefix) if the separator '/' +: is not specified at the beginning or the end of the 'defaultTopicPrefix', +: then it will be added. +""" + +from __future__ import absolute_import +from typing import Mapping, Optional, Sequence, Union + +from .exception import _ExceptionUtil +from . import internals +from .correlationid import CorrelationId +from .utils import conv2str, get_handle, isstr +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + + +class SubscriptionList(CHandle): + """A list of subscriptions. + + Contains a list of subscriptions used when subscribing and unsubscribing. + + A :class:`SubscriptionList` is used when calling + :meth:`Session.subscribe()`, :meth:`Session.resubscribe()` and + :meth:`Session.unsubscribe()`. The entries can be constructed in a variety + of ways. + + The two important elements when creating a subscription are: + + - Subscription string: A subscription string represents a topic whose + updates user is interested in. + - CorrelationId: the unique identifier to tag all data associated with this + subscription. + + The following table describes how various operations use the above + elements: + + +-------------+--------------------------+----------------------------+ + | OPERATION | SUBSCRIPTION STRING | CORRELATION ID | + +=============+==========================+============================+ + | subscribe | | Used to specify the | | Identifier for the | + | | | topic to subscribe to. | | subscription. If | + | | | | uninitialized | + | | | | correlationid was | + | | | | specified an internally | + | | | | generated correlationId | + | | | | will be set for the | + | | | | subscription. | + +-------------+--------------------------+----------------------------+ + | resubscribe | | Used to specify the new| | Identifier of the | + | | | topic to which the | | subscription which | + | | | subscription should be | | needs to be modified. | + | | | modified to. | | + +-------------+--------------------------+----------------------------+ + | unsubscribe | NOT USED | | Identifier of the | + | | | | subscription which | + | | | | needs to be canceled. | + +-------------+--------------------------+----------------------------+ + """ + + def __init__(self) -> None: + """Create an empty :class:`SubscriptionList`.""" + selfhandle = internals.blpapi_SubscriptionList_create() + super(SubscriptionList, self).__init__( + selfhandle, internals.blpapi_SubscriptionList_destroy + ) + self.__handle = selfhandle + + def add( + self, + topic: Optional[str], + fields: Union[str, Sequence[str], None] = None, + options: Union[str, Sequence[str], Mapping, None] = None, + correlationId: Optional[CorrelationId] = None, + ) -> int: + """Add the specified ``topic`` to this :class:`SubscriptionList`. + + Args: + topic: The topic to subscribe to + fields: List of fields to subscribe to + options: List of options + correlationId: Correlation id to associate with the subscription + + Add the specified ``topic``, with the optionally specified ``fields`` + and the ``options`` to this :class:`SubscriptionList`, associating the + optionally specified ``correlationId`` with it. The ``fields`` must be + represented as a comma separated string or a list of strings, + ``options`` - as an ampersand separated string or list of strings or a + ``name -> value`` dictionary. + + Note: + In case of unsubscribe, you can pass empty string or ``None`` for + ``topic``. + """ + if correlationId is None: + correlationId = CorrelationId() + if topic is None: + topic = "" + + if fields: + if isstr(fields): + fields = conv2str(fields) # type: ignore # the isstr() check means fields must be string by this point + else: + fields = ",".join(fields) + if fields: + topic += "?fields=" + fields + + if options: + if isstr(options): + options_str = conv2str(options) # type: ignore # the isstr() check means options must be string by this point + elif isinstance(options, (list, tuple)): + options_str = "&".join(options) + elif isinstance(options, dict): + options_str = "&".join( + [ + key if val is None else f"{key}={val}" + for key, val in options.items() + ] + ) + else: + options_str = "" + + if options_str: + opts_prefix = "&" if fields else "?" + topic += opts_prefix + options_str + + return internals.blpapi_SubscriptionList_addHelper( + self.__handle, topic, correlationId + ) + + def append(self, other: "typehints.SubscriptionList") -> int: + """Append a copy of the specified :class:`SubscriptionList` to this + list. + + Args: + other: List to append to this one + """ + return internals.blpapi_SubscriptionList_append( + self.__handle, get_handle(other) + ) + + def clear(self) -> int: + """Remove all entries from this object.""" + return internals.blpapi_SubscriptionList_clear(self.__handle) + + def size(self) -> int: + """ + Returns: + The number of subscriptions in this object. + """ + return internals.blpapi_SubscriptionList_size(self.__handle) + + def correlationIdAt(self, index: int) -> CorrelationId: + r""" + Args: + index: Index of the entry in the list + + Returns: + Correlation id of the ``index``\th entry. + + Raises: + Exception: If ``index >= size()``. + """ + errorCode, cid = internals.blpapi_SubscriptionList_correlationIdAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return CorrelationId(cid) + + def topicStringAt(self, index: int) -> str: + """ + Args: + index: Index of the entry in the list + + Returns: + The full topic string at the specified ``index``. + + Raises: + Exception: If ``index >= size()``. + """ + errorCode, topic = internals.blpapi_SubscriptionList_topicStringAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return topic + + def addResolved( + self, + subscriptionString: str, + correlationId: Optional[CorrelationId] = None, + ) -> int: + """ + Args: + subscriptionString: Fully-resolved subscription string + correlationId: Correlation id to associate with the + subscription + + Add the specified ``subscriptionString`` to this + :class:`SubscriptionList` object, associating the specified + ``correlationId`` with it. The subscription string may include + options. The behavior of this function, and of functions operating on + this :class:`SubscriptionList` object, is undefined unless + ``subscriptionString`` is a fully-resolved subscription string; clients + that cannot provide fully-resolved subscription strings should use + :meth:`add()` instead. + + Note: + It is at the discretion of each function operating on a + :class:`SubscriptionList` whether to perform resolution on this + subscription. + """ + if correlationId is None: + correlationId = CorrelationId() + return internals.blpapi_SubscriptionList_addResolved( + self.__handle, subscriptionString, correlationId + ) + + def isResolvedTopicAt(self, index: int) -> bool: + """ + Args: + index: Index of the entry in the list + + Returns: + ``True`` if the ``index``th entry in this + ``SubscriptionList`` object was created using :meth:`addResolved()` + and ``False`` if it was created using :meth:`add()`. An exception + is thrown if ``index >= size()``. + """ + err, res = internals.blpapi_SubscriptionList_isResolvedAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(err) + return res + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/test/__init__.py b/src/blpapi/test/__init__.py new file mode 100644 index 0000000..ae57d0c --- /dev/null +++ b/src/blpapi/test/__init__.py @@ -0,0 +1,7 @@ +# __init__.py + +# pylint: disable=missing-docstring + +from .messageformatter import MessageFormatter +from .messageproperties import MessageProperties +from .testutil import * diff --git a/src/blpapi/test/messageformatter.py b/src/blpapi/test/messageformatter.py new file mode 100644 index 0000000..4ab258a --- /dev/null +++ b/src/blpapi/test/messageformatter.py @@ -0,0 +1,466 @@ +# messageformatter.py + +""" Class for formatting mock messages. """ + +# pylint: disable=function-redefined,ungrouped-imports,no-name-in-module + +from functools import singledispatch, update_wrapper +from datetime import date, time, datetime +from json import dumps +from typing import Any, Callable + +from blpapi import internals, Name +from blpapi.typehints import ( + AnyPythonDatetime, + BlpapiMessageFormatterHandle, + SupportedElementTypes, +) +from blpapi.datetime import _DatetimeUtil +from blpapi.exception import _ExceptionUtil +from blpapi.utils import ( + conv2str, + get_handle, + isstr, + MAX_32BIT_INT, + MIN_32BIT_INT, + MIN_64BIT_INT, + MAX_64BIT_INT, +) +from blpapi.chandle import CHandle + + +def _singledispatchmethod(arg_index: int) -> Callable: + """Decorator to implement singledispatch on a class method. + `arg_index` indicates the argument whose type will be used to determine + the function to which to dispatch. + """ + + def _singleDispatchMethodImpl(func: Callable) -> Callable: + """Implementation of `_singledispatchmethod`.""" + dispatcher = singledispatch(func) + + # `dispatcher` is `func` wrapped by singledispatch + # `dispatcher` has an attribute `register()`, which is a decorator, + # which registers the typed funcs to call based on the arg passed to + # `func` + def _wrapper(*args: Any, **kw: Any) -> Any: + # singledispatch bases the type on the first arg, which is `self` + # in a method. Instead, we need the 3rd argument, skipping over + # `self` and `name` in `setElement(self, name, value)` + return dispatcher.dispatch(args[arg_index].__class__)(*args, **kw) + + # give `_wrapper` a `.register()` attribute + # pylint: disable=no-member + _wrapper.__setattr__("register", dispatcher.register) + # makes `_wrapper` look like `func` with regards to metadata and + # attributes + update_wrapper(_wrapper, func) + return _wrapper + + return _singleDispatchMethodImpl + + +class MessageFormatter(CHandle): + """:class:`MessageFormatter` is used to populate/format a message. It + supports writing only once to each field. Attempting to set an already set + element will fail. + + Note that the behavior is undefined if: + + * A message is formatted with :meth:`formatMessageJson` or + :meth:`formatMessageXml` or :meth:`formatMessageDict` is further + formatted. + + * A message formatted with `set*()` or `append*()` is further formatted + using :meth:`formatMessageJson` or :meth:`formatMessageXml` or + :meth:`formatMessageDict`. + + Currently, the JSON and XML formatting methods have some known limitations: + + * The parsers can not differentiate complex field types + (sequences, choices, arrays) that are empty with complex field types that + are missing / null. These fields are dropped and absent in the message + contents. + + * Enumerations of type "Datetime", or any "Datetime" element with timezone + offset or sub-microsecond precision (e.g. nanoseconds) are not supported. + """ + + def __init__(self, handle: BlpapiMessageFormatterHandle) -> None: + """For internal use only.""" + super(MessageFormatter, self).__init__( + handle, internals.blpapi_MessageFormatter_destroy + ) + self.__handle = handle + + def _handle(self) -> BlpapiMessageFormatterHandle: + return self.__handle + + def setElement(self, name: Name, value: SupportedElementTypes) -> None: + """Set the element with the specified ``name`` to the specified + ``value`` in the current :class:`blpapi.Message` referenced by this + :class:`MessageFormatter`. + + Args: + name: Identifies the element which will be set to ``value``. + value: The value to assign to the specified element. + + Raises: + Exception: An exception is raised if any of the following are true: + - The ``name`` is invalid for the current message + - The element identified by ``name`` has already been set + - The ``value`` cannot be assigned to the element identified by + ``name`` + + Note: + **Please use** :class:`blpapi.Name` **over** :class:`str` **where possible for** + ``name``. :class:`blpapi.Name` **objects should be initialized + once and then reused** as each :class:`blpapi.Name` instance refers to an + entry in a global static table which grows in an unbounded manner. + """ + + # Although the function type hint is `name: Name` because we want to encourage using Names, + # clients may actually pass a string, so we check and convert if needed + # mypy complains that conv2str doesn't take Name, which we can ignore after isstr check + if isstr(name): + name = Name(conv2str(name)) # type: ignore + self._setElement(name, value) + + # pylint: disable=unused-argument,no-self-use + @_singledispatchmethod(2) + def _setElement(self, name: Name, value: SupportedElementTypes) -> None: + """Implementation for :meth:`setElement`. + + Args: + name (Name): Identifies the element which will be set to ``value`` + value (bool or str or bytes or int or float or date or time or + datetime or Name or None): + The value to assign to the specified element. + + Raises: + Exception: An exception is raised if any of the following are true: + - The ``name`` is invalid for the current message + - The element identified by ``name`` has already been set + - The ``value`` cannot be assigned to the element identified by + ``name`` + """ + raise TypeError( + f"The type of value {value!r} is not supported. Type" + f" is {type(value)}. Please refer to the" + " documentation for the supported types." + ) + + @_setElement.register(bool) + def _(self, name: Name, value: bool) -> None: + """Dispatch method for setting `bool` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueBool( + self.__handle, get_handle(name), value + ) + ) + + @_setElement.register(datetime) + @_setElement.register(date) + @_setElement.register(time) + def _(self, name: Name, value: AnyPythonDatetime) -> None: + """Dispatch method for setting time types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueHighPrecisionDatetime( + self.__handle, + get_handle(name), + _DatetimeUtil.convertToBlpapi(value), + ) + ) + + @_setElement.register(int) + def _setElementInt(self, name: Name, value: int) -> None: + """Dispatch method for setting integer types.""" + if MIN_32BIT_INT <= value <= MAX_32BIT_INT: + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueInt32( + self.__handle, get_handle(name), value + ) + ) + elif MIN_64BIT_INT <= value <= MAX_64BIT_INT: + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueInt64( + self.__handle, get_handle(name), value + ) + ) + else: + raise ValueError("Value is out of element's supported range") + + @_setElement.register(float) + def _(self, name: Name, value: float) -> None: + """Dispatch method for setting `float` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueFloat( + self.__handle, get_handle(name), value + ) + ) + + @_setElement.register(Name) + def _(self, name: Name, value: Name) -> None: + """Dispatch method for setting `Name` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueFromName( + self.__handle, get_handle(name), get_handle(value) + ) + ) + + @_setElement.register(type(None)) + def _(self, name: Name, _: Any) -> None: + """Dispatch method for setting `None` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueNull( + self.__handle, get_handle(name) + ) + ) + + @_setElement.register(str) + def _(self, name: Name, value: str) -> None: + """Dispatch method for setting string types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueString( + self.__handle, get_handle(name), value + ) + ) + + @_setElement.register(bytes) + def _(self, name: Name, value: bytes) -> None: + """Dispatch method for setting `bytes` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_setValueBytes( + self.__handle, get_handle(name), value + ) + ) + + def pushElement(self, name: Name) -> None: + """Change the level at which this :class:`MessageFormatter` is + operating to the element specified by ``name``. + + After this returns, the context of the :class:`MessageFormatter` is set + to the element specified by ``name`` in the schema and any calls to + :meth:`setElement` or meth:`pushElement` are applied at that level. + + If ``name`` represents an array of scalars then :meth:`appendValue` + must be used to add values. + + If ``name`` represents an array of complex types then + :meth:`appendElement()` must be used. + + Args: + name: Specifies the :class:`blpapi.Element` on which to operate. + The element must identify either a choice, a sequence or an + array at the current level of the schema or the behavior is + undefined. + + Raises: + Exception: If the ``name`` is invalid for the current message or if + the element identified by ``name`` has already been set. + + Note: + **Please use** :class:`blpapi.Name` **over** :class:`str` **where possible for** + ``name``. :class:`blpapi.Name` **objects should be initialized + once and then reused** as each :class:`blpapi.Name` instance refers to an + entry in a global static table which grows in an unbounded manner. + """ + + # Although the function type hint is `name: Name` because we want to encourage using Names, + # clients may actually pass a string, so we check and convert if needed + # mypy complains that conv2str doesn't take Name, which we can ignore after isstr check + if isstr(name): + name = Name(conv2str(name)) # type: ignore + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_pushElement( + self.__handle, get_handle(name) + ) + ) + + def popElement(self) -> None: + """Undo the most recent call to :meth:`pushElement` or + :meth:`appendElement` on this :class:`MessageFormatter` and return the + context of the :class:`MessageFormatter` to where it was before the + call to :meth:`pushElement` or :meth:`appendElement`. Once + :meth:`popElement` has been called, it is invalid to attempt to + re-visit the same context. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_popElement(self.__handle) + ) + + @_singledispatchmethod(1) + def appendValue(self, value: SupportedElementTypes) -> None: + """Append the specified ``value`` to the element on which this + :class:`MessageFormatter` is operating. + + Args: + value: The value to append. + + Raises: + Exception: If the schema of the message is flat or the current + element to which ``value`` is appended is not an array. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueString( + self.__handle, value + ) + ) + + @appendValue.register(bool) + def _(self, value: bool) -> None: + """Dispatch method for appending `bool` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueBool( + self.__handle, value + ) + ) + + @appendValue.register(datetime) + @appendValue.register(date) + @appendValue.register(time) + def _(self, value: AnyPythonDatetime) -> None: + """Dispatch method for appending time types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueHighPrecisionDatetime( + self.__handle, _DatetimeUtil.convertToBlpapi(value) + ) + ) + + @appendValue.register(int) + def _appendValueInt(self, value: int) -> None: + """Dispatch method for appending integer types.""" + if MIN_32BIT_INT <= value <= MAX_32BIT_INT: + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueInt32( + self.__handle, value + ) + ) + elif MIN_64BIT_INT <= value <= MAX_64BIT_INT: + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueInt64( + self.__handle, value + ) + ) + else: + raise ValueError("Value is out of element's supported range") + + @appendValue.register(float) + def _(self, value: float) -> None: + """Dispatch method for appending `float` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueFloat( + self.__handle, value + ) + ) + + @appendValue.register(Name) + def _(self, value: Name) -> None: + """Dispatch method for appending `Name` types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueFromName( + self.__handle, get_handle(value) + ) + ) + + @appendValue.register(str) + def _(self, value: str) -> None: + """Dispatch method for appending string types.""" + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendValueString( + self.__handle, value + ) + ) + + def appendElement(self) -> None: + """Create an array :class:`blpapi.Element` and append it to the + :class:`blpapi.Element` on which this :class:`MessageFormatter` is + operating. + + Raises: + Exception: If the schema of the :class:`blpapi.Message` is flat or + the current :class:`blpapi.Element` to which this new + :class:`blpapi.Element` is being appended is not an array, a + sequence or a choice. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_appendElement(self.__handle) + ) + + def formatMessageJson(self, jsonMessage: str) -> None: + """Format the :class:`blpapi.Message` from its ``JSON`` representation. + + Args: + jsonMessage (str): A ``JSON``-formatted ``str`` representing the + content used to format the message. + + Raises: + Exception: If the method fails to format the + :class:`blpapi.Message`. + + The behavior is undefined if further formatting is done using + this :class:`MessageFormatter`. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_FormatMessageJson( + self.__handle, jsonMessage + ) + ) + + def formatMessageXml(self, xmlMessage: str) -> None: + """Format the :class:`blpapi.Message` from its ``XML`` representation. + + Args: + xmlMessage (str): An ``XML``-formatted ``str`` representing the + content used to format the message. + + Raises: + Exception: If the method fails to format the + :class:`blpapi.Message`. + + The behavior is undefined if further formatting is done using + this :class:`MessageFormatter`. + """ + _ExceptionUtil.raiseOnError( + internals.blpapi_MessageFormatter_FormatMessageXml( + self.__handle, xmlMessage + ) + ) + + def formatMessageDict(self, dictMessage: dict) -> None: + """Format the :class:`blpapi.Message` from its ``dict`` representation. + + Args: + dictMessage: A dictionary representing the content used to + format the message. + + Raises: + Exception: If the method fails to format the + :class:`blpapi.Message`. + + The behavior is undefined if further formatting is done using + this :class:`MessageFormatter`. + """ + self.formatMessageJson(dumps(dictMessage)) + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/test/messageproperties.py b/src/blpapi/test/messageproperties.py new file mode 100644 index 0000000..70d5743 --- /dev/null +++ b/src/blpapi/test/messageproperties.py @@ -0,0 +1,143 @@ +# messageproperties.py + +""" Class for defining properties of mock messages. """ + +from typing import Sequence +import blpapi +from blpapi import internals +from blpapi.exception import _ExceptionUtil +from blpapi.datetime import _DatetimeUtil +from blpapi import typehints +from ..utils import get_handle + + +class MessageProperties: + """ + This class represents properties of a message that are not part of the + message contents, such as the correlation ids or timestamp. + """ + + def __init__(self) -> None: + """ + Create 'MessageProperties' with default values. + + Default value for the 'CorrelationId' property is an empty list. + Default value for the 'recapType' property is 'Message.RECAPTYPE_NONE'. + Default value for the 'fragmentType' property is + 'Message.FRAGMENT_NONE'. + Default value for the 'Service' and 'timeReceived' is "unset". + """ + rc, self.__handle = internals.blpapi_MessageProperties_create() + _ExceptionUtil.raiseOnError(rc) + + def __del__(self) -> None: + try: + self.destroy() + except (NameError, AttributeError): + pass + + def destroy(self) -> None: + """Destroy this :class:`MessageProperties`.""" + if self.__handle: + internals.blpapi_MessageProperties_destroy(self.__handle) + self.__handle = None + + def setCorrelationIds( + self, cids: Sequence["typehints.CorrelationId"] + ) -> None: + """ + Set the `correlationIds` properties of the message. + + Args: + cids: list of correlation ids of the message. + """ + errorCode = internals.blpapi_MessageProperties_setCorrelationIds( + self.__handle, list(cids) + ) + _ExceptionUtil.raiseOnError(errorCode) + + def setRecapType( + self, + recapType: int, + fragmentType: int = blpapi.Message.FRAGMENT_NONE, + ) -> None: + """ + Set the `recapType` and `fragmentType` properties of the message. + + Args: + recapType: Recap type of the message. See :class:`blpapi.Message` + for valid values. + fragmentType: Optional. Fragment type of the message. See + :class:`blpapi.Message` for valid values. The default value is + ``blpapi.Message.FRAGMENT_NONE``. + """ + errorCode = internals.blpapi_MessageProperties_setRecapType( + self.__handle, recapType, fragmentType + ) + _ExceptionUtil.raiseOnError(errorCode) + + def setTimeReceived(self, timestamp: typehints.AnyPythonDatetime) -> None: + """ + Set the `timeReceived` property of the message. + + Args: + timestamp (datetime.datetime): Timestamp of the message. + """ + ts = _DatetimeUtil.convertToBlpapi(timestamp) + errorCode = internals.blpapi_MessageProperties_setTimeReceived( + self.__handle, ts + ) + _ExceptionUtil.raiseOnError(errorCode) + + def setRequestId(self, requestId: str) -> None: + """ + Set the `requestId` property. + A copy of this string is expected to be returned + by :meth:`blpapi.Message.getRequestId()`. + If `requestId` is empty or `None`, the method throws. + + Args: + requestId (str): RequestId of the message. + """ + errorCode = internals.blpapi_MessageProperties_setRequestId( + self.__handle, requestId + ) + _ExceptionUtil.raiseOnError(errorCode) + + def setService(self, service: "typehints.Service") -> None: + """ + Set the `service` property of the message. + + Args: + service (blpapi.Service): Service of the message. + """ + errorCode = internals.blpapi_MessageProperties_setService( + self.__handle, get_handle(service) + ) + _ExceptionUtil.raiseOnError(errorCode) + + def _handle(self) -> typehints.BlpapiMessagePropertiesHandle: + """For internal use only.""" + return self.__handle + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/test/testutil.py b/src/blpapi/test/testutil.py new file mode 100644 index 0000000..1634857 --- /dev/null +++ b/src/blpapi/test/testutil.py @@ -0,0 +1,191 @@ +# testutil.py + +""" This module provides a set of utility functions to allow SDK clients to +create events/messages for unit-testing their applications. +""" + +from typing import Optional +from blpapi import internals +from blpapi import Event, Name, SchemaElementDefinition, Service, Topic +from blpapi.exception import _ExceptionUtil +from blpapi.utils import conv2str, get_handle, isstr +from blpapi.test import MessageProperties, MessageFormatter + + +def createEvent(eventType: int) -> Event: + """Create an :class:`blpapi.Event` with the specified ``eventType`` to be + used for testing. + + Args: + eventType: Specifies the type of event. See :class:`blpapi.Event` + for a list of enumerated values (e.g., `Event.SUBSCRIPTION_DATA`). + + Returns: + An event used for testing. It cannot be used for publishing. + + The behavior is undefined if :class:`blpapi.EventFormatter` is + used with the returned :class:`blpapi.Event`. + """ + rc, event_handle = internals.blpapi_TestUtil_createEvent(eventType) + _ExceptionUtil.raiseOnError(rc) + event = Event(event_handle, sessions=None) + return event + + +def appendMessage( + event: Event, + elementDef: SchemaElementDefinition, + properties: Optional[MessageProperties] = None, +) -> MessageFormatter: + """Create a new message and append it to the specified ``event``. + Return a :class:`MessageFormatter` to format the last appended message. + + Args: + event: The ``event`` to which the new message will be appended. The + ``event`` must be a test :class:`blpapi.Event` created by + :meth:`createEvent()`. + elementDef: Used to verify and encode the contents of the message. + properties: Used to set the metadata properties for the message. + + Returns: + The :class:`MessageFormatter` used to format the last appended message. + + Raises: + Exception: If the method fails to append the message. + """ + if properties is None: + properties = MessageProperties() + rc, formatter_handle = internals.blpapi_TestUtil_appendMessage( + get_handle(event), + get_handle(elementDef), # type: ignore + get_handle(properties), # type: ignore + ) + _ExceptionUtil.raiseOnError(rc) + message_formatter = MessageFormatter(formatter_handle) + return message_formatter + + +def deserializeService(serviceXMLStr: str) -> Service: + """Create a :class:`blpapi.Service` instance from the specified + ``serviceXMLStr``. + + Args: + serviceXMLStr: A ``str`` representation of a + :class:`blpapi.Service` in ``XML`` format. The ``str`` should only + contain ASCII characters without any embedded ``null`` characters. + Returns: + A :class:`blpapi.Service` created from ``serviceXMLStr``. + + Raises: + Exception: If deserialization fails. + """ + rc, service_handle = internals.blpapi_TestUtil_deserializeService( + serviceXMLStr, len(serviceXMLStr) + ) + _ExceptionUtil.raiseOnError(rc) + let_it_leak = True # for now, we prefer leaks to crashes + service = Service(service_handle, set(), let_it_leak) + return service + + +def serializeService(service: Service) -> str: + """Serialize the provided ``service`` in ``XML`` format. + + Args: + service: The :class:`blpapi.Service` to be serialized. + + Returns: + The ``service`` represented as an ``XML`` formatted ``str``. + + Raises: + Exception: If the service can't be serialized successfully. + """ + service_str = internals.blpapi_TestUtil_serializeServiceHelper( + get_handle(service) + ) + return service_str + + +def createTopic(service: Service, isActive: bool = True) -> Topic: + """Create a valid :class:`blpapi.Topic` with the specified ``service`` to + support testing publishers. The expected use case is to support returning a + custom :class:`blpapi.Topic` while mocking + :meth:`blpapi.ProviderSession.getTopic()` methods. + + Args: + service: The :class:`blpapi.Service` to which the returned + :class:`blpapi.Topic` will belong. + isActive: Optional. Specifies whether the returned + :class:`blpapi.Topic` is active. + + Returns: + A valid :class:`blpapi.Topic` with the specified ``service``. + """ + rc, topic_handle = internals.blpapi_TestUtil_createTopic( + get_handle(service), isActive + ) + _ExceptionUtil.raiseOnError(rc) + topic = Topic(topic_handle, sessions=set()) + return topic + + +def getAdminMessageDefinition( + messageName: Name, +) -> SchemaElementDefinition: + """Return the definition for an admin message of the specified + ``messageName``. + + Args: + messageName: The name of the desired admin message. + + Returns: + The element definition for the message specified by ``messageName``. + + Raises: + Exception: If ``messageName`` does not name an admin message. + + Note: + **Please use** :class:`blpapi.Name` **over** :class:`str` **where possible for** + ``messageName``. :class:`blpapi.Name` **objects should be initialized + once and then reused** as each :class:`blpapi.Name` instance refers to an + entry in a global static table which grows in an unbounded manner. + """ + + # Although the function type hint is `name: Name` because we want to encourage using Names, + # clients may actually pass a string, so we check and convert if needed + # mypy complains that conv2str doesn't take Name, which we can ignore after isstr check + if isstr(messageName): + messageName = Name(conv2str(messageName)) # type: ignore + ( + rc, + schema_element_definition_handle, + ) = internals.blpapi_TestUtil_getAdminMessageDefinition( + get_handle(messageName) + ) + _ExceptionUtil.raiseOnError(rc) + schema_definition = SchemaElementDefinition( + schema_element_definition_handle, set() + ) + return schema_definition + + +__copyright__ = """ +Copyright 2020. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/topic.py b/src/blpapi/topic.py new file mode 100644 index 0000000..3a14951 --- /dev/null +++ b/src/blpapi/topic.py @@ -0,0 +1,101 @@ +# topic.py + +"""Provide representation of a Topic + +This component provides a topic that is used for publishing data on. +""" +from typing import Any, Set, Optional +from .typehints import BlpapiTopicHandle +from . import internals +from . import typehints # pylint: disable=unused-import +from .service import Service +from .utils import get_handle +from .chandle import CHandle + + +class Topic(CHandle): + """Used to identify the stream on which a message is published. + + Topic objects are obtained from :meth:`~ProviderSession.createTopics()` on + :class:`ProviderSession`. They are used when adding a message to an Event + for publishing using :meth:`~EventFormatter.appendMessage()` on + :class:`EventFormatter`. + """ + + def __init__( + self, + handle: Optional[BlpapiTopicHandle] = None, + sessions: Optional[Set["typehints.AbstractSession"]] = None, + ): + """Create a :class:`Topic` object. + + Args: + handle: Handle to the internal implementation + sessions: Sessions associated with this object + + A :class:`Topic` created with ``handle`` set to ``None`` is not a valid + topic and must be assigned to from a valid topic before it can be used. + """ + super(Topic, self).__init__(handle, internals.blpapi_Topic_destroy) + self.__sessions = sessions if sessions is not None else set() + + def isValid(self) -> bool: # pylint: disable=useless-parent-delegation + """ + Returns: + ``True`` if this :class:`Topic` is valid and can be used to + publish a message on. + """ + return super().isValid() + + def isActive(self) -> bool: + """ + Returns: + ``True`` if this topic was elected by the platform to become + the primary publisher. + """ + return bool(internals.blpapi_Topic_isActive(self._handle())) + + def service(self) -> "typehints.Service": + """ + Returns: + Service: The service for which this topic was created. + """ + return Service( + internals.blpapi_Topic_service(self._handle()), self.__sessions + ) + + def __lt__(self, other: "typehints.Topic") -> bool: + """2-way comparison of Topic objects.""" + return ( + internals.blpapi_Topic_compare(self._handle(), get_handle(other)) + < 0 + ) + + def __eq__(self, other: Any) -> bool: + """2-way comparison of Topic objects.""" + return ( + internals.blpapi_Topic_compare(self._handle(), get_handle(other)) + == 0 + ) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/topiclist.py b/src/blpapi/topiclist.py new file mode 100644 index 0000000..436ec74 --- /dev/null +++ b/src/blpapi/topiclist.py @@ -0,0 +1,289 @@ +# topiclist.py + +"""Provide a representation of a list of topics. + +This component implements a list of topics which require topic creation. +""" +from typing import Optional, Set, Union + +from .exception import _ExceptionUtil +from .message import Message +from .resolutionlist import ResolutionList +from . import internals +from . import utils +from .utils import get_handle +from .correlationid import CorrelationId +from .chandle import CHandle +from . import typehints # pylint: disable=unused-import + + +# pylint: disable=protected-access +class TopicList(CHandle, metaclass=utils.MetaClassForClassesWithEnums): + """A list of topics which require creation. + + Contains a list of topics which require creation. + + Created from topic strings or from ``TOPIC_SUBSCRIBED`` or + ``RESOLUTION_SUCCESS`` messages. This is passed to a + :meth:`~ProviderSession.createTopics()` call or + :meth:`~ProviderSession.createTopicsAsync()` call on a + :class:`ProviderSession`. It is updated and returned by the + :meth:`~ProviderSession.createTopics()` call. + """ + + NOT_CREATED = internals.TOPICLIST_NOT_CREATED + CREATED = internals.TOPICLIST_CREATED + FAILURE = internals.TOPICLIST_FAILURE + + def __init__(self, original: Optional[ResolutionList] = None) -> None: + """Create an empty :class:`TopicList`, or a :class:`TopicList` based on + ``original`` :class:`ResolutionList`. + + Args: + ``original``: Original resolution list to use. + + Raises: + TypeError: If ``original`` is not an instance of + :class:`ResolutionList`. + + If ``original`` is ``None`` - create empty :class:`TopicList`. + Otherwise create a :class:`TopicList` from ``original``. + In this case ``original`` is used by handle, so if the caller + modifies original resolution list after the call, + :class:`TopicList` also changes because owns the same handle. + """ + if isinstance(original, ResolutionList): + selfhandle = internals.blpapi_TopicList_createFromResolutionList( + get_handle(original) + ) + self.__sessions = original._sessions() + elif original is not None: + raise TypeError( + "'original' should be an instance of 'ResolutionList'" + ) + else: + selfhandle = internals.blpapi_TopicList_create(None) + self.__sessions = set() + super(TopicList, self).__init__( + selfhandle, internals.blpapi_TopicList_destroy + ) + self.__handle = selfhandle + + def add( + self, + topicOrMessage: Union[str, Message], + correlationId: Optional[CorrelationId] = None, + ) -> int: + """Add the specified topic or topic from message to this + :class:`TopicList`. + + Args: + topicOrMessage: Topic string or message to create + a topic from + correlationId: CorrelationId to associate with the + topic + + Returns: + ``0`` on success or negative number on failure. + + Raises: + TypeError: If ``correlationId`` is not an instance of + :class:`CorrelationId`. + + If topic is passed as ``topicOrMessage``, add the topic to this list, + optionally specifying a ``correlationId``. After a successful call to + :meth:`add()` the status for this entry is ``NOT_CREATED``. + + If :class:`Message` is passed as ``topicOrMessage``, add the topic + contained in the specified ``topicSubscribedMessage`` or + ``resolutionSuccessMessage`` to this list, optionally specifying a + ``correlationId``. After a successful call to :meth:`add()` the status + for this entry is ``NOT_CREATED``. + """ + if correlationId is None: + correlationId = CorrelationId() + if not isinstance(correlationId, CorrelationId): + raise TypeError( + "correlationId should be an instance of 'CorrelationId'" + ) + if isinstance(topicOrMessage, Message): + return internals.blpapi_TopicList_addFromMessage( + self.__handle, get_handle(topicOrMessage), correlationId + ) + return internals.blpapi_TopicList_add( + self.__handle, topicOrMessage, correlationId + ) + + def correlationIdAt(self, index: int) -> CorrelationId: + r""" + Args: + index: Index of the entry in the list + + Returns: + Correlation id of the ``index``\th entry. + + Raises: + Exception: If ``index >= size()``. + """ + errorCode, cid = internals.blpapi_TopicList_correlationIdAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return CorrelationId(cid) + + def topicString(self, correlationId: CorrelationId) -> str: + """ + Args: + correlationId: Correlation id associated with the + topic. + + Returns: + Topic of the entry identified by 'correlationId'. + + Raises: + Exception: If the ``correlationId`` does not identify an entry in + this list. + """ + errorCode, topic = internals.blpapi_TopicList_topicString( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return topic + + def topicStringAt(self, index: int) -> str: + r""" + Args: + index: Index of the entry + + Returns: + The full topic string of the ``index``\th entry in this list. + + Raises: + Exception: If ``index >= size()``. + """ + errorCode, topic = internals.blpapi_TopicList_topicStringAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return topic + + def status(self, correlationId: CorrelationId) -> int: + """ + Args: + correlationId: Correlation id associated with the + entry + + Returns: + Status of the entry in this list identified by the + specified ``correlationId``. This may be :attr:`NOT_CREATED`, + :attr:`CREATED` and :attr:`FAILURE`. + + Raises: + Exception: If the ``correlationId`` does not identify an entry in + this list. + """ + errorCode, status = internals.blpapi_TopicList_status( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return status + + def statusAt(self, index: int) -> int: + r""" + Args: + index: Index of the entry + + Returns: + Status of the ``index``\th entry in this list. This may be + :attr:`NOT_CREATED`, :attr:`CREATED` and :attr:`FAILURE`. + + Raises: + Exception: If ``index >= size()``. + """ + errorCode, status = internals.blpapi_TopicList_statusAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return status + + def message(self, correlationId: CorrelationId) -> Message: + """ + Args: + correlationId: Correlation id associated with the + message + + Returns: + Message received during creation of the topic identified + by the specified ``correlationId``. + + Raises: + Exception: If ``correlationId`` does not identify an entry in this + :class:`TopicList`. + + The message returned can be used when creating an instance of + :class:`Topic`. + """ + errorCode, message = internals.blpapi_TopicList_message( + self.__handle, correlationId + ) + _ExceptionUtil.raiseOnError(errorCode) + return Message(message, sessions=self._sessions()) + + def messageAt(self, index: int) -> Message: + """ + Args: + index: Index of the entry + + Returns: + Message received during creation of the entry at + ``index``. + + Raises: + Exception: If ``index >= size()``. + + The message returned can be used when creating an instance of + :class:`Topic`. + """ + errorCode, message = internals.blpapi_TopicList_messageAt( + self.__handle, index + ) + _ExceptionUtil.raiseOnError(errorCode) + return Message(message, sessions=self._sessions()) + + def size(self) -> int: + """Return the number of entries in this :class:`TopicList`.""" + return internals.blpapi_TopicList_size(self.__handle) + + def _sessions(self) -> Set["typehints.AbstractSession"]: + """Return session(s) that this 'TopicList' is related to. + + For internal use.""" + return self.__sessions + + def _addSession(self, session: "typehints.AbstractSession") -> None: + """Add a new session to this 'TopicList'. + + For internal use.""" + self.__sessions.add(session) + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/typehints.py b/src/blpapi/typehints.py new file mode 100644 index 0000000..81ee9db --- /dev/null +++ b/src/blpapi/typehints.py @@ -0,0 +1,64 @@ +# typehints.py + +"""Type definitions for common type hints""" + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from blpapi import AbstractSession + from blpapi import AuthOptions + from blpapi import ConstantList + from blpapi import CorrelationId + from blpapi import Element + from blpapi import Event + from blpapi import EventDispatcher + from blpapi import EventQueue + from blpapi import Message + from blpapi import Name + from blpapi import Identity + from blpapi import ResolutionList + from blpapi import Request + from blpapi import SchemaElementDefinition + from blpapi import Service + from blpapi import Session + from blpapi import SessionOptions + from blpapi import SubscriptionList + from blpapi import TlsOptions + from blpapi import Topic + from blpapi import TopicList + +import datetime +from typing import Union, Any + +AnyPythonDatetime = Union[datetime.datetime, datetime.date, datetime.time] +BlpapiNameOrIndex = Union["Name", int] +SupportedElementTypes = Union[ + "Name", str, bytes, bool, int, float, AnyPythonDatetime, None +] +# placeholders for opaque handles +BlpapiAbstractSessionHandle = Any +BlpapiAuthOptionsHandle = Any +BlpapiAuthAppHandle = Any +BlpapiAuthTokenHandle = Any +BlpapiAuthUserHandle = Any +BlpapiConstantHandle = Any +BlpapiConstantListHandle = Any +BlpapiDatetime = Union[Any, "blpapi_HighPrecisionDatetime_tag"] # type: ignore +BlpapiElementHandle = Any +BlpapiEventHandle = Any +BlpapiIdentityHandle = Any +BlpapiMessageHandle = Any +BlpapiMessageFormatterHandle = Any +BlpapiMessagePropertiesHandle = Any +BlpapiNameHandle = Any +BlpapiOperationHandle = Any +BlpapiProviderSessionHandle = Any +BlpapiRequestHandle = Any +BlpapiRequestTemplateHandle = Any +BlpapiSchemaHandle = Any +BlpapiSchemaElementDefinitionHandle = Any +BlpapiSchemaTypeDefinitionHandle = Any +BlpapiServiceHandle = Any +BlpapiSessionHandle = Any +BlpapiTlsOptionsHandle = Any +BlpapiTopicHandle = Any diff --git a/src/blpapi/utils.py b/src/blpapi/utils.py new file mode 100644 index 0000000..8fb74c1 --- /dev/null +++ b/src/blpapi/utils.py @@ -0,0 +1,217 @@ +# utils.py + +"""Internal utils.""" + +from collections.abc import Iterator as IteratorABC, Sequence +from ctypes import c_void_p +from typing import Any, Callable, Union, Optional +from typing import Iterator as IteratorType +import functools +import warnings + +from .chandle import CHandle + + +STR_TYPES = (bytes, str) + +MIN_32BIT_INT = -(2**31) +MAX_32BIT_INT = 2**31 - 1 +MIN_64BIT_INT = -(2**63) +MAX_64BIT_INT = 2**63 - 1 + + +# pylint: disable=too-few-public-methods +class Iterator(IteratorABC): + """Universal iterator for many of BLPAPI objects. + + It can be used to iterate any sub-items in an item which has + the following methods: + * method returning the number of sub-items + * method returning the 'index'ed sub-item + + For example, it is currently used as an iterator for Service's event + definition in the following way: + + class Service(object): + ... + # Return an iterator over this Service's event definitions. + def eventDefinitions(self): + return utils.Iterator( + self, + Service.numEventDefinitions, + Service.getEventDefinitionAt) + + ... + + """ + + def __init__( + self, + objToIterate: Any, + numFunc: Callable[[Any], int], + getFunc: Callable[[Any, int], Any], + ) -> None: + self.__obj = objToIterate + self.__index = 0 + self.__num = numFunc(objToIterate) + self.__getter = getFunc + + def __iter__(self) -> IteratorType: + return self + + def __next__(self) -> Any: + if self.__index == self.__num: + raise StopIteration() + res = self.__getter(self.__obj, self.__index) + self.__index += 1 + return res + + next = __next__ + + +class MetaClassForClassesWithEnums(type): + """This meta class protects enums from changes. + + This meta class does not let change values of class members with names in + uppercase (a typical naming convention for enums). + + """ + + class EnumError(TypeError): + """Raise this on attempt to change value of an enumeration constant.""" + + def __setattr__(cls, name: str, value: Any) -> None: + """Change the value of an attribute if it is not an enum. + + Raise EnumError exception otherwise. + """ + if name.isupper() and name in cls.__dict__: + raise cls.EnumError(f"Can't change value of enum {name}") + type.__setattr__(cls, name, value) + + def __delattr__(cls, name: str) -> None: + """Unbind the attribute if it is not an enum. + + Raise EnumError exception otherwise. + """ + if name.isupper() and name in cls.__dict__: + raise cls.EnumError(f"Can't unbind enum {name}") + type.__delattr__(cls, name) + + +def get_handle(thing: Optional[CHandle]) -> Any: + """Returns the result of thing._handle() or None if thing is None or + thing._handle() is c_void_p and its value is None. + """ + # pylint: disable=protected-access + if thing is None: + return None + handle = thing._handle() + if handle is None: + return None + if isinstance(handle, c_void_p) and handle.value is None: + return None + return handle + + +def invoke_if_valid(cb: Any, value: Any) -> Any: + """Returns the result of cb(value) if cb is callable, else -- just value""" + if cb is None or not callable(cb): + return value + return cb(value) + + +def deprecated(func_or_reason: Union[Callable, str]) -> Callable: + """ + This is a decorator which can be used to mark classes or functions + as deprecated. It results in a warning being emitted when the class or the + function is called. + + To use this, decorate the deprecated class or function with + **@deprecated** with or without a message: + + code-block:: python + + from blpapi.util import deprecated + + @deprecated + def old_function(msg): + print(msg) + + @deprecated + class OldClass: + + @deprecated("use another function") + def old_function(self, msg); + print(msg) + """ + + is_func = callable(func_or_reason) + message = "see docstring for details." if is_func else func_or_reason + + def decorate(func: Callable) -> Callable: + @functools.wraps(func) + def wrap_func(*args: Any, **kwargs: Any) -> Any: + warnings.warn( + f"{func.__name__} is deprecated, {message}.", + category=DeprecationWarning, + stacklevel=2, + ) + return func(*args, **kwargs) + + return wrap_func + + if is_func: + return decorate(func_or_reason) # type: ignore + + return decorate + + +# NOTE: `isNonScalarSequence` is used to determine whether `obj` is a +# `Sequence` but does not behave like a scalar. Useful for `Element` and +# `Event` formatting. +# pylint: disable=deprecated-class,no-name-in-module +def isNonScalarSequence(obj: Any) -> bool: + scalarTypes = (str, bytes, bytearray, memoryview) + return isinstance(obj, Sequence) and not isinstance(obj, scalarTypes) + + +# NOTE: Our Python3 wrapper uses unicode strings (str type) for passing +# strings to C-functions so we need to decode byte-strings first to get unicode +# strings. Rule of thumb: to pass string to any wrapper function convert +# it using `conv2str` function first, to check that type of the string +# is correct - use `isstr` function. +def conv2str(s: Union[bytes, str]) -> str: + """Convert byte string to unicode string.""" + if isinstance(s, bytes): + return s.decode() + if isinstance(s, str): + return s + + +def isstr(s: Any) -> bool: + if isinstance(s, STR_TYPES): + return True + return False + + +__copyright__ = """ +Copyright 2012. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +""" diff --git a/src/blpapi/version.py b/src/blpapi/version.py new file mode 100644 index 0000000..2891181 --- /dev/null +++ b/src/blpapi/version.py @@ -0,0 +1,39 @@ +# version.py + +"""Provide BLPAPI SDK versions""" + +from . import internals + +__version__ = "3.24.11" +__expected_cpp_sdk_version__ = "3.24.11" + + +def print_version() -> None: + """Print version information of BLPAPI python module and blpapi C++ SDK""" + print("Python BLPAPI SDK version: ", version()) + print("C++ BLPAPI SDK version: ", cpp_sdk_version()) + print("Expected C++ SDK version >= ", expected_cpp_sdk_version()) + + +def version() -> str: + """ + Returns: + str: BLPAPI Python module version + """ + return __version__ + + +def cpp_sdk_version() -> str: + """ + Returns: + str: BLPAPI C++ SDK dependency version + """ + return internals.blpapi_getVersionInfo() + + +def expected_cpp_sdk_version() -> str: + """ + Returns: + str: Expected (minimum compatible) BLPAPI C++ SDK dependency version + """ + return __expected_cpp_sdk_version__ diff --git a/src/blpapi/zfputil.py b/src/blpapi/zfputil.py new file mode 100644 index 0000000..5a589dc --- /dev/null +++ b/src/blpapi/zfputil.py @@ -0,0 +1,109 @@ +# zfputil.py + +"""Provide utilities designed for the Zero Footprint solution clients that +leverage private leased lines to the Bloomberg network. + +This file defines a 'ZfpUtil' class which is used to prepare session options +for private leased lines. + +Usage +---- + +The following snippet shows how to use ZfpUtil to start a Session. + +tlsOptions = blpapi.TlsOptions.createFromFiles( ... ) +sessionOptions = blpapi.ZfpUtil.getZfpOptionsForLeasedLines( + blpapi.ZfpUtil.REMOTE_8194, + tlsOptions) + +sessionOptions.setAuthenticationOptions( ... ) + +session = blpapi.Session(sessionOptions) +session.start() +""" +from . import utils +from . import internals +from . import typehints # pylint: disable=unused-import +from .exception import _ExceptionUtil +from .sessionoptions import SessionOptions + + +# pylint: disable=too-few-public-methods +class ZfpUtil(metaclass=utils.MetaClassForClassesWithEnums): + """Utility used to prepare :class:`SessionOptions` for private leased + lines. + + The following snippet shows how to use :class:`ZfpUtil` to start a + ``Session``:: + + tlsOptions = blpapi.TlsOptions.createFromFiles( ... ) + sessionOptions = blpapi.ZfpUtil.getZfpOptionsForLeasedLines( + blpapi.ZfpUtil.REMOTE_8194, + tlsOptions) + + sessionOptions.setAuthenticationOptions( ... ) + + session = blpapi.Session(sessionOptions) + session.start() + """ + + REMOTE_8194 = internals.ZFPUTIL_REMOTE_8194 + REMOTE_8196 = internals.ZFPUTIL_REMOTE_8196 + + @staticmethod + def getZfpOptionsForLeasedLines( + remote: int, tlsOptions: "typehints.TlsOptions" + ) -> "typehints.SessionOptions": + """Creates a :class:`SessionOptions` object for applications that + leverage private leased lines to the Bloomberg network. + + Args: + remote (int): Type of the remote to connect to + tlsOptions (TlsOptions): Tls options to use when connecting + + Returns: + SessionOptions: :class:`SessionOptions` object for applications + that leverage private leased lines to the Bloomberg network. + + Raises: + Exception: If failed to obtain the session options + + Note: + The :class:`SessionOptions` object is only valid for private leased + line connectivity. + + Note: + This is a costly operation that is preferably called once per + application. + """ + sessionOptions = SessionOptions() + err = internals.blpapi_ZfpUtil_getOptionsForLeasedLines( + utils.get_handle(sessionOptions), + utils.get_handle(tlsOptions), + remote, + ) + _ExceptionUtil.raiseOnError(err) + + return sessionOptions + + +__copyright__ = """ +Copyright 2019. Bloomberg Finance L.P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above +copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +"""