From 857b9fa205aa42aca5edae05b865f1cc63d8ea46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 22 Apr 2014 12:21:50 +0530 Subject: [PATCH] Better QVariant use detection --- setup/qt5-migrate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/qt5-migrate.py b/setup/qt5-migrate.py index 479f313bab..ce372a841c 100644 --- a/setup/qt5-migrate.py +++ b/setup/qt5-migrate.py @@ -33,15 +33,16 @@ def all_py_files(): def detect_qvariant(): count = 0 - pat = re.compile(b'|'.join(b'QVariant NONE toInt toBool toString toPyObject canConvert toBitArray toByteArray toHash toFloat toMap toLine toPoint toReal toRect toTime toUInt toUrl'.split())) # noqa + pat = re.compile(b'|'.join(br'QVariant NONE toInt toBool toString\(\) toPyObject canConvert toBitArray toByteArray toHash toFloat toMap toLine toPoint toReal toRect toTime toUInt toUrl'.split())) # noqa + exclusions = {} for path in all_py_files(): if os.path.basename(path) in { 'BeautifulSoup.py', 'icu.py', 'smtp.py', 'Zeroconf.py', 'date.py', 'apsw_shell.py', } or 'pylrs' in path: continue raw = open(path, 'rb').read() - m = pat.search(raw) - if m is not None: - print (path, '\t', m.group()) + matches = set(pat.findall(raw)) - exclusions.get(path, set()) + if matches: + print (path, '\t', ', '.join(matches)) count += 1 print ('Detected %d files with possible usage of QVariant' % count)