summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-24 11:39:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-24 23:28:34 +0100
commit67c6cc854f0add255a0559b9104c83b5d2ffde64 (patch)
tree2e5faf3e9245fcd54f0abdc1673c819ea29edd26 /bitbake/lib/bb/data.py
parentfdfb3fdc5b45468ebd1d8356cde6ceded1075092 (diff)
downloadpoky-67c6cc854f0add255a0559b9104c83b5d2ffde64.tar.gz
bitbake: data: Clean up datastore accesses and True/False values
We should use the d.xxxVar syntax rather than the older function style. Also replace 0/1 with the more pythonic True/False. No functionality changes. (Bitbake rev: 90fdd69cca951f8bd2ff634f3b42fccd4fc03095) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data.py')
-rw-r--r--bitbake/lib/bb/data.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 2f90be6f61..a21de112e7 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -84,7 +84,7 @@ def setVar(var, value, d):
84 d.setVar(var, value) 84 d.setVar(var, value)
85 85
86 86
87def getVar(var, d, exp = 0): 87def getVar(var, d, exp = False):
88 """Gets the value of a variable""" 88 """Gets the value of a variable"""
89 return d.getVar(var, exp) 89 return d.getVar(var, exp)
90 90
@@ -161,9 +161,9 @@ def expandKeys(alterdata, readdata = None):
161 # usefulness of the expand cache 161 # usefulness of the expand cache
162 for key in sorted(todolist): 162 for key in sorted(todolist):
163 ekey = todolist[key] 163 ekey = todolist[key]
164 newval = alterdata.getVar(ekey, 0) 164 newval = alterdata.getVar(ekey, False)
165 if newval is not None: 165 if newval is not None:
166 val = alterdata.getVar(key, 0) 166 val = alterdata.getVar(key, False)
167 if val is not None: 167 if val is not None:
168 bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)) 168 bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
169 alterdata.renameVar(key, ekey) 169 alterdata.renameVar(key, ekey)
@@ -174,7 +174,7 @@ def inheritFromOS(d, savedenv, permitted):
174 for s in savedenv.keys(): 174 for s in savedenv.keys():
175 if s in permitted: 175 if s in permitted:
176 try: 176 try:
177 d.setVar(s, getVar(s, savedenv, True), op = 'from env') 177 d.setVar(s, savedenv.getVar(s, True), op = 'from env')
178 if s in exportlist: 178 if s in exportlist:
179 d.setVarFlag(s, "export", True, op = 'auto env export') 179 d.setVarFlag(s, "export", True, op = 'auto env export')
180 except TypeError: 180 except TypeError:
@@ -182,39 +182,39 @@ def inheritFromOS(d, savedenv, permitted):
182 182
183def emit_var(var, o=sys.__stdout__, d = init(), all=False): 183def emit_var(var, o=sys.__stdout__, d = init(), all=False):
184 """Emit a variable to be sourced by a shell.""" 184 """Emit a variable to be sourced by a shell."""
185 if getVarFlag(var, "python", d): 185 if d.getVarFlag(var, "python"):
186 return 0 186 return False
187 187
188 export = getVarFlag(var, "export", d) 188 export = d.getVarFlag(var, "export")
189 unexport = getVarFlag(var, "unexport", d) 189 unexport = d.getVarFlag(var, "unexport")
190 func = getVarFlag(var, "func", d) 190 func = d.getVarFlag(var, "func")
191 if not all and not export and not unexport and not func: 191 if not all and not export and not unexport and not func:
192 return 0 192 return False
193 193
194 try: 194 try:
195 if all: 195 if all:
196 oval = getVar(var, d, 0) 196 oval = d.getVar(var, False)
197 val = getVar(var, d, 1) 197 val = d.getVar(var, True)
198 except (KeyboardInterrupt, bb.build.FuncFailed): 198 except (KeyboardInterrupt, bb.build.FuncFailed):
199 raise 199 raise
200 except Exception as exc: 200 except Exception as exc:
201 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc))) 201 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc)))
202 return 0 202 return False
203 203
204 if all: 204 if all:
205 d.varhistory.emit(var, oval, val, o) 205 d.varhistory.emit(var, oval, val, o)
206 206
207 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: 207 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
208 return 0 208 return False
209 209
210 varExpanded = expand(var, d) 210 varExpanded = d.expand(var)
211 211
212 if unexport: 212 if unexport:
213 o.write('unset %s\n' % varExpanded) 213 o.write('unset %s\n' % varExpanded)
214 return 0 214 return False
215 215
216 if val is None: 216 if val is None:
217 return 0 217 return False
218 218
219 val = str(val) 219 val = str(val)
220 220
@@ -223,7 +223,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
223 val = val[3:] # Strip off "() " 223 val = val[3:] # Strip off "() "
224 o.write("%s() %s\n" % (varExpanded, val)) 224 o.write("%s() %s\n" % (varExpanded, val))
225 o.write("export -f %s\n" % (varExpanded)) 225 o.write("export -f %s\n" % (varExpanded))
226 return 1 226 return True
227 227
228 if func: 228 if func:
229 # NOTE: should probably check for unbalanced {} within the var 229 # NOTE: should probably check for unbalanced {} within the var
@@ -239,7 +239,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
239 alter = re.sub('\n', ' \\\n', alter) 239 alter = re.sub('\n', ' \\\n', alter)
240 alter = re.sub('\\$', '\\\\$', alter) 240 alter = re.sub('\\$', '\\\\$', alter)
241 o.write('%s="%s"\n' % (varExpanded, alter)) 241 o.write('%s="%s"\n' % (varExpanded, alter))
242 return 0 242 return False
243 243
244def emit_env(o=sys.__stdout__, d = init(), all=False): 244def emit_env(o=sys.__stdout__, d = init(), all=False):
245 """Emits all items in the data store in a format such that it can be sourced by a shell.""" 245 """Emits all items in the data store in a format such that it can be sourced by a shell."""
@@ -438,7 +438,7 @@ def generate_dependencies(d):
438 return tasklist, deps, values 438 return tasklist, deps, values
439 439
440def inherits_class(klass, d): 440def inherits_class(klass, d):
441 val = getVar('__inherit_cache', d) or [] 441 val = d.getVar('__inherit_cache', False) or []
442 needle = os.path.join('classes', '%s.bbclass' % klass) 442 needle = os.path.join('classes', '%s.bbclass' % klass)
443 for v in val: 443 for v in val:
444 if v.endswith(needle): 444 if v.endswith(needle):