Parser
elva.parser
Module defining parsers for events of changes Y data type.
Classes:
-
EventParser
–Parser base class.
-
TextEventParser
–TextEvent
parser base class. -
ArrayEventParser
–ArrayEvent
parser base class. -
MapEventParser
–MapEvent
parser base class.
EventParser
Bases: Component
Parser base class.
This class is supposed to be inherited from and extended.
Methods:
-
check
–Check for the correct
event
type. -
parse
–Queue
event
for parsing asynchronously. -
parse_nowait
–Queue
event
for parsing synchronously. -
parse_event
–Hook called when an
event
has been queued for parsing and which performs further actions.
Attributes:
-
event_type
(TextEvent | ArrayEvent | MapEvent
) –Event type this parser is supposed to handle.
event_type
instance-attribute
Event type this parser is supposed to handle.
check(event)
Check for the correct event
type.
Parameters:
-
event
(TextEvent | ArrayEvent | MapEvent
) –object holding event information of changes to a Y data type.
Raises:
-
TypeError
–if
event
is not an instance ofevent_type
.
Source code in src/elva/parser.py
parse(event)
async
Queue event
for parsing asynchronously.
Parameters:
-
event
(TextEvent | ArrayEvent | MapEvent
) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
parse_nowait(event)
Queue event
for parsing synchronously.
Parameters:
-
event
(TextEvent | ArrayEvent | MapEvent
) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
parse_event(event)
async
Hook called when an event
has been queued for parsing and which performs further actions.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
event
(TextEvent | ArrayEvent | MapEvent
) –object holding event information of changes to a Y data type.
Source code in src/elva/parser.py
TextEventParser
Bases: EventParser
TextEvent
parser base class.
Methods:
-
parse_event
–Hook called when an
event
has been queued for parsing and which performs further actions. -
on_retain
–Hook called on action
retain
. -
on_insert
–Hook called on action
insert
. -
on_delete
–Hook called on action
delete
.
Attributes:
-
event_type
–Event type this parser is supposed to handle.
event_type = TextEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event
has been queued for parsing and which performs further actions.
Parameters:
-
event
(TextEvent
) –object holding event information of changes to a Y text data type.
Source code in src/elva/parser.py
on_retain(range_offset)
async
Hook called on action retain
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y text data type.
Source code in src/elva/parser.py
on_insert(range_offset, insert_value)
async
Hook called on action insert
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y text data type.
-
insert_value
(Any
) –value that was inserted at
range_offset
Source code in src/elva/parser.py
on_delete(range_offset, range_length)
async
Hook called on action delete
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y text data type.
-
range_length
(int
) –number of bytes deleted starting at
range_offset
Source code in src/elva/parser.py
ArrayEventParser
Bases: EventParser
ArrayEvent
parser base class.
Methods:
-
parse_event
–Hook called when an
event
has been queued for parsing and which performs further actions. -
on_retain
–Hook called on action
retain
. -
on_insert
–Hook called on action
insert
. -
on_delete
–Hook called on action
delete
.
Attributes:
-
event_type
–Event type this parser is supposed to handle.
event_type = ArrayEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event
has been queued for parsing and which performs further actions.
Parameters:
-
event
(ArrayEvent
) –object holding event information of changes to a Y array data type.
Source code in src/elva/parser.py
on_retain(range_offset)
async
Hook called on action retain
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y array data type.
Source code in src/elva/parser.py
on_insert(range_offset, insert_value)
async
Hook called on action insert
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y array data type.
-
insert_value
(Any
) –value that was inserted at
range_offset
Source code in src/elva/parser.py
on_delete(range_offset, range_length)
async
Hook called on action delete
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
range_offset
(int
) –byte offset in the Y array data type.
-
range_length
(int
) –number of items deleted starting at
range_offset
Source code in src/elva/parser.py
MapEventParser
Bases: EventParser
MapEvent
parser base class.
Methods:
-
parse_event
–Hook called when an
event
has been queued for parsing and which performs further actions. -
on_add
–Hook called on action
add
. -
on_delete
–Hook called on action
delete
.
Attributes:
-
event_type
–Event type this parser is supposed to handle.
event_type = MapEvent
class-attribute
instance-attribute
Event type this parser is supposed to handle.
parse_event(event)
async
Hook called when an event
has been queued for parsing and which performs further actions.
Parameters:
-
event
(MapEvent
) –object holding event information of changes to a Y map data type.
Source code in src/elva/parser.py
on_add(key, new_value)
async
on_delete(key, old_value)
async
Hook called on action delete
.
This method is defined as a no-op and supposed to be implemented in the inheriting subclass.
Parameters:
-
key
(str
) –key deleted from the Y map data type.
-
old_value
(Any
) –value which was associated with
key
in the Y map data type.