OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions | 6 # modification, are permitted provided that the following conditions |
7 # are met: | 7 # are met: |
8 # | 8 # |
9 # 1. Redistributions of source code must retain the above | 9 # 1. Redistributions of source code must retain the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 28 matching lines...) Expand all Loading... |
39 _log = logging.getLogger(__name__) | 39 _log = logging.getLogger(__name__) |
40 | 40 |
41 | 41 |
42 def convert_for_webkit(new_path, filename, reference_support_info, host=Host()): | 42 def convert_for_webkit(new_path, filename, reference_support_info, host=Host()): |
43 """ Converts a file's |contents| so it will function correctly in its |new_p
ath| in Webkit. | 43 """ Converts a file's |contents| so it will function correctly in its |new_p
ath| in Webkit. |
44 | 44 |
45 Returns the list of modified properties and the modified text if the file wa
s modifed, None otherwise.""" | 45 Returns the list of modified properties and the modified text if the file wa
s modifed, None otherwise.""" |
46 contents = host.filesystem.read_binary_file(filename) | 46 contents = host.filesystem.read_binary_file(filename) |
47 converter = _W3CTestConverter(new_path, filename, reference_support_info, ho
st) | 47 converter = _W3CTestConverter(new_path, filename, reference_support_info, ho
st) |
48 if filename.endswith('.css'): | 48 if filename.endswith('.css'): |
49 return converter.add_webkit_prefix_to_unprefixed_properties(contents) | 49 return converter.add_webkit_prefix_to_unprefixed_properties(contents.dec
ode('utf-8')) |
50 else: | 50 else: |
51 converter.feed(contents.decode('utf-8')) | 51 converter.feed(contents.decode('utf-8')) |
52 converter.close() | 52 converter.close() |
53 return converter.output() | 53 return converter.output() |
54 | 54 |
55 | 55 |
56 class _W3CTestConverter(HTMLParser): | 56 class _W3CTestConverter(HTMLParser): |
57 def __init__(self, new_path, filename, reference_support_info, host=Host()): | 57 def __init__(self, new_path, filename, reference_support_info, host=Host()): |
58 HTMLParser.__init__(self) | 58 HTMLParser.__init__(self) |
59 | 59 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 self.converted_data.extend(['&#', name, ';']) | 254 self.converted_data.extend(['&#', name, ';']) |
255 | 255 |
256 def handle_comment(self, data): | 256 def handle_comment(self, data): |
257 self.converted_data.extend(['<!-- ', data, ' -->']) | 257 self.converted_data.extend(['<!-- ', data, ' -->']) |
258 | 258 |
259 def handle_decl(self, decl): | 259 def handle_decl(self, decl): |
260 self.converted_data.extend(['<!', decl, '>']) | 260 self.converted_data.extend(['<!', decl, '>']) |
261 | 261 |
262 def handle_pi(self, data): | 262 def handle_pi(self, data): |
263 self.converted_data.extend(['<?', data, '>']) | 263 self.converted_data.extend(['<?', data, '>']) |
OLD | NEW |