| 
									
										
										
										
											2010-03-11 22:53:45 +00:00
										 |  |  | #! /usr/bin/env python3 | 
					
						
							| 
									
										
										
										
											1992-05-19 13:52:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Like mkdir, but also make intermediate directories if necessary. | 
					
						
							|  |  |  | # It is not an error if the given directory already exists (as long | 
					
						
							|  |  |  | # as it is a directory). | 
					
						
							|  |  |  | # Errors are not treated specially -- you just get a Python exception. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import sys, os | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2004-07-18 05:56:09 +00:00
										 |  |  |     for p in sys.argv[1:]: | 
					
						
							|  |  |  |         makedirs(p) | 
					
						
							| 
									
										
										
										
											1992-05-19 13:52:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | def makedirs(p): | 
					
						
							| 
									
										
										
										
											2004-07-18 05:56:09 +00:00
										 |  |  |     if p and not os.path.isdir(p): | 
					
						
							|  |  |  |         head, tail = os.path.split(p) | 
					
						
							|  |  |  |         makedirs(head) | 
					
						
							| 
									
										
										
										
											2007-07-17 20:59:35 +00:00
										 |  |  |         os.mkdir(p, 0o777) | 
					
						
							| 
									
										
										
										
											1992-05-19 13:52:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-11 16:34:35 +00:00
										 |  |  | if __name__ == "__main__": | 
					
						
							|  |  |  |     main() |