Exemplo n.º 1
0
    def __init__(self, source, encoding=None):
        if not encoding and source:
            encoding = detect_file_encoding(source)
            logger.debug("detect encoding: file={}, encoding={}".format(
                source, encoding))

        super(TableFileLoaderFactory, self).__init__(source, encoding)
Exemplo n.º 2
0
def get_file_encoding(file_path, encoding):
    from mbstrdecoder import detect_file_encoding

    if encoding:
        return encoding

    encoding = detect_file_encoding(file_path)
    if not encoding:
        return Default.ENCODING

    return encoding