import os
import re

# close chrome before executing the script
fileLocation = os.path.expanduser('~') + r'\AppData\Local\Google\Chrome\User Data\Default\Preferences'
if os.path.exists(fileLocation):
    try:
        RdFile = open(fileLocation, "r")
        RegexContent = RdFile.read()
        RdFile.close()
        RegexContent = re.sub(r'("notification_permission_review[^,]+,"notifications":{).+,\*[^}]+}(},"password_protection")', r'\1\2', RegexContent,
                              flags=re.DOTALL)
        updFile = open(fileLocation, "a")
        updFile.write(RegexContent)
        updFile.close()
        print 'Script was executed successfully'
    except:
        print 'Script execution failed'
else:
    print 'Script execution failed'