Exemplo n.º 1
0
def _FirstStatementsInScriptElements(contents):
    """Returns a list of first statements found in each <script> element."""
    soup = parse_html.BeautifulSoup(contents)
    script_elements = soup.find_all('script', src=None)
    return [_FirstStatement(e.get_text()) for e in script_elements]
Exemplo n.º 2
0
def CheckAffectedFile(affected_file, results, output_api):
    path = affected_file.LocalPath()
    soup = parse_html.BeautifulSoup('\n'.join(affected_file.NewContents()))
    for check in [CheckDoctype, CheckImportOrder]:
        check(path, soup, results, output_api)
Exemplo n.º 3
0
def _HasHtml5Declaration(contents):
    soup = parse_html.BeautifulSoup(contents)
    for item in soup.contents:
        if isinstance(item, bs4.Doctype) and item.lower() == 'html':
            return True
    return False