Skip to content

Commit

Permalink
Fix Python 2.7 supporting
Browse files Browse the repository at this point in the history
  • Loading branch information
liminspace committed Apr 6, 2019
1 parent 911984f commit 0b72888
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.0.19 (2019-04-06)
===================
* Fix Python 2.7 supporting


0.0.18 (2019-04-06)
===================
* Added supporting Django 2.2
Expand Down
2 changes: 1 addition & 1 deletion transtool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.0.18'
__version__ = '0.0.19'

default_app_config = 'transtool.apps.TrantoolConfig'
13 changes: 10 additions & 3 deletions transtool/tools.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
from datetime import datetime
import sys
import difflib
import os
import re
import polib
from datetime import datetime
from django.utils.encoding import force_str
from django.utils import timezone


lc_dir_re = re.compile(r'^.*?locale/[\w\-]{2,5}/LC_MESSAGES$')


def list_clear(list_obj):
if sys.version_info >= (3, 5):
list_obj.clear()
del list_obj[:]


def get_lc_files_list(search_root, exts=('.po', '.mo')):
"""
Returns list of tuple (absolute path, relative path)
Expand All @@ -29,10 +36,10 @@ def get_diff_po(po1_fn, po2_fn):
po1_lines = []
po2_lines = []
for entry in sorted(polib.pofile(po1_fn, wrapwidth=8000), key=lambda obj: obj.msgid):
entry.occurrences.clear()
list_clear(entry.occurrences)
po1_lines.append(force_str(entry))
for entry in sorted(polib.pofile(po2_fn, wrapwidth=8000), key=lambda obj: obj.msgid):
entry.occurrences.clear()
list_clear(entry.occurrences)
po2_lines.append(force_str(entry))
added = removed = 0
for diff_line in difflib.unified_diff(po1_lines, po2_lines):
Expand Down

0 comments on commit 0b72888

Please sign in to comment.