forked from upgrades-migrations/redhat-upgrade-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
82 lines (71 loc) · 2.55 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
#!/usr/bin/python
from distutils.core import setup, Command
from distutils.util import convert_path
from distutils.command.build_scripts import build_scripts
from distutils import log
import os
from os.path import join, basename
from subprocess import check_call
class Gettext(Command):
description = "Use po/POTFILES.in to generate po/<name>.pot"
user_options = []
def initialize_options(self):
self.encoding = 'UTF-8'
self.po_dir = 'po'
self.add_comments = True
def finalize_options(self):
pass
def _xgettext(self, opts):
name = self.distribution.get_name()
version = self.distribution.get_version()
email = self.distribution.get_author_email()
cmd = ['xgettext', '--default-domain', name, '--package-name', name,
'--package-version', version, '--msgid-bugs-address', email,
'--from-code', self.encoding,
'--output', join(self.po_dir, name + '.pot')]
if self.add_comments:
cmd.append('--add-comments')
check_call(cmd + opts)
def run(self):
self._xgettext(['-f', 'po/POTFILES.in'])
class Msgfmt(Command):
description = "Generate po/*.mo from po/*.po"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
po_dir = 'po'
for po in os.listdir(po_dir):
po = join(po_dir, po)
if po.endswith('.po'):
mo = po[:-3]+'.mo'
check_call(['msgfmt', '-vv', po, '-o', mo])
class BuildScripts(build_scripts):
def run(self):
build_scripts.run(self)
for script in self.scripts:
script = convert_path(script)
outfile = join(self.build_dir, basename(script))
if os.path.exists(outfile) and outfile.endswith(".py"):
newfile = outfile[:-3] # drop .py
log.info("renaming %s -> %s", outfile, basename(newfile))
os.rename(outfile, newfile)
setup(name="redhat-upgrade-tool",
version="0.9.1",
description="Red Hat Upgrade",
long_description="",
author="Will Woods",
author_email="[email protected]",
url="https://github.com/dashea/redhat-upgrade-tool",
download_url="https://github.com/dashea/redhat-upgrade-tool/downloads",
license="GPLv2+",
packages=["redhat_upgrade_tool"],
scripts=["redhat-upgrade-tool.py"],
cmdclass={
'gettext': Gettext,
'msgfmt': Msgfmt,
'build_scripts': BuildScripts,
}
)