コード例 #1
0
ファイル: test_loadump.py プロジェクト: birdsarah/karl_data
 def test_custom_encoding(self):
     """
     Ensure trying to encode from ascii on a utf-8 file
     will cause problems.
     """
     lines = i_get_unicode_lines(self.input_data_path, encoding='ascii')
     self.assertRaises(UnicodeDecodeError, list, lines)
コード例 #2
0
ファイル: app_engine.py プロジェクト: birdsarah/karl_data
def log_reader(file_path):
    """
    Iterate over request logs as written by a Google App Engine app.

    :param file_path: Path to an App Engine log file.
    :returns: An iterator of multi-line log records.
    """
    lines = i_get_unicode_lines(file_path)

    return multi_line_records(lines, is_line_start=is_log_start_line)
コード例 #3
0
ファイル: test_loadump.py プロジェクト: birdsarah/karl_data
    def test_default_lines_unicode(self):
        """
        Ensure entering a file path will produce an iterator
        of the lines as unicode.
        """
        lines = i_get_unicode_lines(self.input_data_path)
        first = next(lines)
        second = next(lines)

        self.assertEqual(u'mushroom,fungus\n', first)
        self.assertEqual(u'tomato,fruit\n', second)

        remaining = list(lines)

        self.assertEqual(u'dróżką,utf-8 sample\n', remaining[2])