Skip to content

Commit

Permalink
fix: use pkg_resources to get default config
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Apr 13, 2022
1 parent 34c1fe5 commit 193377a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include stac-check.config.yml
include stac_check/stac-check.config.yml
11 changes: 8 additions & 3 deletions stac_check/lint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pkg_resources
from stac_validator.validate import StacValidate
from stac_validator.utilities import is_valid_url
import json
Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.

0 comments on commit 193377a

Please sign in to comment.