From 5be8801040a91909ff415f716b17a9ae3a9d81d4 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Sun, 12 Jan 2020 12:37:52 -0500 Subject: [PATCH 1/5] bump dev version --- docs/changelog.md | 2 ++ eido/_version.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index c3310025..651d5a1b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. +## [0.0.3] - unreleased + ## [0.0.2] - 2020-01-12 ### Added diff --git a/eido/_version.py b/eido/_version.py index 3b93d0be..d89a3b20 100644 --- a/eido/_version.py +++ b/eido/_version.py @@ -1 +1 @@ -__version__ = "0.0.2" +__version__ = "0.0.3-dev" From 73f8e684ddd3104825864044373a5fa114f05471 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Tue, 14 Jan 2020 11:09:10 -0500 Subject: [PATCH 2/5] make validation case exclusion from error possible --- eido/eido.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/eido/eido.py b/eido/eido.py index b1006f6b..49411012 100644 --- a/eido/eido.py +++ b/eido/eido.py @@ -35,6 +35,11 @@ def build_argparser(): "-s", "--schema", required=True, help="PEP schema file in yaml format.") + parser.add_argument( + "-e", "--exclude-case", default=False, action="store_true", + help="Whether to exclude the validation case from an error. " + "Only the human readable message explaining the error will be raised. " + "Useful when validating large PEPs.") return parser @@ -68,13 +73,14 @@ def _load_yaml(filepath): return data -def validate_project(project, schema): +def validate_project(project, schema, exclude_case=False): """ Validate a project object against a schema :param peppy.Project project: a project object to validate :param str | dict schema: schema dict to validate against or a path to one - :return: + :param bool exclude_case: whether to exclude validated objects from the error. + Useful when used ith large projects """ if isinstance(schema, str) and os.path.isfile(schema): schema_dict = _load_yaml(schema) @@ -83,7 +89,12 @@ def validate_project(project, schema): else: raise TypeError("schema has to be either a dict or a path to an existing file") project_dict = project.to_dict() - jsonschema.validate(project_dict, _preprocess_schema(schema_dict)) + try: + jsonschema.validate(project_dict, _preprocess_schema(schema_dict)) + except jsonschema.exceptions.ValidationError as e: + if not exclude_case: + raise e + raise jsonschema.exceptions.ValidationError(e.message) def main(): @@ -98,5 +109,4 @@ def main(): _LOGGER.debug("Creating a Project object from: {}".format(args.pep)) p = Project(args.pep) _LOGGER.debug("Comparing the Project ('{}') against a schema: {}.".format(args.pep, args.schema)) - validate_project(p, args.schema) - _LOGGER.info("Validation successful") + validate_project(p, args.schema, args.exclude_case) From 9f54612dbd6d0ecd23e7a7635be85e6c15e336be Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Tue, 14 Jan 2020 11:12:16 -0500 Subject: [PATCH 3/5] update changelog --- docs/changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 651d5a1b..bb9e6eb3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. ## [0.0.3] - unreleased +### Added +- Option to exclude the validation case from error messages in both Python API and CLI app with `exclude_case` and `-e`/`--exclude-case`, respectively. ## [0.0.2] - 2020-01-12 From 934de77692128961b97c208221062ed2ee220b04 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Thu, 30 Jan 2020 13:36:26 -0500 Subject: [PATCH 4/5] include requirements in the source distr --- MANIFEST.in | 2 ++ docs/changelog.md | 1 + 2 files changed, 3 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..857bdcf3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include requirements/* +include README.md \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index bb9e6eb3..c32cfbaf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [0.0.3] - unreleased ### Added - Option to exclude the validation case from error messages in both Python API and CLI app with `exclude_case` and `-e`/`--exclude-case`, respectively. +- include requirements in the source distribution ## [0.0.2] - 2020-01-12 From fe3156feb533a0d5bec470c62c041071c091c706 Mon Sep 17 00:00:00 2001 From: Michal Stolarczyk Date: Thu, 30 Jan 2020 13:44:53 -0500 Subject: [PATCH 5/5] version and release date --- docs/changelog.md | 2 +- eido/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index c32cfbaf..63f7df30 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. -## [0.0.3] - unreleased +## [0.0.3] - 2020-01-30 ### Added - Option to exclude the validation case from error messages in both Python API and CLI app with `exclude_case` and `-e`/`--exclude-case`, respectively. - include requirements in the source distribution diff --git a/eido/_version.py b/eido/_version.py index d89a3b20..27fdca49 100644 --- a/eido/_version.py +++ b/eido/_version.py @@ -1 +1 @@ -__version__ = "0.0.3-dev" +__version__ = "0.0.3"