<s> """<STR_LIT>""" <EOL> import random <EOL> import string <EOL> import time <EOL> from math import pow <EOL> from cloudcafe . common . tools import randomstring <EOL> SOURCE_RANDOM = '<STR_LIT>' <EOL> SOURCE_ZEROS = '<STR_LIT>' <EOL> TEMP_LOCATION = '<STR_LIT>' <EOL> EXACT_BYTE = <NUM_LIT:8> <EOL> EXACT_KIBIBYTE = int ( pow ( <NUM_LIT:2> , <NUM_LIT:10> ) ) <EOL> EXACT_MEBIBYTE = int ( pow ( <NUM_LIT:2> , <NUM_LIT:20> ) ) <EOL> EXACT_GIBIBYTE = int ( pow ( <NUM_LIT:2> , <NUM_LIT:30> ) ) <EOL> EXACT_TEBIBYTE = int ( pow ( <NUM_LIT:2> , <NUM_LIT> ) ) <EOL> EXACT_KILOBYTE = int ( pow ( <NUM_LIT:10> , <NUM_LIT:3> ) ) <EOL> EXACT_MEGABYTE = int ( pow ( <NUM_LIT:10> , <NUM_LIT:6> ) ) <EOL> EXACT_GIGABYTE = int ( pow ( <NUM_LIT:10> , <NUM_LIT:9> ) ) <EOL> EXACT_TERABYTE = int ( pow ( <NUM_LIT:10> , <NUM_LIT:12> ) ) <EOL> def timestamp_string ( prefix = None , suffix = None , decimal_precision = <NUM_LIT:6> ) : <EOL> '''<STR_LIT>''' <EOL> t = str ( '<STR_LIT>' % time . time ( ) ) <EOL> int_seconds , dec_seconds = t . split ( '<STR_LIT:.>' ) <EOL> for x in range ( <NUM_LIT:6> - decimal_precision ) : <EOL> dec_seconds = dec_seconds [ : - <NUM_LIT:1> ] <EOL> int_seconds = str ( int_seconds ) <EOL> dec_seconds = str ( dec_seconds ) <EOL> prefix = prefix or '<STR_LIT>' <EOL> suffix = suffix or '<STR_LIT>' <EOL> final = None <EOL> if len ( dec_seconds ) > <NUM_LIT:0> : <EOL> final = '<STR_LIT>' % ( prefix , int_seconds , suffix ) <EOL> else : <EOL> final = '<STR_LIT>' % ( prefix , int_seconds , dec_seconds , suffix ) <EOL> return final <EOL> def random_string ( prefix = None , suffix = None , size = <NUM_LIT:8> ) : <EOL> """<STR_LIT>""" <EOL> if size <= <NUM_LIT:0> : <EOL> return "<STR_LIT>" . format ( prefix or '<STR_LIT>' , suffix or '<STR_LIT>' ) <EOL> charpool = tuple ( string . ascii_letters + string . digits ) <EOL> final_string = "<STR_LIT>" <EOL> while size > <NUM_LIT:0> : <EOL> segment_size = min ( int ( len ( charpool ) / <NUM_LIT:2> ) , size ) <EOL> size = size - segment_size <EOL> final_string += "<STR_LIT>" . join ( <EOL> random . sample ( ( charpool ) , segment_size ) ) <EOL> return "<STR_LIT>" . format ( prefix or '<STR_LIT>' , final_string , suffix or '<STR_LIT>' ) <EOL> def random_ip ( pattern = None ) : <EOL> """<STR_LIT>""" <EOL> if pattern is None : <EOL> pattern = '<STR_LIT>' <EOL> num_asterisks = <NUM_LIT:0> <EOL> for c in pattern : <EOL> if c == '<STR_LIT:*>' : <EOL> num_asterisks += <NUM_LIT:1> <EOL> rand_list = [ random . randint ( <NUM_LIT:1> , <NUM_LIT:255> ) for i in range ( <NUM_LIT:0> , num_asterisks ) ] <EOL> for item in rand_list : <EOL> pattern = pattern . replace ( '<STR_LIT:*>' , str ( item ) , <NUM_LIT:1> ) <EOL> return pattern <EOL> def random_cidr ( ip_pattern = None , mask = None , min_mask = <NUM_LIT:0> , max_mask = <NUM_LIT:30> ) : <EOL> """<STR_LIT>""" <EOL> if mask is None : <EOL> mask = random . randint ( min_mask , max_mask ) <EOL> ip = random_ip ( ip_pattern ) <EOL> return '<STR_LIT>' . join ( [ ip , '<STR_LIT:/>' , str ( mask ) ] ) <EOL> def random_int ( min_int , max_int ) : <EOL> return random . randint ( min_int , max_int ) <EOL> def rand_name ( name = '<STR_LIT:test>' ) : <EOL> return "<STR_LIT>" . format ( <EOL> name = name , suffix = randomstring . get_random_string ( ) ) <EOL> def random_item_in_list ( selection_list ) : <EOL> return random . choice ( selection_list ) <EOL> def bytes_to_gb ( val ) : <EOL> return float ( val ) / <NUM_LIT> <EOL> def gb_to_bytes ( val ) : <EOL> return int ( val * <NUM_LIT> ) <EOL> def bytes_to_mb ( val ) : <EOL> return float ( val ) / <NUM_LIT> </s>
