import functools


def sync_before(f):
    """Use as a decorator to wrap methods that use cell information to
    make sure they sync the latest information from the DB periodically.
    """
    @functools.wraps(f)
    def wrapper(self, *args, **kwargs):
        self._cell_data_sync()
        return f(self, *args, **kwargs)
    return wrapper