From 3249e33251102069c88e2bc3f703cfab51444668 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Tue, 10 May 2016 16:27:19 +0300 Subject: bitbake: toaster: use 'in' instead of has_key Dictionary method has_key is deprecated in python 2 and absent in python 3. Used ' in ' statement to make the code working on both python 2 and python 3. [YOCTO #9584] (Bitbake rev: 3d7ad7ba0d1a6f688ae885817c049f2a8ced11b5) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/views.py | 28 ++++++++++++++-------------- bitbake/lib/toaster/toastermain/settings.py | 2 +- bitbake/lib/toaster/toastermain/urls.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index b7c674a076..82cc52ead8 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -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: diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 8662f393a9..78702fa59e 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py @@ -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: diff --git a/bitbake/lib/toaster/toastermain/urls.py b/bitbake/lib/toaster/toastermain/urls.py index 530a42ffab..1f8599edc3 100644 --- a/bitbake/lib/toaster/toastermain/urls.py +++ b/bitbake/lib/toaster/toastermain/urls.py @@ -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: -- cgit v1.2.3-54-g00ecf