<s> import py <EOL> from os import system , chdir <EOL> from urllib import urlopen <EOL> log_URL = '<STR_LIT>' <EOL> archive_FILENAME = '<STR_LIT>' <EOL> tempdir = py . test . ensuretemp ( "<STR_LIT>" ) <EOL> chdir ( str ( tempdir ) ) <EOL> system ( '<STR_LIT>' % ( log_URL , archive_FILENAME ) ) <EOL> system ( '<STR_LIT>' % archive_FILENAME ) <EOL> chdir ( '<STR_LIT>' ) <EOL> pypydir = tempdir . join ( '<STR_LIT>' ) <EOL> for line in urlopen ( log_URL + '<STR_LIT>' ) . readlines ( ) : <EOL> i = line . find ( '<STR_LIT>' ) <EOL> if i == - <NUM_LIT:1> : <EOL> continue <EOL> filename = line [ i : ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> system ( '<STR_LIT>' % ( log_URL , filename ) ) <EOL> for log_filename in pypydir . listdir ( '<STR_LIT>' ) : <EOL> rename_to = None <EOL> b = log_filename . basename <EOL> if '<STR_LIT:->' in b : <EOL> rename_to = log_filename . basename . replace ( '<STR_LIT:->' , '<STR_LIT>' ) <EOL> elif len ( b ) == <NUM_LIT> : <EOL> months = '<STR_LIT>' . split ( ) <EOL> day = b [ <NUM_LIT:10> : <NUM_LIT:12> ] <EOL> month = months . index ( b [ <NUM_LIT:12> : <NUM_LIT:15> ] ) + <NUM_LIT:1> <EOL> year = b [ <NUM_LIT:15> : <NUM_LIT:20> ] <EOL> rename_to = '<STR_LIT>' % ( year , month , day ) <EOL> if rename_to : <EOL> log_filename . rename ( rename_to ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> for log_filename in pypydir . listdir ( '<STR_LIT>' ) : <EOL> n_messages , visitors = <NUM_LIT:0> , { } <EOL> f = str ( log_filename ) <EOL> for s in file ( f ) : <EOL> if '<STR_LIT:<>' in s and '<STR_LIT:>>' in s : <EOL> n_messages += <NUM_LIT:1> <EOL> elif '<STR_LIT>' in s : <EOL> v = s . split ( ) [ <NUM_LIT:1> ] <EOL> visitors [ v ] = True <EOL> print '<STR_LIT>' % ( f [ - <NUM_LIT:8> : - <NUM_LIT:4> ] , f [ - <NUM_LIT:4> : - <NUM_LIT:2> ] , f [ - <NUM_LIT:2> : ] , n_messages , len ( visitors . keys ( ) ) ) </s>
