def get_encoding_from_line(s):
    """
    Return the encoding specified in the given line or None if none was specified.   
    :param s: line to check
    :type s: str
    :return: the encoding
    :rtype: bool or None
    """
    exp = "^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)"
    m = re.match(exp, s)
    if m is None:
        return None
    else:
        return m.groups()[0]

    Return the encoding specified in the given line or None if none was specified.   
    :param s: line to check
    :type s: str
    :return: the encoding
    :rtype: bool or None
    
tools/encoding_utils.py