def __getattribute__(self, name): """ Decorate custom methods to handle exceptions as we want and as we specify in the "on_exception_return" method decorator """ to_return = None decorated_methods = [ 'title', 'total_time', 'instructions', 'ingredients', 'total_reivew', 'review_score' ] if name in decorated_methods: to_return = '' if name == 'total_time': to_return = 0 if name == 'ingredients': to_return = [] if name == 'total_review': to_return = 0 if name == 'review_score': to_return = [] if to_return is not None: return on_exception_return(to_return)(object.__getattribute__(self, name)) return object.__getattribute__(self, name)
def __getattribute__(self, name): """ Decorate custom methods to handle exceptions as we want and as we specify in the "on_exception_return" method decorator Do not do this META-decorating on testing so to have better traceback """ if not object.__getattribute__(self, 'testing_mode'): to_return = None decorated_methods = [ 'title', 'total_time', 'instructions', 'ingredients', 'links' ] if name in decorated_methods: to_return = '' if name == 'total_time': to_return = 0 if name == 'ingredients': to_return = [] if name == 'links': to_return = [] if to_return is not None: return on_exception_return(to_return)(object.__getattribute__( self, name)) return object.__getattribute__(self, name)
def __getattribute__(self, name): """ Decorate custom methods to handle exceptions as we want and as we specify in the "on_exception_return" method decorator """ to_return = None decorated_methods = [ 'title', 'total_time', 'instructions', 'ingredients', 'links', 'rating', # Added by IsaiahData on 2018-10-16 'num_ratings' # Added by IsaiahData on 2018-10-16 ] if name in decorated_methods: to_return = '' if name == 'total_time': to_return = 0 if name == 'ingredients': to_return = [] if name == 'links': to_return = [] if name == 'rating': to_return = 'n/a' if name == 'num_ratings': to_return = 'n/a' if to_return is not None: return on_exception_return(to_return)(object.__getattribute__( self, name)) return object.__getattribute__(self, name)
def __getattribute__(self, name): """ Decorate custom methods to handle exceptions as we want and as we specify in the "on_exception_return" method decorator """ to_return = None decorated_methods = [ 'title', 'total_time', 'instructions', 'ingredients', 'links', 'URL', 'description', 'imgURL', 'sodium', 'fat', 'cholesterol', 'carbs', 'calories', 'category', 'datePublished' ] if name in decorated_methods: to_return = '' if name == 'total_time': to_return = 0 if name == 'ingredients': to_return = [] if name == 'links': to_return = [] if to_return is not None: return on_exception_return(to_return)(object.__getattribute__(self, name)) return object.__getattribute__(self, name)