Phil Dawson pushed to branch danielsilverstone-ct/use-enumerate at BuildStream / buildstream
Commits:
-
80762ecb
by Benjamin Schubert at 2018-10-26T09:45:39Z
-
f131c407
by Benjamin Schubert at 2018-10-26T10:09:51Z
-
54d89aa1
by Daniel Silverstone at 2018-10-26T10:20:36Z
4 changed files:
- buildstream/_loader/loadelement.py
- buildstream/sandbox/_sandboxbwrap.py
- buildstream/sandbox/_sandboxchroot.py
- buildstream/sandbox/_sandboxdummy.py
Changes:
... | ... | @@ -146,8 +146,8 @@ def _extract_depends_from_node(node, *, key=None): |
146 | 146 |
depends = _yaml.node_get(node, list, key, default_value=[])
|
147 | 147 |
output_deps = []
|
148 | 148 |
|
149 |
- for dep in depends:
|
|
150 |
- dep_provenance = _yaml.node_get_provenance(node, key=key, indices=[depends.index(dep)])
|
|
149 |
+ for index, dep in enumerate(depends):
|
|
150 |
+ dep_provenance = _yaml.node_get_provenance(node, key=key, indices=[index])
|
|
151 | 151 |
|
152 | 152 |
if isinstance(dep, str):
|
153 | 153 |
dependency = Dependency(dep, provenance=dep_provenance, dep_type=default_dep_type)
|
... | ... | @@ -177,10 +177,8 @@ def _extract_depends_from_node(node, *, key=None): |
177 | 177 |
provenance=dep_provenance)
|
178 | 178 |
|
179 | 179 |
else:
|
180 |
- index = depends.index(dep)
|
|
181 |
- p = _yaml.node_get_provenance(node, key=key, indices=[index])
|
|
182 | 180 |
raise LoadError(LoadErrorReason.INVALID_DATA,
|
183 |
- "{}: Dependency is not specified as a string or a dictionary".format(p))
|
|
181 |
+ "{}: Dependency is not specified as a string or a dictionary".format(dep_provenance))
|
|
184 | 182 |
|
185 | 183 |
output_deps.append(dependency)
|
186 | 184 |
|
... | ... | @@ -66,15 +66,15 @@ class SandboxBwrap(Sandbox): |
66 | 66 |
cwd = self._get_work_directory(cwd=cwd)
|
67 | 67 |
env = self._get_environment(cwd=cwd, env=env)
|
68 | 68 |
|
69 |
+ # Convert single-string argument to a list
|
|
70 |
+ if isinstance(command, str):
|
|
71 |
+ command = [command]
|
|
72 |
+ |
|
69 | 73 |
if not self._has_command(command[0], env):
|
70 | 74 |
raise SandboxError("Staged artifacts do not provide command "
|
71 | 75 |
"'{}'".format(command[0]),
|
72 | 76 |
reason='missing-command')
|
73 | 77 |
|
74 |
- # We want command args as a list of strings
|
|
75 |
- if isinstance(command, str):
|
|
76 |
- command = [command]
|
|
77 |
- |
|
78 | 78 |
# Create the mount map, this will tell us where
|
79 | 79 |
# each mount point needs to be mounted from and to
|
80 | 80 |
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
|
... | ... | @@ -57,15 +57,15 @@ class SandboxChroot(Sandbox): |
57 | 57 |
cwd = self._get_work_directory(cwd=cwd)
|
58 | 58 |
env = self._get_environment(cwd=cwd, env=env)
|
59 | 59 |
|
60 |
+ # Convert single-string argument to a list
|
|
61 |
+ if isinstance(command, str):
|
|
62 |
+ command = [command]
|
|
63 |
+ |
|
60 | 64 |
if not self._has_command(command[0], env):
|
61 | 65 |
raise SandboxError("Staged artifacts do not provide command "
|
62 | 66 |
"'{}'".format(command[0]),
|
63 | 67 |
reason='missing-command')
|
64 | 68 |
|
65 |
- # Command must be a list
|
|
66 |
- if isinstance(command, str):
|
|
67 |
- command = [command]
|
|
68 |
- |
|
69 | 69 |
stdout, stderr = self._get_output()
|
70 | 70 |
|
71 | 71 |
# Create the mount map, this will tell us where
|
... | ... | @@ -33,6 +33,10 @@ class SandboxDummy(Sandbox): |
33 | 33 |
cwd = self._get_work_directory(cwd=cwd)
|
34 | 34 |
env = self._get_environment(cwd=cwd, env=env)
|
35 | 35 |
|
36 |
+ # Convert single-string argument to a list
|
|
37 |
+ if isinstance(command, str):
|
|
38 |
+ command = [command]
|
|
39 |
+ |
|
36 | 40 |
if not self._has_command(command[0], env):
|
37 | 41 |
raise SandboxError("Staged artifacts do not provide command "
|
38 | 42 |
"'{}'".format(command[0]),
|