<s> import functools <EOL> import re <EOL> from flask import _request_ctx_stack as stack <EOL> def mobile_template ( template ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( f ) : <EOL> @ functools . wraps ( f ) <EOL> def wrapper ( * args , ** kwargs ) : <EOL> ctx = stack . top <EOL> if ctx is not None and hasattr ( ctx , '<STR_LIT>' ) : <EOL> request = ctx . request <EOL> is_mobile = getattr ( request , '<STR_LIT>' , None ) <EOL> kwargs [ '<STR_LIT>' ] = re . sub ( r'<STR_LIT>' , <EOL> r'<STR_LIT>' if is_mobile else '<STR_LIT>' , <EOL> template ) <EOL> return f ( * args , ** kwargs ) <EOL> return wrapper <EOL> return decorator <EOL> def mobilized ( normal_fn ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( mobile_fn ) : <EOL> @ functools . wraps ( mobile_fn ) <EOL> def wrapper ( * args , ** kwargs ) : <EOL> ctx = stack . top <EOL> if ctx is not None and hasattr ( ctx , '<STR_LIT>' ) : <EOL> request = ctx . request <EOL> if not request . MOBILE : <EOL> return normal_fn ( * args , ** kwargs ) <EOL> return mobile_fn ( * args , ** kwargs ) <EOL> return wrapper <EOL> return decorator </s>
