<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _setup_info_xml(self, languageList):
 '''Setup the info.xml file This function prepares or checks the info.xml file in the project directory - if the info.xml does not exist in the project directory, it copies the template info.xml into the project directory. The project name is obtained from the project directory name - If there is a info.xml file, the resource section is inspected. If the resource section has no valid message set description for the TopologySplpy Resource a warning message is printed''' infoXmlFile = os.path.join(self._tk_dir, 'info.xml') print('Check info.xml:', infoXmlFile) try: TopologySplpyResourceMessageSetFound = False TopologySplpyResourceLanguages = [] tree = ET.parse(infoXmlFile) root = tree.getroot() for resources in root.findall('{http://www.ibm.com/xmlns/prod/streams/spl/toolkitInfo}resources'):
 if self._cmd_args.verbose: print('Resource: ', resources.tag) for messageSet in resources.findall('{http://www.ibm.com/xmlns/prod/streams/spl/toolkitInfo}messageSet'):
 if self._cmd_args.verbose: print('Message set:', messageSet.tag, messageSet.attrib) if 'name' in messageSet.attrib: if messageSet.attrib['name'] == 'TopologySplpyResource': TopologySplpyResourceMessageSetFound = True for lang in messageSet.findall('{http://www.ibm.com/xmlns/prod/streams/spl/toolkitInfo}lang'):
 language = os.path.dirname(lang.text) TopologySplpyResourceLanguages.append(language) if TopologySplpyResourceMessageSetFound: TopologySplpyResourceLanguages.sort() languageList.sort() copiedLanguagesSet = set(languageList) resourceLanguageSet = set(TopologySplpyResourceLanguages) if self._cmd_args.verbose: print('copied language resources:\n', languageList) print('TopologySplpyResource from info.xml:\n', TopologySplpyResourceLanguages) if copiedLanguagesSet == resourceLanguageSet: print('Resource section of info.xml verified') else: errstr = """"ERROR: Message set for the "TopologySplpyResource" is incomplete or invalid. Correct the resource section in info.xml file. Sample info xml:\n"""
 + _INFO_XML_TEMPLATE
                    sys.exit(errstr)
            else:
                errstr = """"ERROR: Message set for the "TopologySplpyResource" is missing. Correct the resource section in info.xml file.
    
                    Sample info xml:\n""" + _INFO_XML_TEMPLATE
                sys.exit(errstr)
        except FileNotFoundError as e:
            print("WARNING: File info.xml not found. Creating info.xml from template")
            #Get default project name from project directory
            projectRootDir = os.path.abspath(self._tk_dir) #os.path.abspath returns the path without trailing /
            projectName = os.path.basename(projectRootDir)
            infoXml=_INFO_XML_TEMPLATE.replace('__SPLPY_TOOLKIT_NAME__', projectName)
            f = open(infoXmlFile, 'w')
            f.write(infoXml)
            f.close()
        except SystemExit as e:
            raise e
        except:
            errstr = """ERROR: File info.xml is invalid or not accessible
    
                Sample info xml:\n""" + _INFO_XML_TEMPLATE
            sys.exit(errstr)