A wrapper around the main loop of the utility which handles opening and closing files.
(self)
| 128 | raise NotImplementedError('add_arguments must be provided by each subclass of CSVKitUtility.') |
| 129 | |
| 130 | def run(self): |
| 131 | """ |
| 132 | A wrapper around the main loop of the utility which handles opening and |
| 133 | closing files. |
| 134 | """ |
| 135 | if 'f' not in self.override_flags: |
| 136 | self.input_file = self._open_input_file(self.args.input_path) |
| 137 | |
| 138 | if getattr(self.args, 'add_bom', False): |
| 139 | self.output_file.buffer.write(BOM_UTF8) |
| 140 | |
| 141 | try: |
| 142 | with warnings.catch_warnings(): |
| 143 | if getattr(self.args, 'no_header_row', None): |
| 144 | warnings.filterwarnings(action='ignore', message='Column names not specified', module='agate') |
| 145 | |
| 146 | self.main() |
| 147 | finally: |
| 148 | if 'f' not in self.override_flags: |
| 149 | self.input_file.close() |
| 150 | |
| 151 | def main(self): |
| 152 | """ |