<s> import hashlib <EOL> import os <EOL> import time <EOL> import random <EOL> import shutil <EOL> import itertools <EOL> from gitpy import LocalRepository <EOL> _filename_gen = ( os . path . join ( "<STR_LIT>" , "<STR_LIT>" % i ) for i in itertools . count ( ) ) <EOL> def get_temporary_location ( ) : <EOL> for path in _filename_gen : <EOL> if not os . path . exists ( path ) : <EOL> return os . path . realpath ( path ) <EOL> def delete_repository ( repo ) : <EOL> shutil . rmtree ( repo . path ) <EOL> def create_repo ( ) : <EOL> returned = LocalRepository ( get_temporary_location ( ) ) <EOL> returned . init ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> filename = "<STR_LIT>" % i <EOL> full_filename = os . path . join ( returned . path , filename ) <EOL> with open ( full_filename , "<STR_LIT:wb>" ) as f : <EOL> print >> f , "<STR_LIT>" <EOL> returned . add ( filename ) <EOL> returned . commit ( message = "<STR_LIT>" ) <EOL> return returned <EOL> def commit_change ( repo ) : <EOL> filename = random . choice ( repo . getUnchangedFiles ( ) ) <EOL> with open ( os . path . join ( repo . path , filename ) , "<STR_LIT>" ) as f : <EOL> print >> f , "<STR_LIT>" , time . asctime ( ) <EOL> repo . add ( filename ) <EOL> return repo . commit ( message = "<STR_LIT>" % time . asctime ( ) ) <EOL> def get_repo_contents ( repo ) : <EOL> returned = { } <EOL> path = repo . path <EOL> if not path . endswith ( os . sep ) : <EOL> path += os . sep <EOL> for dirpath , dirnames , filenames in os . walk ( path ) : <EOL> if '<STR_LIT>' in dirnames : <EOL> dirnames . remove ( '<STR_LIT>' ) <EOL> for filename in filenames : <EOL> full_filename = os . path . join ( dirpath , filename ) <EOL> returned [ full_filename [ len ( path ) : ] ] = hashlib . sha512 ( open ( full_filename , "<STR_LIT:rb>" ) . read ( ) ) . hexdigest ( ) <EOL> return returned </s>
