Skip to content

Commit

Permalink
getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLudwig committed Apr 8, 2018
0 parents commit aa6236f
Show file tree
Hide file tree
Showing 13 changed files with 406 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
@@ -0,0 +1,18 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.bat]
indent_style = tab
end_of_line = crlf

[LICENSE]
insert_final_newline = false
102 changes: 102 additions & 0 deletions .gitignore
@@ -0,0 +1,102 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
8 changes: 8 additions & 0 deletions HISTORY.rst
@@ -0,0 +1,8 @@
=======
History
=======

0.1.0 (2018-04-08)
------------------

* First release on PyPI.
16 changes: 16 additions & 0 deletions LICENSE
@@ -0,0 +1,16 @@
Apache Software License 2.0

Copyright (c) 2018, Florian Ludwig

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

11 changes: 11 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,11 @@
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst

recursive-include tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
recursive-include tests *.yml
8 changes: 8 additions & 0 deletions README.rst
@@ -0,0 +1,8 @@
yacm: yet another config module
===============================

.. image:: https://img.shields.io/pypi/v/yacm.svg
:target: https://pypi.python.org/pypi/yacm


* Free software: Apache Software License 2.0
11 changes: 11 additions & 0 deletions requirements_dev.txt
@@ -0,0 +1,11 @@
pip==9.0.1
bumpversion==0.5.3
wheel==0.30.0
watchdog==0.8.3
flake8==3.5.0
coverage==4.5.1
Sphinx==1.7.1
twine==1.10.0

pytest==3.4.2
pytest-runner==2.11.1
26 changes: 26 additions & 0 deletions setup.cfg
@@ -0,0 +1,26 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:yacm/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

[bdist_wheel]
universal = 1

[flake8]
exclude = docs

[aliases]
# Define setup.py command aliases here
test = pytest

[tool:pytest]
collect_ignore = ['setup.py']

48 changes: 48 additions & 0 deletions setup.py
@@ -0,0 +1,48 @@
#!/usr/bin/env python

from setuptools import setup, find_packages

with open('README.rst') as readme_file:
readme = readme_file.read()

with open('HISTORY.rst') as history_file:
history = history_file.read()

requirements = ['PyYAML>=3.10']

setup_requirements = []

test_requirements = ['pytest', ]

setup(
author="Florian Ludwig",
author_email='f.ludwig@greyrook.com',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
description="yet another config module",
entry_points={
'console_scripts': [
'yacm=yacm.cli:main',
],
},
install_requires=requirements,
license="Apache Software License 2.0",
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='yacm',
name='yacm',
packages=find_packages(include=['yacm']),
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/FlorianLudwig/yacm',
version='0.1.0',
zip_safe=False,
)
3 changes: 3 additions & 0 deletions tests/configs/no_rwdb.yml
@@ -0,0 +1,3 @@
plugins:
db: False
someother_db: True
3 changes: 3 additions & 0 deletions tests/configs/simple.yml
@@ -0,0 +1,3 @@
plugins:
db: True

65 changes: 65 additions & 0 deletions tests/test_yacm.py
@@ -0,0 +1,65 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import yacm

import pytest

import yacm

BASE = os.path.dirname(__file__)


def test_merge():
# check to merge two config files
foo = {'c': {'foo': 1}}
cfg = {}
yacm.merge(cfg, foo)
assert cfg == foo

yacm.merge(cfg, {})
assert cfg == foo

# configs must be dict of dicts
with pytest.raises(AttributeError):
yacm.merge({}, 1)

with pytest.raises(AttributeError):
yacm.merge({}, {'a': 1})


def test_simple():
cfg = yacm.read_file(BASE + '/configs/simple.yml')
assert isinstance(cfg, dict)
assert cfg['plugins']['db'] is True

cfg = yacm.read_file([
BASE + '/configs/simple.yml',
BASE + '/configs/no_rwdb.yml'
])
assert cfg['plugins']['db'] is False
assert cfg['plugins']['someother_db'] is True

cfg = yacm.read_file([
BASE + '/configs/no_rwdb.yml',
BASE + '/configs/simple.yml',
])
assert cfg['plugins']['db'] is True
assert cfg['plugins']['someother_db'] is True


def test_config_paths():
"""when inside a virtualenv we are looking for more configs"""
env = os.environ.get('VIRTUAL_ENV')
if env is not None:
del os.environ['VIRTUAL_ENV']
configs = yacm.get_config_paths('rw')
os.environ['VIRTUAL_ENV'] = '/tmp'
configs_ve = yacm.get_config_paths('rw')
if env is None:
del os.environ['VIRTUAL_ENV']
else:
os.environ['VIRTUAL_ENV'] = env

assert len(configs) < len(configs_ve)

0 comments on commit aa6236f

Please sign in to comment.