Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # encoding: utf-8
- #
- # Copyright (c) 2008 Doug Hellmann All rights reserved.
- #
- """This script creates the example directory and its contents.
- """
- __version__ = "$Id$"
- #end_pymotw_header
- import os
- def mkfile(filename, body=None):
- with open(filename, 'w') as f:
- f.write(body or filename)
- return
- def make_example_dir(top):
- if not os.path.exists(top):
- os.mkdir(top)
- curdir = os.getcwd()
- os.chdir(top)
- os.mkdir('dir1')
- os.mkdir('dir2')
- mkfile('dir1/file_only_in_dir1')
- mkfile('dir2/file_only_in_dir2')
- os.mkdir('dir1/dir_only_in_dir1')
- os.mkdir('dir2/dir_only_in_dir2')
- os.mkdir('dir1/common_dir')
- os.mkdir('dir2/common_dir')
- mkfile('dir1/common_file', 'this file is the same')
- mkfile('dir2/common_file', 'this file is the same')
- mkfile('dir1/not_the_same')
- mkfile('dir2/not_the_same')
- mkfile('dir1/file_in_dir1', 'This is a file in dir1')
- os.mkdir('dir2/file_in_dir1')
- os.chdir(curdir)
- return
- if __name__ == '__main__':
- os.chdir(os.path.dirname(__file__) or os.getcwd())
- make_example_dir('example')
- make_example_dir('example/dir1/common_dir')
- make_example_dir('example/dir2/common_dir')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement