word_search
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:
versionstr - 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_fileUnion[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_fileUnion[None, str], optional - Default None. If str, write output_file to that path.output_reportUnion[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_unsupportedbool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
gw_return_objectglasswall.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_directorystr - The input directory containing files to redact.output_directorystr - The output directory where the redacted files will be written.output_report_directoryOptional[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_unsupportedbool, optional - Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
redacted_files_dictdict - A dictionary of file paths relative to input_directory, and glasswall.GwReturnObj with attributes: "status" (int), "output_file" (bytes), "output_report" (bytes)