pg.ddx.io  pgsql-translators@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-translators@postgresql.org
Subject: Re: branching time
Date: Sun, 28 Apr 2019 13:37:33 -0400
Message-ID: <20190428173733.GA12483@alvherre.pgsql> (raw)
In-Reply-To: <94cfe030-61d0-4b01-2d3a-603e7c326bf1@2ndquadrant.com>

On 2019-Apr-26, Peter Eisentraut wrote:
> On 2019-04-26 20:14, Alvaro Herrera wrote:

> > I think we need to write a filter program that compares MSGFILTER_MSGID
> > to MSGFILTER_PREV_MSGID, and if the only difference is the leading "%s: " 
> > and the trailing "\n", then strip those thing from stdin and write that
> > to stdout.
> 
> I didn't do it that way, which explains the above problems.  We can try
> it a few more times. :)

I wrote one today.  I first tried doing it in bash, which is probably
gonna give me nightmares tonight, so it ended up in Perl.  It's below in
case someone wants to give it a go.  You run it like

  msgfilter -i somefile.po ./filter > somefile-2.po
  mv somefile-2.po somefile.po
(or you can use "sponge").

It wasn't as successful as I expected, mostly because msgfilter is
limited; it doesn't let you remove the "fuzzy" flag from the message
when you get a match, so you need to revise the file afterwards each
updated entry to remove the flag from each entry ... but of course there
are fuzzies for other reasons, so it's very error-prone.  Anyway, I
think it's much faster than doing it all by hand.  It took quite some
time to figure out a correct filter, because it's not clear how the '\n'
is represented in each place.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

filter (text/plain, 407B) download #!/usr/bin/perl use warnings; if (not defined $ENV{MSGFILTER_PREV_MSGID}) { while (<>) { print $_; } exit; } my $first = 1; if (("%s: " . $ENV{MSGFILTER_MSGID} . "\n") eq $ENV{MSGFILTER_PREV_MSGID}) { while ($l = <>) { if ($first) { $l =~ s/^%s: (.*)/$1/; $first = 0; } $l =~ s/\n$// if eof(STDIN); print $l; } } else { while (<>) { print $_; } exit; }

view thread (36+ messages)  latest in thread

Message-ID: <20190428173733.GA12483@alvherre.pgsql>
Permalink:  ../20190428173733.GA12483@alvherre.pgsql/
Also on:    postgresql.org/message-id/20190428173733.GA12483@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-translators@postgresql.org
  Cc: alvherre@2ndquadrant.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: branching time
  In-Reply-To: <20190428173733.GA12483@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox