<s> import errno <EOL> import os <EOL> def make_dirs ( dir_path ) : <EOL> try : <EOL> os . makedirs ( dir_path ) <EOL> except OSError as e : <EOL> if e . errno != errno . EEXIST : <EOL> raise <EOL> def remove_tree ( dir_path , remove_root = True ) : <EOL> if os . path . exists ( dir_path ) : <EOL> for root , dirs , files in os . walk ( dir_path , topdown = False ) : <EOL> for name in files : <EOL> os . remove ( os . path . join ( root , name ) ) <EOL> for name in dirs : <EOL> os . rmdir ( os . path . join ( root , name ) ) <EOL> if remove_root is True : <EOL> os . rmdir ( dir_path ) </s>
