Edric Milaret | 45e26d2 | 2016-05-06 12:09:17 -0400 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Guillaume Roguez | 0ba7a8c | 2017-07-13 13:41:36 -0400 | [diff] [blame] | 3 | ## |
| 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 Milaret | 45e26d2 | 2016-05-06 12:09:17 -0400 | [diff] [blame] | 24 | import os |
| 25 | import shutil |
| 26 | |
Guillaume Roguez | 0ba7a8c | 2017-07-13 13:41:36 -0400 | [diff] [blame] | 27 | print("== Updating from sources") |
| 28 | if os.system("lupdate RingWinClient.pro -no-obsolete"): |
| 29 | print("trying with 'lupdate-qt5'") |
Guillaume Roguez | 61200f4 | 2017-07-13 14:39:07 -0400 | [diff] [blame] | 30 | 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 Milaret | 45e26d2 | 2016-05-06 12:09:17 -0400 | [diff] [blame] | 32 | |
Guillaume Roguez | 0ba7a8c | 2017-07-13 13:41:36 -0400 | [diff] [blame] | 33 | print("== Pushing sources") |
| 34 | os.system("tx push -s") |
Edric Milaret | 45e26d2 | 2016-05-06 12:09:17 -0400 | [diff] [blame] | 35 | |
Guillaume Roguez | 0ba7a8c | 2017-07-13 13:41:36 -0400 | [diff] [blame] | 36 | print("== Pulling translations") |
| 37 | os.system("tx pull -af --minimum-perc=1") |
| 38 | |
| 39 | print("Updating .pro file") |
Edric Milaret | 45e26d2 | 2016-05-06 12:09:17 -0400 | [diff] [blame] | 40 | |
| 41 | translationFiles = [] |
| 42 | |
| 43 | for filename in os.listdir('./translations'): |
| 44 | translationFiles.append("translations/{0}".format(filename)) |
| 45 | |
| 46 | proFile = "RingWinClient.pro" |
| 47 | shutil.move(proFile, proFile + "~") |
| 48 | |
| 49 | destination = open(proFile, "w") |
| 50 | source = open(proFile + "~", "r") |
| 51 | for 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 | |
| 58 | source.close() |
| 59 | destination.close() |
| 60 | os.remove(proFile + "~") |
| 61 | |
Guillaume Roguez | 0ba7a8c | 2017-07-13 13:41:36 -0400 | [diff] [blame] | 62 | print("== All done you can commit now") |