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