<div dir="ltr"><div>Nice !<br><br></div>Thank you !<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-24 9:00 GMT-02:00 <span dir="ltr"><<a href="mailto:bf-docboard-request@blender.org" target="_blank">bf-docboard-request@blender.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Bf-docboard mailing list submissions to<br>
<a href="mailto:bf-docboard@blender.org">bf-docboard@blender.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.blender.org/mailman/listinfo/bf-docboard" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-docboard</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:bf-docboard-request@blender.org">bf-docboard-request@blender.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:bf-docboard-owner@blender.org">bf-docboard-owner@blender.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Bf-docboard digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Translations Tracker (Anton Felix Lorenzen)<br>
2. Re: Translations Tracker (Aaron Carlisle)<br>
3. Re: Translations Tracker (Campbell Barton)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 23 Dec 2015 19:11:11 +0100<br>
From: Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
Subject: [Bf-docboard] Translations Tracker<br>
To: <a href="mailto:bf-docboard@blender.org">bf-docboard@blender.org</a><br>
Message-ID: <<a href="mailto:567AE3BF.7040005@web.de">567AE3BF.7040005@web.de</a>><br>
Content-Type: text/plain; charset=utf-8<br>
<br>
Hi all,<br>
<br>
I re-wrote the script in python,<br>
it's now around 360 times as fast using python3<br>
(and even 675 times when using pypy).<br>
<br>
I overused grep before,<br>
so it took the script 9 minutes to finish,<br>
now it runs in approx. 1 second.<br>
<br>
It also shows files with fuzzy strings in it<br>
and should also run on windows.<br>
<br>
Sincerely,<br>
Anton Felix Lorenzen<br>
<br>
Usage:<br>
|- Paste into file named translations.py<br>
|- "cd" into folder<br>
|- execute python translations.py "C:\path\to\LC_MESSAGES"<br>
<br>
Script:<br>
<br>
#!/usr/bin/env python2<br>
# -*- coding: utf-8 -*-<br>
#<br>
# Translations Tracker 1.0<br>
# works best with pypy<br>
#<br>
# Copyright 2015 Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
#<br>
# Permission is hereby granted, free of charge,<br>
# to any person obtaining a copy of this software<br>
# and associated documentation files (the "Software"),<br>
# to deal in the Software without restriction,<br>
# including without limitation the rights to use, copy,<br>
# modify, merge, publish, distribute, sublicense,<br>
# and/or sell copies of the Software,<br>
# and to permit persons to whom the Software is furnished to do so,<br>
# subject to the following conditions:<br>
#<br>
# The above copyright notice and this permission notice<br>
# shall be included in all copies or substantial portions of the Software.<br>
#<br>
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
MERCHANTABILITY,<br>
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
CLAIM,<br>
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
SOFTWARE<br>
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
<br>
import os<br>
import codecs<br>
import sys<br>
<br>
if(sys.argv and sys.argv[1]):<br>
path = sys.argv[1]<br>
else:<br>
path = "~/locale/fr/LC_MESSAGES"<br>
<br>
# Configuration<br>
fileinfo = '{0[file]:>3} empty, {1[file]:>3} fuzzy of {2[file]:>3}; or<br>
{3:.3f}% in {4}'<br>
allinfo = 'Summary: {0[all]} empty of {1[all]}; or {2:.3f}%'<br>
fuzzyinfo = 'Fuzzy: {0[all]} fuzzy strings in {0[filelist]}'<br>
<br>
msgstrs = {'file': 0, 'all':0}<br>
empty_msgstrs = {'file': 0, 'all': 0}<br>
fuzzy = {'file': 0, 'all': 0, 'filelist': []}<br>
lastLineWasEmptyMsgstr = False<br>
<br>
def forAllInMap(m, fnk, cond):<br>
for key in m:<br>
if(cond(m[key])):<br>
m[key] = fnk(m[key])<br>
<br>
def forAllIntsInMap(m, fnk):<br>
forAllInMap(m, fnk, lambda x: type(x)==int)<br>
<br>
def increaseAllInMap(m):<br>
forAllIntsInMap(m, lambda x: x+1)<br>
<br>
def decreseAllInMap(m):<br>
forAllIntsInMap(m, lambda x: x-1)<br>
<br>
for (root, subs, files) in os.walk(path):<br>
for name in files:<br>
msgstrs['file'] = -1 # First lines contain a "fake" msgstr<br>
msgstrs['all'] -= 1<br>
empty_msgstrs['file'] = 0<br>
fuzzy['file'] = 0<br>
if name.endswith('.po'):<br>
for line in codecs.open(os.path.join(root, name), encoding='utf8'):<br>
if(line[0] == 'm'):<br>
if(line[0:6] == 'msgstr'):<br>
increaseAllInMap(msgstrs)<br>
if(line[0:9] == 'msgstr ""'):<br>
increaseAllInMap(empty_msgstrs)<br>
lastLineWasEmptyMsgstr = True<br>
else:<br>
if(line[0] == '"'):<br>
if(lastLineWasEmptyMsgstr):<br>
decreseAllInMap(empty_msgstrs)<br>
lastLineWasEmptyMsgstr = False<br>
else:<br>
lastLineWasEmptyMsgstr = False<br>
if('fuzzy' in line):<br>
increaseAllInMap(fuzzy)<br>
fuzzy['filelist'] += [name]<br>
<br>
print(fileinfo.format(empty_msgstrs, fuzzy, msgstrs,<br>
float(empty_msgstrs['file'] + fuzzy['file']) / msgstrs['file'],<br>
os.path.join(root[len(path):], name)))<br>
<br>
print(allinfo.format(empty_msgstrs, msgstrs, float(empty_msgstrs['all'])<br>
/ msgstrs['all']))<br>
print(fuzzyinfo.format(fuzzy))<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 23 Dec 2015 18:39:42 -0500<br>
From: Aaron Carlisle <<a href="mailto:carlisle.aaron00@gmail.com">carlisle.aaron00@gmail.com</a>><br>
Subject: Re: [Bf-docboard] Translations Tracker<br>
To: Blender Documentation Project <<a href="mailto:bf-docboard@blender.org">bf-docboard@blender.org</a>><br>
Message-ID:<br>
<CAEX7TpVYsKMaCtoh4=<a href="mailto:BmAb2o7VMSO0_oiWcJ3i_kFbtjBobF%2Bw@mail.gmail.com">BmAb2o7VMSO0_oiWcJ3i_kFbtjBobF+w@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
We may want to include this in trunk like we do with other .py tools in the<br>
main documentation repository, now that it is in python and everyone is<br>
able to use it.<br>
<br>
On Wed, Dec 23, 2015 at 1:11 PM, Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
wrote:<br>
<br>
> Hi all,<br>
><br>
> I re-wrote the script in python,<br>
> it's now around 360 times as fast using python3<br>
> (and even 675 times when using pypy).<br>
><br>
> I overused grep before,<br>
> so it took the script 9 minutes to finish,<br>
> now it runs in approx. 1 second.<br>
><br>
> It also shows files with fuzzy strings in it<br>
> and should also run on windows.<br>
><br>
> Sincerely,<br>
> Anton Felix Lorenzen<br>
><br>
> Usage:<br>
> |- Paste into file named translations.py<br>
> |- "cd" into folder<br>
> |- execute python translations.py "C:\path\to\LC_MESSAGES"<br>
><br>
> Script:<br>
><br>
> #!/usr/bin/env python2<br>
> # -*- coding: utf-8 -*-<br>
> #<br>
> # Translations Tracker 1.0<br>
> # works best with pypy<br>
> #<br>
> # Copyright 2015 Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
> #<br>
> # Permission is hereby granted, free of charge,<br>
> # to any person obtaining a copy of this software<br>
> # and associated documentation files (the "Software"),<br>
> # to deal in the Software without restriction,<br>
> # including without limitation the rights to use, copy,<br>
> # modify, merge, publish, distribute, sublicense,<br>
> # and/or sell copies of the Software,<br>
> # and to permit persons to whom the Software is furnished to do so,<br>
> # subject to the following conditions:<br>
> #<br>
> # The above copyright notice and this permission notice<br>
> # shall be included in all copies or substantial portions of the Software.<br>
> #<br>
> # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> MERCHANTABILITY,<br>
> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
> # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
> CLAIM,<br>
> # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
> # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
> SOFTWARE<br>
> # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
><br>
> import os<br>
> import codecs<br>
> import sys<br>
><br>
> if(sys.argv and sys.argv[1]):<br>
> path = sys.argv[1]<br>
> else:<br>
> path = "~/locale/fr/LC_MESSAGES"<br>
><br>
> # Configuration<br>
> fileinfo = '{0[file]:>3} empty, {1[file]:>3} fuzzy of {2[file]:>3}; or<br>
> {3:.3f}% in {4}'<br>
> allinfo = 'Summary: {0[all]} empty of {1[all]}; or {2:.3f}%'<br>
> fuzzyinfo = 'Fuzzy: {0[all]} fuzzy strings in {0[filelist]}'<br>
><br>
> msgstrs = {'file': 0, 'all':0}<br>
> empty_msgstrs = {'file': 0, 'all': 0}<br>
> fuzzy = {'file': 0, 'all': 0, 'filelist': []}<br>
> lastLineWasEmptyMsgstr = False<br>
><br>
> def forAllInMap(m, fnk, cond):<br>
> for key in m:<br>
> if(cond(m[key])):<br>
> m[key] = fnk(m[key])<br>
><br>
> def forAllIntsInMap(m, fnk):<br>
> forAllInMap(m, fnk, lambda x: type(x)==int)<br>
><br>
> def increaseAllInMap(m):<br>
> forAllIntsInMap(m, lambda x: x+1)<br>
><br>
> def decreseAllInMap(m):<br>
> forAllIntsInMap(m, lambda x: x-1)<br>
><br>
> for (root, subs, files) in os.walk(path):<br>
> for name in files:<br>
> msgstrs['file'] = -1 # First lines contain a "fake" msgstr<br>
> msgstrs['all'] -= 1<br>
> empty_msgstrs['file'] = 0<br>
> fuzzy['file'] = 0<br>
> if name.endswith('.po'):<br>
> for line in codecs.open(os.path.join(root, name),<br>
> encoding='utf8'):<br>
> if(line[0] == 'm'):<br>
> if(line[0:6] == 'msgstr'):<br>
> increaseAllInMap(msgstrs)<br>
> if(line[0:9] == 'msgstr<br>
> ""'):<br>
><br>
> increaseAllInMap(empty_msgstrs)<br>
><br>
> lastLineWasEmptyMsgstr = True<br>
> else:<br>
> if(line[0] == '"'):<br>
> if(lastLineWasEmptyMsgstr):<br>
><br>
> decreseAllInMap(empty_msgstrs)<br>
><br>
> lastLineWasEmptyMsgstr = False<br>
> else:<br>
> lastLineWasEmptyMsgstr =<br>
> False<br>
> if('fuzzy' in line):<br>
><br>
> increaseAllInMap(fuzzy)<br>
> fuzzy['filelist']<br>
> += [name]<br>
><br>
> print(fileinfo.format(empty_msgstrs, fuzzy, msgstrs,<br>
> float(empty_msgstrs['file'] + fuzzy['file']) /<br>
> msgstrs['file'],<br>
> os.path.join(root[len(path):], name)))<br>
><br>
> print(allinfo.format(empty_msgstrs, msgstrs, float(empty_msgstrs['all'])<br>
> / msgstrs['all']))<br>
> print(fuzzyinfo.format(fuzzy))<br>
> _______________________________________________<br>
> Bf-docboard mailing list<br>
> <a href="mailto:Bf-docboard@blender.org">Bf-docboard@blender.org</a><br>
> <a href="http://lists.blender.org/mailman/listinfo/bf-docboard" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-docboard</a><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.blender.org/pipermail/bf-docboard/attachments/20151223/29230808/attachment.html" rel="noreferrer" target="_blank">http://lists.blender.org/pipermail/bf-docboard/attachments/20151223/29230808/attachment.html</a><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 24 Dec 2015 13:49:39 +1100<br>
From: Campbell Barton <<a href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>><br>
Subject: Re: [Bf-docboard] Translations Tracker<br>
To: Blender Documentation Project <<a href="mailto:bf-docboard@blender.org">bf-docboard@blender.org</a>><br>
Message-ID:<br>
<CAEcf3NztKz6fvQrktgZqH37hndXnjux49OogKBYnR_=<a href="mailto:dHJ0VZQ@mail.gmail.com">dHJ0VZQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
Tools like this are handy to keep in our repos.<br>
<br>
Made some changes:<br>
- Show percentages from 0-100, 100 when complete.<br>
- Use argparse for argument handling.<br>
- Add a --quiet option to only report the summary.<br>
- Avoid dictionary access for typical vars.<br>
- Use a set for listing fuzzy files (not to print then many times)<br>
- Move strings for reporting inline.<br>
- Can take multiple path arguments (report for each language).<br>
- Take report as an argument,<br>
(to override print if we want to use multi-processing later).<br>
<br>
Gives overall 6x speedup here,<br>
<br>
Committed <a href="https://developer.blender.org/rBM1029" rel="noreferrer" target="_blank">https://developer.blender.org/rBM1029</a><br>
<br>
On Thu, Dec 24, 2015 at 10:39 AM, Aaron Carlisle<br>
<<a href="mailto:carlisle.aaron00@gmail.com">carlisle.aaron00@gmail.com</a>> wrote:<br>
> We may want to include this in trunk like we do with other .py tools in the<br>
> main documentation repository, now that it is in python and everyone is able<br>
> to use it.<br>
><br>
> On Wed, Dec 23, 2015 at 1:11 PM, Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
> wrote:<br>
>><br>
>> Hi all,<br>
>><br>
>> I re-wrote the script in python,<br>
>> it's now around 360 times as fast using python3<br>
>> (and even 675 times when using pypy).<br>
>><br>
>> I overused grep before,<br>
>> so it took the script 9 minutes to finish,<br>
>> now it runs in approx. 1 second.<br>
>><br>
>> It also shows files with fuzzy strings in it<br>
>> and should also run on windows.<br>
>><br>
>> Sincerely,<br>
>> Anton Felix Lorenzen<br>
>><br>
>> Usage:<br>
>> |- Paste into file named translations.py<br>
>> |- "cd" into folder<br>
>> |- execute python translations.py "C:\path\to\LC_MESSAGES"<br>
>><br>
>> Script:<br>
>><br>
>> #!/usr/bin/env python2<br>
>> # -*- coding: utf-8 -*-<br>
>> #<br>
>> # Translations Tracker 1.0<br>
>> # works best with pypy<br>
>> #<br>
>> # Copyright 2015 Anton Felix Lorenzen <<a href="mailto:anfelor@web.de">anfelor@web.de</a>><br>
>> #<br>
>> # Permission is hereby granted, free of charge,<br>
>> # to any person obtaining a copy of this software<br>
>> # and associated documentation files (the "Software"),<br>
>> # to deal in the Software without restriction,<br>
>> # including without limitation the rights to use, copy,<br>
>> # modify, merge, publish, distribute, sublicense,<br>
>> # and/or sell copies of the Software,<br>
>> # and to permit persons to whom the Software is furnished to do so,<br>
>> # subject to the following conditions:<br>
>> #<br>
>> # The above copyright notice and this permission notice<br>
>> # shall be included in all copies or substantial portions of the<br>
>> Software.<br>
>> #<br>
>> # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
>> # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
>> MERCHANTABILITY,<br>
>> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
>> # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
>> CLAIM,<br>
>> # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
>> # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
>> SOFTWARE<br>
>> # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
>><br>
>> import os<br>
>> import codecs<br>
>> import sys<br>
>><br>
>> if(sys.argv and sys.argv[1]):<br>
>> path = sys.argv[1]<br>
>> else:<br>
>> path = "~/locale/fr/LC_MESSAGES"<br>
>><br>
>> # Configuration<br>
>> fileinfo = '{0[file]:>3} empty, {1[file]:>3} fuzzy of {2[file]:>3}; or<br>
>> {3:.3f}% in {4}'<br>
>> allinfo = 'Summary: {0[all]} empty of {1[all]}; or {2:.3f}%'<br>
>> fuzzyinfo = 'Fuzzy: {0[all]} fuzzy strings in {0[filelist]}'<br>
>><br>
>> msgstrs = {'file': 0, 'all':0}<br>
>> empty_msgstrs = {'file': 0, 'all': 0}<br>
>> fuzzy = {'file': 0, 'all': 0, 'filelist': []}<br>
>> lastLineWasEmptyMsgstr = False<br>
>><br>
>> def forAllInMap(m, fnk, cond):<br>
>> for key in m:<br>
>> if(cond(m[key])):<br>
>> m[key] = fnk(m[key])<br>
>><br>
>> def forAllIntsInMap(m, fnk):<br>
>> forAllInMap(m, fnk, lambda x: type(x)==int)<br>
>><br>
>> def increaseAllInMap(m):<br>
>> forAllIntsInMap(m, lambda x: x+1)<br>
>><br>
>> def decreseAllInMap(m):<br>
>> forAllIntsInMap(m, lambda x: x-1)<br>
>><br>
>> for (root, subs, files) in os.walk(path):<br>
>> for name in files:<br>
>> msgstrs['file'] = -1 # First lines contain a "fake" msgstr<br>
>> msgstrs['all'] -= 1<br>
>> empty_msgstrs['file'] = 0<br>
>> fuzzy['file'] = 0<br>
>> if name.endswith('.po'):<br>
>> for line in codecs.open(os.path.join(root, name),<br>
>> encoding='utf8'):<br>
>> if(line[0] == 'm'):<br>
>> if(line[0:6] == 'msgstr'):<br>
>> increaseAllInMap(msgstrs)<br>
>> if(line[0:9] == 'msgstr<br>
>> ""'):<br>
>><br>
>> increaseAllInMap(empty_msgstrs)<br>
>><br>
>> lastLineWasEmptyMsgstr = True<br>
>> else:<br>
>> if(line[0] == '"'):<br>
>><br>
>> if(lastLineWasEmptyMsgstr):<br>
>><br>
>> decreseAllInMap(empty_msgstrs)<br>
>><br>
>> lastLineWasEmptyMsgstr = False<br>
>> else:<br>
>> lastLineWasEmptyMsgstr =<br>
>> False<br>
>> if('fuzzy' in line):<br>
>><br>
>> increaseAllInMap(fuzzy)<br>
>> fuzzy['filelist']<br>
>> += [name]<br>
>><br>
>> print(fileinfo.format(empty_msgstrs, fuzzy, msgstrs,<br>
>> float(empty_msgstrs['file'] + fuzzy['file']) /<br>
>> msgstrs['file'],<br>
>> os.path.join(root[len(path):], name)))<br>
>><br>
>> print(allinfo.format(empty_msgstrs, msgstrs, float(empty_msgstrs['all'])<br>
>> / msgstrs['all']))<br>
>> print(fuzzyinfo.format(fuzzy))<br>
>> _______________________________________________<br>
>> Bf-docboard mailing list<br>
>> <a href="mailto:Bf-docboard@blender.org">Bf-docboard@blender.org</a><br>
>> <a href="http://lists.blender.org/mailman/listinfo/bf-docboard" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-docboard</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Bf-docboard mailing list<br>
> <a href="mailto:Bf-docboard@blender.org">Bf-docboard@blender.org</a><br>
> <a href="http://lists.blender.org/mailman/listinfo/bf-docboard" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-docboard</a><br>
><br>
<br>
<br>
<br>
--<br>
- Campbell<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Bf-docboard mailing list<br>
<a href="mailto:Bf-docboard@blender.org">Bf-docboard@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-docboard" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-docboard</a><br>
<br>
<br>
End of Bf-docboard Digest, Vol 130, Issue 10<br>
********************************************<br>
</blockquote></div><br></div>