1.1.4.4. completion_providers
This module contains classes for custom auto completion for GtkSourceCompletion. It provides support to recognize special characters and suggests syntax completion.
1.1.4.4.1. Functions
- get_proposal_terms(search, tokens)[source]
Used to iterate through the search dictionary definition representing tokens for completion. Terms within this dictionary have a hierarchy to their definition in which keys are always terms represented as strings and values are either sub-dictionaries following the same pattern or None in the case that the term is a leaf node.
1.1.4.4.2. Classes
- class CustomCompletionProviderBase[source]
Bases:
gi.overrides.GObject.Object
,gi.repository.GtkSource.CompletionProvider
This class is used to create completion providers that will provide syntax completion options and recognize special characters.
- do_match(context)[source]
Called by GtkSourceCompletion to determine if this provider matches the context. This returns true if the
extract()
returns a valid match object from the regular expression.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.- Returns
Whether or not the
extract()
method returned a match.- Return type
- do_populate(context)[source]
An automated function called by GtkSource.Completion, when
do_match()
returns True. This function is used to provide suggested completion words (referred to as proposals) for the context based on the match. This is done by creating a list of suggestions and adding them withGtkSource.CompletionContext.add_proposals()
. Ifextract()
returns None, thenpopulate()
will not be called.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.
- extract(context)[source]
Used to extract the text according to the
left_delimiter
andextraction_regex
. If the extraction regular expression does not match, None is returned.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.- Returns
The resulting match from the
extraction_regex
.- Return type
re.MatchObject
- extraction_regex = ''[source]
The regular expression used to match completion string extracted with the
left_delimiter
.
- left_delimiter_adjustment = 0[source]
A number of characters to adjust to beyond the delimiter string.
- left_limit = 512[source]
The maximum number of characters to search backwards for the
left_delimiter
.
- load_data(completion_data)[source]
When
CustomCompletionProviderBase.data_file
is defined, this function is called on initialization after loading the JSON data encoded within it. This method can then be overridden by subclasses to provide additional setup and define completion data prior to the class being registered as a provider.- Parameters
completion_data – The arbitrary JSON encoded data contained within the specified file.
- populate(context, match)[source]
This is called when the
extraction_regex
returns a match. Subclasses must then use this opportunity to populate the context with proposals.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.match (
re.MatchObject
) – The resulting match from theextraction_regex
.
- class HTMLCompletionProvider[source]
Bases:
king_phisher.client.widget.completion_providers.CustomCompletionProviderBase
A completion provider which supports HTML5 tags and attributes.
- data_file = 'html.json'[source]
A JSON encoded data file from which to load completion data in the format specified in the HTML section.
- load_data(completion_data)[source]
When
CustomCompletionProviderBase.data_file
is defined, this function is called on initialization after loading the JSON data encoded within it. This method can then be overridden by subclasses to provide additional setup and define completion data prior to the class being registered as a provider.- Parameters
completion_data – The arbitrary JSON encoded data contained within the specified file.
- populate(context, match)[source]
This is called when the
extraction_regex
returns a match. Subclasses must then use this opportunity to populate the context with proposals.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.match (
re.MatchObject
) – The resulting match from theextraction_regex
.
- class JinjaCompletionProvider[source]
Bases:
king_phisher.client.widget.completion_providers.CustomCompletionProviderBase
Used as the base completion provider for King Phisher’s Jinja2 template editing.
- data_file = 'jinja.json'[source]
A JSON encoded data file from which to load completion data in the format specified in the Jinja section.
- load_data(completion_data)[source]
When
CustomCompletionProviderBase.data_file
is defined, this function is called on initialization after loading the JSON data encoded within it. This method can then be overridden by subclasses to provide additional setup and define completion data prior to the class being registered as a provider.- Parameters
completion_data – The arbitrary JSON encoded data contained within the specified file.
- populate(context, match)[source]
Utilizes the match from the regular expression check to check for possible matches of
jinja_vars
.- Parameters
context (
GtkSource.CompletionContext
) – The context for the completion.match – The matching object.
- Types match
re.MatchObject
- Returns
List of strings to be used for creation of proposals.
- Return type
- class JinjaEmailCompletionProvider[source]
Bases:
king_phisher.client.widget.completion_providers.JinjaCompletionProvider
Completion provider for Jinja syntax within an Email.
- class JinjaPageCompletionProvider[source]
Bases:
king_phisher.client.widget.completion_providers.JinjaCompletionProvider
Completion provider for Jinja syntax within a web page.