Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pogrep may output two po headers #2129

Open
claudep opened this issue Mar 13, 2012 · 3 comments
Open

pogrep may output two po headers #2129

claudep opened this issue Mar 13, 2012 · 3 comments
Labels
Milestone

Comments

@claudep
Copy link
Member

claudep commented Mar 13, 2012

Version: trunk

When I'm running pogrep (specifically with invert-match), I'm getting a resulting po file with two headers. We already discussed it with Friedel on IRC. A quick-and-dirty patch:

--- /home/users/claudep/pogrep.py   2012-03-13 12:21:34.000000000 +0000
+++ python-packages/lib/python2.6/dist-packages/translate/tools/pogrep.py   2011-06-22 17:47:35.000000000 +0000
@@ -216,6 +216,7 @@
     def filterfile(self, thefile):
         """runs filters on a translation file object"""
         thenewfile = type(thefile)()
-        thenewfile.units = []
       thenewfile.setsourcelanguage(thefile.sourcelanguage)
       thenewfile.settargetlanguage(thefile.targetlanguage)
       for unit in thefile.units:

Another try at higher level:

--- translate/storage/base.py   2011-05-15 20:14:19.000000000 +0200
+++ /home/claude/.../translate/storage/base.py  2012-03-13 14:17:21.759808031 +0100
@@ -543,6 +543,9 @@
         @param unit: The unit that will be added.
         """
         unit._store = self
-        # Prevent two header units in the same store
-        if unit.isheader() and len(self.units) and self.units[0].isheader():
-            self.units[0] = unit
-        else:
-            self.units.append(unit)
- 
     self.units.append(unit)
  
   def addsourceunit(self, source):
@friedelwolff
Copy link
Member

I also got this now with a simple grep (not inverted match).

@friedelwolff
Copy link
Member

From a quick look, I think your second approach is good, except that it should only be done for PO clases (we have a few). So we could maybe put this in pocommon, but at least cpo.py currently also overrides addunit, so we might want to fix it there as well.

@claudep claudep added the tools label Jul 27, 2014
@claudep
Copy link
Member Author

claudep commented Feb 24, 2017

This is still an issue in 2.0. I see that Friedel fixed a similar issue for posegment in a4ac704 and 81ae442.

@unho unho added this to the 2.0.1 milestone Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants