This repository has been archived by the owner on Apr 26, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
126 lines (96 loc) · 2.97 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
#!/usr/bin/env python
# coding: utf-8
"""
Em
--
Em is a terminal tool that prints FILE(s), or standard input to standard
output and highlights the expressions that are matched the PATTERN.
The expression will be highlighted iff the terminal is ANSI-compatible.
Em is Cool
``````````
.. code:: bash
$ tail -f /path/to/log | em "DEBUG|INFO" -f green | em "WARN"
Links
`````
* `documentation <http://em.readthedocs.org/>`_
* `source code <https://github.com/ikalnitsky/em>`_
"""
import os
import glob
import subprocess
from setuptools import setup, Command
install_requires = []
try:
import argparse # NOQA
except ImportError:
install_requires.append('argparse')
class LocaleUpdate(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
root = os.path.dirname(__file__)
src = os.path.join(root, 'em', '__init__.py')
pot = os.path.join(root, 'em', 'locale', 'em.pot')
pos = glob.glob(os.path.join(
root, 'em', 'locale', '*', 'LC_MESSAGES', 'em.po'))
# update .pot file
subprocess.call(['xgettext', src, '--output', pot])
# update .po files from .pot
for po in pos:
subprocess.call(['msgmerge', '--update', '--backup=off', po, pot])
class LocaleCompile(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
root = os.path.dirname(__file__)
pos = glob.glob(os.path.join(
root, 'em', 'locale', '*', 'LC_MESSAGES', 'em.po'))
# compile .po files to .mo
for po in pos:
mo = '{0}.mo'.format(os.path.splitext(po)[0])
subprocess.call(['msgfmt', po, '--output-file', mo])
setup(
name='em',
version='0.4.0',
url='https://github.com/ikalnitsky/em',
license='BSD',
author='Igor Kalnitsky',
author_email='[email protected]',
description="Highlight some PATTERN in terminal's STDOUT",
long_description=__doc__,
include_package_data=True,
packages=[
'em',
'em.tests',
],
install_requires=install_requires,
test_suite='em.tests',
entry_points={
'console_scripts': ['em = em:main'],
},
classifiers=[
'Topic :: Utilities',
'Environment :: Console',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: BSD License',
],
platforms=['Linux', 'MacOS', 'Unix'],
# add custom commands to manage locale files
cmdclass={
'locale_update': LocaleUpdate,
'locale_compile': LocaleCompile,
},
)