diff --git a/.travis.yml b/.travis.yml index 56ef488..1ceec04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ language: python sudo: required dist: xenial python: - - "2.7" - - "3.4" - "3.5" - "3.6" - "3.7" diff --git a/LICENSE b/LICENSE index ce4a5f4..89f8850 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Alexandre Ferland +Copyright (c) 2019 Alexandre Ferland Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dev_requirements.txt b/dev_requirements.txt index 53e0247..7a80518 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,7 +1,7 @@ -r requirements.txt -Flask==1.0.2 -kazoo==2.6.0 -pytest==4.0.0 -python-consul==1.1.0 -python-etcd==0.4.5 +Flask>=1.0.2 +kazoo>=2.6.0 +pytest>=4.0.0 +python-consul>=1.1.0 +python-etcd>=0.4.5 diff --git a/requirements.txt b/requirements.txt index 84d0684..742aff0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ -distconfig==0.1.0 -future==0.17.1 -pathlib==1.0.1 -pytoml==0.1.20 -PyYAML==3.13 -watchdog==0.9.0 +distconfig>=0.1.0 +pathlib>=1.0.1 +pytoml>=0.1.20 +PyYAML>=5.1 +watchdog>=0.9.0 diff --git a/setup.py b/setup.py index 8b52085..da73874 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='vyper-config', - version='0.3.3', + version='0.4.0', description='Python configuration with more fangs', url='http://github.com/admiralobvious/vyper', author='Alexandre Ferland', @@ -12,21 +12,18 @@ zip_safe=False, install_requires=[ 'distconfig>=0.1.0', - 'future>=0.17.1', 'pathlib>=1.0.1', 'pytoml>=0.1.20', - 'PyYAML>=3.13', + 'PyYAML>=5.1', 'watchdog>=0.9.0' ], - setup_requires=["pytest-runner>=4.2"], - tests_require=["pytest>=3.10.1"], + setup_requires=["pytest-runner>=5.1"], + tests_require=["pytest>=5.0.1"], platforms='any', classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/tests/test_vyper.py b/tests/test_vyper.py index 397926e..1d6b02a 100644 --- a/tests/test_vyper.py +++ b/tests/test_vyper.py @@ -102,7 +102,7 @@ def setUp(self): def _init_configs(self): self.v.set_config_type("yaml") - r = yaml.dump(text(yaml_example)) + r = yaml.safe_dump(text(yaml_example)) self.v._unmarshall_reader(r, self.v._config) self.v.set_config_type("json") @@ -115,7 +115,7 @@ def _init_configs(self): def _init_yaml(self): self.v.set_config_type("yaml") - r = yaml.dump(yaml_example) + r = yaml.safe_dump(yaml_example) self.v._unmarshall_reader(r, self.v._config) def _init_json(self, fixture=None): @@ -166,7 +166,7 @@ def test_default(self): def test_unmarshalling(self): self.v.set_config_type("yaml") - r = yaml.dump(yaml_example) + r = yaml.safe_dump(yaml_example) self.v._unmarshall_reader(r, self.v._config) self.assertTrue(self.v.in_config("name")) self.assertFalse(self.v.in_config("state")) @@ -175,7 +175,7 @@ def test_unmarshalling(self): def test_yaml_duplication_nested(self): self.v.set_config_type("yaml") - r = yaml.dump(yaml_duplicate_in_nested) + r = yaml.safe_dump(yaml_duplicate_in_nested) self.v._unmarshall_reader(r, self.v._config) self.assertEqual("yeap", self.v.get("sweet.home.alabama")) self.assertEqual("noway", self.v.get("sweet.job.alabama")) @@ -238,7 +238,7 @@ def test_args_with_bad_value(self): def test_args_override(self): # Yaml config self.v.set_config_type("yaml") - r = yaml.dump("yaml_param: from_yaml") + r = yaml.safe_dump("yaml_param: from_yaml") self.v._unmarshall_reader(r, self.v._config) # Overrides @@ -403,7 +403,7 @@ def test_unmarshall(self): def test_is_set(self): self.v.set_config_type("yaml") - self.v.read_config(yaml.dump(text(yaml_example))) + self.v.read_config(yaml.safe_dump(text(yaml_example))) self.assertTrue(self.v.is_set("clothing.jacket")) self.assertFalse(self.v.is_set("clothing.jackets")) self.assertFalse(self.v.is_set("helloworld")) @@ -483,7 +483,7 @@ def test_complex_bound_case_sensitivity(self): def test_sub(self): self.v.set_config_type("yaml") - self.v.read_config(yaml.dump(text(yaml_example))) + self.v.read_config(yaml.safe_dump(text(yaml_example))) subv = self.v.sub("clothing") self.assertEqual(self.v.get("clothing.pants.size"), @@ -530,10 +530,10 @@ def test_merge_config(self): y = "b: xyz" self.v.set_config_type("yaml") - self.v.read_config(yaml.dump(text(x))) + self.v.read_config(yaml.safe_dump(text(x))) self.assertEqual(self.v.get("a"), "abc") - self.v.merge_config(yaml.dump(text(y))) + self.v.merge_config(yaml.safe_dump(text(y))) self.assertEqual(self.v.get("a"), "abc") self.assertEqual(self.v.get("b"), "xyz") @@ -542,8 +542,8 @@ def test_merge_overwrite_key(self): y = "a: xyz" self.v.set_config_type("yaml") - self.v.read_config(yaml.dump(text(x))) + self.v.read_config(yaml.safe_dump(text(x))) self.assertEqual(self.v.get("a"), "abc") - self.v.merge_config(yaml.dump(text(y))) + self.v.merge_config(yaml.safe_dump(text(y))) self.assertEqual(self.v.get("a"), "xyz") diff --git a/vyper/remote.py b/vyper/remote.py index f70a64d..c0777d6 100644 --- a/vyper/remote.py +++ b/vyper/remote.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from distconfig import Proxy import pytoml as toml import yaml @@ -50,7 +48,7 @@ def _get_parser(self): if self.config_type == "json": return json.loads elif self.config_type in ["yaml", "yml"]: - return yaml.load + return yaml.safe_load elif self.config_type == "toml": return toml.loads @@ -72,4 +70,3 @@ def add_listener(self, cb=None): def _update_kvstore(self, e): self.v._kvstore = e - diff --git a/vyper/util.py b/vyper/util.py index 481da63..a67db18 100644 --- a/vyper/util.py +++ b/vyper/util.py @@ -51,9 +51,9 @@ def unmarshall_config_reader(file_, d, config_type): if config_type in ["yaml", "yml"]: try: - f = yaml.load(file_) + f = yaml.safe_load(file_) try: - d.update(yaml.load(f)) + d.update(yaml.safe_load(f)) except AttributeError: # to read files d.update(f) except Exception as e: diff --git a/vyper/vyper.py b/vyper/vyper.py index 585abe8..929c287 100644 --- a/vyper/vyper.py +++ b/vyper/vyper.py @@ -3,8 +3,6 @@ import os import pprint -from builtins import str as text - from . import constants, errors, remote, util, watch log = logging.getLogger("vyper") @@ -215,9 +213,6 @@ def get_int(self, key): def get_float(self, key): return float(self.get(key)) - def get_unicode(self, key): - return text(self.get(key)) - def get_bytes(self, key): return b"{0}".format(self.get(key))