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

Martin Geisler mg at lazybytes.net
Mon Jul 6 18:02:37 CDT 2009


Cédric Duval <cedricduval at free.fr> writes:

> 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):

I was not able to find anything that actually calls disabled and enabled
with raw=True. So maybe these arguments are not needed?

>      '''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)'

There we have the "lucky" string again :-)

>              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)

Could we not let it be up to the caller of extractdoc to shorten the doc
to the first line?

Then extractdoc could always return a localized version of the full
documentation. When building the hg.1 manpage the caller should prepare
the environment to be in the C locale so that we get the same result as
if we passed the 'raw' flag you have.


-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090707/95001f5d/attachment.pgp 


More information about the Mercurial-devel mailing list