Skip to content

Add support for wildcards #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# W3C validator for Holberton School
For HTML, CSS and SVG files
A script that checks the conformance of HTML, CSS, and SVG files against W3C standards.

This fork enhances the original W3C-Validator by adding wildcard support, allowing you to validate multiple files at once.

Based on 1 API:
- [Markup Validator Web Service API](https://validator.w3.org/docs/api.html)
Expand All @@ -11,7 +13,7 @@ Based on 1 API:
## Quickstart
1. Clone this repo
```sh
git clone https://github.com/holbertonschool/W3C-Validator.git
git clone https://github.com/uosyph/W3C-Validator.git
```

2. Run the validator command from within
Expand All @@ -32,6 +34,10 @@ Multiple files:
./w3c_validator.py index.html article.html css/styles.css
```

```sh
./w3c_validator.py *.html css/*.css
```

All errors are printed in `STDERR`; Exit status = # of errors (0 on success)

## Troubleshooting
Expand Down
11 changes: 9 additions & 2 deletions w3c_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
./w3c_validator.py index.html header.html styles/common.css
```

```
./w3c_validator.py *.html styles/*.css
```

All errors are printed in `STDERR`

Return:
Expand All @@ -29,6 +33,7 @@
import sys
import requests
import os
import glob


def __print_stdout(msg):
Expand Down Expand Up @@ -113,8 +118,10 @@ def __files_loop():
"""Loop that analyses for each file from input arguments
"""
nb_errors = 0
for file_path in sys.argv[1:]:
nb_errors += __analyse(file_path)
for pattern in sys.argv[1:]:
files = glob.glob(pattern)
for file_path in files:
nb_errors += __analyse(file_path)

return nb_errors

Expand Down