Revision a426508d lib/utils.py

b/lib/utils.py
319 319
    # as efficient.
320 320
    if mkdir and err.errno == errno.ENOENT:
321 321
      # Create directory and try again
322
      os.makedirs(os.path.dirname(new), mkdir_mode)
322
      dirname = os.path.dirname(new)
323
      try:
324
        os.makedirs(dirname, mode=mkdir_mode)
325
      except OSError, err:
326
        # Ignore EEXIST. This is only handled in os.makedirs as included in
327
        # Python 2.5 and above.
328
        if err.errno != errno.EEXIST or not os.path.exists(dirname):
329
          raise
330

  
323 331
      return os.rename(old, new)
332

  
324 333
    raise
325 334

  
326 335

  

Also available in: Unified diff