Skip to content
Snippets Groups Projects
atom_format.py 578 B
Newer Older
  • Learn to ignore specific revisions
  • import xml.etree.ElementTree as ET
    
    
    def is_valid(resource, file):
        """Check if the HTTP response is an ATOM feed."""
    
        with open(file.name, "rb") as f:
            try:
                xml = ET.parse(f).getroot()
    
                if xml.tag == "{http://www.w3.org/2005/Atom}feed":
                    return True
                else:
                    resource["error"] = (
                        "Root element is not {http://www.w3.org/2005/Atom}feed"
                    )
                    return False
            except Exception as e:
                resource["error"] = str(e)
                return False