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

Unified Diff: scripts/slave/recipe_modules/path/api.py

Issue 1101673005: Extract functions from path recipe module so that step can depend on it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 8 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 | « scripts/slave/recipe_modules/path/__init__.py ('k') | scripts/slave/recipe_modules/path/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/path/api.py
diff --git a/scripts/slave/recipe_modules/path/api.py b/scripts/slave/recipe_modules/path/api.py
index cf7e90a3d3d9458b66591d35e062b551fc047f4c..a2399225cf1cde75dcfb2906570f8eb6749a67a5 100644
--- a/scripts/slave/recipe_modules/path/api.py
+++ b/scripts/slave/recipe_modules/path/api.py
@@ -185,98 +185,6 @@ class PathApi(recipe_api.RecipeApi):
def assert_absolute(self, path):
assert self.abspath(path) == str(path), '%s is not absolute' % path
- def listdir(self, name, path, step_test_data=None):
- """Wrapper for os.listdir."""
- return self.m.python.inline('listdir %s' % name,
- """
- import json, os, sys
- if os.path.exists(sys.argv[1]) and os.path.isdir(sys.argv[1]):
- with open(sys.argv[2], 'w') as f:
- json.dump(os.listdir(sys.argv[1]), f)
- """,
- args=[path, self.m.json.output()],
- step_test_data=(step_test_data or
- self.test_api.listdir(['file 1', 'file 2'])),
- ).json.output
-
- def makedirs(self, name, path, mode=0777):
- """
- Like os.makedirs, except that if the directory exists, then there is no
- error.
- """
- self.assert_absolute(path)
- self.m.python.inline(
- 'makedirs ' + name,
- """
- import sys, os
- path = sys.argv[1]
- mode = int(sys.argv[2])
- if not os.path.isdir(path):
- if os.path.exists(path):
- print "%s exists but is not a dir" % path
- sys.exit(1)
- os.makedirs(path, mode)
- """,
- args=[path, str(mode)],
- )
- self.mock_add_paths(path)
-
- def rmtree(self, name, path):
- """Wrapper for chromium_utils.RemoveDirectory."""
- self.assert_absolute(path)
- self.m.python.inline(
- 'rmtree ' + name,
- """
- import os, sys
- from common import chromium_utils
-
- if os.path.exists(sys.argv[1]):
- chromium_utils.RemoveDirectory(sys.argv[1])
- """,
- args=[path],
- )
-
- def rmcontents(self, name, path):
- """
- Similar to rmtree, but removes only contents not the directory.
-
- This is useful e.g. when removing contents of current working directory.
- Deleting current working directory makes all further getcwd calls fail
- until chdir is called. chdir would be tricky in recipes, so we provide
- a call that doesn't delete the directory itself.
- """
- self.assert_absolute(path)
- self.m.python.inline(
- 'rmcontents ' + name,
- """
- import os, sys
- from common import chromium_utils
-
- for p in [os.path.join(sys.argv[1], x) for x in os.listdir(sys.argv[1])]:
- if os.path.isdir(p):
- chromium_utils.RemoveDirectory(p)
- else:
- os.unlink(p)
- """,
- args=[path],
- )
-
- def rmwildcard(self, pattern, path, **kwargs):
- """
- Removes all files in the subtree of path matching the glob pattern.
- """
- self.assert_absolute(path)
- self.m.python.inline(
- 'rmwildcard %s in %s' % (pattern, path),
- """
- import sys
- from common import chromium_utils
-
- chromium_utils.RemoveFilesWildcards(sys.argv[1], root=sys.argv[2])
- """,
- args=[pattern,path],
- **kwargs)
-
@recipe_api.non_step
def mkdtemp(self, prefix):
"""Makes a new temp directory, returns path to it."""
« no previous file with comments | « scripts/slave/recipe_modules/path/__init__.py ('k') | scripts/slave/recipe_modules/path/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698