Skip to content

Commit

Permalink
Added style_prints.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Jul 9, 2017
1 parent e0045d4 commit 79cb15a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions uwsgiconf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class Section(SectionBase):
not only into `set_basic_params` method by also into section initializer
using `basic_params_` prefixed group name:
.. code-block:: python
Section(
basic_params_workers=dict(count=3, zombie_reaper=True)
basic_params_master_process=dict(enabled=True)
basic_params_workers=dict(count=3, zombie_reaper=True),
basic_params_master_process=dict(enabled=True),
)
"""
Expand All @@ -52,7 +53,8 @@ class Section(SectionBase):
plugin_python = Options(PythonPlugin) # type: PythonPlugin

class Vars(object):
"""The following variables also known as magic variables could be used as option values where appropriate.
"""The following variables also known as magic variables
could be used as option values where appropriate.
* http://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#magic-variables
Expand Down Expand Up @@ -140,7 +142,7 @@ def get_descriptions(cls):

return OrderedDict(descriptions)

def __init__(self, strict_config=None, name=None, **kwargs):
def __init__(self, strict_config=None, name=None, style_prints=False, **kwargs):
"""
:param bool strict_config: Enable strict configuration parsing.
Expand All @@ -149,9 +151,14 @@ def __init__(self, strict_config=None, name=None, **kwargs):
To use placeholder variables when using strict mode, use the ``set-placeholder`` option.
:param str name: Configuration section name
:param str name: Configuration section name.
:param bool style_prints: Enables styling (e.g. colouring) for ``print_`` family methods.
Could be nice for console and distracting in logs.
"""
self._style_prints = style_prints

super(Section, self).__init__(name=name or 'uwsgi', strict_config=strict_config, **kwargs)

def set_basic_params(self, strict_config=None, **kwargs):
Expand Down Expand Up @@ -207,7 +214,7 @@ def print_out(self, value, indent=None, format_options=None, immediate=False):
if format_options is None:
format_options = 'gray'

if format_options:
if self._style_prints and format_options:

if not isinstance(format_options, dict):
format_options = {'color_fg': format_options}
Expand Down

0 comments on commit 79cb15a

Please sign in to comment.