"""Helper module for HTML file operations.

Copyright (c) 2021 <NAME>
For further information see https://github.com/peter88213/PyWriter
Published under the MIT License (https://opensource.org/licenses/mit-license.php)
"""

import os


def read_html_file(filePath):
    """Open a html file being encoded utf-8 or ANSI.
    Return a tuple:
    [0] = Message beginning with SUCCESS or ERROR.
    [1] = The file content in a single string. 
    """
    try:
        with open(filePath, 'r', encoding='utf-8') as f:
            text = (f.read())
    except:
        # HTML files exported by a word processor may be ANSI encoded.
        try:
            with open(filePath, 'r') as f:
                text = (f.read())

        except(FileNotFoundError):
            return ('ERROR: "' + os.path.normpath(filePath) + '" not found.', None)

    return ('SUCCESS', text)


if __name__ == '__main__':
    pass

"""Helper module for HTML file operations.

Copyright (c) 2021 <NAME>
For further information see https://github.com/peter88213/PyWriter
Published under the MIT License (https://opensource.org/licenses/mit-license.php)
"""

import os


def read_html_file(filePath):
    """Open a html file being encoded utf-8 or ANSI.
    Return a tuple:
    [0] = Message beginning with SUCCESS or ERROR.
    [1] = The file content in a single string. 
    """
    try:
        with open(filePath, 'r', encoding='utf-8') as f:
            text = (f.read())
    except:
        # HTML files exported by a word processor may be ANSI encoded.
        try:
            with open(filePath, 'r') as f:
                text = (f.read())

        except(FileNotFoundError):
            return ('ERROR: "' + os.path.normpath(filePath) + '" not found.', None)

    return ('SUCCESS', text)


if __name__ == '__main__':
    pass

Helper module for HTML file operations.
 
 Copyright (c) 2021 <NAME>
 For further information see https://github.com/peter88213/PyWriter
 Published under the MIT License (https://opensource.org/licenses/mit-license.php) Open a html file being encoded utf-8 or ANSI.
     Return a tuple:
     [0] = Message beginning with SUCCESS or ERROR.
     [1] = The file content in a single string. # HTML files exported by a word processor may be ANSI encoded.