Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. def create_new_dir(self, prefix="./", root="Sims"):
  2. """
  3. Create the directory where to put the simulation
  4. """
  5. self.dirRoot = os.path.join(prefix, root)
  6.  
  7. today = datetime.date.today()
  8. free = False
  9. index = 0
  10.  
  11. dirDate = today.strftime("%d-%m-%Y")
  12.  
  13. dirComp = os.path.join(self.dirRoot, dirDate)
  14. dir = os.path.join(dirComp, "Sim_" + str(index))
  15. while not free :
  16. if os.path.exists(dir):
  17. index = index + 1
  18. simNum = "Sim_" + str(index)
  19. dir = os.path.join(dirComp, simNum )
  20. else:
  21. free = True
  22. os.makedirs(dir)
  23. return dir
Add Comment
Please, Sign In to add comment