Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
[FIX] travis_transifex: Files timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Oct 13, 2016
1 parent d505592 commit 4cad6e5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions travis/travis_transifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from __future__ import unicode_literals
import os
import sys
import polib
import time
import subprocess
from slumber import API, exceptions
from odoo_connection import context_mapping, Odoo10Context
from test_server import setup_server, get_addons_path, \
Expand Down Expand Up @@ -143,27 +144,26 @@ def main(argv=None):
as odoo_context:
for module in addons_list:
print()
print(yellow("Downloading POT file for %s" % module))
print(yellow("Obtaining POT file for %s" % module))
i18n_folder = os.path.join(travis_build_dir, module, 'i18n')
source_filename = os.path.join(i18n_folder, module + ".pot")
# Create i18n/ directory if doesn't exist
if not os.path.exists(os.path.dirname(source_filename)):
os.makedirs(os.path.dirname(source_filename))
with open(source_filename, 'w') as f:
f.write(odoo_context.get_pot_contents(module))
# Strip out empty strings on PO files to avoid overwriting already
# translated strings in TX, but not pushed back to GH yet
# Put the correct timestamp for letting known tx client which
# translations to update
for po_file_name in os.listdir(i18n_folder):
if not po_file_name.endswith('.po'):
continue
po_file_name = os.path.join(i18n_folder, po_file_name)
st = os.stat(po_file_name) # Remember modification time
po_file = polib.pofile(po_file_name)
for entry in po_file.untranslated_entries():
po_file.remove(entry)
po_file.save(po_file_name)
# Overwrite modification time with the old one
os.utime(po_file_name, (st.st_atime, st.st_mtime))
command = ['git', 'log', '--pretty=format:%cd', '-n1',
'--date=raw', po_file_name]
timestamp = float(subprocess.check_output(command).split()[0])
# This converts to UTC the timestamp
timestamp = time.mktime(time.gmtime(timestamp))
os.utime(po_file_name, (timestamp, timestamp))

print()
print(yellow("Linking POT file and Transifex resource"))
Expand Down

0 comments on commit 4cad6e5

Please sign in to comment.