On 04/02/2014 02:23 PM, Zhou Zheng Sheng wrote:
on 2014/04/02 13:51, shaohef(a)linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
>
> When I do i18n translation, I find some string format are wrong.
> So I add a check-local command to help the developer to check their
> string format.
>
> Every developers please run this command before submit your patch.
> Thanks.
>
> After you run this command, it may report some invalid string formats.
> $ make check-local
> Checking for invalid string formatting...
> "KCHREPOS0018E": _("Could not write repository configuration
file
> %(repo_file)"),
>
> You should check %(repo_file) is what you want.
>
> Ref:
>
http://docs.python.org/2/library/string.html
>
> Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
> Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
> ---
> Makefile.am | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Makefile.am b/Makefile.am
> index c68f050..75d457e 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -73,7 +73,15 @@ PEP8_WHITELIST = \
>
> SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py"
>
> +I18N_FILES = plugins/*/i18n.py \
> + src/kimchi/i18n.py \
> + $(NULL)
> +
> check-local:
> + @echo "Checking for invalid string formatting..."
> + @grep -P "%\([^\)]*?\)[^0-9\.bcdeEfgGnosxX%]" $(I18N_FILES) | \
> + while read LINE; do echo "$$LINE"; false; done
Could you explain why "*" is followed by "?" in the regular
expression?
It's a bit confusing to me. I can under stand the other parts.
The
"?" can removed. it is used for lazy match.
Here we can removed it.
See next version.
> + @echo "Checking for invalid string formatting successfully"
> find . -path './.git' -prune -type f -o \
> -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \
> grep -w -v $(SKIP_PYFLAKES_ERR) | \
>
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center