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

Side by Side Diff: src/inspector/build/xxd.py

Issue 2292573002: [inspector] Initial import of v8_inspector. (Closed)
Patch Set: format the code, disable cpplint Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/inspector/build/rjsmin.py ('k') | src/inspector/debugger_script_externs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 the V8 project authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Represent a file as a C++ constant string.
6
7 Usage:
8 python xxd.py VAR SOURCE DEST
9 """
10
11
12 import sys
13 import rjsmin
14
15
16 def main():
17 variable_name, input_filename, output_filename = sys.argv[1:]
18 with open(input_filename) as input_file:
19 input_text = input_file.read()
20 input_text = rjsmin.jsmin(input_text)
21 hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
22 const_declaration = 'const char %s[] = {\n%s\n};\n' % (
23 variable_name, ', '.join(hex_values))
24 with open(output_filename, 'w') as output_file:
25 output_file.write(const_declaration)
26
27 if __name__ == '__main__':
28 sys.exit(main())
OLDNEW
« no previous file with comments | « src/inspector/build/rjsmin.py ('k') | src/inspector/debugger_script_externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698