<s> import hashlib <EOL> def truncate_value ( value , max_length = <NUM_LIT> , from_left = True ) : <EOL> """<STR_LIT>""" <EOL> hash_length = <NUM_LIT:8> <EOL> truncated_length = max_length - hash_length - <NUM_LIT:1> <EOL> if from_left : <EOL> truncated_value = value [ - truncated_length : ] <EOL> else : <EOL> truncated_value = value [ : truncated_length ] <EOL> if len ( value ) > max_length : <EOL> short_hash = hashlib . sha1 ( value ) . hexdigest ( ) [ : hash_length ] <EOL> return '<STR_LIT>' . format ( truncated_value , short_hash ) <EOL> return value <EOL> def get_table_name ( domain , table_id ) : <EOL> def _hash ( domain , table_id ) : <EOL> return hashlib . sha1 ( '<STR_LIT>' . format ( hashlib . sha1 ( domain ) . hexdigest ( ) , table_id ) ) . hexdigest ( ) [ : <NUM_LIT:8> ] <EOL> return truncate_value ( <EOL> '<STR_LIT>' . format ( domain , table_id , _hash ( domain , table_id ) ) , <EOL> from_left = False <EOL> ) <EOL> def get_column_name ( path ) : <EOL> """<STR_LIT>""" <EOL> parts = path . split ( "<STR_LIT:/>" ) <EOL> def _hash ( parts ) : <EOL> front = "<STR_LIT:/>" . join ( parts [ : - <NUM_LIT:1> ] ) <EOL> end = parts [ - <NUM_LIT:1> ] <EOL> return hashlib . sha1 ( '<STR_LIT>' . format ( hashlib . sha1 ( front ) . hexdigest ( ) , end ) ) . hexdigest ( ) [ : <NUM_LIT:8> ] <EOL> new_parts = path [ - <NUM_LIT> : ] . split ( "<STR_LIT:/>" ) <EOL> return "<STR_LIT:_>" . join ( new_parts + [ _hash ( parts ) ] ) </s>
