Exemple #1
0
def readKatalkUserInfo(fname):
    for line in common.feedLine(fname):
        print(line)
        result = katalkParser.parseLine(line)
        if 'TALK_LINE' == result[0]:
            #print(result)
            date, year, talkTime, katalkID, talk = result[1:]
            cmd = commandParser.parseLine(talk)
            if commandParser.USER == cmd[0]:
                yield katalkID, cmd[1], cmd[2] # .user 이대현, 89418022
Exemple #2
0
def trimChatFile(fname):



    # f = open(chatFilePath, 'rb')
    # for line in f:
    #     print(repr(line))
    #     print(line)
    #
    # f.close()


    # with open(chatFilePath, 'r', encoding='utf-8-sig') as f:
    #     for line in f:
    #         print(line)
    #
    # for line in common.feedLine(chatFilePath):
    #     print(line)




    #
    with open('tmp.txt', 'wb') as f:
        f.write(b'\xef\xbb\xbf') # add utf-8 BOM
        for line in common.feedLine(chatFilePath):
            # print(repr(line))
            f.write(line.encode('utf-8'))
            f.write(b'\n')




    # with open('tmp.txt', 'wb') as f:
    #     for line in common.feedLine(fname):
    #         f.write(line.encode('utf-8'))
    #         f.write(b'\r\n')
    #
    #
    # with open('tmp.txt', 'rb') as f:
    #     for line in f:
    #         print(line.decode('utf-8'))


    shutil.copy('tmp.txt', chatFilePath)