<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import re <EOL> from django . template import Library , Node , TemplateSyntaxError <EOL> from django . utils . safestring import mark_safe <EOL> from analytical . utils import is_internal_ip , disable_html , get_identity , get_required_setting <EOL> API_KEY_RE = re . compile ( r'<STR_LIT>' ) <EOL> SETUP_CODE = """<STR_LIT>""" <EOL> IDENTIFY_CODE = """<STR_LIT>""" <EOL> EMBED_CODE = """<STR_LIT>""" <EOL> register = Library ( ) <EOL> @ register . tag <EOL> def performable ( parser , token ) : <EOL> """<STR_LIT>""" <EOL> bits = token . split_contents ( ) <EOL> if len ( bits ) > <NUM_LIT:1> : <EOL> raise TemplateSyntaxError ( "<STR_LIT>" % bits [ <NUM_LIT:0> ] ) <EOL> return PerformableNode ( ) <EOL> class PerformableNode ( Node ) : <EOL> def __init__ ( self ) : <EOL> self . api_key = get_required_setting ( '<STR_LIT>' , API_KEY_RE , <EOL> "<STR_LIT>" ) <EOL> def render ( self , context ) : <EOL> html = SETUP_CODE % { '<STR_LIT>' : self . api_key } <EOL> identity = get_identity ( context , '<STR_LIT>' ) <EOL> if identity is not None : <EOL> html = "<STR_LIT>" % ( IDENTIFY_CODE % identity , html ) <EOL> if is_internal_ip ( context , '<STR_LIT>' ) : <EOL> html = disable_html ( html , '<STR_LIT>' ) <EOL> return html <EOL> @ register . simple_tag <EOL> def performable_embed ( hostname , page_id ) : <EOL> """<STR_LIT>""" <EOL> return mark_safe ( EMBED_CODE % { '<STR_LIT>' : hostname , '<STR_LIT>' : page_id } ) <EOL> def contribute_to_analytical ( add_node ) : <EOL> PerformableNode ( ) <EOL> add_node ( '<STR_LIT>' , PerformableNode ) </s>
