# HG changeset patch # User FUJIWARA Katsunori # Date 1551376389 -32400 # Node ID 55ae5cd31f7607840da6bedbebd75168c0215c8b # Parent 14e8d042993a6bcc0468a2afee8d5e7e130706c9 contrib: refactor preparation logic for patterns of check-code.py This is a part of preparation to apply checking with check-code.py on code fragments embedded in *.t test scripts. Before this patch, preparation logic in _preparepats() of check-code.py is not reusable. It can handle only module global list "checks". This patch splits preparation logic into small internal functions, and add the loop to invoke them, in order to increase reusability of the logic. "c[-2]" is equivalent to "c[3]" for "checks". This patch uses the former, because it will be more reusable for subsequent patch than the latter. diff -r 14e8d042993a -r 55ae5cd31f76 contrib/check-code.py --- a/contrib/check-code.py Fri Mar 01 02:53:05 2019 +0900 +++ b/contrib/check-code.py Fri Mar 01 02:53:09 2019 +0900 @@ -561,8 +561,7 @@ ] def _preparepats(): - for c in checks: - failandwarn = c[-1] + def preparefailandwarn(failandwarn): for pats in failandwarn: for i, pseq in enumerate(pats): # fix-up regexes for multi-line searches @@ -576,10 +575,19 @@ p = re.sub(r'(?