diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b7a704b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 0000000..749a320 --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,14 @@ +name: Test + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: tox + run: | + python -m pip install --upgrade pip + python -m pip install tox + tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7659bd5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: python - -python: - - "2.7" - - "3.4" - -install: - - pip install -r requirements.txt - - pip install -r test-requirements.txt - -script: nosetests - -deploy: - provider: pypi - user: internaphosting - password: - secure: nztUy6LTQreUCivL/g+8PFaFkSKPvAEJEe5i/qvfvJky4j6H5gCdnUl3SULRD2xaNztE/kWiT1hs4PqThR8isoay0gB7/8YhVeoMjMHjvi92LXcNu5zsvNpZMq68XKQU8c4nFCwkBtPdu7IumBuow0OmohnLFb0/zTC13U20dZ+F4PMD842e4SgXtXlwjF5OROVi8Djz7CeLxti3O6FytPCaljN3I/a+qtlxbkI+SUXTGTyZNwatoYdt/UI7O+JfvjT79MDTzQhpfB+O1+z4KhYsTcaXrwLGhggA5VKu10ykBBiRqU9neJ1LJvqdxCpjLjKRcohurrRgmRhtBK4v9+M9bKMsqGOmG15YsJrjhXbahvzjx13cpPds6a1Bf1Hs2Ny1l3SjxRKlRyEQKyhufg4td6MzrzfZyNXTbEk601StSbCWV8Mdj3nVdfS3of2yNYIHeSRaioPuJAZrtb/qnN73n6k44UZbw/p6Tk6Tf1wtCqQI+sHAeG2NVaHp6HDxd5Qdg1Zp2XLxE8GnbkCyuFzjxxIMCrUnv1UBo4B+3xj6FMfINOJs6cCHISvvc0icJEmqIhVZwOicd9Dywj71IvdFDZ1xGR5ehR8M7fCqP+UXBVf+SnYTZPcz9cP+fTCBuLpixiFpsX0qPL75dRHb8X0DoOUuVgHky1VKquNay14= - on: - tags: true - python: 3.4 - repo: internap/python-config-probe diff --git a/README.md b/README.md index 2408c48..222a011 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Build Status](https://travis-ci.org/internap/python-config-probe.svg?branch=master)](https://travis-ci.org/internap/python-config-probe) -[![PyPI version](https://badge.fury.io/py/config-probe.svg)](http://badge.fury.io/py/config-probe) +![Build Status](https://github.com/stephanerobert/config-mixin/actions/workflows/tox.yml/badge.svg?branch=master) +[![PyPI version](https://badge.fury.io/py/config-mixin.svg)](http://badge.fury.io/py/config-mixin) Mission @@ -25,7 +25,7 @@ Use it: - **path** - Initial path to probe. Patterns will be tested against the file structure underneath the path + Initial path to probe. Patterns will be tested against the file structure underneath the path, and it will be ignored in determining the namespacing. - **patterns** @@ -58,7 +58,7 @@ Use it: ## Mocking the probing -Your unit test can have your code use fake_probe instead to which to give a dict and it will appear as if it +Your unit test can have your code use fake_probe instead to which to give a dict, and it will appear as if it was just probed. Example: config = fake_probe({ diff --git a/config-mixin.iml b/config-mixin.iml new file mode 100644 index 0000000..ad3c0a3 --- /dev/null +++ b/config-mixin.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/config_probe/__init__.py b/config_mixin/__init__.py similarity index 89% rename from config_probe/__init__.py rename to config_mixin/__init__.py index a05f901..382c059 100644 --- a/config_probe/__init__.py +++ b/config_mixin/__init__.py @@ -4,9 +4,9 @@ import os import yaml -from munch import Munch, iteritems +from munch import Munch -from config_probe.exceptions import ConfigNotFound +from config_mixin.exceptions import ConfigNotFound NAMESPACE_PLACEHOLDER = "(*)" @@ -46,7 +46,7 @@ def _deduce_namespaces(path_matchers, path_parts): namespaces = [] path_parts, current_part = os.path.split(path_parts) path_matchers, matcher = os.path.split(path_matchers) - while current_part is not "": + while current_part != "": if matcher == NAMESPACE_PLACEHOLDER: namespaces.append(current_part) @@ -67,7 +67,7 @@ def _add_to_configuration(config, namespaces, new_values): def _update(config, values): for k, v in values.items(): - if k in config and isinstance(v, collections.Mapping): + if k in config and isinstance(v, collections.abc.Mapping): _update(config[k], v) else: config[k] = v @@ -83,7 +83,7 @@ def __getattr__(self, k): def _munchify(x): if isinstance(x, dict): - return _Munch((k, _munchify(v)) for k,v in iteritems(x)) + return _Munch((k, _munchify(v)) for k,v in x.items()) elif isinstance(x, (list, tuple)): return type(x)(_munchify(v) for v in x) else: diff --git a/config_probe/exceptions.py b/config_mixin/exceptions.py similarity index 100% rename from config_probe/exceptions.py rename to config_mixin/exceptions.py diff --git a/setup.cfg b/setup.cfg index d9184fb..2c18429 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,8 @@ [metadata] -name = config-probe -url = https://github.com/internap/python-config-probe -author = Internap Hosting -author-email = opensource@internap.com +name = config-mixin +url = https://github.com/stephanerobert/config-mixin +author = Stephane Robert +author-email = stephane.robert@gmail.com summary = Auto-discovery of configurations for easy inline use description-file = README.md @@ -10,19 +10,12 @@ classifier = Development Status :: 4 - Beta Intended Audience :: Developers Intended Audience :: Information Technology - Intended Audience :: System Administrators - Intended Audience :: Telecommunications Industry License :: OSI Approved :: Apache Software License - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.12 [files] packages = - config_probe + config_mixin [bdist_wheel] universal = 1 - -[nosetests] -no-path-adjustment = 1 -logging-level = DEBUG diff --git a/setup.py b/setup.py index aa2d8a0..dff8436 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,30 @@ #!/usr/bin/env python - from setuptools import setup + +def readme(): + with open('README.md') as read_me: + return read_me.read() + + setup( - setup_requires=['pbr'], - pbr=True, + name='config-mixin', + description='Python Configuration File Helper', + long_description=readme(), + long_description_content_type='text/markdown', + classifiers=[ + 'Framework :: tox', + 'Framework :: Pytest', + 'Development Status :: 4 - Beta', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.12', + 'Topic :: Software Development', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology' + ], + author='Stephane Robert', + author_email='stephane.robert@gmail.com', + url='https://github.com/stephanerobert/config-mixin', + version='1.0.0' ) diff --git a/test-requirements.txt b/test-requirements.txt index 3c289d7..106473a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,3 @@ -nose +pytest +pytest-cov pyhamcrest diff --git a/tests/test_config_probe.py b/tests/test_config_mixin.py similarity index 98% rename from tests/test_config_probe.py rename to tests/test_config_mixin.py index 229967c..165c056 100644 --- a/tests/test_config_probe.py +++ b/tests/test_config_mixin.py @@ -1,8 +1,8 @@ import unittest import os -from config_probe import probe, fake_probe -from config_probe.exceptions import ConfigNotFound +from config_mixin import probe, fake_probe +from config_mixin.exceptions import ConfigNotFound from hamcrest import is_, assert_that, has_key diff --git a/tox.ini b/tox.ini index bbdb67d..6c81dd0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,8 @@ [tox] -envlist = py27,py34 +envlist = py311 [testenv] -deps = -r{toxinidir}/test-requirements.txt -commands = nosetests +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = pytest --cov --cov-report term-missing