[med-svn] [Git][med-team/python-easydev][upstream] New upstream version 0.9.37
Andreas Tille
gitlab at salsa.debian.org
Wed Jan 9 16:16:46 GMT 2019
Andreas Tille pushed to branch upstream at Debian Med / python-easydev
Commits:
13c5498f by Andreas Tille at 2019-01-09T15:47:47Z
New upstream version 0.9.37
- - - - -
10 changed files:
- PKG-INFO
- README.rst
- easydev/__init__.py
- easydev/config_tools.py
- easydev/logging_tools.py
- easydev/misc.py
- easydev/timer.py
- setup.cfg
- setup.py
- test/test_url.py
Changes:
=====================================
PKG-INFO
=====================================
@@ -1,12 +1,13 @@
Metadata-Version: 1.1
Name: easydev
-Version: 0.9.35
+Version: 0.9.37
Summary: Common utilities to ease the development of Python packages
Home-page: ['http://packages.python.org/easydev/']
Author: Thomas Cokelaer
Author-email: cokelaer at ebi.ac.uk
License: new BSD
Download-URL: ['http://pypi.python.org/pypi/easydev']
+Description-Content-Type: UNKNOWN
Description: easydev
##########
@@ -28,7 +29,7 @@ Description: easydev
:contributions: Please join https://github.com/cokelaer/easydev
:source: Please use https://github.com/cokelaer/easydev
:issues: Please use https://github.com/cokelaer/easydev/issues
- :Python version supported: 2.6, 2.7, 3.3, 3.4, 3.5, 3.6
+ :Python version supported: 2.7, 3.3, 3.4, 3.5, 3.6
The `easydev <http://pypi.python.org/pypi/easydev/>`_ package
=====================================
README.rst
=====================================
@@ -19,7 +19,7 @@ easydev
:contributions: Please join https://github.com/cokelaer/easydev
:source: Please use https://github.com/cokelaer/easydev
:issues: Please use https://github.com/cokelaer/easydev/issues
-:Python version supported: 2.6, 2.7, 3.3, 3.4, 3.5, 3.6
+:Python version supported: 2.7, 3.3, 3.4, 3.5, 3.6
The `easydev <http://pypi.python.org/pypi/easydev/>`_ package
=====================================
easydev/__init__.py
=====================================
@@ -18,13 +18,17 @@
from __future__ import print_function
#from __future__ import absolute_import
-__version__ = "0.9.34"
-import pkg_resources
+__version__ = "0.9.36"
try:
- version = pkg_resources.require("easydev")[0].version
-except:
+ import pkg_resources
+except ImportError as err:
+ print(err)
+ print("version set to {} manually.".format(__version__))
version = __version__
+else:
+ version = pkg_resources.require("easydev")[0].version
+ __version__ = version
from . import browser
from .browser import browse as onweb
=====================================
easydev/config_tools.py
=====================================
@@ -98,9 +98,11 @@ class ConfigExample(object):
which can be read with ConfigParser as follows:
- .. code-block:: python
- >>> from ConfigParser import ConfigParser
+ .. doctest::
+
+ >>> # Python 3 code
+ >>> from configparser import ConfigParser
>>> config = ConfigParser()
>>> config.read("file.ini")
[]
@@ -133,13 +135,13 @@ class DynamicConfigParser(ConfigParser, object):
You can now also directly access to an option as follows::
- >>> c.General.tag
+ c.General.tag
Then, you can add or remove sections (:meth:`remove_section`, :meth:`add_section`),
or option from a section :meth:`remove_option`. You can save the instance into a file
or print it::
- >>> print(c)
+ print(c)
.. warning:: if you set options manually (e.G. self.GA.test =1 if GA is a
section and test one of its options), then the save/write does not work
@@ -231,8 +233,9 @@ class DynamicConfigParser(ConfigParser, object):
Let us build up a standard config file:
.. code-block:: python
- >>> import ConfigParser
- >>> c = ConfigParser.ConfigParser()
+ >>> # Python 3 code
+ >>> from configparser import ConfigParser
+ >>> c = ConfigParser()
>>> c.add_section('general')
>>> c.set('general', 'step', str(1))
>>> c.set('general', 'verbose', 'True')
=====================================
easydev/logging_tools.py
=====================================
@@ -14,77 +14,98 @@
#
##############################################################################
import logging
+import colorlog
__all__ = ["Logging"]
-class Logging(object):
- """logging utility.
+colors = {
+ 'DEBUG': 'cyan',
+ 'INFO': 'green',
+ 'WARNING': 'yellow',
+ 'ERROR': 'red',
+ 'CRITICAL': 'bold_red'}
- When using the logging utility, it works like a singleton.
- So, once logging level is set, you cannot set it again easily.
- Here is a class that allows to do that.
- .. warning:: this is a bit of a hack. Maybe this is not a proper solution but
- it seems to do the job.
+
+class Logging(object):
+ """logging utility.
::
- >>> l = Logging("INFO")
+ >>> l = Logging("root", "INFO")
>>> l.info("test")
INFO:root:test
>>> l.level = "WARNING"
>>> l.info("test")
-
"""
- # I think that we can not inherit from logging.
- def __init__(self, level):
- """.. rubric:: constructor
-
- :param str level: valid levels are ["INFO", "DEBUG", "WARNING",
- "CRITICAL", "ERROR"]. If set to True, level is internally set to
- INFO. If set to False, level is seet internally to ERROR.
- """
- self._debugLevel = None
- self.debugLevel = level
- self.logging = logging
- self.info = logging.info
- self.warning = logging.warning
- self.critical = logging.critical
- self.error = logging.error
- self.debug = logging.debug
+ def __init__(self, name="root", level="WARNING"):
+ self.name = name
+ formatter = colorlog.ColoredFormatter(
+ "%(log_color)s%(levelname)-8s[%(name)s]: %(reset)s %(blue)s%(message)s",
+ datefmt=None,
+ reset=True,
+ log_colors=colors,
+ secondary_log_colors={},
+ style='%'
+ )
+ handler = colorlog.StreamHandler()
+ handler.setFormatter(formatter)
+ logger = colorlog.getLogger(self.name)
+ if len(logger.handlers) == 0:
+ logger.addHandler(handler)
+ self._set_level(level)
def _set_level(self, level):
- valid_level = [True, False, "INFO", "DEBUG", "WARNING", "CRITICAL", "ERROR"]
- if level is True:
- level = "INFO"
- if level is False:
- level = "ERROR"
- if level in valid_level:
- self._debugLevel = level
- else:
- raise ValueError("The level of debugging must be in %s " %valid_level)
- # I'm not sure this is the best solution, but basicConfig can be called
- # only once and populatse root.handlers list with one instance of
- # logging.StreamHandler. So, I reset it before calling basicConfig
- # that effectively changes the logging behaviour
- logging.root.handlers = []
- logging.basicConfig(level=self._debugLevel)
+ if isinstance(level, bool):
+ if level is True:
+ level = "INFO"
+ if level is False:
+ level = "ERROR"
+ assert level in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
+ logging_level = getattr(colorlog.logging.logging, level)
+ colorlog.getLogger(self.name).setLevel(level)
+
def _get_level(self):
- return self._debugLevel
- debugLevel = property(_get_level, _set_level,
- doc="Read/Write access to the debug level. Must be one of INFO, " + \
- "DEBUG, WARNING, CRITICAL, ERROR")
- level = property(_get_level, _set_level,
- doc="alias to :attr:`~easydev.logging_tools.Logging.debugLevel` (Read-only access)")
-
- # Used copy/deepcopy module
- def __copy__(self):
- print("WARNING: easydev.logging_tools.__copy__ deprecated. use copy() instead")
- s = Logging(self.level)
- return s
-
- def __deepcopy__(self, memo):
- s = Logging(self.level)
- return s
+ level = colorlog.getLogger(self.name).level
+ if level == 10:
+ return "DEBUG"
+ elif level == 20:
+ return "INFO"
+ elif level == 30:
+ return "WARNING"
+ elif level == 40:
+ return "ERROR"
+ elif level == 50:
+ return "CRITICAL"
+ else:
+ return level
+ level = property(_get_level, _set_level)
+
+ def debug(self, msg):
+ colorlog.getLogger(self.name).debug(msg)
+ def info(self, msg):
+ colorlog.getLogger(self.name).info(msg)
+ def warning(self, msg):
+ colorlog.getLogger(self.name).warning(msg)
+ def critical(self, msg):
+ colorlog.getLogger(self.name).critical(msg)
+ def error(self, msg):
+ colorlog.getLogger(self.name).error(msg)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
=====================================
easydev/misc.py
=====================================
@@ -15,7 +15,6 @@
# Documentation: http://easydev-python.readthedocs.io
#
##############################################################################
-
import os
@@ -23,6 +22,7 @@ __all__ = ['get_home', 'cmd_exists']
def get_home():
+ """Return path of the HOME"""
# This function should be robust
# First, let us try with expanduser
try:
@@ -42,6 +42,7 @@ def get_home():
def cmd_exists(cmd):
+ """Return true if the command do exists in the environement"""
try:
import subprocess
# for unix/max only
=====================================
easydev/timer.py
=====================================
@@ -19,7 +19,7 @@
import time
-class Timer():
+class Timer(object):
"""Timer working with *with* statement
::
=====================================
setup.cfg
=====================================
@@ -3,7 +3,6 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
[global]
@@ -24,5 +23,5 @@ attr = !skip,!notravis
upload_dir = doc/build/html/
[tool:pytest]
-addopts = --durations=10 --verbose
+addopts = --cov=easydev --cov-report=term-missing --durations=10 --verbose
=====================================
setup.py
=====================================
@@ -7,7 +7,7 @@ import glob
_MAJOR = 0
_MINOR = 9
-_MICRO = 35
+_MICRO = 37
version = '%d.%d.%d' % (_MAJOR, _MINOR, _MICRO)
release = '%d.%d' % (_MAJOR, _MINOR)
@@ -66,7 +66,7 @@ setup(
"themes/cno/static/*",
"copybutton.js"]},
- install_requires = ['colorama', 'pexpect'],
+ install_requires = ['colorama', 'pexpect', "colorlog"],
extras_require = {
'profiler': ["line_profiler_test"]
},
=====================================
test/test_url.py
=====================================
@@ -5,7 +5,7 @@ from nose.plugins.attrib import attr
def test_isurl():
assert isurl_reachable("www.google.com") == True
assert isurl_reachable("http://www.google.com") == True
- assert isurl_reachable("https://fr.yahoo.com") == False # moved
+ #assert isurl_reachable("https://fr.yahoo.com") == False # moved
assert isurl_reachable("wrong.co.ujj") == False
assert isurl_reachable("http://wrong.co.ujj") == False
assert isurl_reachable("http://wrong.co") == False
View it on GitLab: https://salsa.debian.org/med-team/python-easydev/commit/13c5498ff47821f1dc12522fa0127e9e60310d60
--
View it on GitLab: https://salsa.debian.org/med-team/python-easydev/commit/13c5498ff47821f1dc12522fa0127e9e60310d60
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190109/ab95f0f8/attachment-0001.html>
More information about the debian-med-commit
mailing list