Skip to content

validating locally saved files #4

@ptoche

Description

@ptoche

Is it possible to validate locally saved files?

I tried:

from w3c_validator import validate
file = '/path/to/file.xhtml' 
with open(file, encoding='utf8') as infile:
    # print(infile.readlines()[:10])  # check that the file is properly opened
    messages = validate(infile)["messages"]
    for m in messages:
        print("Type: %(type)s, Line: %(lastLine)d, Description: %(message)s" % m)

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/Users/username/miniconda3/envs/vs/lib/python3.8/site-packages/w3c_validator/validator.py", line 41, in validate
    is_remote = filename.startswith("http://") or filename.startswith(
AttributeError: '_io.TextIOWrapper' object has no attribute 'startswith'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions