File: make_tr.py

package info (click to toggle)
dxf2gcode 20170925-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,992 kB
  • sloc: python: 12,624; xml: 38; makefile: 15
file content (86 lines) | stat: -rwxr-xr-x 2,785 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
Generates the tr file based on the defined PyQt Project File
"""

import os, sys
import subprocess

if "linux" in sys.platform.lower() or "unix" in sys.platform.lower():
    #On Linux, the executable are normaly on the PATH (just install which contains those executables)
    PLYPATH = "pylupdate5"
    LREPATH = None
    names = ["/usr/bin/lrelease-qt5", "/usr/bin/lrelease5", "/usr/bin/lrelease"]
    for name in names:
        if os.path.exists(name):
            LREPATH = name
            break

    if not LREPATH:
        print("ERROR: Cannot file lrelease tool.")
        print("Please consider to install lrelease tool - to use this script.")
        sys.exit(1)

    print("Using Linux platform tools \"%s\" and \"%s\"\n" % (PLYPATH, LREPATH))
else:
    PYTHONPATH = os.path.split(sys.executable)[0]
    # To get pylupdate5.exe use: pip3.exe install PyQt5
    PLYPATH = os.path.join(PYTHONPATH, "scripts/pylupdate5.exe")
    # To get lrelease.exe use: pip3.exe install pyqt5-tools
    LREPATH = os.path.join(PYTHONPATH, "Lib/site-packages/pyqt5-tools/lrelease.exe")
    print("Using Windows platform tools \"%s\" and \"%s\"\n" % (PLYPATH, LREPATH))

FILEPATH = os.path.realpath(os.path.dirname(sys.argv[0]))

FILES = ("../dxf2gcode/core/arcgeo.py",
         "../dxf2gcode/core/project.py",
         "../dxf2gcode/core/shape.py",
         "../dxf2gcode/dxfimport/geoent_arc.py",
         "../dxf2gcode/dxfimport/geoent_circle.py",
         "../dxf2gcode/dxfimport/geoent_line.py",
         "../dxf2gcode/dxfimport/importer.py",
         "../dxf2gcode/globals/config.py",
         "../dxf2gcode/gui/canvas.py",
         "../dxf2gcode/gui/canvas2d.py",
         "../dxf2gcode/gui/canvas3d.py",
         "../dxf2gcode/gui/configwindow.py",
         "../dxf2gcode/gui/messagebox.py",
         "../dxf2gcode/gui/popupdialog.py",
         "../dxf2gcode/gui/treehandling.py",
         "../dxf2gcode/postpro/postprocessor.py",
         "../dxf2gcode/postpro/postprocessorconfig.py",
         "../dxf2gcode/postpro/tspoptimisation.py",
         "../dxf2gcode.py",
         "../dxf2gcode.ui"
         )


TSFILES = ("dxf2gcode_de_DE.ts",
           "dxf2gcode_fr.ts",
           "dxf2gcode_ru.ts")

FILESSTR = ""
for FILE in FILES:
    FILESSTR += ("%s/i18n/%s " % (FILEPATH, FILE))

TSFILESTR = ""
for TSFILE in TSFILES:
    TSFILESTR += ("%s/i18n/%s " % (FILEPATH, TSFILE))

OPTIONS = "-ts"

if len(sys.argv) >= 2 and sys.argv[1] == '--no-pylupdate':
    print("skipping pylupdate")
else:
    cmd1 = ("%s %s %s %s\n" % (PLYPATH, FILESSTR, OPTIONS, TSFILESTR))
    print(cmd1)
    print(subprocess.call(cmd1, shell=True))

cmd2 = ("%s %s\n" % (LREPATH, TSFILESTR))
print(cmd2)
print(subprocess.call(cmd2, shell=True))

print("\nREADY")