File size: 1,364 Bytes
8e72bb5
 
 
 
 
 
 
 
 
 
 
 
 
7dce6dc
 
8e72bb5
 
 
488534f
8e72bb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7dce6dc
8e72bb5
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Test __main__.py."""
# pylint: disable=invalid-name

import tempfile
from fastlid import fastlid

from logzero import logger

# globals()["file2text"] = getattr(importlib.import_module(f"{radiobee.__name__}.file2text"), "file2text")
# from radiobee.process_upload import process_upload  # same as file2text
from radiobee.files2df import files2df
from radiobee.file2text import file2text
from radiobee.lists2cmat import lists2cmat

# from radiobee.cmat2tset import cmat2tset

file1loc = "data/test-dual.txt"
file2loc = ""
file2loc = "data/empty.txt"

file1 = tempfile._TemporaryFileWrapper(open(file1loc, "rb"), file1loc)
if file2loc:
    file2 = tempfile._TemporaryFileWrapper(open(file2loc, "rb"), file2loc)
else:
    file2 = None


def test_file2file1():
    """Test cmat file2 file1."""
    # logger.info("file1: *%s*, file2: *%s*", file1, file2)
    if file2 is not None:
        logger.info("file1.name: *%s*, file2.name: *%s*", file1.name, file2.name)
    else:
        logger.info("file1.name: *%s*, file2: *%s*", file1.name, file2)
    text1 = file2text(file1)
    text2 = file2text(file2)

    fastlid.set_languages = ["en", "zh"]
    lang1, _ = fastlid(text1)
    lang2, _ = fastlid(text2)

    lst1 = [elm.strip() for elm in text1.splitlines() if elm.strip()]
    lst2 = [elm.strip() for elm in text2.splitlines() if elm.strip()]

    del lst1, lst2