mercurial/templater.py
changeset 45316 1b983985edd9
parent 45313 fef64d7a4a84
child 45319 6e6fe826ba69
equal deleted inserted replaced
45315:2901133ec982 45316:1b983985edd9
  1082     '''return the directory used for template files, or None.'''
  1082     '''return the directory used for template files, or None.'''
  1083     path = os.path.normpath(os.path.join(resourceutil.datapath, b'templates'))
  1083     path = os.path.normpath(os.path.join(resourceutil.datapath, b'templates'))
  1084     return path if os.path.isdir(path) else None
  1084     return path if os.path.isdir(path) else None
  1085 
  1085 
  1086 
  1086 
  1087 def open_template(name):
  1087 def open_template(name, templatepath=None):
  1088     '''returns a file-like object for the given template, and its full path
  1088     '''returns a file-like object for the given template, and its full path
  1089 
  1089 
  1090     If the name is a relative path and we're in a frozen binary, the template
  1090     If the name is a relative path and we're in a frozen binary, the template
  1091     will be read from the mercurial.templates package instead. The returned path
  1091     will be read from the mercurial.templates package instead. The returned path
  1092     will then be the relative path.
  1092     will then be the relative path.
  1093     '''
  1093     '''
  1094     templatepath = templatedir()
  1094     if templatepath is None:
       
  1095         templatepath = templatedir()
  1095     if templatepath is not None or os.path.isabs(name):
  1096     if templatepath is not None or os.path.isabs(name):
  1096         f = os.path.join(templatepath, name)
  1097         f = os.path.join(templatepath, name)
  1097         try:
  1098         try:
  1098             return f, open(f, mode='rb')
  1099             return f, open(f, mode='rb')
  1099         except EnvironmentError:
  1100         except EnvironmentError: