if sort_output:
messages.sort()
elif sort_by_file:
- messages.sort(lambda x,y: cmp(x.locations, y.locations))
+ messages.sort(key=lambda m: m.locations)
for message in messages:
if not message.id: # This is the header "message"
msgstr[1] "Voeh"''' in value
assert value.find(b'msgid ""') < value.find(b'msgid "bar"') < value.find(b'msgid "foo"')
+ def test_file_sorted_po(self):
+ catalog = Catalog()
+ catalog.add(u'bar', locations=[('utils.py', 3)])
+ catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), locations=[('main.py', 1)])
+ buf = BytesIO()
+ pofile.write_po(buf, catalog, sort_by_file=True)
+ value = buf.getvalue().strip()
+ assert value.find(b'main.py') < value.find(b'utils.py')
+
def test_file_with_no_lineno(self):
catalog = Catalog()
catalog.add(u'bar', locations=[('utils.py', None)],