From 2b7da4c6f175250b2fdc81650ece762669076399 Mon Sep 17 00:00:00 2001 From: Cordell Blakkan Date: Tue, 31 Dec 2024 12:02:39 -0500 Subject: [PATCH] Update readme --- README.md | 11 ++++++++--- setup.py | 2 +- yamale/command_line.py | 14 +++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2c8332d..21d6965 100644 --- a/README.md +++ b/README.md @@ -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. | |:------------| @@ -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 ------------ @@ -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. @@ -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 diff --git a/setup.py b/setup.py index 06f4a15..3c1745d 100755 --- a/setup.py +++ b/setup.py @@ -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"], diff --git a/yamale/command_line.py b/yamale/command_line.py index 127ceb1..bb20dc1 100644 --- a/yamale/command_line.py +++ b/yamale/command_line.py @@ -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)) @@ -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: @@ -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()]) @@ -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: @@ -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",