Exemplo n.º 1
0
def test_utf16_memory_decoding():
    test_content = u"Äkkilähdöt,Matkakirjoituksia,Matkatoimistot"
    test_content = BytesIO(test_content.encode("utf-16"))
    reader = CSVinMemoryReader(NamedContent("csv", test_content),
                               encoding="utf-16")
    content = list(reader.to_array())
    if PY2:
        content[0] = [s.encode("utf-8") for s in content[0]]
    expected = [["Äkkilähdöt", "Matkakirjoituksia", "Matkatoimistot"]]
    eq_(content, expected)
Exemplo n.º 2
0
def test_utf16_memory_decoding():
    test_content = u'Äkkilähdöt,Matkakirjoituksia,Matkatoimistot'
    test_content = BytesIO(test_content.encode('utf-16'))
    reader = CSVinMemoryReader(NamedContent('csv', test_content),
                               encoding="utf-16")
    content = list(reader.to_array())
    if PY2:
        content[0] = [s.encode('utf-8') for s in content[0]]
    expected = [['Äkkilähdöt', 'Matkakirjoituksia', 'Matkatoimistot']]
    eq_(content, expected)
Exemplo n.º 3
0
def test_utf16_memory_decoding():
    test_content = u"Äkkilähdöt,Matkakirjoituksia,Matkatoimistot"
    test_content = BytesIO(test_content.encode("utf-16"))
    reader = CSVinMemoryReader(
        NamedContent("csv", test_content), encoding="utf-16"
    )
    content = list(reader.to_array())
    if PY2:
        content[0] = [s.encode("utf-8") for s in content[0]]
    expected = [["Äkkilähdöt", "Matkakirjoituksia", "Matkatoimistot"]]
    eq_(content, expected)
def test_utf16_memory_decoding():
    test_content = u'Äkkilähdöt,Matkakirjoituksia,Matkatoimistot'
    test_content = BytesIO(test_content.encode('utf-16'))
    reader = CSVinMemoryReader(
        NamedContent('csv', test_content),
        encoding="utf-16")
    content = list(reader.to_array())
    if PY2:
        content[0] = [s.encode('utf-8') for s in content[0]]
    expected = [['Äkkilähdöt', 'Matkakirjoituksia', 'Matkatoimistot']]
    eq_(content, expected)
Exemplo n.º 5
0
def test_load_ods_data_from_memory():
    io = BytesIO()
    msg = "Please install one of these plugins for read data in 'ods': "
    msg += "pyexcel-ods,pyexcel-ods3"
    try:
        get_data(io, file_type="ods")
    except exceptions.SupportingPluginAvailableButNotInstalled as e:
        eq_(str(e), msg)
Exemplo n.º 6
0
def test_write_xlsx_data_to_memory():
    data = {"Sheet": [[1]]}
    io = BytesIO()
    msg = "Please install one of these plugins for write data in 'xlsx': "
    msg += "pyexcel-xlsx,pyexcel-xlsxw"
    try:
        save_data(io, data, file_type="xlsx")
    except exceptions.SupportingPluginAvailableButNotInstalled as e:
        eq_(str(e), msg)
Exemplo n.º 7
0
def get_io(file_type):
    """A utility function to help you generate a correct io stream

    :param file_type: a supported file type
    :returns: a appropriate io stream, None otherwise
    """
    __file_type = None
    if file_type:
        __file_type = file_type.lower()

    if __file_type in text_stream_types:
        return StringIO()
    elif __file_type in binary_stream_types:
        return BytesIO()
    else:
        return None
Exemplo n.º 8
0
def get_io(file_type):
    """A utility function to help you generate a correct io stream

    :param file_type: a supported file type
    :returns: a appropriate io stream, None otherwise
    """
    __file_type = None
    if file_type:
        __file_type = file_type.lower()

    if __file_type in TEXT_STREAM_TYPES:
        return StringIO()
    elif __file_type in BINARY_STREAM_TYPES:
        return BytesIO()
    else:
        return None
Exemplo n.º 9
0
 def get_io(self):
     return BytesIO()
Exemplo n.º 10
0
def test_writer_unknown_data_from_memory2():
    io = BytesIO()
    # mock it
    manager.register_stream_type("unknown1", "text")
    get_writer(io, file_type="unknown1")
Exemplo n.º 11
0
def test_writer_xlsm_data_from_memory2():
    io = BytesIO()
    get_writer(io, file_type="xlsms")
Exemplo n.º 12
0
def test_load_unknown_data_from_memory():
    io = BytesIO()
    get_data(io, file_type="unknown")
Exemplo n.º 13
0
def test_load_ods_data_from_memory():
    io = BytesIO()
    get_data(io, file_type="ods")