def _get_writer(output_file): """ :rtype : writers.output_writer.OutputWriter """ output_file_extension = extract_file_extension(output_file) if not writer_container.is_format_supported(output_file_extension): raise FileFormatNotSupported(output_file) return writer_container.get(output_file_extension)
def test_extract_file_extension(): assert extract_file_extension('') == '' assert extract_file_extension('text') == '' assert extract_file_extension('.text') == 'text' assert extract_file_extension('a.b.c.text') == 'text' assert extract_file_extension('a.b.c.TeXt') == 'text' assert extract_file_extension('a/b/c.d.TeXt') == 'text'
def _get_reader(input_file): """ :rtype : readers.input_reader.InputReader """ input_file_extension = extract_file_extension(input_file) if not reader_container.is_format_supported(input_file_extension): raise FileFormatNotSupported(input_file) reader = reader_container.get(input_file_extension) assert isinstance(reader, InputReader) reader.open(open(input_file)) return reader