[S] Change in ...osmo-python-tests[master]: osmo_interact: improve vty transcript language by a regular rexex
lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/42762?usp=email ) Change subject: osmo_interact: improve vty transcript language by a regular rexex ...................................................................... osmo_interact: improve vty transcript language by a regular rexex Currently the transcript language understand 3 different tokens: ... (ignore all lines until the following line matches) ... !REGEX (ignore all lines except REXEX) But to support osmo-stp with different compile options, the vty help is indented with different amount of spaces depending on the compile options. To support those add a regular regex using the prefix !r! E.g. OsmoSTP(config-cs7-as)# ? - description Save human-readable description of the object vs + description Save human-readable description of the object Change-Id: Iadcd7a8c3677548a6405e098fe53d0614ef2012c --- M osmopy/osmo_interact/common.py 1 file changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/62/42762/1 diff --git a/osmopy/osmo_interact/common.py b/osmopy/osmo_interact/common.py index 87eca6a..dd62b8a 100644 --- a/osmopy/osmo_interact/common.py +++ b/osmopy/osmo_interact/common.py @@ -218,14 +218,27 @@ - If an 'expect' line is '... !regex', it matches any number of lines like '...', but the given regex must not match any of those lines. + - If the line starts with '!r!' following the regex, but a exact match has priority Return 'True' on match, or a string describing the mismatch. ''' - def match_line(expect_line, got_line): - return expect_line == got_line ANY = '...' ANY_EXCEPT = '... !' + REGEX = '!r!' + + def match_line(expect_line, got_line): + if expect_line == got_line: + return True + + # try to parse the expect_line as regex + if expect_line.startswith(REGEX): + try: + if re.compile(expect_line[len(REGEX):]).match(got_line): + return True + except: + pass + return False e = 0 g = 0 -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/42762?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Iadcd7a8c3677548a6405e098fe53d0614ef2012c Gerrit-Change-Number: 42762 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>
participants (1)
-
lynxis lazus