| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 import subprocess | 3 import subprocess |
| 4 import sys | 4 import sys |
| 5 | 5 |
| 6 import css_properties | 6 import css_properties |
| 7 import in_generator | 7 import in_generator |
| 8 import license | 8 import license |
| 9 | 9 |
| 10 | 10 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 'license': license.license_for_generated_cpp(), | 223 'license': license.license_for_generated_cpp(), |
| 224 'class_name': self.class_name, | 224 'class_name': self.class_name, |
| 225 'property_name_strings': '\n'.join(' "%s\\0"' % name for name in
property_names), | 225 'property_name_strings': '\n'.join(' "%s\\0"' % name for name in
property_names), |
| 226 'property_name_offsets': '\n'.join(' %d,' % offset for offset in
property_offsets), | 226 'property_name_offsets': '\n'.join(' %d,' % offset for offset in
property_offsets), |
| 227 'property_to_enum_map': '\n'.join('%s, %s' % property for property i
n css_name_and_enum_pairs), | 227 'property_to_enum_map': '\n'.join('%s, %s' % property for property i
n css_name_and_enum_pairs), |
| 228 } | 228 } |
| 229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 233 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) | 233 |
| 234 return gperf.communicate(gperf_input)[0] | 234 # If gperf isn't in the path we get an OSError. We don't want to use |
| 235 # the normal solution of shell=True (as this has to run on many |
| 236 # platforms), so instead we catch the error and raise a |
| 237 # CalledProcessError like subprocess would do when shell=True is set. |
| 238 try: |
| 239 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s
ubprocess.PIPE, universal_newlines=True) |
| 240 return gperf.communicate(gperf_input)[0] |
| 241 except OSError: |
| 242 raise subprocess.CalledProcessError(127, gperf_args, output='Command
not found.') |
| 235 | 243 |
| 236 | 244 |
| 237 if __name__ == "__main__": | 245 if __name__ == "__main__": |
| 238 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) | 246 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) |
| OLD | NEW |