<s> """<STR_LIT>""" <EOL> import logging <EOL> import os <EOL> import random <EOL> import re <EOL> appstats_DEBUG = False <EOL> appstats_DUMP_LEVEL = - <NUM_LIT:1> <EOL> appstats_SHELL_OK = os . getenv ( '<STR_LIT>' , '<STR_LIT>' ) . startswith ( '<STR_LIT>' ) <EOL> appstats_DEFAULT_SCRIPT = "<STR_LIT>" <EOL> appstats_KEY_DISTANCE = <NUM_LIT:100> <EOL> appstats_KEY_MODULUS = <NUM_LIT:1000> <EOL> appstats_KEY_NAMESPACE = '<STR_LIT>' <EOL> appstats_KEY_PREFIX = '<STR_LIT>' <EOL> appstats_KEY_TEMPLATE = '<STR_LIT>' <EOL> appstats_PART_SUFFIX = '<STR_LIT>' <EOL> appstats_FULL_SUFFIX = '<STR_LIT>' <EOL> appstats_LOCK_SUFFIX = '<STR_LIT>' <EOL> appstats_MAX_STACK = <NUM_LIT:10> <EOL> appstats_MAX_LOCALS = <NUM_LIT:10> <EOL> appstats_MAX_REPR = <NUM_LIT:100> <EOL> appstats_MAX_DEPTH = <NUM_LIT:10> <EOL> appstats_RE_STACK_BOTTOM = r'<STR_LIT>' <EOL> appstats_RE_STACK_SKIP = r'<STR_LIT>' <EOL> appstats_LOCK_TIMEOUT = <NUM_LIT:1> <EOL> appstats_TZOFFSET = <NUM_LIT:8> * <NUM_LIT> <EOL> appstats_stats_url = '<STR_LIT>' <EOL> appstats_RECORD_FRACTION = <NUM_LIT:1.0> <EOL> appstats_FILTER_LIST = [ ] <EOL> appstats_DATASTORE_DETAILS = False <EOL> appstats_CALC_RPC_COSTS = False <EOL> def appstats_should_record ( env ) : <EOL> if appstats_FILTER_LIST : <EOL> logging . debug ( '<STR_LIT>' , appstats_FILTER_LIST ) <EOL> for filter_dict in appstats_FILTER_LIST : <EOL> for key , regex in filter_dict . iteritems ( ) : <EOL> negated = isinstance ( regex , str ) and regex . startswith ( '<STR_LIT:!>' ) <EOL> if negated : <EOL> regex = regex [ <NUM_LIT:1> : ] <EOL> value = env . get ( key , '<STR_LIT>' ) <EOL> if bool ( re . match ( regex , value ) ) == negated : <EOL> logging . debug ( '<STR_LIT>' , regex , key , value ) <EOL> break <EOL> else : <EOL> logging . debug ( '<STR_LIT>' , filter_dict ) <EOL> break <EOL> else : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if appstats_RECORD_FRACTION >= <NUM_LIT:1.0> : <EOL> return True <EOL> return random . random ( ) < appstats_RECORD_FRACTION <EOL> def appstats_normalize_path ( path ) : <EOL> return path <EOL> def appstats_extract_key ( request ) : <EOL> key = appstats_normalize_path ( request . http_path ( ) ) <EOL> if request . http_method ( ) != '<STR_LIT:GET>' : <EOL> key = '<STR_LIT>' % ( request . http_method ( ) , key ) <EOL> return key </s>
