* [PATCH 0/1] bitbake: BBHandler: Check tab indentation for python code
@ 2018-11-23 11:13 Robert Yang
2018-11-23 11:13 ` [PATCH 1/1] " Robert Yang
0 siblings, 1 reply; 2+ messages in thread
From: Robert Yang @ 2018-11-23 11:13 UTC (permalink / raw)
To: bitbake-devel
The following changes since commit 6b84ac788321b24cfa2e6a883806eb3f3198254b:
ref-manual: Updated list of supported Linux Distros: (2018-11-22 12:20:52 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib rbt/py
http://git.pokylinux.org/cgit.cgi//log/?h=rbt/py
Robert Yang (1):
bitbake: BBHandler: Check tab indentation for python code
bitbake/lib/bb/data.py | 2 --
bitbake/lib/bb/parse/parse_py/BBHandler.py | 11 +++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] bitbake: BBHandler: Check tab indentation for python code
2018-11-23 11:13 [PATCH 0/1] bitbake: BBHandler: Check tab indentation for python code Robert Yang
@ 2018-11-23 11:13 ` Robert Yang
0 siblings, 0 replies; 2+ messages in thread
From: Robert Yang @ 2018-11-23 11:13 UTC (permalink / raw)
To: bitbake-devel
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
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
bitbake/lib/bb/data.py | 2 --
bitbake/lib/bb/parse/parse_py/BBHandler.py | 11 +++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index d66d98c..6bcfcf4 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -322,8 +322,6 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
if varflags.get("python"):
value = d.getVarFlag(key, "_content", False)
parser = bb.codeparser.PythonParser(key, logger)
- if value and "\t" in value:
- logger.warning("Variable %s contains tabs, please remove these (%s)" % (key, d.getVar("FILE")))
parser.parse_python(value, filename=varflags.get("filename"), lineno=varflags.get("lineno"))
deps = deps | parser.references
deps = deps | (keys & parser.execs)
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 01fc47e..f3bf4aa 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('')
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-23 10:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-23 11:13 [PATCH 0/1] bitbake: BBHandler: Check tab indentation for python code Robert Yang
2018-11-23 11:13 ` [PATCH 1/1] " Robert Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.