From 7a67dfa24b53c383c5710bc2437ecd9aec1f9ec7 Mon Sep 17 00:00:00 2001 From: Afxentios Hadjiminas Date: Sat, 27 Oct 2018 22:20:52 +0300 Subject: [PATCH] Separates external test modules dependencies Tidy up --- .travis.yml | 3 +++ CHANGELOG.md | 18 ------------------ CHANGELOG.rst | 29 +++++++++++++++++++++++++++++ MANIFEST.in | 2 +- README.rst | 2 +- config_logger/__init__.py | 1 - config_logger/logger.py | 16 +++++++++++----- setup.cfg | 5 +++++ setup.py | 22 ++++++++++++++-------- tests/filters_test.py | 17 ++++++++++++++++- tests/logger_test.py | 18 +++++++++++++++++- 11 files changed, 97 insertions(+), 36 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 CHANGELOG.rst create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index 13f14ef..a408b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: python sudo: false python: - "2.7" + - "3.0" + - "3.6" + - "3.7" branches: only: diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 72a677f..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ -# History of changes - -## Version 1.1.0 (22/10/18) - -* Support for Python 3, 3.6 and 3.7 - -## Version 1.0.2 (05/06/17) - -* Includes support for extra custom attributes - -## Version 1.0.1 (08/05/17) - -* Provides predefined logging level-filters. -* Currently available filters for writing logs only on the same level file and on same or lower level files. - -## Version 1.0.0 (31/01/17) - -* First working release \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..80f6da0 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,29 @@ +History of changes +==================== + +Version 1.1.1 (27/10/18) +------------------------ + +- Separates external test modules dependencies +- Tidy up + +Version 1.1.0 (22/10/18) +------------------------ + +- Support for Python 3, 3.6 and 3.7 + +Version 1.0.2 (05/06/17) +------------------------ + +- Includes support for extra custom attributes + +Version 1.0.1 (08/05/17) +------------------------ + +- Provides predefined logging level-filters. +- Currently available filters for writing logs only on the same level file and on same or lower level files. + +Version 1.0.0 (31/01/17) +------------------------ + +- First working release \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 32a76bc..217104f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include README.rst include LICENSE.txt -include CHANGELOG.md \ No newline at end of file +include CHANGELOG.rst \ No newline at end of file diff --git a/README.rst b/README.rst index 801b4f5..810cd3a 100644 --- a/README.rst +++ b/README.rst @@ -119,7 +119,7 @@ License This project is licensed under the MIT license. -.. _Changelog: https://github.com/afxentios/config-logger/blob/master/CHANGELOG.md +.. _Changelog: https://github.com/afxentios/config-logger/blob/master/CHANGELOG.rst .. _Issue tracker: https://github.com/afxentios/config-logger/issues .. _latest release: https://github.com/afxentios/config-logger/releases .. _Configuration dictionary schema: https://docs.python.org/3/library/logging.config.html#logging-config-dictschema diff --git a/config_logger/__init__.py b/config_logger/__init__.py index 9df12b1..aaa6c7e 100644 --- a/config_logger/__init__.py +++ b/config_logger/__init__.py @@ -2,5 +2,4 @@ from .logger import Logger __all__ = ['Logger'] -__version__ = '1.1.0' __author__ = 'Afxentios Hadjiminas' diff --git a/config_logger/logger.py b/config_logger/logger.py index b88d672..30169f5 100644 --- a/config_logger/logger.py +++ b/config_logger/logger.py @@ -6,11 +6,17 @@ try: from config_manager import ConfigManager, FileFormatError except ImportError: - sys.exit(""" - The config_manager module is needed to read the logging configurations, - install it from https://pypi.org/project/config-manager/ - or run pip install config-manager. - """) + if sys.version_info < (3, 0, 0): + print("[-] The config_manager module is needed to read the logging configurations" + "\ninstall it from https://pypi.org/project/config-manager/" + "\nor run `pip install config-manager`.") + raise + else: + sys.exit(""" + The config_manager module is needed to read the logging configurations, + install it from https://pypi.org/project/config-manager/ + or run `pip install config-manager`. + """) class Logger(object): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c6d1672 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[metadata] +description-file = + README.rst + CHANGELOG.rst + diff --git a/setup.py b/setup.py index 2f6da43..e5d49ba 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,29 @@ -from setuptools import setup, find_packages - -import config_logger +from setuptools import find_packages +from setuptools import setup def readme(): - with open("README.rst") as f: + with open('README.rst') as f: return f.read() setup(name='config-logger', - version=config_logger.__version__, + version='1.1.1', description='A simple configurable logger for python projects', long_description=readme(), url='https://github.com/afxentios/config-logger', license='MIT', - author=config_logger.__author__, + author='Afxentios Hadjiminas', author_email='afxentios@hadjimina.com', - keywords=["logging", "configurable", "configuration"], + keywords=['logging', 'configurable', 'configuration'], packages=find_packages(), - install_requires=['PyYAML', 'config-manager', 'testfixtures'], + install_requires=['pyyaml', + 'config-manager'], + extras_require={ + 'test': ['unittest2', + 'mock', + 'testfixtures'] + }, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -29,5 +34,6 @@ def readme(): 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Python Modules'] ) diff --git a/tests/filters_test.py b/tests/filters_test.py index e5dcfbc..9319751 100644 --- a/tests/filters_test.py +++ b/tests/filters_test.py @@ -1,9 +1,24 @@ +import sys + try: import unittest2 as unittest except ImportError: import unittest -from mock import Mock +try: + from mock import Mock +except ImportError: + if sys.version_info < (3, 0, 0): + print("[-] The mock module is needed to create mock objects," + "\ninstall it from https://pypi.org/project/mock/" + "\nor run `pip install mock`.") + raise + else: + sys.exit(""" + The mock module is needed to create mock objects, + install it from https://pypi.org/project/mock/ + or run `pip install mock`. + """) from config_logger import SameLevelFilter, LessEqualLevelFilter diff --git a/tests/logger_test.py b/tests/logger_test.py index ec693a8..814510d 100644 --- a/tests/logger_test.py +++ b/tests/logger_test.py @@ -1,3 +1,5 @@ +import sys + try: import unittest2 as unittest except ImportError: @@ -6,7 +8,21 @@ import logging from config_manager import ConfigManager -from mock import patch + +try: + from mock import patch +except ImportError: + if sys.version_info < (3, 0, 0): + print("[-] The mock module is needed to create mock objects," + "\ninstall it from https://pypi.org/project/mock/" + "\nor run `pip install mock`.") + raise + else: + sys.exit(""" + The mock module is needed to create mock objects, + install it from https://pypi.org/project/mock/ + or run `pip install mock`. + """) from testfixtures import log_capture from config_logger import Logger