Skip to main content
Version: 16.11.0

glasswall

tempfile​

__version__​

__version__ = "5.9.0"

GwReturnObj​

class GwReturnObj()

An object intended mostly for internal use that has different attributes depending on which library and functionality utilises it, such as status, buffer, and buffer_bytes

__init__​

def __init__(**kwargs)

ft_pdf​

class ft_pdf(FileTypeEnumSuccess)

integer​

integer = 16

string​

string = "pdf"

ft_doc​

class ft_doc(FileTypeEnumSuccess)

integer​

integer = 17

string​

string = "doc"

ft_docx​

class ft_docx(FileTypeEnumSuccess)

integer​

integer = 18

string​

string = "docx"

ft_ppt​

class ft_ppt(FileTypeEnumSuccess)

integer​

integer = 19

string​

string = "ppt"

ft_pptx​

class ft_pptx(FileTypeEnumSuccess)

integer​

integer = 20

string​

string = "pptx"

ft_xls​

class ft_xls(FileTypeEnumSuccess)

integer​

integer = 21

string​

string = "xls"

ft_xlsx​

class ft_xlsx(FileTypeEnumSuccess)

integer​

integer = 22

string​

string = "xlsx"

ft_png​

class ft_png(FileTypeEnumSuccess)

integer​

integer = 23

string​

string = "png"

ft_jpeg​

class ft_jpeg(FileTypeEnumSuccess)

integer​

integer = 24

string​

string = "jpeg"

ft_gif​

class ft_gif(FileTypeEnumSuccess)

integer​

integer = 25

string​

string = "gif"

ft_emf​

class ft_emf(FileTypeEnumSuccess)

integer​

integer = 26

string​

string = "emf"

ft_wmf​

class ft_wmf(FileTypeEnumSuccess)

integer​

integer = 27

string​

string = "wmf"

ft_rtf​

class ft_rtf(FileTypeEnumSuccess)

integer​

integer = 28

string​

string = "rtf"

ft_bmp​

class ft_bmp(FileTypeEnumSuccess)

integer​

integer = 29

string​

string = "bmp"

ft_tiff​

class ft_tiff(FileTypeEnumSuccess)

integer​

integer = 30

string​

string = "tiff"

ft_pe​

class ft_pe(FileTypeEnumSuccess)

integer​

integer = 31

string​

string = "pe"

ft_macho​

class ft_macho(FileTypeEnumSuccess)

integer​

integer = 32

string​

string = "macho"

ft_elf​

class ft_elf(FileTypeEnumSuccess)

integer​

integer = 33

string​

string = "elf"

ft_mp4​

class ft_mp4(FileTypeEnumSuccess)

integer​

integer = 34

string​

string = "mp4"

ft_mp3​

class ft_mp3(FileTypeEnumSuccess)

integer​

integer = 35

string​

string = "mp3"

ft_mp2​

class ft_mp2(FileTypeEnumSuccess)

integer​

integer = 36

string​

string = "mp2"

ft_wav​

class ft_wav(FileTypeEnumSuccess)

integer​

integer = 37

string​

string = "wav"

ft_mpg​

class ft_mpg(FileTypeEnumSuccess)

integer​

integer = 38

string​

string = "mpg"

ft_coff​

class ft_coff(FileTypeEnumSuccess)

integer​

integer = 39

string​

string = "coff"

ft_json​

class ft_json(FileTypeEnumSuccess)

integer​

integer = 40

string​

string = "json"

ft_vbamacros​

class ft_vbamacros(FileTypeEnumSuccess)

integer​

integer = 41

string​

string = "vba"

ft_svg​

class ft_svg(FileTypeEnumSuccess)

integer​

integer = 42

string​

string = "svg"

ft_webp​

class ft_webp(FileTypeEnumSuccess)

integer​

integer = 43

string​

string = "webp"

ft_dylib​

class ft_dylib(FileTypeEnumSuccess)

integer​

integer = 44

string​

string = "dylib"

ft_utf8​

class ft_utf8(FileTypeEnumSuccess)

integer​

integer = 45

string​

string = "utf8"

ft_ascii​

class ft_ascii(FileTypeEnumSuccess)

integer​

integer = 46

string​

string = "ascii"

ft_zip​

class ft_zip(FileTypeEnumSuccess)

integer​

integer = 256

string​

string = "zip"

ft_gzip​

class ft_gzip(FileTypeEnumSuccess)

integer​

integer = 257

string​

string = "gz"

ft_bzip2​

class ft_bzip2(FileTypeEnumSuccess)

integer​

integer = 258

string​

string = "bz2"

ft_7zip​

class ft_7zip(FileTypeEnumSuccess)

integer​

integer = 259

string​

string = "7z"

ft_rar​

class ft_rar(FileTypeEnumSuccess)

integer​

integer = 260

string​

string = "rar"

ft_tar​

class ft_tar(FileTypeEnumSuccess)

integer​

integer = 261

string​

string = "tar"

ft_xz​

class ft_xz(FileTypeEnumSuccess)

integer​

integer = 262

string​

string = "xz"

ft_ooxml​

class ft_ooxml(FileTypeEnumSuccess)

integer​

integer = 512

string​

string = "ooxml"

ft_office​

class ft_office(FileTypeEnumSuccess)

integer​

integer = 513

string​

string = "office"

ft_bin​

class ft_bin(FileTypeEnumSuccess)

integer​

integer = 514

string​

string = "bin"

ft_xml​

class ft_xml(FileTypeEnumSuccess)

integer​

integer = 515

string​

string = "xml"

ft_docxPackageInCfb​

class ft_docxPackageInCfb(FileTypeEnumSuccess)

integer​

integer = 768

string​

string = "docxPackageInCfb"

ft_xlsxPackageInCfb​

class ft_xlsxPackageInCfb(FileTypeEnumSuccess)

integer​

integer = 769

string​

string = "xlsxPackageInCfb"

ft_pptxPackageInCfb​

class ft_pptxPackageInCfb(FileTypeEnumSuccess)

integer​

integer = 770

string​

string = "pptxPackageInCfb"

ft_xlscore​

class ft_xlscore(FileTypeEnumSuccess)

integer​

integer = 771

string​

string = "xlscore"

ft_doccore​

class ft_doccore(FileTypeEnumSuccess)

integer​

integer = 772

string​

string = "doccore"

ft_pptcore​

class ft_pptcore(FileTypeEnumSuccess)

integer​

integer = 773

string​

string = "pptcore"

ft_picturestream​

class ft_picturestream(FileTypeEnumSuccess)

integer​

integer = 774

string​

string = "picturestream"

ft_printersettings​

class ft_printersettings(FileTypeEnumSuccess)

integer​

integer = 775

string​

string = "printersettings"

ft_equationnative​

class ft_equationnative(FileTypeEnumSuccess)

integer​

integer = 776

string​

string = "equationnative"

ft_compobj​

class ft_compobj(FileTypeEnumSuccess)

integer​

integer = 777

string​

string = "compobj"

ft_docsummary​

class ft_docsummary(FileTypeEnumSuccess)

integer​

integer = 778

string​

string = "docsummary"

ft_opc​

class ft_opc(FileTypeEnumSuccess)

integer​

integer = 779

string​

string = "opc"

ft_cfb​

class ft_cfb(FileTypeEnumSuccess)

integer​

integer = 780

string​

string = "cfb"

ft_interchangePackage​

class ft_interchangePackage(FileTypeEnumSuccess)

integer​

integer = 781

string​

string = "interchangePackage"

ft_pdf_core2​

class ft_pdf_core2(FileTypeEnumSuccess)

integer​

integer = 782

string​

string = "pdf_core2"

ft_fi​

class ft_fi(FileTypeEnumSuccess)

integer​

integer = 783

string​

string = "fi"

ft_pdfContentStream​

class ft_pdfContentStream(FileTypeEnumSuccess)

integer​

integer = 784

string​

string = "pdfContentStream"

ft_rebuild​

class ft_rebuild(FileTypeEnumSuccess)

integer​

integer = 785

string​

string = "rebuild"

ft_gwlens​

class ft_gwlens(FileTypeEnumSuccess)

integer​

integer = 786

string​

string = "gwlens"

UnknownErrorCode​

class UnknownErrorCode(FileTypeEnumError)

Unknown error code.

ft_unknown​

class ft_unknown(FileTypeEnumError)

integer​

integer = 0

string​

string = "unknown"

ft_fileIssues​

class ft_fileIssues(FileTypeEnumError)

integer​

integer = 1

string​

string = "fileIssues"

ft_bufferIssues​

class ft_bufferIssues(FileTypeEnumError)

integer​

integer = 2

string​

string = "bufferIssues"

ft_internalIssues​

class ft_internalIssues(FileTypeEnumError)

integer​

integer = 3

string​

string = "internalIssues"

ft_licenseExpired​

class ft_licenseExpired(FileTypeEnumError)

integer​

integer = 4

string​

string = "licenseExpired"

ft_passwordProtectedOpcFile​

class ft_passwordProtectedOpcFile(FileTypeEnumError)

integer​

integer = 5

string​

string = "passwordProtectedOpcFile"

ft_nullPointerArgument​

class ft_nullPointerArgument(FileTypeEnumError)

integer​

integer = 6

string​

string = "nullPointerArgument"

ft_unsupportedFileType​

class ft_unsupportedFileType(FileTypeEnumError)

integer​

integer = 7

string​

string = "unsupportedFileType"

FileTypeEnum​

class FileTypeEnum()

Base class for all file type enumerations.

FileTypeEnumError​

class FileTypeEnumError(FileTypeEnum, Exception)

Enumerations that correspond to an error.

FileTypeEnumSuccess​

class FileTypeEnumSuccess(FileTypeEnum)

Enumerations that correspond to a file type.

FileTypeEnumSuccess​

error_list​

error_list = FileTypeEnumError.__subclasses__()

success_list​

success_list = FileTypeEnumSuccess.__subclasses__()

int_str_map​

int_str_map = {
fte_class.integer: fte_class.string
for fte_class in error_list + success_li ...

str_int_map​

str_int_map = {
fte_class.string: fte_class.integer
for fte_class in error_list + success_li ...

int_class_map​

int_class_map = {
fte_class.integer: fte_class
for fte_class in error_list + success_list
...

is_success​

def is_success(file_type: Union[int, str, FileTypeEnumError,
FileTypeEnumSuccess])

Checks if a file type corresponds to a success.

Arguments:

  • file_type Union[int, str, FileTypeEnumError, FileTypeEnumSuccess] - An enum int returned by Glasswall, str representation of file type, or subclass of FileTypeEnum.

Returns:

  • bool - Returns True if file_type corresponds to a successful file type, else False.

file_type_int_to_str​

def file_type_int_to_str(integer: int)

Converts a file type enum int to a string.

Arguments:

  • integer int - The enum int that Glasswall returns when ing a file type.

Returns:

Union[type(None), str]: The string representation of a file type, or None.

file_type_str_to_int​

def file_type_str_to_int(string: str)

Converts a file type string to an enum int.

Arguments:

  • string str - A string representation of a file type.

Returns:

Union[type(None), int]: The enum int that Glasswall returns when determining a file type, or None.

xml​

namespaces​

namespaces = {"gw": "http://glasswall.com/namespace"}

glasswall​

fmt​

fmt = "%(asctime)s.%(msecs)03d\t%(name)-29s\t%(levelname)-8s\t%(funcName)s\t\t%(message)s"

datefmt​

datefmt = "%Y-%m-%d %H:%M:%S"

log_formatter​

log_formatter = logging.Formatter(fmt, datefmt)

log_file_path​

log_file_path = os.path.join(
glasswall._TEMPDIR, "logs",
f'{datetime.now().strftime("%Y-%m- ...

log​

log = logging.getLogger(__name__)

log_handler​

log_handler = logging.FileHandler(log_file_path,
mode="w",
...

log_level​

log_level = os.environ.get("glasswall_log_level", logging.DEBUG)

console​

console = logging.StreamHandler()

console_level​

console_level = os.environ.get("glasswall_console_level", logging.INFO)

format_object​

def format_object(obj)

Task​

class Task()

__init__​

def __init__(func: Callable,
args: Optional[tuple] = None,
kwargs: Optional[dict] = None)

__eq__​

def __eq__(other)

__hash__​

def __hash__()

__repr__​

def __repr__()

TaskResult​

class TaskResult()

timeout_seconds​

timeout_seconds = None

memory_limit_in_gib​

memory_limit_in_gib = None

start_time​

start_time = None

end_time​

end_time = None

elapsed_time​

elapsed_time = None

out_of_memory​

out_of_memory = None

timed_out​

timed_out = None

max_memory_used_in_gib​

max_memory_used_in_gib = None

exit_code​

exit_code = None

__init__​

def __init__(task: Task,
success: bool,
result: Any = None,
exception: Union[Exception, None] = None)

__eq__​

def __eq__(other)

__hash__​

def __hash__()

__repr__​

def __repr__()

execute_task_and_put_in_queue​

def execute_task_and_put_in_queue(task: Task,
queue: "Queue[TaskResult]") -> None

TaskWatcher​

class TaskWatcher()

process​

process = None

start_time​

start_time = None

end_time​

end_time = None

elapsed_time​

elapsed_time = None

__init__​

def __init__(task: Task,
task_results_queue: "Queue[TaskResult]",
timeout_seconds: Optional[float] = None,
memory_limit_in_gib: Optional[float] = None,
sleep_time: float = 0.001,
memory_limit_polling_rate: float = 0.1,
auto_start: bool = True)

start_task​

def start_task() -> None

terminate_task​

def terminate_task() -> None

terminate_task_with_timeout​

def terminate_task_with_timeout() -> None

terminate_task_with_out_of_memory​

def terminate_task_with_out_of_memory() -> None

clean_watcher_queue​

def clean_watcher_queue()

watch_task​

def watch_task() -> None

update_queue​

def update_queue() -> None

psutil​

bytes_to_gigibytes​

def bytes_to_gigibytes(num_bytes: int) -> float

get_total_memory_usage_in_gib​

def get_total_memory_usage_in_gib(pid: Optional[int]) -> float

Calculate the total memory usage of a process and its child processes in gigibytes (GiB).

Arguments:

  • pid int, optional - The process ID for which memory usage is to be calculated. If None, returns 0.0.

Returns:

  • float - The total memory usage of the process and its children in GiB. If pid is None, returns 0.0.

get_available_memory_bytes​

def get_available_memory_bytes() -> int

Returns the available memory in bytes.

get_available_memory_gib​

def get_available_memory_gib() -> float

Returns the available memory in gigabytes.

GlasswallProcessManager​

class GlasswallProcessManager()

__init__​

def __init__(max_workers: Optional[int] = None,
worker_timeout_seconds: Optional[float] = None,
memory_limit_in_gib: Optional[float] = None)

__enter__​

def __enter__()

__exit__​

def __exit__(exc_type, exc_val, exc_tb)

queue_task​

def queue_task(task: Task)

as_completed​

def as_completed() -> Generator[TaskResult, None, None]

start_tasks​

def start_tasks()

wait_for_completed_process​

def wait_for_completed_process()

remove_completed_active_processes​

def remove_completed_active_processes()

clean_task_results_queue​

def clean_task_results_queue()

Library​

class Library()

A Glasswall library.

__init__​

def __init__(library_path: str)

load_library​

def load_library(library_path: str)

Success​

class Success(WordSearchSuccess)

WordSearch success code 1.

success_codes​

success_codes = {
1: Success,
}

UnknownErrorCode​

class UnknownErrorCode(WordSearchError)

Unknown error code.

Fail​

class Fail(WordSearchError)

WordSearch error code 0.

DisallowedItemFound​

class DisallowedItemFound(WordSearchError)

WordSearch error code -1024. Item disallowed by policy found in file.

RequiredItemNotFound​

class RequiredItemNotFound(WordSearchError)

WordSearch error code -1025. Item required by policy not found in file.

IllegalActionRedact​

class IllegalActionRedact(WordSearchError)

WordSearch error code -1026. Redact action specified but filetype doesn't support redaction.

IllegalActionRequire​

class IllegalActionRequire(WordSearchError)

WordSearch error code -1027. Require action specified but filetype doesn't support redaction.

IllegalActionNoRequire​

class IllegalActionNoRequire(WordSearchError)

WordSearch error code -1028. Require action not specified but filetype needs one.

FiletypeUnsupported​

class FiletypeUnsupported(WordSearchError)

WordSearch error code -1029. Filetype supported by Editor but not by Word Search.

error_codes​

error_codes = {
0: Fail,
-1024: DisallowedItemFound,
-1025: RequiredItemNotFound,
-1 ...

WordSearchError​

class WordSearchError(Exception)

Base class for all WordSearch errors.

WordSearchSuccess​

class WordSearchSuccess()

Base class for all WordSearch successes.

WordSearch​

class WordSearch(Library)

A high level Python wrapper for Glasswall WordSearch.

__init__​

def __init__(library_path: str)

version​

def version()

Returns the Glasswall library version.

Returns:

  • version str - The Glasswall library version.

redact_file​

@glasswall.utils.deprecated_alias(xml_config="content_management_policy")
def redact_file(input_file: Union[str, bytes, bytearray, io.BytesIO],
content_management_policy: Union[str, bytes, bytearray,
io.BytesIO],
output_file: Union[None, str] = None,
output_report: Union[None, str] = None,
homoglyphs: Union[None, str, bytes, bytearray,
io.BytesIO] = None,
raise_unsupported: bool = True)

Redacts text from input_file using the given content_management_policy and homoglyphs file, optionally writing the redacted file and report to the paths specified by output_file and output_report.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes. content_management_policy (Union[str, bytes, bytearray, io.BytesIO)]): The content management policy to apply.
  • output_file Union[None, str], optional - Default None. If str, write output_file to that path.
  • output_report Union[None, str], optional - Default None. If str, write output_file to that path. homoglyphs (Union[None, str, bytes, bytearray, io.BytesIO)], optional): Default None. The homoglyphs json file path or bytes.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

redact_directory​

@glasswall.utils.deprecated_alias(xml_config="content_management_policy")
def redact_directory(input_directory: str,
content_management_policy: Union[
str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.policy.Policy],
output_directory: Optional[str] = None,
output_report_directory: Optional[str] = None,
homoglyphs: Union[None, str, bytes, bytearray,
io.BytesIO] = None,
raise_unsupported: bool = True)

Redacts all files in a directory and it's subdirectories using the given content_management_policy and homoglyphs file. The redacted files are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing files to redact.
  • output_directory str - The output directory where the redacted files will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where analysis reports for each redacted file will be written. content_management_policy (Union[str, bytes, bytearray, io.BytesIO)]): The content management policy to apply. homoglyphs (Union[None, str, bytes, bytearray, io.BytesIO)], optional): Default None. The homoglyphs file path, str, or bytes.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • redacted_files_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

os_info​

os_info = {
"Linux": {
"archive_manager": {
"file_name": "libglasswall.archi ...

Success​

class Success(RebuildSuccess)

Rebuild success code 1. This value indicates the operation completed successfully. Any required Analysis or Protection was carried out and completed.

success_codes​

success_codes = {
1: Success,
}

UnknownErrorCode​

class UnknownErrorCode(RebuildError)

Unknown error code.

Error​

class Error(RebuildError)

Rebuild error code 0. This value indicates that the document was non-conformant in some way, but any requested output files were written.

SuccessDocumentWriteFailure​

class SuccessDocumentWriteFailure(RebuildError)

Rebuild error code -1. This value indicates that the document was managed successfully, but a failure occurred when writing the managed version of the document to file.

SuccessAnalysisWriteFailure​

class SuccessAnalysisWriteFailure(RebuildError)

Rebuild error code -2. This value indicates that the document was analysed successfully, but a failure occurred when writing the analysis of the document to file.

ErrorAnalysisWriteFailure​

class ErrorAnalysisWriteFailure(RebuildError)

Rebuild error code -3. This value indicates that the document was non-conformant in some way, and a failure occurred when writing the analysis of the document to file.

SuccessReportWriteFailure​

class SuccessReportWriteFailure(RebuildError)

Rebuild error code -4. This value indicates that the document was processed successfully, but that a failure occurred when writing the processing report to file.

SuccessDocumentReportWriteFailure​

class SuccessDocumentReportWriteFailure(RebuildError)

Rebuild error code -5. This value indicates that the document was managed successfully, but a failure occurred when writing both the managed version of the document and the processing report to file.

ErrorReportWriteFailure​

class ErrorReportWriteFailure(RebuildError)

Rebuild error code -6. This value indicates that the document was non-conformant in some way, and that a failure occurred when writing the processing report to file.

SuccessAnalysisReportWriteFailure​

class SuccessAnalysisReportWriteFailure(RebuildError)

Rebuild error code -7. This value indicates that the document was analysed successfully, but a failure occurred when writing both the analysis of the document and the processing report to file.

ErrorAnalysisReportWriteFailure​

class ErrorAnalysisReportWriteFailure(RebuildError)

Rebuild error code -8. This value indicates that the document was non-conformant in some way, but a failure occurred when writing both the analysis of the document and the processing report to file.

InternalError​

class InternalError(RebuildError)

Rebuild error code -9. This value indicates an uncategorised error

SuccessDocumentAnalysisReportWriteFailure​

class SuccessDocumentAnalysisReportWriteFailure(RebuildError)

Rebuild error code -10. This value indicates that the document was analysed successfully, but failures occurred when writing the document, the analysis of the document and the processing report to file (AMP mode).

SuccessDocumentAnalysisWriteFailure​

class SuccessDocumentAnalysisWriteFailure(RebuildError)

Rebuild error code -11. This value indicates that the document was analysed successfully, but failures occurred when writing the document and the analysis of the document to file (AMP mode).

SuccessExportWriteFailure​

class SuccessExportWriteFailure(RebuildError)

Rebuild error code -12. This value indicates that the document was exported successfully, but failures occurred when writing the archive package. (Export mode)

ErrorExportWriteFailure​

class ErrorExportWriteFailure(RebuildError)

Rebuild error code -13. This value indicates that the document was non-conformant in some way, and failures occurred when writing the archive package. (Export mode)

ErrorRejectedFileFailure​

class ErrorRejectedFileFailure(RebuildError)

Rebuild error code -16. This value indicates that the document was processed successfully but rejected based on policy.

error_codes​

error_codes = {
0: Error,
-1: SuccessDocumentWriteFailure,
-2: SuccessAnalysisWriteFailu ...

RebuildError​

class RebuildError(Exception)

Base class for all Glasswall Rebuild errors.

RebuildSuccess​

class RebuildSuccess()

Base class for all Glasswall Rebuild successes.

Rebuild​

class Rebuild(Library)

A high level Python wrapper for Glasswall Rebuild / Classic.

__init__​

def __init__(library_path: str)

validate_licence​

def validate_licence()

Validates the licence of the library by attempting to call protect_file on a known supported file.

Raises:

  • RebuildError - If the licence could not be validated.

version​

def version()

Returns the Glasswall library version.

Returns:

  • version str - The Glasswall library version.

determine_file_type​

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

Returns an int representing the file type / file format of a file.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file, can be a local path.
  • 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 format.

get_content_management_policy​

def get_content_management_policy()

Gets the current content management configuration.

Returns:

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

set_content_management_policy​

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

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

Arguments:

  • 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.

Returns:

  • status int - The result of the Glasswall API call.

protect_file​

def protect_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Union[None, 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 Union[None, str], optional - 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.
  • 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: Union[None, 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 Union[None, 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: Union[None, 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 Union[None, str], optional - 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.
  • 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: Union[None, 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 Union[None, 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.

export_file​

def export_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Union[None, 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.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The input file path or bytes.
  • output_file Union[None, str], optional - 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.
  • 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: Union[None, 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 Union[None, 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.

import_file​

def import_file(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Union[None, 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 Union[None, str], optional - 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: Union[None, 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 Union[None, 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.

GWFileErrorMsg​

def GWFileErrorMsg()

Retrieve the Glasswall Process error message.

Returns:

  • error_message str - The Glasswall Process error message.

ArchiveManager​

class ArchiveManager(Library)

A high level Python wrapper for Glasswall Archive Manager.

__init__​

def __init__(library_path)

version​

def version()

Returns the Glasswall library version.

Returns:

  • version str - The Glasswall library version.

release​

def release()

Releases any resources held by the Glasswall Archive Manager library.

supported_archives​

@property
@functools.lru_cache()
def supported_archives()

Returns a list of supported archive file formats.

is_supported_archive​

@functools.lru_cache()
def is_supported_archive(archive_type: str)

Returns True if the archive type (e.g. 7z) is supported.

list_archive_paths​

def list_archive_paths(directory: str,
recursive: bool = True,
absolute: bool = True,
followlinks: bool = True)

Returns a list of file paths of supported archives in a directory and all of its subdirectories.

determine_file_type​

def determine_file_type(input_file: str,
as_string: bool = False,
raise_unsupported: bool = True)

Returns an int representing the file type of an archive.

Arguments:

input_file (str) The input file path.

  • as_string bool, optional - Return file type as string, eg: "xz" instead of: 262. 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 format.

analyse_archive​

def analyse_archive(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.ArchiveManager] = None,
raise_unsupported: bool = True)

Extracts the input_file archive and processes each file within the archive using the Glasswall engine. Repackages all files regenerated by the Glasswall engine into a new archive, optionally writing the new archive and report to the paths specified by output_file and output_report.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The archive file path or bytes.
  • output_file Optional[str], optional - Default None. If str, write the archive to the output_file path.
  • output_report Optional[str], optional - Default None. If str, write the analysis report to the output_report path.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes including: "status" (int), "output_file" (bytes), "output_report" (bytes)

analyse_directory​

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

Calls analyse_archive on each file in input_directory using the given content management configuration. The resulting archives and analysis reports are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing archives to analyse.
  • output_directory Optional[str], optional - Default None. If str, the output directory where the archives containing analysis reports of each file will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where xml reports for each archive will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • analysed_archives_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

protect_archive​

def protect_archive(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.ArchiveManager] = None,
raise_unsupported: bool = True)

Extracts the input_file archive and processes each file within the archive using the Glasswall engine. Repackages all files regenerated by the Glasswall engine into a new archive, optionally writing the new archive and report to the paths specified by output_file and output_report.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The archive file path or bytes.
  • output_file Optional[str], optional - Default None. If str, write the archive to the output_file path.
  • output_report Optional[str], optional - Default None. If str, write the analysis report to the output_report path.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes including: "status" (int), "output_file" (bytes), "output_report" (bytes)

protect_directory​

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

Calls protect_archive on each file in input_directory using the given content management configuration. The resulting archives are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing archives to protect.
  • output_directory Optional[str], optional - Default None. If str, the output directory where the archives will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where xml reports for each archive will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • protected_archives_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

file_to_file_unpack​

def file_to_file_unpack(input_file: str,
output_directory: str,
raise_unsupported: bool = True)

file_to_file_pack​

def file_to_file_pack(input_directory: str,
output_directory: str,
file_type: Optional[str] = None,
add_extension: Optional[bool] = True,
raise_unsupported: Optional[bool] = True)

unpack​

def unpack(input_file: str,
output_directory: str,
recursive: bool = True,
include_file_type: bool = False,
raise_unsupported: bool = True,
delete_origin: bool = False)

Unpack an archive, maintaining directory structure. Supported archive formats are: "7z", "bz2", "gz", "rar", "tar", "xz", "zip".

Arguments:

  • input_file str - The archive file path
  • output_directory str - The output directory where the archive will be unpacked to a new directory.
  • recursive bool, optional - Default True. Recursively unpack all nested archives.
  • include_file_type bool, optional - Default False. Include the archive format in the directory name. Useful when there are multiple same-named archives of different formats.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
  • delete_origin bool, optional - Default False. Delete input_file after unpacking to output_directory.

unpack_directory​

def unpack_directory(input_directory: str,
output_directory: str,
recursive: bool = True,
include_file_type: Optional[bool] = False,
raise_unsupported: bool = True,
delete_origin: bool = False)

Unpack a directory of archives, maintaining directory structure.

Arguments:

  • input_directory str - The input directory containing archives to unpack.
  • output_directory str - The output directory where archives will be unpacked to a new directory.
  • recursive bool, optional - Default True. Recursively unpack all nested archives.
  • include_file_type bool, optional - Default False. Include the archive format in the directory name. Useful when there are multiple same-named archives of different formats.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
  • delete_origin bool, optional - Default False. Delete input_file after unpacking to output_directory.

pack_directory​

def pack_directory(input_directory: str,
output_directory: str,
file_type: str,
add_extension: Optional[bool] = True,
raise_unsupported: Optional[bool] = True,
delete_origin: Optional[bool] = False)

Pack a directory. Supported archive formats are: "7z", "bz2", "gz", "rar", "tar", "xz", "zip".

Arguments:

  • input_directory str - The input directory containing files to archive.
  • output_directory str - The output directory to store the created archive.
  • file_type str - The archive file type.
  • add_extension bool, optional - Default: True. Archive file type extension to result file.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
  • delete_origin bool, optional - Default False. Delete input_directory after packing to output_directory.

export_archive​

def export_archive(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.ArchiveManager] = None,
raise_unsupported: bool = True)

Exports an archive using the Glasswall engine.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The archive file path or bytes.
  • output_file Optional[str], optional - Default None. If str, write the archive to the output_file path.
  • output_report Optional[str], optional - Default None. If str, write the analysis report to the output_report path.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes including: "status" (int), "output_file" (bytes), "output_report" (bytes)

export_directory​

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

Calls export_archive on each file in input_directory. The exported archives are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing archives to export.
  • output_directory Optional[str], optional - Default None. If str, the output directory where the archives will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where xml reports for each archive will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], 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:

  • exported_archives_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

import_archive​

def import_archive(
input_file: Union[str, bytes, bytearray, io.BytesIO],
output_file: Optional[str] = None,
output_report: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.ArchiveManager] = None,
include_analysis_report: Optional[bool] = False,
raise_unsupported: Optional[bool] = True)

Imports an archive using the Glasswall engine.

Arguments:

  • input_file Union[str, bytes, bytearray, io.BytesIO] - The archive file path or bytes.
  • output_file Optional[str], optional - Default None. If str, write the archive to the output_file path.
  • output_report Optional[str], optional - Default None. If str, write the analysis report to the output_report path.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], optional - The content management policy to apply.
  • include_analysis_report Optional[bool], optional - Default False. If True, write the analysis report into the imported archive.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • gw_return_object glasswall.GwReturnObj - An instance of class glasswall.GwReturnObj containing attributes including: "status" (int), "output_file" (bytes), "output_report" (bytes)

import_directory​

def import_directory(
input_directory: str,
output_directory: Optional[str],
output_report_directory: Optional[str] = None,
content_management_policy: Union[
None, str, bytes, bytearray, io.BytesIO,
glasswall.content_management.policies.ArchiveManager] = None,
include_analysis_report: Optional[bool] = False,
raise_unsupported: bool = True)

Calls import_archive on each file in input_directory. The imported archives are written to output_directory maintaining the same directory structure as input_directory.

Arguments:

  • input_directory str - The input directory containing archives to import.
  • output_directory Optional[str], optional - Default None. If str, the output directory where the archives will be written.
  • output_report_directory Optional[str], optional - Default None. If str, the output directory where xml reports for each archive will be written.
  • content_management_policy Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.ArchiveManager], optional - The content management policy to apply.
  • include_analysis_report Optional[bool], optional - Default False. If True, write the analysis report into the imported archive.
  • raise_unsupported bool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.

Returns:

  • imported_archives_dict dict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)

Success​

class Success(ArchiveManagerSuccess)

ArchiveManager success code 1.

success_codes​

success_codes = {
1: Success,
}

UnknownErrorCode​

class UnknownErrorCode(ArchiveManagerError)

Unknown error code.

Fail​

class Fail(ArchiveManagerError)

ArchiveManager error code 0.

error_codes​

error_codes = {
0: Fail,
}

ArchiveManagerError​

class ArchiveManagerError(Exception)

Base class for all Glasswall ArchiveManager errors.

ArchiveManagerSuccess​

class ArchiveManagerSuccess()

Base class for all Glasswall ArchiveManager successes.

OK​

class OK(EditorSuccess)

Editor success code 0.

OKWithCleaning​

class OKWithCleaning(EditorSuccess)

Editor success code 1.

success_codes​

success_codes = {
0: OK,
1: OKWithCleaning,
}

UnknownErrorCode​

class UnknownErrorCode(EditorError)

Unknown error code.

GeneralFail​

class GeneralFail(EditorError)

Editor error code -1.

UnexpectedEndOfFile​

class UnexpectedEndOfFile(EditorError)

Editor error code -2.

LicenceExpired​

class LicenceExpired(EditorError)

Editor error code -3.

LicenseExpired​

LicenseExpired = LicenceExpired

alias <= 0.2.42

IncorrectSessionSetup​

class IncorrectSessionSetup(EditorError)

Editor error code -4.

IncorrectPolicySetup​

class IncorrectPolicySetup(EditorError)

Editor error code -5.

UnableToLoadInput​

class UnableToLoadInput(EditorError)

Editor error code -6.

FileTypeUnknown​

class FileTypeUnknown(EditorError)

Editor error code -7.

UnknownSessionID​

class UnknownSessionID(EditorError)

Editor error code -8.

ArgumentError​

class ArgumentError(EditorError)

Editor error code -9.

UnableToLoadImport​

class UnableToLoadImport(EditorError)

Editor error code -10.

CameraDidNotInitialise​

class CameraDidNotInitialise(EditorError)

Editor error code -11.

NoCamerasConnected​

class NoCamerasConnected(EditorError)

Editor error code -12.

EngineeringOnlyGoesToFile​

class EngineeringOnlyGoesToFile(EditorError)

Editor error code -13.

UnableToWriteOutput​

class UnableToWriteOutput(EditorError)

Editor error code -14

UnableToWriteExport​

class UnableToWriteExport(EditorError)

Editor error code -15

FileRejected​

class FileRejected(EditorError)

Editor error code -16

UnableToWriteExportTextDump​

class UnableToWriteExportTextDump(EditorError)

Editor error code -17

UnableToWriteAnalysisReport​

class UnableToWriteAnalysisReport(EditorError)

Editor error code -18

InputTooLarge​

class InputTooLarge(EditorError)

Editor error code -19

InputZeroBytes​

class InputZeroBytes(EditorError)

Editor error code -20

error_codes​

error_codes = {
-1: GeneralFail,
-2: UnexpectedEndOfFile,
-3: LicenseExpired,
-4: In ...

Editor​

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 representing 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.

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.

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'.

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'.

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.

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] = None,
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] = None,
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] = None,
analysis_directory: Optional[str] = None,
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).

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] = None,
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 (export_file_bytes, analysis_report_bytes).

export_and_analyse_directory​

def export_and_analyse_directory(
input_directory: str,
output_directory: Optional[str] = None,
analysis_directory: Optional[str] = None,
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 (export_file_bytes, analysis_report_bytes).

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] = None,
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.

import_and_analyse_file​

def import_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)

Imports and analyses a file in a single session, returning both imported 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 imported 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 (import_file_bytes, analysis_report_bytes).

import_and_analyse_directory​

def import_and_analyse_directory(
input_directory: str,
output_directory: Optional[str] = None,
analysis_directory: Optional[str] = None,
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 import 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 export .zip files to process.
  • output_directory Optional[str] - The output directory for imported 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 (import_file_bytes, analysis_report_bytes).

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.

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'.

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.

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.

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.

licence_details​

def licence_details()

Returns a string containing details of the licence.

Returns:

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

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'.

EditorError​

class EditorError(Exception)

Base class for all Glasswall Editor errors.

EditorSuccess​

class EditorSuccess()

Base class for all Glasswall Editor successes.

log​

as_bytes​

def as_bytes(file_: Union[bytes, bytearray, io.BytesIO])

Returns file_ as bytes.

Arguments:

  • file_ Union[bytes, bytearray, io.BytesIO] - The file

Returns:

bytes

Raises:

  • TypeError - If file_ is not an instance of: bytes, bytearray, io.BytesIO

as_io_BytesIO​

def as_io_BytesIO(file_: Union[bytes, bytearray])

Returns file_ as io.BytesIO object.

Arguments:

  • file_ Union[bytes, bytearray] - The bytes or bytearray of the file

Returns:

io.BytesIO object

Raises:

  • TypeError - If file_ is not an instance of: bytes, bytearray, io.BytesIO

as_snake_case​

def as_snake_case(string)

as_title​

def as_title(string)

buffer_to_bytes​

def buffer_to_bytes(buffer: ct.c_void_p, buffer_length: ct.c_size_t)

Convert ctypes buffer and buffer_length to bytes.

Arguments:

buffer (ct.c_void_p()): The file buffer. buffer_length (ct.c_size_t()): The file buffer length.

Returns:

  • bytes bytes - The file as bytes.

CwdHandler​

class CwdHandler()

Changes the current working directory to new_cwd on enter, and back to previous cwd on exit.

Arguments:

  • new_cwd str - The new current working directory to temporarily change to.

__init__​

def __init__(new_cwd: str)

__enter__​

def __enter__()

__exit__​

def __exit__(type, value, traceback)

delete_directory​

def delete_directory(directory: str, keep_folder: bool = False)

Delete a directory and its contents.

Arguments:

  • directory str - The directory path.
  • keep_folder bool, optional - Default False. If False, only delete contents.

delete_empty_subdirectories​

def delete_empty_subdirectories(directory: str)

Deletes all empty subdirectories of a given directory.

Arguments:

  • directory str - The directory to delete subdirectories from.

Returns:

None

flatten_list​

def flatten_list(list_: Iterable)

Returns a flattened list. [[1, 2], ["3"], (4, 5,), [6]] --> [1, 2, "3", 4, 5, 6]

get_file_type​

def get_file_type(file_path: str)

Returns the filetype of a file. "data/files/splat.zip" -> "zip"

get_libraries​

def get_libraries(directory: str,
library_names: Optional[List[str]] = None,
ignore_errors: bool = False)

Recursively calls get_library on each library from glasswall.libraries.os_info on the given directory.

Arguments:

  • directory str - The directory to search from.
  • library_names List[str], optional - List of libraries to return, if None iterates all libraries found in glasswall.libraries.os_info
  • ignore_errors bool, optional - Default False, prevents get_library raising FileNotFoundError when True.

Returns:

  • libraries dict[str, str] - A dictionary of library names and their absolute file paths.

get_library​

def get_library(library: str, directory: str)

Returns a path to the specified library found from the current directory or any subdirectory. If multiple libraries exist, returns the file with the latest modified time.

Arguments:

  • library str - The library to search for, ie: "rebuild", "word_search"
  • directory str - The directory to search from.

Returns:

  • library_file_path str - The absolute file path to the library.

Raises:

  • KeyError - Unsupported OS or library name was not found in glasswall.libraries.os_info.
  • FileNotFoundError - Library was not found.

iterate_directory_entries​

def iterate_directory_entries(directory: str,
file_type: str = 'all',
absolute: bool = True,
recursive: bool = True,
followlinks: bool = True,
start_directory: str = None)

Generate entries (files, directories, or both) in a given directory using os.scandir().

Arguments:

  • directory str - The path to the directory whose entries are to be listed.
  • file_type str, optional - Type of entries to return.
    • 'all': Return both files and directories (default).
    • 'files': Return only files.
    • 'directories': Return only directories.
  • absolute bool, optional - Whether to return absolute paths (default) or relative paths.
  • recursive bool, optional - Whether to recurse into subdirectories (default is True).
  • followlinks bool, optional - Whether to follow symbolic links and yield entries from the target directory (default is True).
  • start_directory str, optional - The starting directory used to calculate relative paths (default is None).

Yields:

  • str - The full path of each file or directory found in the specified directory.

Raises:

  • ValueError - If an invalid 'file_type' value is provided.
  • NotADirectoryError - If the directory does not exist.

Example:

directory = '/path/to/your/directory'

Iterate through all entries (files and directories) in the directory

for entry in iterate_directory_entries(directory): print(entry)

Iterate through only file entries in the directory

for file in iterate_directory_entries(directory, file_type='files'): print("File:", file)

Iterate through only directory entries in the directory

for directory in iterate_directory_entries(directory, file_type='directories'): print("Directory:", directory)

list_file_paths​

def list_file_paths(directory: str,
file_type: str = 'files',
absolute: bool = True,
recursive: bool = True,
followlinks: bool = True) -> list

List all file paths in a given directory and its subdirectories.

Arguments:

  • directory str - The path to the directory whose file paths are to be listed.
  • file_type str, optional - Type of entries to return.
    • 'all': Return both files and directories.
    • 'files': Return only files (default).
    • 'directories': Return only directories.
  • absolute bool, optional - Whether to return absolute paths (default is True).
  • recursive bool, optional - Whether to recurse into subdirectories (default is True).
  • followlinks bool, optional - Whether to follow symbolic links and list file paths from the target directory (default is True).

Returns:

  • list - A list of file paths found in the specified directory and its subdirectories.

Example:

directory = '/path/to/your/directory' file_paths = list_file_paths(directory) print(file_paths)

list_subdirectory_paths​

def list_subdirectory_paths(directory: str,
recursive: bool = False,
absolute: bool = True)

Returns a list of paths to subdirectories in a directory.

Arguments:

  • directory str - The directory to list subdirectories from.
  • recursive bool, optional - Default False. Include subdirectories of subdirectories.
  • absolute bool, optional - Default True. Return paths as absolute paths. If False, returns relative paths.

Returns:

  • subdirectories list - A list of subdirectory paths.

load_dependencies​

def load_dependencies(dependencies: list, ignore_errors: bool = False)

Calls ctypes.cdll.LoadLibrary on each file path in dependencies.

Arguments:

  • dependencies list - A list of absolute file paths of library dependencies.
  • ignore_errors bool, optional - Default False, avoid raising exceptions from ct.cdll.LoadLibrary if ignore_errors is True.

Returns:

  • missing_dependencies list - A list of missing dependencies, or an empty list.

round_up​

def round_up(number: float, decimals=0) -> float

Rounds a number up to a specified number of decimal places.

Arguments:

  • number float - The number to be rounded.
  • decimals int, optional - The number of decimal places to round to. Defaults to 0.

Returns:

  • float - The rounded number.

Examples:

>>> round_up(105, 0) 105.0 >>> round_up(0.015, 2) 0.02 >>> round_up(0.025, 2) 0.03 >>> round_up(0.00001, 2) 0.01

TempDirectoryPath​

class TempDirectoryPath()

Gives a path to a uniquely named temporary directory that does not currently exist on enter, deletes the directory if it exists on exit.

Arguments:

  • delete bool, optional - Default True. Delete the temporary directory on exit

__init__​

def __init__(delete: bool = True)

__enter__​

def __enter__()

__exit__​

def __exit__(type, value, traceback)

TempFilePath​

class TempFilePath()

Gives a path to a uniquely named temporary file that does not currently exist on enter, deletes the file if it exists on exit.

Arguments:

  • directory Union[str, None], optional - The directory to create a temporary file in.
  • delete bool, optional - Default True. Delete the temporary file on on exit

__init__​

def __init__(directory: Union[str, None] = None, delete: bool = True)

__enter__​

def __enter__()

__exit__​

def __exit__(type, value, traceback)

validate_xml​

def validate_xml(
xml: Union[str, bytes, bytearray, io.BytesIO,
"glasswall.content_management.policies.policy.Policy"])

Attempts to parse the xml provided, returning the xml as string. Raises ValueError if the xml cannot be parsed.

Arguments:

  • xml Union[str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy] - The xml string, or file path, bytes, or ContentManagementPolicy instance to parse.

Returns:

  • xml_string str - A string representation of the xml.

Raises:

  • ValueError - if the xml cannot be parsed.
  • TypeError - if the type of arg "xml" is invalid

xml_as_dict​

def xml_as_dict(xml)

Converts a simple single-level xml into a dictionary.

Arguments:

  • xml Union[str, bytes, bytearray, io.BytesIO] - The xml string, or file path, or bytes to parse.

Returns:

  • dict_ dict - A dictionary of element tag : text

deprecated_alias​

def deprecated_alias(**aliases: str) -> Callable

Decorator for deprecated function and method arguments.

Use as follows:

@deprecated_alias(old_arg='new_arg') def myfunc(new_arg): ...

https://stackoverflow.com/a/49802489

rename_kwargs​

def rename_kwargs(func_name: str, kwargs: Dict[str, Any], aliases: Dict[str,
str])

Helper function for deprecating function arguments.

https://stackoverflow.com/a/49802489

deprecated_function​

def deprecated_function(replacement_function)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

geotiff​

class geotiff(Switch)

__init__​

def __init__(value: str)

embedded_files​

class embedded_files(Switch)

__init__​

def __init__(value: str)

embedded_images​

class embedded_images(Switch)

__init__​

def __init__(value: str)
class external_hyperlinks(Switch)

__init__​

def __init__(value: str)
class internal_hyperlinks(Switch)

__init__​

def __init__(value: str)

hidden_data​

class hidden_data(Switch)

__init__​

def __init__(value: str)

macros​

class macros(Switch)

__init__​

def __init__(value: str)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

review_comments​

class review_comments(Switch)

__init__​

def __init__(value: str)

slide_notes​

class slide_notes(Switch)

__init__​

def __init__(value: str)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

jfif​

class jfif(Switch)

__init__​

def __init__(value: str)

acroform​

class acroform(Switch)

__init__​

def __init__(value: str)

actions_all​

class actions_all(Switch)

__init__​

def __init__(value: str)

digital_signatures​

class digital_signatures(Switch)

__init__​

def __init__(value: str)

embedded_files​

class embedded_files(Switch)

__init__​

def __init__(value: str)

embedded_images​

class embedded_images(Switch)

__init__​

def __init__(value: str)
class external_hyperlinks(Switch)

__init__​

def __init__(value: str)
class internal_hyperlinks(Switch)

__init__​

def __init__(value: str)

javascript​

class javascript(Switch)

__init__​

def __init__(value: str)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

value_outside_reasonable_limits​

class value_outside_reasonable_limits(Switch)

__init__​

def __init__(value: str)

watermark​

class watermark(Switch)

__init__​

def __init__(value: str)

Switch​

class Switch()

A Content Management Policy switch which has a name and a value, and can have attributes.

__init__​

def __init__(name: str,
value: str,
attributes: Optional[dict] = None,
restrict_values: Optional[list] = None)

__str__​

def __str__()

__repr__​

def __repr__()

Change string representation of object.

__lt__​

def __lt__(other)

Used for sorting. Sort by "name" then "value".

value​

@property
def value()

value​

@value.setter
def value(value)

text​

@property
def text()

String representation of XML.

connections​

class connections(Switch)

__init__​

def __init__(value: str)

dynamic_data_exchange​

class dynamic_data_exchange(Switch)

__init__​

def __init__(value: str)

embedded_files​

class embedded_files(Switch)

__init__​

def __init__(value: str)

embedded_images​

class embedded_images(Switch)

__init__​

def __init__(value: str)
class external_hyperlinks(Switch)

__init__​

def __init__(value: str)

hidden_data​

class hidden_data(Switch)

__init__​

def __init__(value: str)
class internal_hyperlinks(Switch)

__init__​

def __init__(value: str)

macros​

class macros(Switch)

__init__​

def __init__(value: str)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

review_comments​

class review_comments(Switch)

__init__​

def __init__(value: str)

tracked_changes​

class tracked_changes(Switch)

__init__​

def __init__(value: str)

foreign_objects​

class foreign_objects(Switch)

__init__​

def __init__(value: str)
class hyperlinks(Switch)

__init__​

def __init__(value: str)

scripts​

class scripts(Switch)

__init__​

def __init__(value: str)

bmp​

class bmp(Switch)

An ArchiveManager bmp switch.

__init__​

def __init__(value: str)

doc​

class doc(Switch)

An ArchiveManager doc switch.

__init__​

def __init__(value: str)

docx​

class docx(Switch)

An ArchiveManager docx switch.

__init__​

def __init__(value: str)

elf​

class elf(Switch)

An ArchiveManager elf switch.

__init__​

def __init__(value: str)

emf​

class emf(Switch)

An ArchiveManager emf switch.

__init__​

def __init__(value: str)

gif​

class gif(Switch)

An ArchiveManager gif switch.

__init__​

def __init__(value: str)

jpeg​

class jpeg(Switch)

An ArchiveManager jpeg switch.

__init__​

def __init__(value: str)

mp3​

class mp3(Switch)

An ArchiveManager mp3 switch.

__init__​

def __init__(value: str)

mp4​

class mp4(Switch)

An ArchiveManager mp4 switch.

__init__​

def __init__(value: str)

mpg​

class mpg(Switch)

An ArchiveManager mpg switch.

__init__​

def __init__(value: str)

o​

class o(Switch)

An ArchiveManager o switch.

__init__​

def __init__(value: str)

pdf​

class pdf(Switch)

An ArchiveManager pdf switch.

__init__​

def __init__(value: str)

pe​

class pe(Switch)

An ArchiveManager pe switch.

__init__​

def __init__(value: str)

png​

class png(Switch)

An ArchiveManager png switch.

__init__​

def __init__(value: str)

ppt​

class ppt(Switch)

An ArchiveManager ppt switch.

__init__​

def __init__(value: str)

pptx​

class pptx(Switch)

An ArchiveManager pptx switch.

__init__​

def __init__(value: str)

tiff​

class tiff(Switch)

An ArchiveManager tiff switch.

__init__​

def __init__(value: str)

txt​

class txt(Switch)

An ArchiveManager txt switch.

__init__​

def __init__(value: str)

wav​

class wav(Switch)

An ArchiveManager wav switch.

__init__​

def __init__(value: str)

wmf​

class wmf(Switch)

An ArchiveManager wmf switch.

__init__​

def __init__(value: str)

xls​

class xls(Switch)

An ArchiveManager xls switch.

__init__​

def __init__(value: str)

xlsx​

class xlsx(Switch)

An ArchiveManager xlsx switch.

__init__​

def __init__(value: str)

dynamic_data_exchange​

class dynamic_data_exchange(Switch)

__init__​

def __init__(value: str)

embedded_files​

class embedded_files(Switch)

__init__​

def __init__(value: str)

embedded_images​

class embedded_images(Switch)

__init__​

def __init__(value: str)
class external_hyperlinks(Switch)

__init__​

def __init__(value: str)

hidden_data​

class hidden_data(Switch)

__init__​

def __init__(value: str)

in_text_comments​

class in_text_comments(Switch)

__init__​

def __init__(value: str)
class internal_hyperlinks(Switch)

__init__​

def __init__(value: str)

macros​

class macros(Switch)

__init__​

def __init__(value: str)

metadata​

class metadata(Switch)

__init__​

def __init__(value: str)

review_comments​

class review_comments(Switch)

__init__​

def __init__(value: str)

tracked_changes​

class tracked_changes(Switch)

__init__​

def __init__(value: str)

enable_hash_sha256​

class enable_hash_sha256(Switch)

__init__​

def __init__(value: str)

export_embedded_images​

class export_embedded_images(Switch)

__init__​

def __init__(value: str)

interchange_best_compression​

class interchange_best_compression(Switch)

__init__​

def __init__(value: str)

interchange_pretty​

class interchange_pretty(Switch)

__init__​

def __init__(value: str)

interchange_type​

class interchange_type(Switch)

__init__​

def __init__(value: str)

ArchiveManager​

class ArchiveManager(Policy)

A content management policy for ArchiveManager.

Arguments:

  • default str - The default action to be performed. (allow, disallow, sanitise)
  • default_archive_manager str - The default action to be performed for archiveConfig. (no_action, discard, process)
  • config dict - Additional configuration settings passed to the ConfigElement with the same name as the key.

Example:

ArchiveManager( default="allow", default_archive_manager="process", config={

  • "pdfConfig" - {"embeddedImages": "disallow"},
  • "wordConfig" - {"embeddedImages": "disallow"},
  • "archiveConfig" - {
  • "@recursionDepth" - "100",
  • "jpeg" - "discard" } } )

__init__​

def __init__(default: str = "sanitise",
default_archive_manager: str = "process",
config: dict = {})

Policy​

class Policy()

A Content Management Policy made up of a list of ConfigElement instances.

__init__​

def __init__(config_elements: list = [],
default: Optional[str] = None,
default_config_elements: list = [],
config: dict = {},
**kwargs)

__str__​

def __str__()

__getattr__​

def __getattr__(name)

text​

@property
def text()

String representation of XML.

encode​

def encode(*args)

UTF-8 encoded string representation of XML.

get_config_element_names​

def get_config_element_names()

Returns a sorted list of unique ConfigElement.name values from self.config_elements.

remove_switch​

def remove_switch(config_element: Union[ConfigElement, str],
switch: Union[Switch, str])

Removes all Switch instances from config_element.switches that match arg "switch" where the ConfigElement instance in self.config_elements matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name to match.
  • switch Union[Switch, str] - A Switch instance or Switch.name to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.
  • glasswall.content_management.errors.switches.SwitchNotFound - The switch was not found.

add_switch​

def add_switch(config_element: Union[ConfigElement, str],
switch: Switch,
replace: bool = True)

Adds a Switch to any ConfigElement in self.config_elements that matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or str to match ConfigElement.name.
  • switch Switch - A Switch instance.
  • replace bool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute as arg "switch" within a ConfigElement that matches arg "config_element".

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

remove_config_element​

def remove_config_element(config_element: Union[ConfigElement, str])

Removes all ConfigElement instances from self.config_elements that match arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name attribute to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

add_config_element​

def add_config_element(config_element: ConfigElement, replace=True)

Adds a ConfigElement instance to self.config_elements.

Arguments:

  • config_element ConfigElement - A ConfigElement instance.
  • replace bool, optional - Default True. Deletes any pre-existing ConfigElement with the same .name attribute in self.config_elements.

Returns:

self

get_attributes​

@staticmethod
def get_attributes(dictionary: dict)

Returns attributes from arg "dictionary". Attributes are key value pairs that have a key starting with "@". The "@" is excluded in the returned keys.

get_switches​

@staticmethod
def get_switches(dictionary: dict)

Returns switches from arg "dictionary". Switches are key value pairs that do not have a key starting with "@".

from_string​

@staticmethod
def from_string(string: str)

Create Policy object from string.

Arguments:

  • string str - A string representation of an xml content management policy, or a file path.

Returns:

  • new_policy glasswall.content_management.policies.Policy - A Policy object.

Editor​

class Editor(Policy)

A content management policy for Editor.

__init__​

def __init__(default: str = "sanitise", config: dict = {})

WordSearch​

class WordSearch(Policy)

A content management policy for Word Search.

WordSearch(default="allow", config={ "textSearchConfig": { "@libVersion": "core2", "textList": [ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]}, ] } })

__init__​

def __init__(default: str = "allow", config: dict = {})

add_textItem​

def add_textItem(text: str,
replacementChar: str,
textSetting: str = "redact",
**kwargs)

Adds a textItem to the textSearchConfig textList subelements.

remove_textItem​

def remove_textItem(text: str)

Removes a textItem from the textSearchConfig textList subelements.

Rebuild​

class Rebuild(Policy)

A content management policy for Rebuild.

__init__​

def __init__(default: str = "sanitise", config: dict = {})

SwitchNotFound​

class SwitchNotFound(ContentManagementPolicyError)

The Content Management Policy Switch could not be found.

RestrictedValue​

class RestrictedValue(ContentManagementPolicyError)

The Content Management Policy Switch has an unexpected value.

ConfigElementNotFound​

class ConfigElementNotFound(ContentManagementPolicyError)

The Content Management Policy ConfigElement could not be found.

ContentManagementPolicyError​

class ContentManagementPolicyError(Exception)

Content Management Policy base error.

xlsConfig​

class xlsConfig(ConfigElement)

An xlsConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: xlsConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

jpegConfig​

class jpegConfig(ConfigElement)

A jpegConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: jpegConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

tiffConfig​

class tiffConfig(ConfigElement)

A tiffConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: tiffConfig(geotiff="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes={}, **kwargs)

wordConfig​

class wordConfig(ConfigElement)

A wordConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: wordConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

svgConfig​

class svgConfig(ConfigElement)

A svgConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: svgConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

gifConfig​

class gifConfig(ConfigElement)

A gifConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: gifConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

ConfigElement​

class ConfigElement()

A Content Management Policy configuration element which has a name, and can have attributes, switches, and subelements.

__init__​

def __init__(
name: str,
attributes: dict = {},
switches: list = [],
subelements: list = [],
default: Optional[str] = None,
default_switches: list = [],
config: dict = {},
switches_module: "glasswall.content_management.switches" = Switch)

__str__​

def __str__()

__getattr__​

def __getattr__(name)

__repr__​

def __repr__()

Change string representation of object.

__lt__​

def __lt__(other)

Used for sorting. Sort by "name" then "switches".

text​

@property
def text()

String representation of XML.

get_switch_names​

def get_switch_names()

Returns a sorted list of unique Switch.name values from self.switches.

remove_switch​

def remove_switch(switch: Union[Switch, str])

Removes all Switch instances from self.switches that match arg "switch".

Arguments:

  • switch Union[Switch, str] - A Switch instance or str to match Switch.name.

Returns:

self

Raises:

  • glasswall.content_management.errors.switches.SwitchNotFound - The switch was not found.

add_switch​

def add_switch(switch: Switch, replace: bool = True)

Adds a Switch instance to self.switches.

Arguments:

  • switch Switch - A Switch instance.
  • replace bool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute in self.switches.

Returns:

self

archiveConfig​

class archiveConfig(ConfigElement)

An archiveConfig ConfigElement.

Arguments:

  • default str - The default action: no_action, discard, or process.

    Key word arguments can be specified to change individual switch values: archiveConfig(default="no_action", jpeg="discard", pdf="process")

__init__​

def __init__(default: str = "process", attributes: dict = {}, **kwargs)

webpConfig​

class webpConfig(ConfigElement)

A webpConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: webpConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

textList​

class textList(ConfigElement)

A textList ConfigElement.

__init__​

def __init__(subelements: list = [])

sysConfig​

class sysConfig(ConfigElement)

A sysConfig ConfigElement.

Key word arguments can be specified to change individual switch values: sysConfig(interchange_type="sisl",interchange_pretty="true",)

__init__​

def __init__(attributes={}, **kwargs)

pptConfig​

class pptConfig(ConfigElement)

A pptConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: pptConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

pdfConfig​

class pdfConfig(ConfigElement)

A pdfConfig ConfigElement.

Arguments:

  • default str - The default action: allow, disallow, or sanitise.

    Key word arguments can be specified to change individual switch values: pdfConfig(default="allow", embedded_images="sanitise")

__init__​

def __init__(default: str = "sanitise", attributes: dict = {}, **kwargs)

textSearchConfig​

class textSearchConfig(ConfigElement)

A textSearchConfig ConfigElement.

textSearchConfig( libVersion="core2", textList_subelements=[ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]} ] )

__init__​

def __init__(attributes: dict = {}, textList_subelements: list = [], **kwargs)