[PATCH STABLE] i18n: use actual filename, in which function is defined, for hg.pot

Yuya Nishihara yuya at tcha.org
Thu Aug 3 11:36:28 EDT 2017


On Wed, 02 Aug 2017 22:36:45 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1501599731 -32400
> #      Wed Aug 02 00:02:11 2017 +0900
> # Branch stable
> # Node ID b6d0bcd19b4dffb2360f909f459c27104ad16565
> # Parent  76b171209151fe41dbf8dbfec473cc533f3b40ca
> # Available At https://bitbucket.org/foozy/mercurial-wip
> #              hg pull https://bitbucket.org/foozy/mercurial-wip -r b6d0bcd19b4d
> # EXP-Topic i18n-fix-update-pot-issues
> i18n: use actual filename, in which function is defined, for hg.pot

> +            funcmod = inspect.getmodule(func)
> +            extra = ''
> +            if funcmod.__package__ == funcmod.__name__:
> +                extra = '/__init__'
> +            actualpath = '%s%s.py' % (funcmod.__name__.replace('.', '/'), extra)
> +
>              src = inspect.getsource(func)
> -            name = "%s.%s" % (path, func.__name__)
> +            name = "%s.%s" % (actualpath, func.__name__)
>              lineno = inspect.getsourcelines(func)[1]

Perhaps inspect.getsourcefile() can be used.


More information about the Mercurial-devel mailing list