gtparse fails on this file

Bug #848950 reported by TLE
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
PyG3T
Won't Fix
High
Ask Hjorth Larsen

Bug Description

When trying to use the latest trunk version (revision 65) of gtgrep on the attached file it fails

knielsen@knielsen-ThinkPad-T61:~/Dropbox/translations/evolution/3-2$ gtgrep -i reminder evolution.master.da.po
Traceback (most recent call last):
  File "/home/knielsen/code/pyg3t/bin/gtgrep", line 5, in <module>
    gtgrep.main()
  File "/home/knielsen/code/pyg3t/pyg3t/gtgrep.py", line 229, in main
    cat = parse(input)
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 553, in parse
    for chunk in chunk_iter(input, include_obsoletes=True):
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 503, in get_message_chunks
    line, msgctxt = _extract_string(line, input, patterns['msgctxt'])
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 467, in _extract_string
    string = extract_string(lines, header)
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 424, in extract_string
    raise PoSyntaxError('%s not found. Line was: %s' % (header, line))
pyg3t.gtparse.PoSyntaxError: msgctxt " not found. Line was: msgctxt "cal-reminders"

Revision history for this message
TLE (k-nielsen81) wrote :
Revision history for this message
TLE (k-nielsen81) wrote :

Ok, so this is actually a gtparse error. The problem as I could see it is that the method extract_string does this:
if not line.startswith(header + ' "'):
but for some reason the header for the msgctxt already contains its ' "', so it can be fixed by this diff:

=== modified file 'pyg3t/gtparse.py'
--- pyg3t/gtparse.py 2011-06-19 17:20:03 +0000
+++ pyg3t/gtparse.py 2011-09-14 12:37:27 +0000
@@ -430,7 +430,7 @@
     return ''.join([headerline] + otherlines)

 linepatterns = dict(comment='#',
- msgctxt='msgctxt "',
+ msgctxt='msgctxt', # Used to be 'msgctxt "'
                     msgid='msgid',
                     msgid_plural='msgid_plural',
                     msgstr='msgstr',

However, I cannot really see if there is a particular reason that it was like that.

summary: - gtgrep fails on this file
+ gtparse fails on this file
Revision history for this message
TLE (k-nielsen81) wrote :

After having fixed the bug above I ran into another one, which as far as I can see is unrelated:

Traceback (most recent call last):
  File "/home/knielsen/code/pyg3t/bin/podiff", line 5, in <module>
    podiff.main()
  File "/home/knielsen/code/pyg3t/pyg3t/podiff.py", line 278, in main
    cat_old = parse(open(args[0]))
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 554, in parse
    for chunk in chunk_iter(input, include_obsoletes=True):
  File "/home/knielsen/code/pyg3t/pyg3t/gtparse.py", line 503, in get_message_chunks
    if line.startswith(patterns['msgctxt']):
AttributeError: 'NoneType' object has no attribute 'startswith'

As far as I can tell it is triggerede when the parser encounters a translator created comment in the obsolete part. The part the triggers the fist error is this one:

# Jeg har fjernet mellemrum før ?, idet jeg antager at det er en fejl.
# Følg op på fejlrapport: https://bugzilla.gnome.org/show_bug.cgi?id=595002
#~ msgid ""
#~ "Retracting a message may remove it from the recipient's mailbox. Are you "
#~ "sure you want to do this?"
#~ msgstr ""
#~ "At tilbagetrække en besked kan fjerne den fra modtagerens brevbakke. Er "
#~ "du sikker på, at du ønsker at gøre dette?"

It also responds to fuzzys in the obsolotes, like this one:

#, fuzzy
#~ msgid "Migrate local mbox folders to maildir"
#~ msgstr "Opret en ny mappe til at gemme post i"

So I'm assuming that the problem is that there is content in the obsolete section that has no #~ in front of it. The problem is what to do with it. As far as I could tell from the gettext documentation page, the only requirement for an obsolete section is that the whole thing is a comment, and since that is true here, it may in fact be legal syntax.

However I'm unsure of how to fix this, or if having

Changed in pyg3t:
assignee: nobody → Ask Hjorth Larsen (askhl)
status: New → Fix Committed
importance: Undecided → High
TLE (k-nielsen81)
Changed in pyg3t:
status: Fix Committed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.