[PATCH 4/4] Implement and use decorator for logging UI storage actions

Vratislav Podzimek vpodzime at redhat.com
Tue Apr 8 14:22:10 UTC 2014


On Tue, 2014-04-08 at 15:57 +0200, Vratislav Podzimek wrote:
> We now have many functions that can all run with the UI storage logging filter.
> Instead of using the context manager and indenting the code quite a lot we can
> decorate those functions to run in the context manager. This makes the code
> better readable.
> 
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/ui/gui/spokes/custom.py | 252 +++++++++++++++++++------------------
>  1 file changed, 130 insertions(+), 122 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
> index b87158b..f9b00e8 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -86,6 +86,8 @@ from pyanaconda.ui.gui.categories.system import SystemCategory
>  from gi.repository import Gdk, Gtk
>  from gi.repository.AnacondaWidgets import MountpointSelector
>  
> +from functools import wraps
> +
>  import logging
>  log = logging.getLogger("anaconda")
>  
> @@ -136,6 +138,14 @@ MOUNTPOINT_DESCRIPTIONS = {"Swap": N_("The 'swap' area on your computer is used
>                                             "bootloader configuration on some PPC platforms.")
>                              }
>  
> +def ui_storage_logged(func):
> +    @wraps(func)
> +    def decorated(*args, **kwargs):
> +        with ui_storage_logger():
> +            func(*args, **kwargs)
This should be 'return func(*args, **kwargs)'. Fixed locally.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list