Hi Alex, Am Freitag, dem 31.03.2023 um 16:05 +0200 schrieb Alexander Kanavin: > On Fri, 31 Mar 2023 at 12:40, Enrico Jorns <[email protected]> wrote: > > +re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]') > > This piece of 'magic' needs to be explained :) What does it define?
this is actually 'stolen' from labgrid's implementation for barebox[1] or shell[2] drivers which have exactly the same needs: They need to remove the ansii (color) control codes from the strings in order to match the text only. The unprocessed barebox console prompt would look like: ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored linux terminal output of course. The "\x1b\[" from the regex catches the standard start of ansii escape sequence while the rest catches the actual command code executed. Regards, Enrico [1] https://github.com/labgrid-project/labgrid/blob/e05f530c22513cd775b4f84e28f6c8c920b95102/labgrid/driver/bareboxdriver.py#L44 [2] https://github.com/labgrid-project/labgrid/blob/5d3d5714976b37df0f9a9b769c581fe1f83ccbdc/labgrid/driver/shelldriver.py#L61 > Alex > -- Pengutronix e.K. | Enrico Jörns | Embedded Linux Consulting & Support | https://www.pengutronix.de/ | Steuerwalder Str. 21 | Phone: +49-5121-206917-180 | 31137 Hildesheim, Germany | Fax: +49-5121-206917-9 |
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#179631): https://lists.openembedded.org/g/openembedded-core/message/179631 Mute This Topic: https://lists.openembedded.org/mt/97970648/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
