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

Unified Diff: Source/build/scripts/xxd.py

Issue 42793005: Port xxd.pl to xxd.py (Perl to Python) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Python 2.6 (not 2.7): {} => {0} Created 7 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 | « Source/build/scripts/xxd.pl ('k') | Source/core/core_derived_sources.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/build/scripts/xxd.py
diff --git a/Tools/Scripts/print-layout-test-types b/Source/build/scripts/xxd.py
old mode 100755
new mode 100644
similarity index 72%
copy from Tools/Scripts/print-layout-test-types
copy to Source/build/scripts/xxd.py
index 3cc36c64bb26ebaf0e173e0dad4ce8c9b0b1cd52..858236c9a63b88449bfb0cf7ffbc771c10360046
--- a/Tools/Scripts/print-layout-test-types
+++ b/Source/build/scripts/xxd.py
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-#
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,9 +26,25 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+"""Represent a file as a C++ constant string.
+
+Usage:
+python xxd.py VAR SOURCE DEST
+"""
+
import sys
-from webkitpy.common import host
-from webkitpy.layout_tests import print_layout_test_types
-print_layout_test_types.main(host.Host(), sys.argv[1:])
+def main():
+ variable_name, input_filename, output_filename = sys.argv[1:]
+ with open(input_filename) as input_file:
+ input_text = input_file.read()
+ hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
+ const_declaration = 'const unsigned char %s[] = {\n%s\n};\n' % (
+ variable_name, ', '.join(hex_values))
+ with open(output_filename, 'w') as output_file:
+ output_file.write(const_declaration)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « Source/build/scripts/xxd.pl ('k') | Source/core/core_derived_sources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698