def name_from_xml(xml_path):
    """ Get a name from an qiproject.xml file

    """
    mess  = "Invalid qiproject.xml file detected!\n"
    mess += "(%s)\n" % xml_path
    if not os.path.exists(xml_path):
        return None
    tree = etree.ElementTree()
    try:
        tree.parse(xml_path)
    except Exception, e:
        ui.fatal(e)

    # Read name
    root = tree.getroot()
    if root.tag != "project":
        mess += "Root node must be 'project'"
        ui.fatal(mess)
    if root.get("version") == "3":
        project_elem = root.find("qbuild")
        if not project_elem:
            return
    else:
        project_elem = root

    name = project_elem.get('name')
    if not name:
        mess += "'project' node must have a 'name' attribute"
        ui.fatal(mess)

    return name
dataset/ETHPy150Open aldebaran/qibuild/python/qibuild/actions/convert.py/name_from_xml/original