def METHOD_NAME(self):
    # read original file
    with open('../../appengine/src/com/google/appinventor/client/Images.java', 'r') as f:
        text = f.read()
    #open template and insert variables
    with open('Image.java.template') as f:
        newtxt = f.read() % (
            self.compName, self.compImgName, self.compImgName)
    # if already exists a declaration with same name
    if re.search(re.escape(newtxt), text):
        raise DuplicateError
    # insert new component in file and write
    text = re.sub(re.escape('procedures();'), 'procedures();\n%s' % newtxt, text)
    with open('../../appengine/src/com/google/appinventor/client/Images.java', 'w') as f:
        f.write(text)