Release 1.2.1

This commit is contained in:
Wojciech Kozlowski 2017-03-14 22:12:24 +00:00
parent c29553985c
commit 4c8bfc2763
7 changed files with 17 additions and 44 deletions

View File

@ -1,6 +1,11 @@
Changelog
=========
1.2.1
-----
- Dummy implementation used when PyLg is disabled has been simplified.
1.2.0
-----

View File

@ -147,7 +147,7 @@ template.
- ``MESSAGE_WIDTH`` (default = ``0``) - the column width for the
message. A width of zero means unlimited.
- ``MESSAGE_WRAP`` (default = ``True``) - if ``True``, PyLG will wrap
- ``MESSAGE_WRAP`` (default = ``True``) - if ``True``, PyLg will wrap
the message to fit within the column width. Otherwise, the message
will be truncated.

View File

@ -21,4 +21,4 @@ from .loadSettings import PYLG_ENABLE
if PYLG_ENABLE:
from .pylg import TraceFunction, trace
else:
from .dummy import TraceFunction, trace
from .dummy import TraceFunctionDummy as TraceFunction, trace

View File

@ -17,57 +17,25 @@
# -----------------------------------------------------------------------------
from functools import partial
from .pylg import TraceFunction
class TraceFunction(object):
class TraceFunctionDummy(TraceFunction):
""" Dummy implementation of TraceFunction.
"""
def __get__(self, obj, objtype):
""" Support for instance functions.
"""
return partial(self.__call__, obj)
def __init__(self, *args, **kwargs):
""" Constructor for dummy TraceFunction. Note that the behaviour is
different depending on whether TraceFunction is passed any
parameters. For details see the non-dummy implementation.
""" Constructor for dummy TraceFunction.
"""
# ---------------------------------------------------------------------
# Make sure this decorator is never called with no arguments.
# Rather than having an entirely empty dummy class, we call
# the superclass constructor to have input verification even
# when PyLg is disabled.
# ---------------------------------------------------------------------
assert args or kwargs
if args:
# -----------------------------------------------------------------
# The function init_function will verify the input.
# -----------------------------------------------------------------
self.init_function(*args, **kwargs)
if kwargs:
trace_args_str = 'trace_args'
trace_rv_str = 'trace_rv'
# -----------------------------------------------------------------
# If kwargs is non-empty, it should only contain trace_rv,
# trace_args, or both and args should be empty. Assert all
# this.
# -----------------------------------------------------------------
assert not args
assert (len(kwargs) > 0) and (len(kwargs) <= 2)
if len(kwargs) == 1:
assert (trace_rv_str in kwargs) or (trace_args_str in kwargs)
elif len(kwargs) == 2:
assert (trace_rv_str in kwargs) and (trace_args_str in kwargs)
self.function = None
super(TraceFunctionDummy, self).__init__(*args, **kwargs)
def __call__(self, *args, **kwargs):

View File

@ -332,7 +332,7 @@ class TraceFunction(object):
value = kwargs[name]
else:
value = self.function.defaults[name]
msg += self.get_value_string(value) + ", "
msg += self.get_value_string(value) + ", "
msg = msg[:-2]

View File

@ -109,7 +109,7 @@ TRACE_MESSAGE = True
MESSAGE_WIDTH = 0
# -----------------------------------------------------------------------------
# If True, PyLG will wrap the message to fit within the column
# If True, PyLg will wrap the message to fit within the column
# width. Otherwise, the message will be truncated.
# -----------------------------------------------------------------------------
MESSAGE_WRAP = True

View File

@ -9,7 +9,7 @@ with open(path.join(pwd, 'README.rst'), encoding='utf-8') as f:
setup(
name='PyLg',
version='1.2.0',
version='1.2.1',
description='Python module to facilitate and automate the process of writing runtime logs.',
long_description=long_description,
url='https://gitlab.wojciechkozlowski.eu/wojtek/PyLg',