Updates to helper scripts
* Python 3 compatible * Consistent quote symbol
This commit is contained in:
parent
23cbd581db
commit
7d679eb480
|
@ -32,23 +32,20 @@ def create_gettext_js(js_dir):
|
||||||
locations.append((os.path.basename(filename), lineno + 1))
|
locations.append((os.path.basename(filename), lineno + 1))
|
||||||
strings[string] = locations
|
strings[string] = locations
|
||||||
|
|
||||||
keys = strings.keys()
|
gettext_tpl = '''GetText={maps:{},\
|
||||||
keys.sort()
|
|
||||||
|
|
||||||
gettext_tpl = """GetText={maps:{},\
|
|
||||||
add:function(string,translation) {this.maps[string]=translation},\
|
add:function(string,translation) {this.maps[string]=translation},\
|
||||||
get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}}
|
get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}}
|
||||||
function _(string) {return GetText.get(string)}\
|
function _(string) {return GetText.get(string)}\
|
||||||
"""
|
'''
|
||||||
|
|
||||||
gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js')
|
gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js')
|
||||||
with open(gettext_file, 'w') as fp:
|
with open(gettext_file, 'w') as fp:
|
||||||
fp.write(gettext_tpl)
|
fp.write(gettext_tpl)
|
||||||
for key in keys:
|
for key in sorted(strings.keys()):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
fp.write('\n// %s\n' % ', '.join(map(lambda x: '%s:%s' % x, strings[key])))
|
fp.write('\n// %s\n' % ', '.join(['%s:%s' % x for x in strings[key]]))
|
||||||
fp.write("GetText.add('%(key)s','${escape(_(\"%(key)s\"))}')\n" % locals())
|
fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
create_gettext_js(WEBUI_JS_DIR)
|
create_gettext_js(WEBUI_JS_DIR)
|
||||||
print "Created %s" % WEBUI_JS_DIR
|
print('Created %s' % WEBUI_JS_DIR)
|
||||||
|
|
|
@ -58,7 +58,7 @@ for (dirpath, dirnames, filenames) in os.walk("deluge"):
|
||||||
call(["intltool-extract", "--quiet", "--type=gettext/glade", filepath])
|
call(["intltool-extract", "--quiet", "--type=gettext/glade", filepath])
|
||||||
to_translate.append(filepath + ".h")
|
to_translate.append(filepath + ".h")
|
||||||
|
|
||||||
with open(INFILES_LIST, "wb") as f:
|
with open(INFILES_LIST, "w") as f:
|
||||||
for line in to_translate:
|
for line in to_translate:
|
||||||
f.write(line + "\n")
|
f.write(line + "\n")
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ for (dirpath, dirnames, filenames) in os.walk(WEBUI_RENDER_DIR):
|
||||||
if os.path.splitext(filename)[1] == ".html":
|
if os.path.splitext(filename)[1] == ".html":
|
||||||
js_to_translate.append(os.path.join(dirpath, filename))
|
js_to_translate.append(os.path.join(dirpath, filename))
|
||||||
|
|
||||||
with open(INFILES_LIST, "wb") as f:
|
with open(INFILES_LIST, "w") as f:
|
||||||
for line in js_to_translate:
|
for line in js_to_translate:
|
||||||
f.write(line + "\n")
|
f.write(line + "\n")
|
||||||
|
|
||||||
|
@ -107,4 +107,4 @@ for filepath in to_translate:
|
||||||
# Update web js gettext
|
# Update web js gettext
|
||||||
create_gettext_js(WEBUI_JS_DIR)
|
create_gettext_js(WEBUI_JS_DIR)
|
||||||
|
|
||||||
print "Created %s and updated gettext.js" % POT_FILEPATH
|
print("Created %s and updated gettext.js" % POT_FILEPATH)
|
||||||
|
|
|
@ -92,12 +92,12 @@ def minify_js_dir(source_dir):
|
||||||
source_files = source_files_list(source_dir)
|
source_files = source_files_list(source_dir)
|
||||||
|
|
||||||
if not source_files:
|
if not source_files:
|
||||||
print 'No js files found, skipping %s' % source_dir
|
print('No js files found, skipping %s' % source_dir)
|
||||||
return
|
return
|
||||||
|
|
||||||
concat_src_files(source_files, file_debug_js)
|
concat_src_files(source_files, file_debug_js)
|
||||||
minify_file(file_debug_js, file_minified_js)
|
minify_file(file_debug_js, file_minified_js)
|
||||||
print 'Minified %s' % source_dir
|
print('Minified %s' % source_dir)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
|
|
162
setup.py
162
setup.py
|
@ -58,7 +58,7 @@ class BuildTranslations(cmd.Command):
|
||||||
description = 'Compile .po files into .mo files & create .desktop file'
|
description = 'Compile .po files into .mo files & create .desktop file'
|
||||||
|
|
||||||
user_options = [
|
user_options = [
|
||||||
('build-lib', None, "lib build folder"),
|
('build-lib', None, 'lib build folder'),
|
||||||
('develop', 'D', 'Compile translations in develop mode (deluge/i18n)')
|
('develop', 'D', 'Compile translations in develop mode (deluge/i18n)')
|
||||||
]
|
]
|
||||||
boolean_options = ['develop']
|
boolean_options = ['develop']
|
||||||
|
@ -118,10 +118,10 @@ class BuildTranslations(cmd.Command):
|
||||||
|
|
||||||
|
|
||||||
class BuildPlugins(cmd.Command):
|
class BuildPlugins(cmd.Command):
|
||||||
description = "Build plugins into .eggs"
|
description = 'Build plugins into .eggs'
|
||||||
|
|
||||||
user_options = [
|
user_options = [
|
||||||
('install-dir=', None, "develop install folder"),
|
('install-dir=', None, 'develop install folder'),
|
||||||
('develop', 'D', 'Compile plugins in develop mode')
|
('develop', 'D', 'Compile plugins in develop mode')
|
||||||
]
|
]
|
||||||
boolean_options = ['develop']
|
boolean_options = ['develop']
|
||||||
|
@ -135,21 +135,21 @@ class BuildPlugins(cmd.Command):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Build the plugin eggs
|
# Build the plugin eggs
|
||||||
plugin_path = "deluge/plugins/*"
|
plugin_path = 'deluge/plugins/*'
|
||||||
|
|
||||||
for path in glob.glob(plugin_path):
|
for path in glob.glob(plugin_path):
|
||||||
if os.path.exists(os.path.join(path, "setup.py")):
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
||||||
if self.develop and self.install_dir:
|
if self.develop and self.install_dir:
|
||||||
os.system("cd " + path + "&& " + sys.executable +
|
os.system('cd ' + path + '&& ' + sys.executable +
|
||||||
" setup.py develop --install-dir=%s" % self.install_dir)
|
' setup.py develop --install-dir=%s' % self.install_dir)
|
||||||
elif self.develop:
|
elif self.develop:
|
||||||
os.system("cd " + path + "&& " + sys.executable + " setup.py develop")
|
os.system('cd ' + path + '&& ' + sys.executable + ' setup.py develop')
|
||||||
else:
|
else:
|
||||||
os.system("cd " + path + "&& " + sys.executable + " setup.py bdist_egg -d ..")
|
os.system('cd ' + path + '&& ' + sys.executable + ' setup.py bdist_egg -d ..')
|
||||||
|
|
||||||
|
|
||||||
class EggInfoPlugins(cmd.Command):
|
class EggInfoPlugins(cmd.Command):
|
||||||
description = "create a distribution's .egg-info directory"
|
description = 'Create .egg-info directories for plugins'
|
||||||
|
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
|
@ -161,24 +161,24 @@ class EggInfoPlugins(cmd.Command):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Build the plugin eggs
|
# Build the plugin eggs
|
||||||
plugin_path = "deluge/plugins/*"
|
plugin_path = 'deluge/plugins/*'
|
||||||
|
|
||||||
for path in glob.glob(plugin_path):
|
for path in glob.glob(plugin_path):
|
||||||
if os.path.exists(os.path.join(path, "setup.py")):
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
||||||
os.system("cd " + path + "&& " + sys.executable + " setup.py egg_info")
|
os.system('cd ' + path + '&& ' + sys.executable + ' setup.py egg_info')
|
||||||
|
|
||||||
|
|
||||||
class Build(_build):
|
class Build(_build):
|
||||||
sub_commands = [('build_trans', None), ('build_plugins', None)] + _build.sub_commands
|
sub_commands = [('build_trans', None), ('build_plugins', None)] + _build.sub_commands
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Run all sub-commands (at least those that need to be run)
|
# Run all sub-commands (at least those that need to be run).
|
||||||
_build.run(self)
|
_build.run(self)
|
||||||
try:
|
try:
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
print "Found libtorrent version: %s" % lt.version
|
print('Found libtorrent version: %s' % lt.version)
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
print "Warning libtorrent not found: %s" % e
|
print('Warning libtorrent not found: %s' % e)
|
||||||
|
|
||||||
|
|
||||||
class InstallData(_install_data):
|
class InstallData(_install_data):
|
||||||
|
@ -194,10 +194,8 @@ class InstallData(_install_data):
|
||||||
|
|
||||||
|
|
||||||
class CleanPlugins(cmd.Command):
|
class CleanPlugins(cmd.Command):
|
||||||
description = "Cleans the plugin folders"
|
description = 'Cleans the plugin folders'
|
||||||
user_options = [
|
user_options = [('all', 'a', 'Remove all build output, not just temporary by-products')]
|
||||||
('all', 'a', "remove all build output, not just temporary by-products")
|
|
||||||
]
|
|
||||||
boolean_options = ['all']
|
boolean_options = ['all']
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
|
@ -207,37 +205,37 @@ class CleanPlugins(cmd.Command):
|
||||||
self.set_undefined_options('clean', ('all', 'all'))
|
self.set_undefined_options('clean', ('all', 'all'))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print("Cleaning the plugin's folders..")
|
print('Cleaning the plugin\'s folders...')
|
||||||
|
|
||||||
plugin_path = "deluge/plugins/*"
|
plugin_path = 'deluge/plugins/*'
|
||||||
|
|
||||||
for path in glob.glob(plugin_path):
|
for path in glob.glob(plugin_path):
|
||||||
if os.path.exists(os.path.join(path, "setup.py")):
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
||||||
c = "cd " + path + " && " + sys.executable + " setup.py clean"
|
c = 'cd ' + path + ' && ' + sys.executable + ' setup.py clean'
|
||||||
if self.all:
|
if self.all:
|
||||||
c += " -a"
|
c += ' -a'
|
||||||
print("Calling '%s'" % c)
|
print('Calling \'%s\'' % c)
|
||||||
os.system(c)
|
os.system(c)
|
||||||
|
|
||||||
# Delete the .eggs
|
# Delete the .eggs
|
||||||
if path[-4:] == ".egg":
|
if path[-4:] == '.egg':
|
||||||
print("Deleting %s" % path)
|
print('Deleting %s' % path)
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
egg_info_dir_path = "deluge/plugins/*/*.egg-info"
|
egg_info_dir_path = 'deluge/plugins/*/*.egg-info'
|
||||||
|
|
||||||
for path in glob.glob(egg_info_dir_path):
|
for path in glob.glob(egg_info_dir_path):
|
||||||
# Delete the .egg-info's directories
|
# Delete the .egg-info's directories
|
||||||
if path[-9:] == ".egg-info":
|
if path[-9:] == '.egg-info':
|
||||||
print("Deleting %s" % path)
|
print('Deleting %s' % path)
|
||||||
for fpath in os.listdir(path):
|
for fpath in os.listdir(path):
|
||||||
os.remove(os.path.join(path, fpath))
|
os.remove(os.path.join(path, fpath))
|
||||||
os.removedirs(path)
|
os.removedirs(path)
|
||||||
|
|
||||||
root_egg_info_dir_path = "deluge*.egg-info"
|
root_egg_info_dir_path = 'deluge*.egg-info'
|
||||||
|
|
||||||
for path in glob.glob(root_egg_info_dir_path):
|
for path in glob.glob(root_egg_info_dir_path):
|
||||||
print("Deleting %s" % path)
|
print('Deleting %s' % path)
|
||||||
for fpath in os.listdir(path):
|
for fpath in os.listdir(path):
|
||||||
os.remove(os.path.join(path, fpath))
|
os.remove(os.path.join(path, fpath))
|
||||||
os.removedirs(path)
|
os.removedirs(path)
|
||||||
|
@ -253,7 +251,7 @@ class Clean(_clean):
|
||||||
_clean.run(self)
|
_clean.run(self)
|
||||||
|
|
||||||
if os.path.exists(desktop_data):
|
if os.path.exists(desktop_data):
|
||||||
print("Deleting %s" % desktop_data)
|
print('Deleting %s' % desktop_data)
|
||||||
os.remove(desktop_data)
|
os.remove(desktop_data)
|
||||||
|
|
||||||
cmdclass = {
|
cmdclass = {
|
||||||
|
@ -296,68 +294,68 @@ if not windows_check() and os.path.exists(desktop_data):
|
||||||
_data_files.append(('share/applications', [desktop_data]))
|
_data_files.append(('share/applications', [desktop_data]))
|
||||||
|
|
||||||
entry_points = {
|
entry_points = {
|
||||||
"console_scripts": [
|
'console_scripts': [
|
||||||
"deluge-console = deluge.ui.console:start",
|
'deluge-console = deluge.ui.console:start',
|
||||||
"deluge-web = deluge.ui.web:start",
|
'deluge-web = deluge.ui.web:start',
|
||||||
"deluged = deluge.main:start_daemon"
|
'deluged = deluge.main:start_daemon'
|
||||||
],
|
],
|
||||||
"gui_scripts": [
|
'gui_scripts': [
|
||||||
"deluge = deluge.main:start_ui",
|
'deluge = deluge.main:start_ui',
|
||||||
"deluge-gtk = deluge.ui.gtkui:start"
|
'deluge-gtk = deluge.ui.gtkui:start'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
if windows_check():
|
if windows_check():
|
||||||
entry_points["console_scripts"].extend([
|
entry_points['console_scripts'].extend([
|
||||||
"deluge-debug = deluge.main:start_ui",
|
'deluge-debug = deluge.main:start_ui',
|
||||||
"deluge-web-debug = deluge.ui.web:start",
|
'deluge-web-debug = deluge.ui.web:start',
|
||||||
"deluged-debug = deluge.main:start_daemon"])
|
'deluged-debug = deluge.main:start_daemon'])
|
||||||
|
|
||||||
# Main setup
|
# Main setup
|
||||||
setup(
|
setup(
|
||||||
name="deluge",
|
name='deluge',
|
||||||
version=get_version(prefix='deluge-', suffix='.dev0'),
|
version=get_version(prefix='deluge-', suffix='.dev0'),
|
||||||
fullname="Deluge Bittorrent Client",
|
fullname='Deluge Bittorrent Client',
|
||||||
description="Bittorrent Client",
|
description='Bittorrent Client',
|
||||||
author="Andrew Resch, Damien Churchill",
|
author='Andrew Resch, Damien Churchill',
|
||||||
author_email="andrewresch@gmail.com, damoxc@gmail.com",
|
author_email='andrewresch@gmail.com, damoxc@gmail.com',
|
||||||
keywords="torrent bittorrent p2p fileshare filesharing",
|
keywords='torrent bittorrent p2p fileshare filesharing',
|
||||||
long_description="""Deluge is a bittorrent client that utilizes a
|
long_description='''Deluge is a bittorrent client that utilizes a
|
||||||
daemon/client model. There are various user interfaces available for
|
daemon/client model. There are various user interfaces available for
|
||||||
Deluge such as the GTKui, the webui and a console ui. Deluge uses
|
Deluge such as the GTKui, the webui and a console ui. Deluge uses
|
||||||
libtorrent in it's backend to handle the bittorrent protocol.""",
|
libtorrent in it's backend to handle the bittorrent protocol.''',
|
||||||
url="http://deluge-torrent.org",
|
url='http://deluge-torrent.org',
|
||||||
license="GPLv3",
|
license='GPLv3',
|
||||||
cmdclass=cmdclass,
|
cmdclass=cmdclass,
|
||||||
tests_require=['pytest'],
|
tests_require=['pytest'],
|
||||||
data_files=_data_files,
|
data_files=_data_files,
|
||||||
package_data={"deluge": ["ui/gtkui/glade/*.ui",
|
package_data={'deluge': ['ui/gtkui/glade/*.ui',
|
||||||
"ui/data/pixmaps/*.png",
|
'ui/data/pixmaps/*.png',
|
||||||
"ui/data/pixmaps/*.svg",
|
'ui/data/pixmaps/*.svg',
|
||||||
"ui/data/pixmaps/*.ico",
|
'ui/data/pixmaps/*.ico',
|
||||||
"ui/data/pixmaps/*.gif",
|
'ui/data/pixmaps/*.gif',
|
||||||
"ui/data/pixmaps/flags/*.png",
|
'ui/data/pixmaps/flags/*.png',
|
||||||
"plugins/*.egg",
|
'plugins/*.egg',
|
||||||
"i18n/*/LC_MESSAGES/*.mo",
|
'i18n/*/LC_MESSAGES/*.mo',
|
||||||
"ui/web/index.html",
|
'ui/web/index.html',
|
||||||
"ui/web/css/*.css",
|
'ui/web/css/*.css',
|
||||||
"ui/web/icons/*.png",
|
'ui/web/icons/*.png',
|
||||||
"ui/web/images/*.gif",
|
'ui/web/images/*.gif',
|
||||||
"ui/web/images/*.png",
|
'ui/web/images/*.png',
|
||||||
"ui/web/js/*.js",
|
'ui/web/js/*.js',
|
||||||
"ui/web/js/*/*.js",
|
'ui/web/js/*/*.js',
|
||||||
"ui/web/js/*/.order",
|
'ui/web/js/*/.order',
|
||||||
"ui/web/js/*/*/*.js",
|
'ui/web/js/*/*/*.js',
|
||||||
"ui/web/js/*/*/.order",
|
'ui/web/js/*/*/.order',
|
||||||
"ui/web/js/*/*/*/*.js",
|
'ui/web/js/*/*/*/*.js',
|
||||||
"ui/web/render/*.html",
|
'ui/web/render/*.html',
|
||||||
"ui/web/themes/css/*.css",
|
'ui/web/themes/css/*.css',
|
||||||
"ui/web/themes/images/*/*.gif",
|
'ui/web/themes/images/*/*.gif',
|
||||||
"ui/web/themes/images/*/*.png",
|
'ui/web/themes/images/*/*.png',
|
||||||
"ui/web/themes/images/*/*/*.gif",
|
'ui/web/themes/images/*/*/*.gif',
|
||||||
"ui/web/themes/images/*/*/*.png"
|
'ui/web/themes/images/*/*/*.png'
|
||||||
]},
|
]},
|
||||||
packages=find_packages(exclude=["plugins", "docs", "tests"]),
|
packages=find_packages(exclude=['plugins', 'docs', 'tests']),
|
||||||
namespace_packages=["deluge", "deluge.plugins"],
|
namespace_packages=['deluge', 'deluge.plugins'],
|
||||||
entry_points=entry_points
|
entry_points=entry_points
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Authors: Douglas Creager <dcreager@dcreager.net>
|
# Authors: Douglas Creager <dcreager@dcreager.net>
|
||||||
# Calum Lind <calumlind@gmail.com>
|
# Calum Lind <calumlind@gmail.com>
|
||||||
|
@ -41,7 +42,7 @@ def call_git_describe(prefix="", suffix=""):
|
||||||
cmd = "git describe --tags --match %s[0-9]*" % prefix
|
cmd = "git describe --tags --match %s[0-9]*" % prefix
|
||||||
try:
|
try:
|
||||||
output = Popen(cmd.split(), stdout=PIPE, stderr=PIPE).communicate()
|
output = Popen(cmd.split(), stdout=PIPE, stderr=PIPE).communicate()
|
||||||
version = output[0].strip().replace(prefix, "")
|
version = output[0].decode("utf-8").strip().replace(prefix, "")
|
||||||
if "-" in version:
|
if "-" in version:
|
||||||
version = ".dev".join(version.replace(suffix, "").split("-")[:2])
|
version = ".dev".join(version.replace(suffix, "").split("-")[:2])
|
||||||
return version
|
return version
|
||||||
|
@ -70,4 +71,4 @@ def get_version(prefix="", suffix=""):
|
||||||
return version
|
return version
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print get_version(prefix="deluge-", suffix=".dev0")
|
print(get_version(prefix="deluge-", suffix=".dev0"))
|
||||||
|
|
Loading…
Reference in New Issue