diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2018-11-23 19:13:44 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-05 13:04:54 +0000 |
commit | f7060a43995279723036c37d173f846a3613180e (patch) | |
tree | 1ca51dba885c34c24d04addde9854b25de26c4b7 /bitbake/lib/bb/parse | |
parent | eff9942d30c34a8290fa3ff5edafe32a8992c633 (diff) | |
download | openembedded-core-contrib-f7060a43995279723036c37d173f846a3613180e.tar.gz |
bitbake: bitbake: BBHandler: Check tab indentation for python code
The previous check was in data.py which only can check code like "python
funcname()" in the dependency chain, but there are 3 kinds of python functions:
- python()
- def py_funcname()
- python funcname()
Add the checking to BBHandler to check and warn for all of them.
The warning looks like:
WARNING: /path/to/recipes-core/busybox/busybox_1.29.2.bb: python should use 4 spaces indentation, but found tabs in busybox.inc, line 75
(Bitbake rev: 0cdc5b81fc1f5e5281a525a657e420ebc3bb9e90)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 01fc47e512..f3bf4aa529 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -46,6 +46,7 @@ __deltask_regexp__ = re.compile("deltask\s+(?P<func>\w+)") __addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) __def_regexp__ = re.compile( r"def\s+(\w+).*:" ) __python_func_regexp__ = re.compile( r"(\s+.*)|(^$)|(^#)" ) +__python_tab_regexp__ = re.compile(" *\t") __infunc__ = [] __inpython__ = False @@ -160,6 +161,16 @@ def handle(fn, d, include): def feeder(lineno, s, fn, root, statements, eof=False): global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, bb, __residue__, __classname__ + + # Check tabs in python functions: + # - def py_funcname(): covered by __inpython__ + # - python(): covered by '__anonymous' == __infunc__[0] + # - python funcname(): covered by __infunc__[3] + if __inpython__ or (__infunc__ and ('__anonymous' == __infunc__[0] or __infunc__[3])): + tab = __python_tab_regexp__.match(s) + if tab: + bb.warn('python should use 4 spaces indentation, but found tabs in %s, line %s' % (root, lineno)) + if __infunc__: if s == '}': __body__.append('') |