grim/local-pipelines

Parents 39d40318db3f
Children f2d1342040e3
pipeline: turn the _get_steps and _steps into a single steps property
--- a/pipelines/pipeline.py Tue Jul 26 21:33:58 2016 -0500
+++ b/pipelines/pipeline.py Tue Jul 26 23:07:52 2016 -0700
@@ -32,17 +32,18 @@
self.branch = branch
self.env = env or {}
- self.steps = self._get_steps()
-
- def _get_steps(self):
+ @property
+ def steps(self):
+ ret = self.config["pipelines"]["default"]
if "branches" in self.config["pipelines"]:
branches = self.config["pipelines"]["branches"]
for pattern, steps in branches.iteritems():
if fnmatch.fnmatch(self.branch, pattern):
- return steps
+ ret = steps
+ break
- return self.config["pipelines"]["default"]
+ return [Step.from_dict(s["step"]) for s in ret]
def _determine_image(self, step):
return step.image or self.config.get("image")
@@ -79,13 +80,10 @@
return " ".join(cmd)
- def _steps(self):
- return [Step.from_dict(s["step"]) for s in self.steps]
-
def run(self):
return_code = 0
- for n, step in enumerate(self._steps()):
+ for n, step in enumerate(self.steps):
script = step.script_file()
command = self._get_command(step, script)