Prints words appearing in two different response pages >>> showStaticWords("this is a test", "this is another test") ['this']
(firstPage, secondPage, minLength=3)
| 2259 | return retVal |
| 2260 | |
| 2261 | def showStaticWords(firstPage, secondPage, minLength=3): |
| 2262 | """ |
| 2263 | Prints words appearing in two different response pages |
| 2264 | |
| 2265 | >>> showStaticWords("this is a test", "this is another test") |
| 2266 | ['this'] |
| 2267 | """ |
| 2268 | |
| 2269 | infoMsg = "finding static words in longest matching part of dynamic page content" |
| 2270 | logger.info(infoMsg) |
| 2271 | |
| 2272 | firstPage = getFilteredPageContent(firstPage) |
| 2273 | secondPage = getFilteredPageContent(secondPage) |
| 2274 | |
| 2275 | infoMsg = "static words: " |
| 2276 | |
| 2277 | if firstPage and secondPage: |
| 2278 | match = SequenceMatcher(None, firstPage, secondPage).find_longest_match(0, len(firstPage), 0, len(secondPage)) |
| 2279 | commonText = firstPage[match[0]:match[0] + match[2]] |
| 2280 | commonWords = getPageWordSet(commonText) |
| 2281 | else: |
| 2282 | commonWords = None |
| 2283 | |
| 2284 | if commonWords: |
| 2285 | commonWords = [_ for _ in commonWords if len(_) >= minLength] |
| 2286 | commonWords.sort(key=functools.cmp_to_key(lambda a, b: cmp(a.lower(), b.lower()))) |
| 2287 | |
| 2288 | for word in commonWords: |
| 2289 | infoMsg += "'%s', " % word |
| 2290 | |
| 2291 | infoMsg = infoMsg.rstrip(", ") |
| 2292 | else: |
| 2293 | infoMsg += "None" |
| 2294 | |
| 2295 | logger.info(infoMsg) |
| 2296 | |
| 2297 | return commonWords |
| 2298 | |
| 2299 | def isWindowsDriveLetterPath(filepath): |
| 2300 | """ |
no test coverage detected
searching dependent graphs…