~vcs-imports/pybabel/trunk

« back to all changes in this revision

Viewing changes to babel/messages/pofile.py

  • Committer: fschwarz
  • Date: 2012-08-04 23:10:41 UTC
  • Revision ID: svn-v4:59ecc08e-a131-0410-9ea7-d4c0f28ac310:trunk:639
handle irregular multi-line msgstr (no "" as first line) gracefully (#171)

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    :return: the denormalized string
76
76
    :rtype: `unicode` or `str`
77
77
    """
78
 
    if string.startswith('""'):
79
 
        lines = []
80
 
        for line in string.splitlines()[1:]:
81
 
            lines.append(unescape(line))
 
78
    if '\n' in string:
 
79
        escaped_lines = string.splitlines()
 
80
        if string.startswith('""'):
 
81
            escaped_lines = escaped_lines[1:]
 
82
        lines = map(unescape, escaped_lines)
82
83
        return ''.join(lines)
83
84
    else:
84
85
        return unescape(string)
110
111
    ...         print (message.id, message.string)
111
112
    ...         print ' ', (message.locations, message.flags)
112
113
    ...         print ' ', (message.user_comments, message.auto_comments)
113
 
    (u'foo %(name)s', '')
 
114
    (u'foo %(name)s', u'')
114
115
      ([(u'main.py', 1)], set([u'fuzzy', u'python-format']))
115
116
      ([], [])
116
 
    ((u'bar', u'baz'), ('', ''))
 
117
    ((u'bar', u'baz'), (u'', u''))
117
118
      ([(u'main.py', 3)], set([]))
118
119
      ([u'A user comment'], [u'An auto comment'])
119
120