Skip to main content

libraries.editor.editor

ct​

functools​

io​

os​

contextmanager​

Union​

Optional​

glasswall​

dft​

utils​

log​

format_object​

errors​

successes​

Library​

Editor Objects​

class Editor(Library)

A high level Python wrapper for Glasswall Editor / Core2.

__init__​

def __init__(library_path: str,
licence: Union[str, bytes, bytearray, io.BytesIO] = None)

Initialise the Editor instance.

Arguments:

  • library_path str - The file or directory path to the Editor library.
  • licence str, bytes, bytearray, or io.BytesIO, optional - The licence file content or path. This can be:
    • A string representing the file path to the licence.
    • A bytes or bytearray object containing the licence data.
    • An io.BytesIO object for in-memory licence data. If not specified, it is assumed that the licence file is located in the same directory as the library_path.

validate_licence​

def validate_licence()

Validates the licence of the library by checking the licence details.

Raises:

  • LicenceExpired - If the licence has expired or could not be validated.

version​

def version()

Returns the Glasswall library version.

Returns:

  • version str - The Glasswall library version.

open_session​

def open_session()

Open a new Glasswall session.

Returns:

  • session int - An incrementing integer repsenting the current session.

close_session​

def close_session(session: int) -> int

Close the Glasswall session. All resources allocated by the session will be destroyed.

Arguments:

  • session int - The session to close.

Returns:

  • status int - The status code of the function call.

new_session​

@contextmanager
def new_session()

Context manager. Opens a new session on entry and closes the session on exit.

run_session​

def run_session(session)

Runs the Glasswall session and begins processing of a file.

Arguments:

  • session int - The session to run.

Returns:

  • status int - The status code of the function call.

determine_file_type​

def determine_file_type(input_file: Union[str, bytes, bytearray, io.BytesIO],
as_string: bool = False,
raise_unsupported: bool = True) -> Union[int, str]

Determine the file type of a given input file, either as an integer identifier or a string.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file to analyse. It can be provided as a file path (str), bytes, bytearray, or a BytesIO object.
  • as_string bool, optional - Return file type as string, eg: "bmp" instead of: 29. Defaults to False.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • file_type Union[int, str] - The file type.

_GW2GetPolicySettings​

def _GW2GetPolicySettings(session: int, policy_format: int = 0)

Get current policy settings for the given session.

Arguments:

  • session int - The session integer.
  • policy_format int - The format of the content management policy. 0=XML.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', 'status', 'policy'.

get_content_management_policy​

def get_content_management_policy(session: int)

Returns the content management configuration for a given session.

Arguments:

  • session int - The session integer.

Returns:

  • xml_string str - The XML string of the current content management configuration.

_GW2RegisterPoliciesFile​

def _GW2RegisterPoliciesFile(session: int,
input_file: str,
policy_format: int = 0)

Registers the policies to be used by Glasswall when processing files.

Arguments:

  • session int - The session integer.
  • input_file str - The content management policy input file path.
  • policy_format int - The format of the content management policy. 0=XML.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'input_file', 'policy_format', 'status'.

_GW2RegisterPoliciesMemory​

def _GW2RegisterPoliciesMemory(session: int,
input_file: bytes,
policy_format: int = 0)

Registers the policies in memory to be used by Glasswall when processing files.

Arguments:

  • session int - The session integer.
  • input_file str - The content management policy input file bytes.
  • policy_format int - The format of the content management policy. 0=XML.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.

set_content_management_policy​

def set_content_management_policy(
session: int,
input_file: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
policy_format=0)

Sets the content management policy configuration. If input_file is None then default settings (sanitise) are applied.

Arguments:

  • session int - The session integer.
  • input_file Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - Default None (sanitise). The content management policy to apply.
  • policy_format int - The format of the content management policy. 0=XML.

Returns:

  • result (glasswall.GwReturnObj): Depending on the input 'input_file':

  • If input_file is a str file path:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'policy_format', 'status'.

  • If input_file is a file in memory:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.

_GW2RegisterInputFile​

def _GW2RegisterInputFile(session: int, input_file: str)

Register an input file for the given session.

Arguments:

  • session int - The session integer.
  • input_file str - The input file path.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.

_GW2RegisterInputMemory​

def _GW2RegisterInputMemory(session: int, input_file: bytes)

Register an input file in memory for the given session.

Arguments:

  • session int - The session integer.
  • input_file bytes - The input file in memory.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

register_input​

def register_input(session: int, input_file: Union[str, bytes, bytearray,
io.BytesIO])

Register an input file or bytes for the given session.

Arguments:

  • session int - The session integer.
  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.

Returns:

  • result (glasswall.GwReturnObj): Depending on the input 'input_file':

  • If input_file is a str file path:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.

  • If input_file is a file in memory:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

_GW2RegisterOutFile​

def _GW2RegisterOutFile(session: int, output_file: str)

Register an output file for the given session.

Arguments:

  • session int - The session integer.
  • output_file str - The output file path.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

_GW2RegisterOutputMemory​

def _GW2RegisterOutputMemory(session: int)

Register an output file in memory for the given session.

Arguments:

  • session int - The session integer.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

register_output​

def register_output(session, output_file: Optional[str] = None)

Register an output file for the given session. If output_file is None the file will be returned as 'buffer' and 'buffer_length' attributes.

Arguments:

  • session int - The session integer.
  • output_file Optional[str] - If specified, during run session the file will be written to output_file, otherwise the file will be written to the glasswall.GwReturnObj 'buffer' and 'buffer_length' attributes.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attribute 'status' indicating the result of the function call. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.

_GW2RegisterAnalysisFile​

def _GW2RegisterAnalysisFile(session: int,
output_file: str,
analysis_format: int = 0)

Register an analysis output file for the given session.

Arguments:

  • session int - The session integer.
  • output_file str - The analysis output file path.
  • analysis_format int - The format of the analysis report. 0=XML, 1=XMLExtended

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'analysis_format', 'status'.

_GW2RegisterAnalysisMemory​

def _GW2RegisterAnalysisMemory(session: int, analysis_format: int = 0)

Register an analysis output file in memory for the given session.

Arguments:

  • session int - The session integer.
  • analysis_format int - The format of the analysis report. 0=XML, 1=XMLExtended

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'analysis_format', 'status'.

register_analysis​

def register_analysis(session: int, output_file: Optional[str] = None)

Registers an analysis file for the given session. The analysis file will be created during the session's run_session call.

Arguments:

  • session int - The session integer.
  • output_file Optional[str] - Default None. The file path where the analysis will be written. None returns the analysis as bytes.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'status', 'session', 'analysis_format'. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size. If output_file is not None (file mode) 'output_file' is included.

protect_file​

def protect_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Protects a file using the current content management configuration, returning the file bytes. The protected file is written to output_file if it is provided.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Optional[str] - The output file path where the protected file will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • file_bytes bytes - The protected file bytes.

protect_directory​

def protect_directory(
input_directory: str,
output_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Recursively processes all files in a directory in protect mode using the given content management policy. The protected files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to protect.
  • output_directory Optional[str] - The output directory where the protected file will be written, or None to not write files.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - Default None (sanitise). The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • protected_files_dict dict - A dictionary of file paths relative to input_directory, and file bytes.

analyse_file​

def analyse_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Analyses a file, returning the analysis bytes. The analysis is written to output_file if it is provided.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Optional[str] - The output file path where the analysis file will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • file_bytes bytes - The analysis file bytes.

analyse_directory​

def analyse_directory(
input_directory: str,
output_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Analyses all files in a directory and its subdirectories. The analysis files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to analyse.
  • output_directory Optional[str] - The output directory where the analysis files will be written, or None to not write files.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - Default None (sanitise). The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • analysis_files_dict dict - A dictionary of file paths relative to input_directory, and file bytes.

protect_and_analyse_file​

def protect_and_analyse_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_analysis_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Protects and analyses a file in a single session, returning both protected file bytes and analysis report bytes.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Optional[str] - The output file path where the protected file will be written.
  • output_analysis_report Optional[str] - The output file path where the XML analysis report will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

Tuple[Optional[bytes], Optional[bytes]]: A tuple of (protected_file_bytes, analysis_report_bytes).

protect_and_analyse_directory​

def protect_and_analyse_directory(
input_directory: str,
output_directory: Optional[str],
analysis_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Recursively processes all files in a directory using protect and analyse mode with the given content management policy. Outputs are written to output_directory and analysis_directory maintaining the same structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to process.
  • output_directory Optional[str] - The output directory for protected files.
  • analysis_directory Optional[str] - The output directory for XML analysis reports.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • result_dict dict - A dictionary mapping relative file paths to tuples of (protected_file_bytes, analysis_report_bytes).

_GW2RegisterExportFile​

def _GW2RegisterExportFile(session: int, output_file: str)

Register an export output file for the given session.

Arguments:

  • session int - The session integer.
  • output_file str - The export output file path.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

_GW2RegisterExportMemory​

def _GW2RegisterExportMemory(session: int)

Register an export output file in memory for the given session.

Arguments:

  • session int - The session integer.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

register_export​

def register_export(session: int, output_file: Optional[str] = None)

Registers a file to be exported for the given session. The export file will be created during the session's run_session call.

Arguments:

  • session int - The session integer.
  • output_file Optional[str] - Default None. The file path where the export will be written. None exports the file in memory.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attribute 'status' indicating the result of the function call and 'session', the session integer. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.

export_file​

def export_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Export a file, returning the .zip file bytes. The .zip file is written to output_file if it is provided.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Optional[str] - The output file path where the .zip file will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • file_bytes bytes - The exported .zip file.

export_directory​

def export_directory(
input_directory: str,
output_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Exports all files in a directory and its subdirectories. The export files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to export.
  • output_directory Optional[str] - The output directory where the export files will be written, or None to not write files.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - Default None (sanitise). The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • export_files_dict dict - A dictionary of file paths relative to input_directory, and file bytes.

export_and_analyse_file​

def export_and_analyse_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_analysis_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Exports and analyses a file in a single session, returning both exported .zip bytes and analysis report bytes.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Optional[str] - The output file path where the .zip export will be written.
  • output_analysis_report Optional[str] - The output file path where the XML analysis report will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

Tuple[Optional[bytes], Optional[bytes]]: A tuple of (exported_file_bytes, analysis_report_bytes).

export_and_analyse_directory​

def export_and_analyse_directory(
input_directory: str,
output_directory: Optional[str],
analysis_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Recursively processes all files in a directory using export and analyse mode with the given content management policy. Outputs are written to output_directory and analysis_directory maintaining the same structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to process.
  • output_directory Optional[str] - The output directory for exported .zip files.
  • analysis_directory Optional[str] - The output directory for XML analysis reports.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • result_dict dict - A dictionary mapping relative file paths to tuples of (exported_file_bytes, analysis_report_bytes).

_GW2RegisterImportFile​

def _GW2RegisterImportFile(session: int, input_file: str)

Register an import input file for the given session.

Arguments:

  • session int - The session integer.
  • input_file str - The input import file path.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

_GW2RegisterImportMemory​

def _GW2RegisterImportMemory(session: int, input_file: bytes)

Register an import input file in memory for the given session.

Arguments:

  • session int - The session integer.
  • input_file str - The input import file in memory.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

register_import​

def register_import(session: int, input_file: Union[str, bytes, bytearray,
io.BytesIO])

Registers a .zip file to be imported for the given session. The constructed file will be created during the session's run_session call.

Arguments:

  • session int - The session integer.
  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input import file path or bytes.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attribute 'status' indicating the result of the function call. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.

import_file​

def import_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Import a .zip file, constructs a file from the .zip file and returns the file bytes. The file is written to output_file if it is provided.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The .zip input file path or bytes.
  • output_file Optional[str] - The output file path where the constructed file will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - The content management policy to apply to the session.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • file_bytes bytes - The imported file bytes.

import_directory​

def import_directory(
input_directory: str,
output_directory: Optional[str],
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"] = None,
raise_unsupported: bool = True)

Imports all files in a directory and its subdirectories. Files are expected as .zip but this is not forced. The constructed files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to import.
  • output_directory Optional[str] - The output directory where the constructed files will be written, or None to not write files.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional - Default None (sanitise). The content management policy to apply.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • import_files_dict dict - A dictionary of file paths relative to input_directory, and file bytes.

_GW2FileErrorMsg​

def _GW2FileErrorMsg(session: int)

Retrieve the Glasswall Session Process error message.

Arguments:

  • session int - The session integer.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status', 'error_message'.

file_error_message​

@functools.lru_cache()
def file_error_message(session: int) -> str

Retrieve the Glasswall Session Process error message.

Arguments:

  • session int - The session integer.

Returns:

  • error_message str - The Glasswall Session Process error message.

GW2GetFileType​

def GW2GetFileType(session: int, file_type_id)

Retrieve the file type as a string.

Arguments:

  • session int - The session integer.
  • file_type_id int - The file type id.

Returns:

  • file_type str - The formal file name for the corresponding file id.

GW2GetFileTypeID​

def GW2GetFileTypeID(session: int, file_type_str)

Retrieve the Glasswall file type id given a file type string.

Arguments:

  • session int - The session integer.
  • file_type_str str - The file type as a string.

Returns:

  • file_type_id str - The Glasswall file type id for the specified file type.

get_file_type_info​

def get_file_type_info(file_type: Union[str, int])

Retrieve information about a file type based on its identifier.

Arguments:

  • file_type Union[str, int] - The file type identifier. This can be either a string representing a file extension (e.g. 'bmp') or an integer corresponding to a file type (e.g. 29).

Returns:

  • file_type_info (Union[int, str]): Depending on the input 'file_type':
  • If file_type is a string (e.g. 'bmp'):
  • If the file type is recognised, returns an integer corresponding to that file type.
  • If the file type is not recognised, returns 0.
  • If file_type is an integer (e.g. 29):
  • If the integer corresponds to a recognised file type, returns a more detailed string description of the file type (e.g. 'BMP Image').
  • If the integer does not match any recognised file type, returns an empty string.

get_file_info​

@utils.deprecated_function(replacement_function=get_file_type_info)
def get_file_info(*args, **kwargs)

Deprecated in 1.0.6. Use get_file_type_info.

_GW2RegisterReportFile​

def _GW2RegisterReportFile(session: int, output_file: str)

Register an output report file path for the given session.

Arguments:

  • session int - The session integer.
  • output_file str - The file path of the output report file.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

register_report_file​

def register_report_file(session: int, output_file: str)

Register the report file path for the given session.

Arguments:

  • session int - The session integer.
  • output_file str - The file path of the report file.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

_GW2GetIdInfo​

def _GW2GetIdInfo(session: int, issue_id: int)

Retrieves the group description for the given Issue ID. e.g. issue_id 96 returns "Document Processing Instances"

Arguments:

  • session int - The session integer.
  • issue_id int - The issue id.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'issue_id', 'buffer_length', 'buffer', 'status', 'id_info'.

get_id_info​

def get_id_info(issue_id: int, raise_unsupported: bool = True)

Retrieves the group description for the given Issue ID. e.g. issue_id 96 returns "Document Processing Instances"

Arguments:

  • issue_id int - The issue id.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • id_info str - The group description for the given Issue ID.

_GW2GetAllIdInfo​

def _GW2GetAllIdInfo(session: int)

Retrieves the XML containing all the Issue ID ranges with their group descriptions

Arguments:

  • session int - The session integer.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'analysis_format', 'status', 'all_id_info'.

get_all_id_info​

def get_all_id_info(output_file: Optional[str] = None,
raise_unsupported: bool = True) -> str

Retrieves the XML containing all the Issue ID ranges with their group descriptions

Arguments:

  • output_file Optional[str] - The output file path where the analysis file will be written.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • all_id_info str - A string XML analysis report containing all id info.

_GW2FileSessionStatus​

def _GW2FileSessionStatus(session: int)

Retrieves the Glasswall Session Status. Also gives a high level indication of the processing that was carried out on the last document processed by the library

Arguments:

  • session int - The session integer.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'session_status', 'buffer', 'buffer_length', 'status', 'message'.

file_session_status_message​

def file_session_status_message(session: int,
raise_unsupported: bool = True) -> str

Retrieves the Glasswall session status message. Gives a high level indication of the processing that was carried out.

Arguments:

  • session int - The session integer.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

result.message (str):The file session status message.

_GW2LicenceDetails​

def _GW2LicenceDetails(session: int)

Returns a human readable string containing licence details.

Arguments:

  • session int - The session integer.

Returns:

  • licence_details str - A human readable string representing the relevant information contained in the licence.

licence_details​

def licence_details()

Returns a string containing details of the licence.

Returns:

  • result str - A string containing details of the licence.

_GW2RegisterExportTextDumpMemory​

def _GW2RegisterExportTextDumpMemory(session: int)

Registers an export text dump to be written in memory.

Arguments:

  • session int - The session integer.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

_GW2RegisterExportTextDumpFile​

def _GW2RegisterExportTextDumpFile(session: int, output_file: str)

Registers an export text dump to be written to file.

Arguments:

  • session int - The session integer.
  • output_file str - The file path of the text dump file.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'output_file', 'status'.

_GW2RegisterLicenceFile​

def _GW2RegisterLicenceFile(session: int, input_file: str)

Registers a "gwkey.lic" licence from file path.

Arguments:

  • session int - The session integer.
  • input_file str - The "gwkey.lic" licence input file path.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.

_GW2RegisterLicenceMemory​

def _GW2RegisterLicenceMemory(session: int, input_file: bytes)

Registers a "gwkey.lic" licence from memory.

Arguments:

  • session int - The session integer.
  • input_file bytes - The "gwkey.lic" licence input file.

Returns:

  • gw_return_object glasswall.GwReturnObj - A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

register_licence​

def register_licence(session: int, input_file: Union[str, bytes, bytearray,
io.BytesIO])

Registers a "gwkey.lic" licence from file path or memory.

Arguments:

  • session int - The session integer.
  • input_file Union[str, bytes, bytearray, io.BytesIO] - The "gwkey.lic" licence. It can be provided as a file path (str), bytes, bytearray, or a BytesIO object.

Returns:

  • result (glasswall.GwReturnObj): Depending on the input 'input_file':

  • If input_file is a str file path:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.

  • If input_file is a file in memory:

  • gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.