UserContentFilterStore#
Added in version 2.24.
Superclasses: Object
Handles storage of user content filters on disk.
The WebKitUserContentFilterStore provides the means to import and save
JSON rule sets,
which can be loaded later in an efficient manner. Once filters are stored,
the UserContentFilter
objects which represent them can be added to
a UserContentManager
with add_filter()
.
JSON rule sets are imported using save()
and stored
on disk in an implementation defined format. The contents of a filter store must be
managed using the UserContentFilterStore
: a list of all the stored filters
can be obtained with fetch_identifiers()
,
load()
can be used to retrieve a previously saved
filter, and removed from the store with remove()
.
Constructors#
- class UserContentFilterStore
- classmethod new(storage_path: str) UserContentFilterStore #
Create a new
UserContentFilterStore
to manipulate filters stored atstorage_path
.The path must point to a local filesystem, and will be created if needed.
Added in version 2.24.
- Parameters:
storage_path – path where data for filters will be stored on disk
Methods#
- class UserContentFilterStore
- fetch_identifiers(cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously retrieve a list of the identifiers for all the stored filters.
When the operation is finished,
callback
will be invoked, which then can usefetch_identifiers_finish()
to obtain the list of filter identifiers.Added in version 2.24.
- Parameters:
cancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when the removal is completeduser_data – the data to pass to the callback function
- fetch_identifiers_finish(result: AsyncResult) list[str] #
Finishes an asynchronous fetch of the list of stored filters.
Finishes an asynchronous fetch of the list of identifiers for the stored filters previously started with
fetch_identifiers()
.Added in version 2.24.
- Parameters:
result – a
AsyncResult
- load(identifier: str, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously load a content filter given its
identifier
.The filter must have been previously stored using
save()
.When the operation is finished,
callback
will be invoked, which then can useload_finish()
to obtain the resulting filter.Added in version 2.24.
- Parameters:
identifier – a filter identifier
cancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when the load is completeduser_data – the data to pass to the callback function
- load_finish(result: AsyncResult) UserContentFilter #
Finishes an asynchronous filter load previously started with
load()
.Added in version 2.24.
- Parameters:
result – a
AsyncResult
- remove(identifier: str, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously remove a content filter given its
identifier
.When the operation is finished,
callback
will be invoked, which then can useremove_finish()
to check whether the removal was successful.Added in version 2.24.
- Parameters:
identifier – a filter identifier
cancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when the removal is completeduser_data – the data to pass to the callback function
- remove_finish(result: AsyncResult) bool #
Finishes an asynchronous filter removal previously started with
remove()
.Added in version 2.24.
- Parameters:
result – a
AsyncResult
- save(identifier: str, source: Bytes, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously save a content filter from a set source rule.
Asynchronously save a content filter from a source rule set in the WebKit content extesions JSON format.
The
identifier
can be used afterwards to refer to the filter when usingremove()
andload()
. When theidentifier
has been used in the past, the new filter source will replace the one saved beforehand for the same identifier.When the operation is finished,
callback
will be invoked, which then can usesave_finish()
to obtain the resulting filter.Added in version 2.24.
- Parameters:
identifier – a string used to identify the saved filter
source –
Bytes
containing the rule set in JSON formatcancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when saving is completeduser_data – the data to pass to the callback function
- save_finish(result: AsyncResult) UserContentFilter #
Finishes an asynchronous filter save previously started with
save()
.Added in version 2.24.
- Parameters:
result – a
AsyncResult
- save_from_file(identifier: str, file: File, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously save a content filter from the contents of a file.
Asynchronously save a content filter from the contents of a file, which must be native to the platform, as checked by
is_native()
. Seesave()
for more details.When the operation is finished,
callback
will be invoked, which then can usesave_finish()
to obtain the resulting filter.Added in version 2.24.
- Parameters:
identifier – a string used to identify the saved filter
file – a
File
containing the rule set in JSON formatcancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when saving is completeduser_data – the data to pass to the callback function
- save_from_file_finish(result: AsyncResult) UserContentFilter #
Finishes and asynchronous filter save previously started with
save_from_file()
.Added in version 2.24.
- Parameters:
result – a
AsyncResult