[PATCH 4 of 8] extensions: allow fetching raw descriptions instead of localized synopses

Cédric Duval cedricduval at free.fr
Sat Jul 4 15:05:10 CDT 2009


# HG changeset patch
# User Cédric Duval <cedricduval at free.fr>
# Date 1246737838 -7200
# Node ID 7fa8585db93f7621ba132b0ca03cc675634080c3
# Parent  9ed801746dffaa8093991c959436bd2f34ead2bb
extensions: allow fetching raw descriptions instead of localized synopses

Useful for when gettext() should be called at a later time.

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -136,21 +136,21 @@
                 exts[e] = path
     return exts
 
-def disabled():
+def disabled(raw=False):
     '''find disabled extensions
     returns a dict of {name: desc}, and the max name length'''
 
     # extensions found from hgext's path
     import hgext
     extpath = os.path.dirname(os.path.abspath(hgext.__file__))
-    d = extractdoc(extpath)
+    d = extractdoc(extpath, raw)
 
     exts = dict([ (k, v) for k, v in d.iteritems() if k not in _order ])
     maxlength = max([ len(name) for name in exts.keys() or [''] ])
 
     return exts, maxlength
 
-def extractdoc(extpath):
+def extractdoc(extpath, raw):
     '''extract descriptions from extensions in extpath
     returns a dict of {name: desc}'''
     exts = {}
@@ -160,25 +160,27 @@
         except IOError:
             continue
         else:
-            doc = extdoc.moduledoc(file)
+            doc = extdoc.moduledoc(file) or '(no help text available)'
             file.close()
 
-        if doc: # extracting localized synopsis
-            exts[name] = extdoc.synopsis(doc)
-        else:
-            exts[name] = _('(no help text available)')
+        if not raw:
+            doc = extdoc.synopsis(doc)
+   
+        exts[name] = doc
 
     return exts
 
-def enabled():
+def enabled(raw=False):
     '''return a dict of {name: desc} of extensions, and the max name length'''
     exts = {}
     maxlength = 0
     exthelps = []
     for ename, ext in extensions():
         doc = ext.__doc__ or '(no help text available)'
+        if not raw:
+            doc = extdoc.synopsis(doc)
         ename = ename.split('.')[-1]
+        exts[ename] = doc
         maxlength = max(len(ename), maxlength)
-        exts[ename] = extdoc.synopsis(doc)
 
     return exts, maxlength



More information about the Mercurial-devel mailing list