[PATCH 5 of 6] check-code: detect "missing _() in ui message" more exactly

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Jun 1 14:54:09 EDT 2016


At Wed, 1 Jun 2016 23:56:10 +0900,
Yuya Nishihara wrote:
> 
> On Tue, 31 May 2016 14:57:52 -0400, timeless wrote:
> > FUJIWARA Katsunori wrote:
> > > This patch also applies "()" instead of "_()" on messages below to
> > > hide false-positives:
> > 
> > I'd really rather have a function for this. See the other thread where
> > you wanted to remove `_()`.
> 
> I don't get it. Why do we need a function for py3k? Can you elaborate?
> 
> > +    (r'ui\.(status|progress|write|note|warn)\('
> > +     # any strings might precede a string, which contains translatable message
> > +     '[ \t\n]*(([\'"]|\'\'\'|""")[^\'"]*([\'"]|\'\'\'|""")[ \t\n]+)*'
> > +     # sequence consisting of below might precede translatable message
> > +     # - formatting string ("% 10s", "%05d", "% -3.2f", "%*s" and so on)
> > +     # - escaped character ("\\", "\n", "\0", and so on)
> > +     # - character other than '%', 'b' (as '\') and 'x' (as alphabet)
> > +     #   (this can't use [^...] style, because _preparepats() forcibly
> > +     #    adds '\n' to such pattern )
> > +     '([\'"]|\'\'\'|""")'
> > +     '((%([ n]?[PM]?([0-9p]+|A))?x)|b[bnx]|[ \nnpqAPMo])*x',
> 
> r'' prefix is necessary for all string fragments. You might be interested in
> extended format (?x).
> 
> https://docs.python.org/2.7/library/re.html#re.X

I'll post revised one.

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list