comparison mercurial/templater.py @ 2001:a439b7b51530

Windows py2exe version didn't handle names given to templatepath() correctly
author Lee Cantey <lcantey@gmail.com>
date Fri, 24 Mar 2006 10:33:18 -0800
parents 04c17fc39c84
children e3eba577a0ae
comparison
equal deleted inserted replaced
2000:6f6e210b38cf 2001:a439b7b51530
290 } 290 }
291 291
292 def templatepath(name=None): 292 def templatepath(name=None):
293 '''return location of template file or directory (if no name). 293 '''return location of template file or directory (if no name).
294 returns None if not found.''' 294 returns None if not found.'''
295 # executable version (py2exe) doesn't support __file__
296 if hasattr(sys, 'frozen'):
297 module = sys.executable
298 else:
299 module = __file__
295 for f in 'templates', '../templates': 300 for f in 'templates', '../templates':
296 fl = f.split('/') 301 fl = f.split('/')
297 if name: fl.append(name) 302 if name: fl.append(name)
298 p = os.path.join(os.path.dirname(__file__), *fl) 303 p = os.path.join(os.path.dirname(module), *fl)
299 if (name and os.path.exists(p)) or os.path.isdir(p): 304 if (name and os.path.exists(p)) or os.path.isdir(p):
300 return os.path.normpath(p) 305 return os.path.normpath(p)
301 else:
302 # executable version (py2exe) doesn't support __file__
303 if hasattr(sys, 'frozen'):
304 return os.path.join(sys.prefix, "templates")