Skip to content

Commit

Permalink
Merge pull request #31 from KyleJamesWalker/limit-pyyaml
Browse files Browse the repository at this point in the history
Limit PyYaml & Flake8 Fixes
  • Loading branch information
KyleJamesWalker authored Mar 13, 2019
2 parents f438db7 + eb1b7d4 commit 5019d8d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 42 deletions.
9 changes: 5 additions & 4 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
3.6.3
3.4.3
3.5.4
2.7.14
ys-dev
3.7.2
3.6.6
3.5.6
2.7.9
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ clean:
@find . -name '*.pyc' -delete
@find . -name '__pycache__' -delete

pyenv_envs:
pip install -U detox tox tox-pyenv
CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 2.7.14
CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.4.3
CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.5.4
CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.6.3
pyenv local 2.7.14 3.4.3 3.5.4 3.6.3
pip install -U detox tox tox-pyenv pip setuptools

test3:
-tox -e py36 $(test_extra_params)
-tox -e py37 $(test_extra_params)

test:
detox
tox -p auto

build:
PYENV_VERSION=yset-36 python setup.py build
PYENV_VERSION=ys-dev python setup.py build
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

requirements = {
"package": [
"PyYAML",
"PyYAML<4",
],
"test": [
"nose",
Expand All @@ -25,7 +25,7 @@

setup(
name='yamlsettings',
version='1.0.2',
version='1.0.3',
description='Yaml Settings Configuration Module',
long_description=readme,
author='Kyle James Walker',
Expand Down
6 changes: 3 additions & 3 deletions tests/test_yamldict.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ def test_load_all(self):
for test_input in ['fancy.yml', ['fancy.yml']]:
section_count = 0
for c_yml in load_all(test_input):
if section_count is 0:
if section_count == 0:
self.assertEqual(c_yml.test.id1.name, 'hi')
self.assertEqual(c_yml.test.test[2].sub_test.a, 10)
self.assertEqual(c_yml.test.test[2].sub_test.b.name, 'hi')
elif section_count is 1:
elif section_count == 1:
self.assertEqual(c_yml.test_2.test2.message, 'same here')
elif section_count is 2:
elif section_count == 2:
self.assertEqual(c_yml.test_3.test.name, 'Hello')
section_count += 1
self.assertEqual(section_count, 3)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ max-line-length = 80
max-complexity = 20

[tox]
envlist = py27, py34, py35, py36
envlist = py27, py35, py36, py37

[testenv]
deps =
Expand Down
40 changes: 20 additions & 20 deletions yamlsettings/yamldict.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ def update(self, yaml_dict):
''' Update the content (i.e. keys and values) with yaml_dict.
'''
def _update_node(base_node, update_node):
if isinstance(update_node, YAMLDict) or \
isinstance(update_node, dict):
if not (isinstance(base_node, YAMLDict)):
# NOTE: A regular dictionary is replaced by a new
# YAMLDict object.
new_node = YAMLDict()
else:
new_node = base_node
for k, v in update_node.items():
new_node[k] = _update_node(new_node.get(k), v)
elif isinstance(update_node, list) or \
isinstance(update_node, tuple):
# NOTE: A list/tuple is replaced by a new list/tuple.
new_node = []
for v in update_node:
new_node.append(_update_node(None, v))
if isinstance(update_node, tuple):
new_node = tuple(new_node)
if isinstance(update_node, YAMLDict) or \
isinstance(update_node, dict):
if not (isinstance(base_node, YAMLDict)):
# NOTE: A regular dictionary is replaced by a new
# YAMLDict object.
new_node = YAMLDict()
else:
new_node = update_node
return new_node
new_node = base_node
for k, v in update_node.items():
new_node[k] = _update_node(new_node.get(k), v)
elif isinstance(update_node, list) or \
isinstance(update_node, tuple):
# NOTE: A list/tuple is replaced by a new list/tuple.
new_node = []
for v in update_node:
new_node.append(_update_node(None, v))
if isinstance(update_node, tuple):
new_node = tuple(new_node)
else:
new_node = update_node
return new_node
# Convert non-YAMLDict objects to a YAMLDict
if not (isinstance(yaml_dict, YAMLDict) or
isinstance(yaml_dict, dict)):
Expand Down

0 comments on commit 5019d8d

Please sign in to comment.