-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
194 lines (159 loc) · 6.75 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
from setuptools import setup, Command
import datetime
import gettext
import os
import platform
import site
gettext.install('filenamelength', 'filenamelength/locale')
class Doxygen(Command):
description = "Create/update doxygen documentation in doc/html"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("Creating Doxygen Documentation")
os.system("""sed -i -e "41d" doc/Doxyfile""")#Delete line 41
os.system("""sed -i -e "41iPROJECT_NUMBER = {}" doc/Doxyfile""".format(__version__))#Insert line 41
os.system("rm -Rf build")
os.chdir("doc")
os.system("doxygen Doxyfile")
os.system("rsync -avzP -e 'ssh -l turulomio' html/ frs.sourceforge.net:/home/users/t/tu/turulomio/userweb/htdocs/doxygen/filenamelength/ --delete-after")
os.chdir("..")
class Procedure(Command):
description = "Create/update doxygen documentation in doc/html"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print(_("New Release:"))
print(_(" * Change version and date in version.py"))
print(_(" * Edit Changelog in README"))
print(" * python setup.py doc")
print(" * mcedit locale/es.po")
print(" * python setup.py doc")
print(" * python setup.py install")
print(" * python setup.py doxygen")
print(" * git commit -a -m 'filenamelength-{}'".format(__version__))
print(" * git push")
print(_(" * Make a new tag in github"))
print(" * python setup.py sdist upload -r pypi")
print(" * python setup.py uninstall")
print(_(" * Create a new gentoo ebuild with the new version"))
print(_(" * Upload to portage repository"))
class Uninstall(Command):
description = "Uninstall installed files with install"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
if platform.system()=="Linux":
os.system("rm -Rf {}/filenamelength*".format(site.getsitepackages()[0]))
os.system("rm /usr/bin/filenamelength")
os.system("rm /usr/share/man/man1/filenamelength.1")
os.system("rm /usr/share/man/es/man1/filenamelength.1")
else:
print(_("Uninstall command only works in Linux"))
class Compile(Command):
description = "Compile ui and images"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from sys import path
path.append("filenamelength")
from github import download_from_github
download_from_github('turulomio','reusingcode','python/decorators.py', 'filenamelength')
download_from_github('turulomio','reusingcode','python/libmanagers.py', 'filenamelength')
download_from_github('turulomio','reusingcode','python/github.py', 'filenamelength')
download_from_github('turulomio','reusingcode','python/datetime_functions.py', 'filenamelength')
class Doc(Command):
description = "Update man pages and translations"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
#es
os.system("xgettext -L Python --no-wrap --no-location --from-code='UTF-8' -o locale/filenamelength.pot *.py filenamelength/*.py")
os.system("msgmerge -N --no-wrap -U locale/es.po locale/filenamelength.pot")
os.system("msgfmt -cv -o filenamelength/locale/es/LC_MESSAGES/filenamelength.mo locale/es.po")
for language in ["en", "es"]:
self.mangenerator(language)
def mangenerator(self, language):
"""
Create man pages for parameter language
"""
from mangenerator import Man
if language=="en":
gettext.install('filenamelength', 'badlocale')
man=Man("man/man1/filenamelength")
else:
lang1=gettext.translation('filenamelength', 'filenamelength/locale', languages=[language])
lang1.install()
man=Man("man/es/man1/filenamelength")
print(" - DESCRIPTION in {} is {}".format(language, _("DESCRIPTION")))
man.setMetadata("filenamelength", 1, datetime.date.today(), "Mariano Muñoz", _("Admin options to work with the max length of the name of your files"))
man.setSynopsis("""usage: filenamelength [-h] [--version]
[--create_examples | --remove_examples | --minimum MINIMUM]
[--order_by_length]""")
man.header(_("DESCRIPTION"), 1)
man.paragraph(_("This app has the following mandatory parameters:"), 1)
man.paragraph("--create_example", 2, True)
man.paragraph(_("With --pretend and --remove you can use this parameters:"), 1)
########################################################################
## Version of modele captured from version to avoid problems with package dependencies
__version__= None
with open('filenamelength/version.py', encoding='utf-8') as f:
for line in f.readlines():
if line.find("__version__ =")!=-1:
__version__=line.split("'")[1]
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
if platform.system()=="Linux":
data_files=[('/usr/share/man/man1/', ['man/man1/filenamelength.1']),
('/usr/share/man/es/man1/', ['man/es/man1/filenamelength.1'])
]
else:
data_files=[]
setup(name='filenamelength',
version=__version__,
description='Admin options to work with the max length of the name of your files',
long_description=long_description,
long_description_content_type='text/markdown',
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
],
keywords='remove files datetime patterns',
url='https://too-many-files.sourceforge.io/',
author='Turulomio',
author_email='[email protected]',
license='GPL-3',
packages=['filenamelength'],
entry_points = {'console_scripts': ['filenamelength=filenamelength.filenamelength:main',
],
},
install_requires=['colorama','setuptools'],
data_files=data_files,
cmdclass={
'doxygen': Doxygen,
'doc': Doc,
'uninstall':Uninstall,
'procedure': Procedure,
'compile': Compile,
},
zip_safe=False,
include_package_data=True
)
_=gettext.gettext#To avoid warnings