blob: 0264115e4eeb6e8c744b82c7c5a914e241373afa [file] [log] [blame]
Edric Milaret45e26d22016-05-06 12:09:17 -04001#!/usr/bin/python
2
Guillaume Roguez0ba7a8c2017-07-13 13:41:36 -04003##
4## Copyright (C) 2016-2017 Savoir-faire Linux Inc.
5##
6## Author: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com>
7## Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
8##
9## This program is free software; you can redistribute it and/or modify
10## it under the terms of the GNU General Public License as published by
11## the Free Software Foundation; either version 3 of the License, or
12## (at your option) any later version.
13##
14## This program is distributed in the hope that it will be useful,
15## but WITHOUT ANY WARRANTY; without even the implied warranty of
16## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17## GNU General Public License for more details.
18##
19## You should have received a copy of the GNU General Public License
20## along with this program; if not, write to the Free Software
21## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22##
23
Edric Milaret45e26d22016-05-06 12:09:17 -040024import os
25import shutil
26
Guillaume Roguez0ba7a8c2017-07-13 13:41:36 -040027print("== Updating from sources")
28if os.system("lupdate RingWinClient.pro -no-obsolete"):
29 print("trying with 'lupdate-qt5'")
Guillaume Roguez61200f42017-07-13 14:39:07 -040030 if os.system("lupdate-qt5 RingWinClient.pro -no-obsolete"):
31 raise RuntimeError("unable to find any suitable lupdate Qt tool on this system. Stopping")
Edric Milaret45e26d22016-05-06 12:09:17 -040032
Guillaume Roguez0ba7a8c2017-07-13 13:41:36 -040033print("== Pushing sources")
34os.system("tx push -s")
Edric Milaret45e26d22016-05-06 12:09:17 -040035
Guillaume Roguez0ba7a8c2017-07-13 13:41:36 -040036print("== Pulling translations")
37os.system("tx pull -af --minimum-perc=1")
38
39print("Updating .pro file")
Edric Milaret45e26d22016-05-06 12:09:17 -040040
41translationFiles = []
42
43for filename in os.listdir('./translations'):
44 translationFiles.append("translations/{0}".format(filename))
45
46proFile = "RingWinClient.pro"
47shutil.move(proFile, proFile + "~")
48
49destination = open(proFile, "w")
50source = open(proFile + "~", "r")
51for line in source:
52 if not ".ts" in line:
53 destination.write(line)
54 if "TRANSLATIONS = " in line:
55 for filename in translationFiles:
56 destination.write(" {0} \\\n".format(filename))
57
58source.close()
59destination.close()
60os.remove(proFile + "~")
61
Guillaume Roguez0ba7a8c2017-07-13 13:41:36 -040062print("== All done you can commit now")