[oe-commits] [bitbake] 02/04: toaster: use 'in' instead of has_key
git at git.openembedded.org
git at git.openembedded.org
Fri May 13 16:53:11 UTC 2016
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit a7fc710e6ee295b0d8325183fc12632ffb3da7a7
Author: Ed Bartosh <ed.bartosh at linux.intel.com>
AuthorDate: Tue May 10 16:27:19 2016 +0300
toaster: use 'in' instead of has_key
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]
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/toaster/toastergui/views.py | 28 ++++++++++++++--------------
lib/toaster/toastermain/settings.py | 2 +-
lib/toaster/toastermain/urls.py | 2 +-
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index b7c674a..82cc52e 100755
--- a/lib/toaster/toastergui/views.py
+++ b/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/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py
index 8662f39..78702fa 100644
--- a/lib/toaster/toastermain/settings.py
+++ b/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/lib/toaster/toastermain/urls.py b/lib/toaster/toastermain/urls.py
index 530a42f..1f8599e 100644
--- a/lib/toaster/toastermain/urls.py
+++ b/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:
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list