<s> import os <EOL> import shutil <EOL> remove_dirs = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def rmgeneric ( path , __func__ ) : <EOL> try : <EOL> __func__ ( path ) <EOL> return <NUM_LIT:1> <EOL> except OSError as e : <EOL> print ( '<STR_LIT>' . format ( path , e ) ) <EOL> return <NUM_LIT:0> <EOL> def rmfiles ( path = None , * extensions ) : <EOL> path = path or os . curdir <EOL> if not os . path . isdir ( path ) : <EOL> return <NUM_LIT:0> <EOL> assert extensions <EOL> for ext in extensions : <EOL> assert ext <EOL> trem = <NUM_LIT:0> <EOL> tall = <NUM_LIT:0> <EOL> files = os . listdir ( path ) <EOL> for name in files : <EOL> fullpath = os . path . join ( path , name ) <EOL> if os . path . isfile ( fullpath ) : <EOL> sf = name . split ( '<STR_LIT:.>' ) <EOL> if len ( sf ) == <NUM_LIT:2> and sf [ <NUM_LIT:1> ] in extensions : <EOL> tall += <NUM_LIT:1> <EOL> trem += rmgeneric ( fullpath , os . remove ) <EOL> elif name == '<STR_LIT>' : <EOL> shutil . rmtree ( fullpath ) <EOL> tall += <NUM_LIT:1> <EOL> elif os . path . isdir ( fullpath ) and not name . startswith ( '<STR_LIT:.>' ) : <EOL> r , ra = rmfiles ( fullpath , * extensions ) <EOL> trem += r <EOL> tall += ra <EOL> return trem , tall <EOL> def run ( ) : <EOL> for path in remove_dirs : <EOL> if os . path . isdir ( path ) : <EOL> print ( '<STR_LIT>' % path ) <EOL> shutil . rmtree ( path ) <EOL> removed , allfiles = rmfiles ( os . curdir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' . format ( removed , allfiles ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> run ( ) </s>
