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

Unified Diff: mojo/tools/roll/utils.py

Issue 864953003: Teach update_from_chromium.py to preserve certain files through roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: nit Created 5 years, 11 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
« build/config/mojo.gni ('K') | « mojo/tools/roll/update_from_chromium.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/tools/roll/utils.py
diff --git a/mojo/tools/roll/utils.py b/mojo/tools/roll/utils.py
index dcdfc3510e700aa7eace92f09761c7633986c533..bf10cdcbce014d03303eae1c0d5392c17f164ee3 100755
--- a/mojo/tools/roll/utils.py
+++ b/mojo/tools/roll/utils.py
@@ -3,9 +3,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import contextlib
import fnmatch
import os
import subprocess
+import shutil
+import tempfile
mojo_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
os.pardir, os.pardir, os.pardir)
@@ -23,6 +26,16 @@ def find(patterns, start='.'):
filename = os.path.join(path, basename)
yield filename
+# From
+# http://stackoverflow.com/questions/13379742/right-way-to-clean-up-a-temporary-folder-in-python-class
+@contextlib.contextmanager
+def temp_dir(*args, **kwargs):
+ d = tempfile.mkdtemp(*args, **kwargs)
+ try:
+ yield d
+ finally:
+ shutil.rmtree(d)
+
def filter_file(path, predicate):
with open(path, 'r+') as f:
lines = f.readlines()
« build/config/mojo.gni ('K') | « mojo/tools/roll/update_from_chromium.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698