OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 18 matching lines...) Expand all Loading... |
29 import os.path | 29 import os.path |
30 import shutil | 30 import shutil |
31 | 31 |
32 from in_file import InFile | 32 from in_file import InFile |
33 | 33 |
34 | 34 |
35 class Writer(object): | 35 class Writer(object): |
36 # Subclasses should override. | 36 # Subclasses should override. |
37 class_name = None | 37 class_name = None |
38 defaults = None | 38 defaults = None |
| 39 default_parameters = None |
39 | 40 |
40 def __init__(self, in_file_path): | 41 def __init__(self, in_file_path): |
41 self.in_file = InFile.load_from_path(in_file_path, self.defaults) | 42 self.in_file = InFile.load_from_path(in_file_path, self.defaults, self.d
efault_parameters) |
42 | 43 |
43 # Subclasses should override. | 44 # Subclasses should override. |
44 def generate_header(self): | 45 def generate_header(self): |
45 raise NotImplementedError | 46 raise NotImplementedError |
46 | 47 |
47 # Subclasses should override. | 48 # Subclasses should override. |
48 def generate_implementation(self): | 49 def generate_implementation(self): |
49 raise NotImplementedError | 50 raise NotImplementedError |
50 | 51 |
51 def _forcibly_create_text_file_at_path_with_contents(self, file_path, conten
ts): | 52 def _forcibly_create_text_file_at_path_with_contents(self, file_path, conten
ts): |
(...skipping 28 matching lines...) Expand all Loading... |
80 script_name = os.path.basename(argv[0]) | 81 script_name = os.path.basename(argv[0]) |
81 args = argv[1:] | 82 args = argv[1:] |
82 if len(args) < 1: | 83 if len(args) < 1: |
83 print "USAGE: %i INPUT_FILE [OUTPUT_DIRECTORY]" % script_name | 84 print "USAGE: %i INPUT_FILE [OUTPUT_DIRECTORY]" % script_name |
84 exit(1) | 85 exit(1) |
85 output_dir = args[1] if len(args) > 1 else os.getcwd() | 86 output_dir = args[1] if len(args) > 1 else os.getcwd() |
86 | 87 |
87 writer = self._writer_class(args[0]) | 88 writer = self._writer_class(args[0]) |
88 writer.write_header(output_dir) | 89 writer.write_header(output_dir) |
89 writer.write_implmentation(output_dir) | 90 writer.write_implmentation(output_dir) |
OLD | NEW |