Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: recipe_engine/recipe_api.py

Issue 2415793003: Setup basic Runtime with properties and platform.
Patch Set: Split out, more immutables, better utilization. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/loader.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/recipe_api.py
diff --git a/recipe_engine/recipe_api.py b/recipe_engine/recipe_api.py
index 8827e4c4cf81994edf679d5d216406a3d7829fd6..e69984ed718bd97b913c7ab6bfe73fe84e30f00c 100644
--- a/recipe_engine/recipe_api.py
+++ b/recipe_engine/recipe_api.py
@@ -84,15 +84,24 @@ def RequireClient(name):
class PropertiesClient(object):
- """A recipe engine client representing the recipe engine properties."""
+ """A recipe engine client representing the recipe engine properties.
+
+ The retained properties are frozen, and can be safely passed around.
+ """
IDENT = 'properties'
- def __init__(self, engine):
- self._engine = engine
+ def __init__(self, rt):
+ self._rt = rt
+
+ @property
+ def properties(self):
+ """Returns (types.FrozenDict): Frozen properties."""
+ return self._rt.properties
- def get_properties(self):
- return copy.deepcopy(self._engine.properties)
+ def mutable_properties(self):
iannucci 2016/10/19 16:41:03 this seems really dangerous to me; we've never exp
dnj 2016/10/19 16:44:05 The mutable properties function returns a deepcopy
+ """Returns (dict): Mutable original properties dict."""
+ return self._rt.mutable_properties()
class StepClient(object):
@@ -127,6 +136,36 @@ class StepClient(object):
return self._engine.run_step(StepConfig.create(**step_dict))
+class PlatformClient(object):
+ """A recipe engine client to expose a common view of the running platform."""
+
+ IDENT = 'platform'
+
+ def __init__(self, plat):
+ self._plat = plat
+
+ # Export normalization methods.
+ self.norm_plat = plat.norm_plat
+ self.norm_bits = plat.norm_bits
+
+ # Export platform constants.
+ self.WIN = plat.WIN
+ self.LINUX = plat.LINUX
+ self.MAC = plat.MAC
+
+ @property
+ def name(self):
+ return self._plat.name
+
+ @property
+ def bits(self):
+ return self._plat.bits
+
+ @property
+ def arch(self):
+ return self._plat.arch
+
+
class DependencyManagerClient(object):
"""A recipe engine client representing the dependency manager."""
« no previous file with comments | « recipe_engine/loader.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698