comparison makeitso/makeitso.py @ 87:3571417ef92e

interpolate file permissions
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Jan 2011 14:39:21 -0800
parents 2c1310e94645
children 712a6d358083
comparison
equal deleted inserted replaced
86:2c1310e94645 87:3571417ef92e
214 def substitute(self, **variables): 214 def substitute(self, **variables):
215 output = ContentTemplate.substitute(self, **variables) 215 output = ContentTemplate.substitute(self, **variables)
216 f = self.output 216 f = self.output
217 217
218 if isinstance(f, basestring): 218 if isinstance(f, basestring):
219 path = f
219 if os.path.isdir(f): 220 if os.path.isdir(f):
220 f = os.path.join(f, basename(self.name)) 221 path = os.path.join(path, basename(self.name))
221 f = file(f, 'w') 222 f = file(path, 'w')
222 print >> f, output 223 print >> f, output
223 f.close() 224 f.close()
225 try:
226 os.chmod(f, os.stat(self.name).st_mode)
227 except:
228 pass
224 else: 229 else:
225 print >> f, output 230 print >> f, output
226 try:
227 os.chmod(self.output, os.stat(self.name).st_mode)
228 except:
229 pass
230
231 231
232 class DirectoryTemplate(ContentTemplate): 232 class DirectoryTemplate(ContentTemplate):
233 """template for a directory structure""" 233 """template for a directory structure"""
234 234
235 def __init__(self, directory, output=None, interactive=True, variables=None): 235 def __init__(self, directory, output=None, interactive=True, variables=None):