def improve():
    """Disables access to websites that are defined as 'distractors'"""
    with open(settings.HOSTS_FILE, "r+") as hosts_file:
        contents = hosts_file.read()
        if not settings.START_TOKEN in contents and not settings.END_TOKEN in contents:
            hosts_file.write(settings.START_TOKEN + "\n")
            for site in set(settings.DISTRACTORS):
                hosts_file.write("{0}\t{1}\n".format(settings.REDIRECT_TO, site))
                for sub_domain in settings.SUB_DOMAINS:
                    hosts_file.write("{0}\t{1}.{2}\n".format(settings.REDIRECT_TO, sub_domain, site))
            hosts_file.write(settings.END_TOKEN + "\n")

    reset_network("Concentration is now improved :D!")
def improve ( ) : with open ( settings . HOSTS_FILE , "r+" ) as hosts_file : contents = hosts_file . read ( ) if not settings . START_TOKEN in contents and not settings . END_TOKEN in contents : hosts_file . write ( settings . START_TOKEN + "\n" ) for site in set ( settings . DISTRACTORS ) : hosts_file . write ( "{0}\t{1}\n" . format ( settings . REDIRECT_TO , site ) ) for sub_domain in settings . SUB_DOMAINS : hosts_file . write ( "{0}\t{1}.{2}\n" . format ( settings . REDIRECT_TO , sub_domain , site ) ) hosts_file . write ( settings . END_TOKEN + "\n" ) reset_network ( "Concentration is now improved :D!" )
Disables access to websites that are defined as 'distractors