Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
cblakkan committed Dec 31, 2024
1 parent d0472d0 commit 2b7da4c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Yamale (ya·ma·lē)
=================
[![Build Status](https://github.com/23andMe/Yamale/actions/workflows/run-tests.yml/badge.svg)](https://github.com/23andMe/Yamale/actions/workflows/run-tests.yml)
[![PyPI](https://img.shields.io/pypi/v/yamale.svg)](https://pypi.python.org/pypi/yamale)
[![downloads](https://static.pepy.tech/badge/yamale/month)](https://pepy.tech/project/yamale)
[![versions](https://img.shields.io/pypi/pyversions/yamale.svg)](https://github.com/yamale/yamale)
[![license](https://img.shields.io/github/license/23andMe/yamale.svg)](https://github.com/23andMe/Yamale/blob/master/LICENSE)

| :warning: Ensure that your schema definitions come from internal or trusted sources. Yamale does not protect against intentionally malicious schemas. |
|:------------|
Expand All @@ -11,8 +16,6 @@ A schema and validator for YAML.
What's YAML? See the current spec [here](http://www.yaml.org/spec/1.2/spec.html) and an introduction
to the syntax [here](https://github.com/Animosity/CraftIRC/wiki/Complete-idiot's-introduction-to-yaml).

[![Build Status](https://github.com/23andMe/Yamale/actions/workflows/run-tests.yml/badge.svg)](https://github.com/23andMe/Yamale/actions/workflows/run-tests.yml)
[![PyPI](https://img.shields.io/pypi/v/yamale.svg)](https://pypi.python.org/pypi/yamale)

Requirements
------------
Expand All @@ -25,6 +28,8 @@ Install
### pip
```bash
$ pip install yamale
# or to include ruamel.yaml as a dependency
$ pip install yamale[ruamel]
```

NOTE: Some platforms, e.g., Mac OS, may ship with only Python 2 and may not have pip installed.
Expand Down Expand Up @@ -66,7 +71,7 @@ options:
-p PARSER, --parser PARSER
YAML library to load files. Choices are "ruamel" or "pyyaml" (default).
-n CPU_NUM, --cpu-num CPU_NUM
number of child processes to spawn for validation. Default is 4. 'auto' to use CPU count
number of child processes to spawn for validation. Default is 4. 'auto' to use CPU count.
-x, --no-strict disable strict mode, unexpected elements in the data will be accepted.
-v, --verbose show verbose information
-V, --version show program's version number and exit
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=["pyyaml"],
extras_requires={"ruamel": ["ruamel.yaml"]},
extras_require={"ruamel": ["ruamel.yaml"]},
python_requires=">=3.8",
entry_points={
"console_scripts": ["yamale=yamale.command_line:main"],
Expand Down
14 changes: 7 additions & 7 deletions yamale/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _find_schema(data_path, schema_name):
def _validate_file(yaml_path, schema_name, parser, strict, should_exclude):
if should_exclude(yaml_path):
return
print("Validating %s..." % yaml_path)
s = _find_schema(yaml_path, schema_name)
if not s:
raise ValueError("Invalid schema name for '{}' or schema not found.".format(schema_name))
Expand All @@ -79,7 +78,6 @@ def _validate_dir(root, schema_name, cpus, parser, strict, should_exclude):
pool = multiprocessing.Pool(processes=cpus)
res = []
error_messages = []
print("Finding yaml files...")
for root, _, files in os.walk(root):
for f in files:
if (f.endswith(".yaml") or f.endswith(".yml")) and f != schema_name:
Expand All @@ -90,10 +88,9 @@ def _validate_dir(root, schema_name, cpus, parser, strict, should_exclude):
if schema_path:
res.append(pool.apply_async(_validate, (schema_path, yaml_path, parser, strict, False)))
else:
print("No schema found for: %s" % yaml_path)
print(f"No schema found for: {yaml_path}")

print("Found %s yaml files." % len(res))
print("Validating...")
print(f"Found {len(res)} yaml files to validate...")
for r in res:
sub_results = r.get(timeout=300)
error_messages.extend([str(sub_result) for sub_result in sub_results if not sub_result.isValid()])
Expand All @@ -114,8 +111,11 @@ def should_exclude(yaml_path):

for path in paths:
abs_path = os.path.abspath(path)
if not os.path.exists(abs_path):
if os.path.exists(abs_path):
print(f"Validating {path}...")
else:
raise ValueError(f"Path does not exist: {path}")

if os.path.isdir(abs_path):
_validate_dir(abs_path, schema_name, cpus, parser, strict, should_exclude)
else:
Expand Down Expand Up @@ -155,7 +155,7 @@ def int_or_auto(num_cpu):
"--cpu-num",
default=4,
type=int_or_auto,
help="number of child processes to spawn for validation. Default is 4. 'auto' to use CPU count",
help="number of child processes to spawn for validation. Default is 4. 'auto' to use CPU count.",
)
parser.add_argument(
"-x",
Expand Down

0 comments on commit 2b7da4c

Please sign in to comment.