summaryrefslogtreecommitdiffstats
path: root/pavement.py
diff options
context:
space:
mode:
Diffstat (limited to 'pavement.py')
-rw-r--r--pavement.py135
1 files changed, 109 insertions, 26 deletions
diff --git a/pavement.py b/pavement.py
index ac9a6fa1a..0cdfb4872 100644
--- a/pavement.py
+++ b/pavement.py
@@ -1,12 +1,18 @@
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import with_statement
from paver.easy import *
from paver.setuputils import setup
from paver.doctools import cog
+import os
import sys
+import shutil
import re
+from glob import glob
+from tempfile import mkdtemp
from urllib import urlretrieve
from subprocess import call, Popen, PIPE
from zipfile import ZipFile
@@ -15,7 +21,7 @@ PROJECT_DIR = path(__file__).dirname()
sys.path.append(PROJECT_DIR)
options = environment.options
-path('pyload').mkdir()
+path("pyload").mkdir()
extradeps = []
if sys.version_info <= (2, 5):
@@ -23,24 +29,24 @@ if sys.version_info <= (2, 5):
setup(
name="pyload",
- version="0.4.9",
+ version="0.4.10",
description='Fast, lightweight and full featured download manager.',
- long_description=open(PROJECT_DIR / "README").read(),
- keywords = ('pyload', 'download-manager', 'one-click-hoster', 'download'),
+ long_description=open(PROJECT_DIR / "README.md").read(),
+ keywords = ("pyload", "download-manager", "one-click-hoster", "download"),
url="http://pyload.org",
download_url='http://pyload.org/download',
license='GPL v3',
author="pyLoad Team",
author_email="support@pyload.org",
platforms = ('Any',),
- #package_dir={'pyload': 'src'},
- packages=['pyload'],
+ #package_dir={'pyload': "src"},
+ packages=["pyload"],
#package_data=find_package_data(),
#data_files=[],
include_package_data=True,
- exclude_package_data={'pyload': ['docs*', 'scripts*', 'tests*']}, #exluced from build but not from sdist
+ exclude_package_data={'pyload': ["docs*", "scripts*", "tests*"]}, #exluced from build but not from sdist
# 'bottle >= 0.10.0' not in list, because its small and contain little modifications
- install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup>=3.2, <3.3'] + extradeps,
+ install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup >= 3.2, < 3.3'] + extradeps,
extras_require={
'SSL': ["pyOpenSSL"],
'DLC': ['pycrypto'],
@@ -86,20 +92,21 @@ options(
virtual="virtualenv2",
),
cog=Bunch(
- pattern="*.py",
+ pattern="*.py",
)
)
# xgettext args
-xargs = ["--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad",
+xargs = ["--language=Python", "--add-comments=L10N",
+ "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad",
"--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"]
@task
@needs('cog')
def html():
"""Build html documentation"""
- module = path("docs") / "module"
- module.rmtree()
+ module = path("docs") / "pyload"
+ pyload.rmtree()
call_task('paver.doctools.html')
@@ -136,7 +143,7 @@ def get_source(options):
file.chmod(0755)
(pyload / ".hgtags").remove()
- (pyload / ".hgignore").remove()
+ (pyload / ".gitignore").remove()
#(pyload / "docs").rmtree()
f = open(pyload / "__init__.py", "wb")
@@ -162,10 +169,10 @@ def thrift(options):
print "add import for TApplicationException manually as long it is not fixed"
- outdir = path("module") / "remote" / "thriftbackend"
+ outdir = path("pyload") / "remote" / "thriftbackend"
(outdir / "gen-py").rmtree()
- cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots,dynamic", outdir / "pyload.thrift"]
+ cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots, dynamic", outdir / "pyload.thrift"]
if options.gen:
cmd.insert(len(cmd) - 1, "--gen")
@@ -180,14 +187,14 @@ def thrift(options):
(outdir / "gen-py").move(outdir / "thriftgen")
#create light ttypes
- from module.remote.socketbackend.create_ttypes import main
+ from pyload.remote.socketbackend.create_ttypes import main
main()
@task
def compile_js():
""" Compile .coffee files to javascript"""
- root = path("module") / "web" / "media" / "js"
+ root = path("pyload") / "web" / "media" / "js"
for f in root.glob("*.coffee"):
print "generate", f
coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE)
@@ -202,22 +209,21 @@ def compile_js():
@task
def generate_locale():
- """ Generates localisation files """
+ """ Generates localization files """
- EXCLUDE = ["BeautifulSoup.py", "module/gui", "module/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload",
+ EXCLUDE = ["BeautifulSoup.py", "pyload/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload",
"setup.py"]
- makepot("core", path("module"), EXCLUDE, "./pyLoadCore.py\n")
+ makepot("core", path("pyload"), EXCLUDE, "./pyload.py\n")
- makepot("gui", path("module") / "gui", [], includes="./pyLoadGui.py\n")
- makepot("cli", path("module") / "cli", [], includes="./pyLoadCli.py\n")
- makepot("setup", "", [], includes="./module/setup.py\n")
+ makepot("cli", path("pyload") / "cli", [], includes="./pyload-cli.py\n")
+ makepot("setup", "", [], includes="./pyload/setup.py\n")
EXCLUDE = ["ServerThread.py", "web/media/default"]
# strings from js files
strings = set()
- for fi in path("module/web").walkfiles():
+ for fi in path("pyload/web").walkfiles():
if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue
with open(fi, "rb") as c:
content = c.read()
@@ -225,13 +231,13 @@ def generate_locale():
strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content))
strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content))
- trans = path("module") / "web" / "translations.js"
+ trans = path("pyload") / "web" / "translations.js"
with open(trans, "wb") as js:
for s in strings:
js.write('_("%s")\n' % s)
- makepot("django", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"])
+ makepot("django", path("pyload/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"])
trans.remove()
@@ -241,6 +247,83 @@ def generate_locale():
@task
+@cmdopts([
+ ('key=', 'k', 'api key')
+])
+def upload_translations(options):
+ """ Uploads the locale files to translation server """
+ tmp = path(mkdtemp())
+
+ shutil.copy('locale/crowdin.yaml', tmp)
+ os.mkdir(tmp / 'pyLoad')
+ for f in glob('locale/*.pot'):
+ if os.path.isfile(f):
+ shutil.copy(f, tmp / 'pyLoad')
+
+ config = tmp / 'crowdin.yaml'
+ content = open(config, 'rb').read()
+ content = content.format(key=options.key, tmp=tmp)
+ f = open(config, 'wb')
+ f.write(content)
+ f.close()
+
+ call(['crowdin-cli', '-c', config, 'upload', 'source'])
+
+ shutil.rmtree(tmp)
+
+ print "Translations uploaded"
+
+
+@task
+@cmdopts([
+ ('key=', 'k', 'api key')
+])
+def download_translations(options):
+ """ Downloads the translated files from translation server """
+ tmp = path(mkdtemp())
+
+ shutil.copy('locale/crowdin.yaml', tmp)
+ os.mkdir(tmp / 'pyLoad')
+ for f in glob('locale/*.pot'):
+ if os.path.isfile(f):
+ shutil.copy(f, tmp / 'pyLoad')
+
+ config = tmp / 'crowdin.yaml'
+ content = open(config, 'rb').read()
+ content = content.format(key=options.key, tmp=tmp)
+ f = open(config, 'wb')
+ f.write(content)
+ f.close()
+
+ call(['crowdin-cli', '-c', config, 'download'])
+
+ for language in (tmp / 'pyLoad').listdir():
+ if not language.isdir():
+ continue
+
+ target = path('locale') / language.basename()
+ print "Copy language %s" % target
+ if target.exists():
+ shutil.rmtree(target)
+
+ shutil.copytree(language, target)
+
+ shutil.rmtree(tmp)
+
+
+@task
+def compile_translations():
+ """ Compile PO files to MO """
+ for language in path('locale').listdir():
+ if not language.isdir():
+ continue
+
+ for f in glob(language / 'LC_MESSAGES' / '*.po'):
+ print "Compiling %s" % f
+ call(['msgfmt', '-o', f.replace('.po', '.mo'), f])
+
+
+@task
def tests():
call(["nosetests2"])