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

Unified Diff: bindings/scripts/utilities.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 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 | « bindings/scripts/interface_dependency_resolver.py ('k') | bindings/scripts/v8_attributes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bindings/scripts/utilities.py
diff --git a/bindings/scripts/utilities.py b/bindings/scripts/utilities.py
index 367476598a1b8e0b115f749d41ce258941e91d78..4d80ca7d1b3dc7df5f5e0b01676a68ec943456b6 100644
--- a/bindings/scripts/utilities.py
+++ b/bindings/scripts/utilities.py
@@ -11,6 +11,10 @@ import os
import cPickle as pickle
import re
import string
+import subprocess
+
+
+KNOWN_COMPONENTS = frozenset(['core', 'modules'])
class IdlBadFilenameError(Exception):
@@ -23,6 +27,16 @@ def idl_filename_to_interface_name(idl_filename):
return os.path.splitext(os.path.basename(idl_filename))[0]
+def idl_filename_to_component(idl_filename):
+ path = os.path.dirname(os.path.realpath(idl_filename))
+ while path:
+ dirname, basename = os.path.split(path)
+ if basename.lower() in KNOWN_COMPONENTS:
+ return basename.lower()
+ path = dirname
+ raise 'Unknown component type for %s' % idl_filename
+
+
################################################################################
# Basic file reading/writing
################################################################################
@@ -38,6 +52,34 @@ def read_file_to_list(filename):
return [line.rstrip('\n') for line in f]
+def resolve_cygpath(cygdrive_names):
+ if not cygdrive_names:
+ return []
+ cmd = ['cygpath', '-f', '-', '-wa']
+ process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ idl_file_names = []
+ for file_name in cygdrive_names:
+ process.stdin.write('%s\n' % file_name)
+ process.stdin.flush()
+ idl_file_names.append(process.stdout.readline().rstrip())
+ process.stdin.close()
+ process.wait()
+ return idl_file_names
+
+
+def read_idl_files_list_from_file(filename):
+ """Similar to read_file_to_list, but also resolves cygpath."""
+ with open(filename) as input_file:
+ file_names = sorted([os.path.realpath(line.rstrip('\n'))
+ for line in input_file])
+ idl_file_names = [file_name for file_name in file_names
+ if not file_name.startswith('/cygdrive')]
+ cygdrive_names = [file_name for file_name in file_names
+ if file_name.startswith('/cygdrive')]
+ idl_file_names.extend(resolve_cygpath(cygdrive_names))
+ return idl_file_names
+
+
def read_pickle_files(pickle_filenames):
for pickle_filename in pickle_filenames:
with open(pickle_filename) as pickle_file:
@@ -49,6 +91,9 @@ def write_file(new_text, destination_filename, only_if_changed):
with open(destination_filename) as destination_file:
if destination_file.read() == new_text:
return
+ destination_dirname = os.path.dirname(destination_filename)
+ if not os.path.exists(destination_dirname):
+ os.makedirs(destination_dirname)
with open(destination_filename, 'w') as destination_file:
destination_file.write(new_text)
« no previous file with comments | « bindings/scripts/interface_dependency_resolver.py ('k') | bindings/scripts/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698