Skip to content

Commit

Permalink
added @wraps decorator to..., well, decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaquin L. Pereyra committed Sep 7, 2016
1 parent 3300ede commit 0bbd665
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions gui/gtk/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def safe_io_with_server(response_in_emergency):
anything happens, it will return the response in emergency.
"""
def safe_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
res = func(*args, **kwargs)
Expand All @@ -24,10 +25,8 @@ def scrollable(width=-1, height=-1, overlay_scrolling=False):
"""A function that takes optinal width and height and returns
the scrollable decorator. -1 is the default GTK option for both
width and height."""

def scrollable_decorator(func):
"""Takes a function and returns the scroll_object_wrapper."""

@wraps(func)
def scroll_object_wrapper(*args, **kwargs):
"""Takes arguments and obtains the original object from
Expand Down
3 changes: 2 additions & 1 deletion model/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from config.configuration import getInstanceConfiguration
from utils.logs import getLogger
import model.api as api
#import model.guiapi as guiapi
from model.guiapi import notification_center as notifier
from gui.customevents import *
from functools import wraps


# XXX: consider re-writing this module! There's alot of repeated code
Expand Down Expand Up @@ -206,6 +206,7 @@ def _checkParent(self, parent_type):
parent_type before adding it.
"""
def checkParentDecorator(add_func):
@wraps(add_func)
def addWrapper(new_obj, parent_id=None, *args):
parent = self.mappers_manager.find(parent_type, parent_id)
if parent:
Expand Down
2 changes: 2 additions & 0 deletions persistence/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from model.diff import ModelObjectDiff, MergeSolver
from model.conflict import ConflictUpdate
from config.configuration import getInstanceConfiguration
from functools import wraps

CONF = getInstanceConfiguration()

Expand All @@ -30,6 +31,7 @@ def local_changes():
return _LOCAL_CHANGES_ID_TO_REV

def _ignore_in_changes(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
json = func(*args, **kwargs)
if json['ok']:
Expand Down

0 comments on commit 0bbd665

Please sign in to comment.