From 193377a820bd9afb87c30999feee6ed9aa2a2a29 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 13 Apr 2022 10:02:58 -0600 Subject: [PATCH] fix: use pkg_resources to get default config --- MANIFEST.in | 2 +- stac_check/lint.py | 11 ++++++++--- .../stac-check.config.yml | 0 3 files changed, 9 insertions(+), 4 deletions(-) rename stac-check.config.yml => stac_check/stac-check.config.yml (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 2756203..d75e319 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include stac-check.config.yml \ No newline at end of file +include stac_check/stac-check.config.yml \ No newline at end of file diff --git a/stac_check/lint.py b/stac_check/lint.py index 3282cfd..1d2fd4f 100644 --- a/stac_check/lint.py +++ b/stac_check/lint.py @@ -1,3 +1,4 @@ +import pkg_resources from stac_validator.validate import StacValidate from stac_validator.utilities import is_valid_url import json @@ -42,9 +43,13 @@ def __post_init__(self): @staticmethod def parse_config(config_file): - default_config_file = os.getenv("STAC_CHECK_CONFIG", "stac-check.config.yml") - with open(default_config_file) as f: - default_config = yaml.load(f, Loader=yaml.FullLoader) + default_config_file = os.getenv("STAC_CHECK_CONFIG") + if default_config_file: + with open(default_config_file) as f: + default_config = yaml.load(f, Loader=yaml.FullLoader) + else: + with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f: + default_config = yaml.load(f, Loader=yaml.FullLoader) if config_file: with open(config_file) as f: config = yaml.load(f, Loader=yaml.FullLoader) diff --git a/stac-check.config.yml b/stac_check/stac-check.config.yml similarity index 100% rename from stac-check.config.yml rename to stac_check/stac-check.config.yml