:right-sidebar: True Parser =================================================================== .. currentmodule:: gi.repository.Gcr .. class:: Parser(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: Parser(**properties) new() -> Gcr.Parser Constructors ------------ .. rst-class:: interim-class .. class:: Parser :no-index: .. classmethod:: new() -> ~gi.repository.Gcr.Parser Create a new :obj:`~gi.repository.Gcr.Parser` Methods ------- .. rst-class:: interim-class .. class:: Parser :no-index: .. method:: add_password(password: str | None = None) -> None Add a password to the set of passwords to try when parsing locked or encrypted items. This is usually called from the :obj:`~gi.repository.Gcr.Parser.signals.authenticate` signal. :param password: a password to try .. method:: format_disable(format: ~gi.repository.Gcr.DataFormat) -> None Disable parsing of the given format. Use :const:`~gi.repository.Gcr.DataFormat.ALL` to disable all the formats. :param format: The format identifier .. method:: format_enable(format: ~gi.repository.Gcr.DataFormat) -> None Enable parsing of the given format. Use :const:`~gi.repository.Gcr.DataFormat.ALL` to enable all the formats. :param format: The format identifier .. method:: format_supported(format: ~gi.repository.Gcr.DataFormat) -> bool Check whether the given format is supported by the parser. :param format: The format identifier .. method:: get_filename() -> str Get the filename of the parser item. .. method:: get_parsed() -> ~gi.repository.Gcr.Parsed Get the currently parsed item .. method:: get_parsed_attributes() -> ~gi.repository.Gck.Attributes | None Get the attributes which make up the currently parsed item. This is generally only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: get_parsed_block() -> bytes | None Get the raw data block that represents this parsed object. This is only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: get_parsed_bytes() -> ~gi.repository.GLib.Bytes Get the raw data block that represents this parsed object. This is only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: get_parsed_description() -> str | None Get a description for the type of the currently parsed item. This is generally only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: get_parsed_format() -> ~gi.repository.Gcr.DataFormat Get the format of the raw data block that represents this parsed object. This corresponds with the data returned from :obj:`~gi.repository.Parser.get_parsed_block`. This is only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: get_parsed_label() -> str | None Get the label of the currently parsed item. This is generally only valid during the :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. method:: parse_bytes(data: ~gi.repository.GLib.Bytes) -> bool Parse the data. The :obj:`~gi.repository.Gcr.Parser.signals.parsed` and :obj:`~gi.repository.Gcr.Parser.signals.authenticate` signals may fire during the parsing. :param data: the data to parse .. method:: parse_data(data: ~typing.Sequence[int]) -> bool Parse the data. The :obj:`~gi.repository.Gcr.Parser.signals.parsed` and :obj:`~gi.repository.Gcr.Parser.signals.authenticate` signals may fire during the parsing. A copy of the data will be made. Use :obj:`~gi.repository.Parser.parse_bytes` to avoid this. :param data: the data to parse .. method:: parse_stream(input: ~gi.repository.Gio.InputStream, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Parse items from the data in a :obj:`~gi.repository.Gio.InputStream`. This function may block while reading from the input stream. Use :obj:`~gi.repository.Parser.parse_stream_async` for a non-blocking variant. The :obj:`~gi.repository.Gcr.Parser.signals.parsed` and :obj:`~gi.repository.Gcr.Parser.signals.authenticate` signals may fire during the parsing. :param input: The input stream :param cancellable: An optional cancellation object .. method:: parse_stream_async(input: ~gi.repository.Gio.InputStream, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Parse items from the data in a :obj:`~gi.repository.Gio.InputStream`. This function completes asyncronously and doesn't block. The :obj:`~gi.repository.Gcr.Parser.signals.parsed` and :obj:`~gi.repository.Gcr.Parser.signals.authenticate` signals may fire during the parsing. :param input: The input stream :param cancellable: An optional cancellation object :param callback: Called when the operation result is ready. :param user_data: Data to pass to callback .. method:: parse_stream_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Complete an operation to parse a stream. :param result: The operation result .. method:: set_filename(filename: str | None = None) -> None Sets the filename of the parser item. :param filename: a string of the filename of the parser item Properties ---------- .. rst-class:: interim-class .. class:: Parser :no-index: .. attribute:: props.parsed_attributes :type: ~gi.repository.Gck.Attributes Get the attributes that make up the currently parsed item. This is generally only valid during a :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. attribute:: props.parsed_description :type: str The description of the type of the currently parsed item. This is generally only valid during a :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. .. attribute:: props.parsed_label :type: str The label of the currently parsed item. This is generally only valid during a :obj:`~gi.repository.Gcr.Parser.signals.parsed` signal. Signals ------- .. rst-class:: interim-class .. class:: Parser.signals :no-index: .. method:: authenticate(count: int) -> bool This signal is emitted when an item needs to be unlocked or decrypted before it can be parsed. The ``count`` argument specifies the number of times the signal has been emitted for a given item. This can be used to display a message saying the previous password was incorrect. Typically the :func:`~gi.repository.Gcr.Parser.add_password` function is called in response to this signal. If :const:`False` is returned, then the authentication was not handled. If no handlers return :const:`True` then the item is not parsed and an error with the code :const:`~gi.repository.Gcr.DataError.CANCELLED` will be raised. :param count: the number of times this item has been authenticated .. method:: parsed() -> None This signal is emitted when an item is sucessfully parsed. To access the information about the item use the :func:`~gi.repository.Gcr.Parser.get_parsed_label`, :func:`~gi.repository.Gcr.Parser.get_parsed_attributes` and :func:`~gi.repository.Gcr.Parser.get_parsed_description` functions. Virtual Methods --------------- .. rst-class:: interim-class .. class:: Parser :no-index: .. method:: do_authenticate(count: int) -> bool The default handler for the authenticate signal. :param count: .. method:: do_parsed() -> None The default handler for the parsed signal. Fields ------ .. rst-class:: interim-class .. class:: Parser :no-index: .. attribute:: parent .. attribute:: pv