Given lists or strings contain lines separated using newline characters. This function matches those lines one by one, interpreting the lines in the res parameter as regular expressions.
(lines=None, res=None)
| 193 | |
| 194 | |
| 195 | def match_re(lines=None, res=None): |
| 196 | """ |
| 197 | Given lists or strings contain lines separated using newline characters. |
| 198 | This function matches those lines one by one, interpreting the lines in the |
| 199 | res parameter as regular expressions. |
| 200 | |
| 201 | """ |
| 202 | if not type(lines) is ListType: |
| 203 | lines = split(lines, "\n") |
| 204 | if not type(res) is ListType: |
| 205 | res = split(res, "\n") |
| 206 | if len(lines) != len(res): |
| 207 | return |
| 208 | for i in range(len(lines)): |
| 209 | if not re.compile("^" + res[i] + "$").search(lines[i]): |
| 210 | return |
| 211 | return 1 |
| 212 | |
| 213 | |
| 214 | class TestCmd: |