Mercurial > mozilla > hg > DocumentIt
comparison document_it.py @ 19:493683e17eae
now renders correctly to filesystem for preview
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 02 Aug 2011 19:45:34 -0700 |
parents | f7dc318832dc |
children | 7299c4529b41 |
comparison
equal
deleted
inserted
replaced
18:f7dc318832dc | 19:493683e17eae |
---|---|
157 dest = dest[len('file://'):] | 157 dest = dest[len('file://'):] |
158 | 158 |
159 # create a directory if needed | 159 # create a directory if needed |
160 dirname = os.path.dirname(dest) | 160 dirname = os.path.dirname(dest) |
161 if os.path.exists(dirname): | 161 if os.path.exists(dirname): |
162 assert os.path.isdir(dirname), "%s exists and is not a directory" % dirname | 162 if not os.path.isdir(dirname): |
163 # deal with filesystem directories vs PATH_INFO | |
164 f = file(dirname) | |
165 buffer = f.read() | |
166 f.close() | |
167 os.remove(dirname) | |
168 os.makedirs(dirname) | |
169 f = file(os.path.join(dirname, 'index.html'), 'w') | |
170 f.write(buffer) | |
171 f.close() | |
163 else: | 172 else: |
164 os.makedirs(dirname) | 173 os.makedirs(dirname) |
165 | 174 |
166 # render | 175 # render |
167 f = file(dest, 'w') | 176 f = file(dest, 'w') |