# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved.
# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved.
# Copyright (c) 2024 Bentley Systems, Incorporated. All rights reserved.
### extends 'class_empty.py'
### block ClassImports
# NOTICE: Do not edit anything here, it is generated code
from . import gxapi_cy
from geosoft.gxapi import GXContext, float_ref, int_ref, str_ref
### endblock ClassImports
### block Header
# NOTICE: The code generator will not replace the code in this block
### endblock Header
### block ClassImplementation
# NOTICE: Do not edit anything here, it is generated code
[docs]
class GXDOCU(gxapi_cy.WrapDOCU):
"""
GXDOCU class.
Class to work with documents
"""
[docs]
def __init__(self, handle=0):
super(GXDOCU, self).__init__(GXContext._get_tls_geo(), handle)
[docs]
@classmethod
def null(cls):
"""
A null (undefined) instance of `GXDOCU <geosoft.gxapi.GXDOCU>`
:returns: A null `GXDOCU <geosoft.gxapi.GXDOCU>`
:rtype: GXDOCU
"""
return GXDOCU()
[docs]
def is_null(self):
"""
Check if this is a null (undefined) instance
:returns: True if this is a null (undefined) instance, False otherwise.
:rtype: bool
"""
return self._internal_handle() == 0
# Miscellaneous
[docs]
def copy(self, doc_us):
"""
Copy `GXDOCU <geosoft.gxapi.GXDOCU>`
:param doc_us: Source `GXDOCU <geosoft.gxapi.GXDOCU>`
:type doc_us: GXDOCU
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
self._copy(doc_us)
[docs]
@classmethod
def create(cls):
"""
Create a document onject
:returns: `GXDOCU <geosoft.gxapi.GXDOCU>` Object
:rtype: GXDOCU
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
ret_val = gxapi_cy.WrapDOCU._create(GXContext._get_tls_geo())
return GXDOCU(ret_val)
[docs]
@classmethod
def create_s(cls, bf):
"""
Create from a serialized source
:param bf: `GXBF <geosoft.gxapi.GXBF>` from which to read `GXDOCU <geosoft.gxapi.GXDOCU>`
:type bf: GXBF
:returns: `GXDOCU <geosoft.gxapi.GXDOCU>` Object
:rtype: GXDOCU
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
ret_val = gxapi_cy.WrapDOCU._create_s(GXContext._get_tls_geo(), bf)
return GXDOCU(ret_val)
[docs]
def get_file(self, file):
"""
Get the document and place in a file.
:param file: File to which to write document
:type file: str
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
self._get_file(file.encode())
[docs]
def doc_name(self, name):
"""
The document name.
:param name: Buffer to fill with document name
:type name: str_ref
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
name.value = self._doc_name(name.value.encode())
[docs]
def file_name(self, name):
"""
The original document file name.
:param name: Buffer to fill with document file name
:type name: str_ref
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
name.value = self._file_name(name.value.encode())
[docs]
def is_reference(self):
"""
Is the document only a reference (a URL) ?
:returns: 1 - Yes, 0 - No
:rtype: int
.. versionadded:: 5.1.6
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
ret_val = self._is_reference()
return ret_val
[docs]
def open(self, mode):
"""
Open a document in the document viewer
:param mode: :ref:`DOCU_OPEN`
:type mode: int
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
**Note:** On Windows, the default application for the file extension is
used to open the file.
"""
self._open(mode)
[docs]
def serial(self, bf):
"""
Serialize `GXDOCU <geosoft.gxapi.GXDOCU>`
:param bf: `GXBF <geosoft.gxapi.GXBF>` in which to write object
:type bf: GXBF
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
"""
self._serial(bf)
[docs]
def set_file(self, type, name, file):
"""
Set the document from a file source.
:param type: Document type
:param name: Document name, if "" file name will be used
:param file: Document file, must exist
:type type: str
:type name: str
:type file: str
.. versionadded:: 5.1.1
**License:** `Geosoft Open License <https://geosoftgxdev.atlassian.net/wiki/spaces/GD/pages/2359406/License#License-open-lic>`_
**Note:** Document types are normally identified by their extension. If you
leave the document type blank, the extension of the document file
will be used as the document type.
To resolve conflicting types, you can define your own unique type
by entering your own type "extension" string.
The following types are pre-defined (as are any normal Geosoft
file types):
"htm" HTML
"html" HTML
"txt" ASCII text file
"doc" Word for Windows document
"pdf" Adobe PDF
"map" Geosoft map file
"mmap" Mapinfo map file (real extension "map")
"grd" Geosoft grid file
"gdb" Geosoft database
URL Document Links
The document name can be a URL link to the document using one of
the supported protocols. The following protocols are supported:
http://www.mywebserver.com/MyFile.doc - `GXHTTP <geosoft.gxapi.GXHTTP>`
dap://my.dap.server.com/dcs?DatasetName?MyFile.doc - DAP (DAP Document Access)
ftp://my.ftp.server.com/Dir1/MyFile.doc - FTP protocol
The full file name will be stored but no data will be stored with
the `GXDOCU <geosoft.gxapi.GXDOCU>` class and the document can be retrieved using the sGetFile_DOCU
method.
"""
self._set_file(type.encode(), name.encode(), file.encode())
### endblock ClassImplementation
### block ClassExtend
# NOTICE: The code generator will not replace the code in this block
### endblock ClassExtend
### block Footer
# NOTICE: The code generator will not replace the code in this block
### endblock Footer