]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: toaster: use 'in' instead of has_key
authorEd Bartosh <ed.bartosh@linux.intel.com>
Tue, 10 May 2016 13:27:19 +0000 (16:27 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 14 May 2016 22:05:15 +0000 (23:05 +0100)
Dictionary method has_key is deprecated in python 2 and absent
in python 3.

Used '<key> in <dict>' statement to make the code working on
both python 2 and python 3.

[YOCTO #9584]

(Bitbake rev: 3d7ad7ba0d1a6f688ae885817c049f2a8ced11b5)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/toaster/toastergui/views.py
bitbake/lib/toaster/toastermain/settings.py
bitbake/lib/toaster/toastermain/urls.py

index b7c674a076f07ecbac18a984f6233d24d9961db1..82cc52ead87c3bb6c1d06c676b507d37699d2baa 100755 (executable)
@@ -2235,10 +2235,10 @@ if True:
 
 
     def xhr_importlayer(request):
-        if (not request.POST.has_key('vcs_url') or
-            not request.POST.has_key('name') or
-            not request.POST.has_key('git_ref') or
-            not request.POST.has_key('project_id')):
+        if ('vcs_url' not in request.POST or
+            'name' not in request.POST or
+            'git_ref' not in request.POST or
+            'project_id' not in request.POST):
           return HttpResponse(jsonfilter({"error": "Missing parameters; requires vcs_url, name, git_ref and project_id"}), content_type = "application/json")
 
         layers_added = [];
@@ -2294,7 +2294,7 @@ if True:
                 layer_version.save()
 
                 # Add the dependencies specified for this new layer
-                if (post_data.has_key("layer_deps") and
+                if ('layer_deps' in post_data and
                     version_created and
                     len(post_data["layer_deps"]) > 0):
                     for layer_dep_id in post_data["layer_deps"].split(","):
@@ -2348,7 +2348,7 @@ if True:
         def error_response(error):
             return HttpResponse(jsonfilter({"error": error}), content_type = "application/json")
 
-        if not request.POST.has_key("layer_version_id"):
+        if "layer_version_id" not in request.POST:
             return error_response("Please specify a layer version id")
         try:
             layer_version_id = request.POST["layer_version_id"]
@@ -2357,26 +2357,26 @@ if True:
             return error_response("Cannot find layer to update")
 
 
-        if request.POST.has_key("vcs_url"):
+        if "vcs_url" in request.POST:
             layer_version.layer.vcs_url = request.POST["vcs_url"]
-        if request.POST.has_key("dirpath"):
+        if "dirpath" in request.POST:
             layer_version.dirpath = request.POST["dirpath"]
-        if request.POST.has_key("commit"):
+        if "commit" in request.POST:
             layer_version.commit = request.POST["commit"]
-        if request.POST.has_key("up_branch"):
+        if "up_branch" in request.POST:
             layer_version.up_branch_id = int(request.POST["up_branch"])
 
-        if request.POST.has_key("add_dep"):
+        if "add_dep" in request.POST:
             lvd = LayerVersionDependency(layer_version=layer_version, depends_on_id=request.POST["add_dep"])
             lvd.save()
 
-        if request.POST.has_key("rm_dep"):
+        if "rm_dep" in request.POST:
             rm_dep = LayerVersionDependency.objects.get(layer_version=layer_version, depends_on_id=request.POST["rm_dep"])
             rm_dep.delete()
 
-        if request.POST.has_key("summary"):
+        if "summary" in request.POST:
             layer_version.layer.summary = request.POST["summary"]
-        if request.POST.has_key("description"):
+        if "description" in request.POST:
             layer_version.layer.description = request.POST["description"]
 
         try:
index 8662f393a983718da277f2603914e1234ca72e06..78702fa59ead939ceccff72320b7217e56e08160 100644 (file)
@@ -321,7 +321,7 @@ currentdir = os.path.dirname(__file__)
 for t in os.walk(os.path.dirname(currentdir)):
     modulename = os.path.basename(t[0])
     #if we have a virtualenv skip it to avoid incorrect imports
-    if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
+    if 'VIRTUAL_ENV' in os.environ and os.environ['VIRTUAL_ENV'] in t[0]:
         continue
 
     if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS:
index 530a42ffabdd1b1449a4c5510d0f212cd478a515..1f8599edc37847b9aadf3f85c016728ee2fcacae 100644 (file)
@@ -71,7 +71,7 @@ import os
 currentdir = os.path.dirname(__file__)
 for t in os.walk(os.path.dirname(currentdir)):
     #if we have a virtualenv skip it to avoid incorrect imports
-    if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
+    if 'VIRTUAL_ENV' in os.environ and os.environ['VIRTUAL_ENV'] in t[0]:
         continue
 
     if "urls.py" in t[2] and t[0] != currentdir: