]> code.ossystems Code Review - openembedded-core.git/commitdiff
oelint.bbclass: remove duplicated code
authorRobert Yang <liezhi.yang@windriver.com>
Thu, 19 Mar 2015 05:33:01 +0000 (22:33 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 22 Mar 2015 09:19:33 +0000 (09:19 +0000)
The old code 'if not srcpath.find("{PN}") == -1:' looks strange, use
'if srcpath.find("{PN}") != -1:' and remove duplicated code.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/oelint.bbclass

index 1cee4b0f25ca46315febccd54c199d3c613066e8..3e0150375664ca2ab7075b6d62d93d2016fca609 100644 (file)
@@ -54,6 +54,12 @@ python do_lint() {
         f.close()
         return ret
 
+    def checkPN(pkgname, varname, str):
+        if str.find("{PN}") != -1:
+            bb.warn("%s: should use BPN instead of PN in %s" % (pkgname, varname))
+        if str.find("{P}") != -1:
+            bb.warn("%s: should use BP instead of P in %s" % (pkgname, varname))
+
     length = len("file://")
     for item in srcuri:
         if item.startswith("file://"):
@@ -72,14 +78,7 @@ python do_lint() {
     #
     for s in srcuri:
         if not s.startswith("file://"):
-            if not s.find("{PN}") == -1:
-                bb.warn("%s: should use BPN instead of PN in SRC_URI" % pkgname)
-            if not s.find("{P}") == -1:
-                bb.warn("%s: should use BP instead of P in SRC_URI" % pkgname)
+            checkPN(pkgname, 'SRC_URI', s)
 
-    srcpath = d.getVar("S")
-    if not srcpath.find("{PN}") == -1:
-        bb.warn("%s: should use BPN instead of PN in S" % pkgname)
-    if not srcpath.find("{P}") == -1:
-        bb.warn("%s: should use BP instead of P in S" % pkgname)
+    checkPN(pkgname, 'S', d.getVar('S'))
 }