-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
134 lines (107 loc) · 3.72 KB
/
setup.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import os.path
from distutils.cmd import Command
from cx_Freeze import setup, Executable, build
from babel.messages import frontend as babel
WIN_NT = os.name == "nt"
catalogs = [
"en_US","en_GB","en_CA","en_AU","en_NZ","fr_FR","fr_CH","fr_CA","de_DE",
"es_ES","es_MX","es_VE","es_AR","pl_PL","pt_PT","pt_BR","tr_TR","ru_RU",
"fil_PH"
]
class CommandAdapter(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
class InitAll(CommandAdapter):
description = "Initialise all translation catalogs"
def run(self):
for catalog in catalogs:
babel_ic = babel.init_catalog(self.distribution)
babel_ic.initialize_options()
babel_ic.locale = catalog
babel_ic.input_file = "locale/rc_profit_calc.pot"
babel_ic.output_dir = "locale"
babel_ic.output_file = "locale/{}/LC_MESSAGES/rc_profit_calc.po".format(catalog)
babel_ic.finalize_options()
babel_ic.run()
class UpdateAll(CommandAdapter):
description = "Update all translation catalogs"
def run(self):
for catalog in catalogs:
babel_uc = babel.update_catalog(self.distribution)
babel_uc.initialize_options()
babel_uc.locale = catalog
babel_uc.input_file = "locale/rc_profit_calc.pot"
babel_uc.output_dir = "locale"
babel_uc.output_file = "locale/{}/LC_MESSAGES/rc_profit_calc.po".format(catalog)
babel_uc.finalize_options()
babel_uc.run()
class CompileAll(CommandAdapter):
description = "Compile all translation catalogs"
def run(self):
babel_cc = babel.compile_catalog(self.distribution)
babel_cc.domain = ["rc_profit_calc"]
babel_cc.directory = "./locale"
babel_cc.run()
class BuildWithCompile(build):
def run(self):
babel_cc = babel.compile_catalog(self.distribution)
babel_cc.domain = ["rc_profit_calc"]
babel_cc.directory = "./locale"
babel_cc.run()
super().run()
class ExtractMessages(CommandAdapter):
description = "Extract translation messages"
def run(self):
babel_em = babel.extract_messages(self.distribution)
babel_em.initialize_options()
babel_em.input_dirs = "."
babel_em.output_file = "locale/rc_profit_calc.pot"
babel_em.finalize_options()
babel_em.run()
def list_mo_files(folder, domain):
mo_files = []
for locale in os.listdir(folder):
if os.path.isdir(os.path.join(folder, locale)):
mo_files.append(os.path.join(folder, locale, "LC_MESSAGES",
domain + ".mo"))
return mo_files
SRC_PATH = os.path.dirname(__file__)
include_files = []
for mo_file in list_mo_files("locale", "rc_profit_calc"):
include_files.append(
(os.path.join(SRC_PATH, mo_file), mo_file),
)
target_name = "Rollercoin Profit Calculator.exe" if WIN_NT else "rollercoin-profit-calculator"
executables = [
Executable(
"rc_profit_calc.py",
base=None,
targetName=target_name,
icon="icon.ico"
)
]
options = {
'build_exe': {
'packages': ["os"],
'optimize': 2,
'include_files': include_files
}
}
setup(
options=options,
name="Rollercoin Profit Calculator",
version="0.1.2",
description="Calculator that allows you to determine which cryptocurrency "
"is the most profitable to mine on the rollercoin.com site",
executables=executables,
cmdclass={
'build': BuildWithCompile,
'compile_catalogs': CompileAll,
'extract_messages': ExtractMessages,
'init_catalogs': InitAll,
'update_catalogs': UpdateAll
}
)