<s> from __future__ import unicode_literals <EOL> import re <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . utils . functional import allow_lazy <EOL> from django . utils . importlib import import_module <EOL> def get_function ( function_path ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> mod_name , func_name = function_path . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> mod = import_module ( mod_name ) <EOL> except ImportError as e : <EOL> raise ImproperlyConfigured ( ( '<STR_LIT>' % <EOL> ( mod_name , e ) ) ) <EOL> return getattr ( mod , func_name ) <EOL> def keeptags ( value , tags ) : <EOL> tags = [ re . escape ( tag ) for tag in tags . split ( ) ] <EOL> def _replacer ( match ) : <EOL> if match . group ( <NUM_LIT:1> ) in tags : <EOL> return match . group ( <NUM_LIT:0> ) <EOL> else : <EOL> return '<STR_LIT>' <EOL> return re . sub ( r'<STR_LIT>' , _replacer , value ) <EOL> keeptags = allow_lazy ( keeptags ) </s>
