DiamondLightSource / tickit

Event-based hardware simulation framework
Apache License 2.0
7 stars 0 forks source link

MultiCommandInterpreter #90

Closed MattPrit closed 1 year ago

MattPrit commented 2 years ago

Fixes #77

89 and #93 should be merged first.

Adds an interpreter capable of parsing multiple commands from a single message. This differs from the interpreter in #82 in that it is used when a message can contain multiple commands with no delimiter.

The interpreter works by attempting to match the regex pattern associated with each defined command with the start of the message; of those that match, the match corresponding to the largest number of characters is chosen. The matched part of the message is then removed and the process is repeated.

The current implementation is slightly nasty for a few reasons:

codecov[bot] commented 2 years ago

Codecov Report

Merging #90 (3c797fd) into master (b15df3c) will increase coverage by 0.05%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
+ Coverage   98.59%   98.65%   +0.05%     
==========================================
  Files          70       70              
  Lines        2141     2236      +95     
==========================================
+ Hits         2111     2206      +95     
  Misses         30       30              
Impacted Files Coverage Δ
tickit/adapters/interpreters/command/__init__.py 100.00% <100.00%> (ø)
...apters/interpreters/command/command_interpreter.py 100.00% <100.00%> (ø)
.../interpreters/command/multi_command_interpreter.py 100.00% <100.00%> (ø)
...kit/adapters/interpreters/command/regex_command.py 100.00% <100.00%> (ø)
tickit/__init__.py

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

abbiemery commented 1 year ago

Closing this as not planned. When it becomes desired again raise a new issue, linked to this #177 .