From fedd36444a815442f94b1d3f908a4242d721d613 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 21 Jul 2013 16:34:49 +0200 Subject: Paver task to automatically fix module imports --- pavement.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'pavement.py') diff --git a/pavement.py b/pavement.py index 28c955e0d..e89ef0c07 100644 --- a/pavement.py +++ b/pavement.py @@ -54,6 +54,14 @@ xargs = ["--language=Python", "--add-comments=L10N", "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyload", "--package-version=%s" % __version__, "--msgid-bugs-address='bugs@pyload.org'"] +# Modules replace rules +module_replace = [ +('from module.plugins.Hoster import Hoster', 'from pyload.plugins.Hoster import Hoster'), +('from module.common.json_layer import json_loads', 'from pyload.utils import json_loads'), +('from module.utils import parseFileSize', 'from pyload.utils import parseFileSize'), +('from module.', 'from pyload.') # This should be always the last one +] + @task @needs('cog') @@ -243,6 +251,22 @@ def clean(): path("dist").rmtree() +@task +def replace_module_imports(): + """Replace imports from stable syntax to master""" + for root, dirnames, filenames in os.walk('pyload/plugins'): + for filename in fnmatch.filter(filenames, '*.py'): + path = os.path.join(root, filename) + f = open(path, 'r') + content = f.read() + f.close() + for rule in module_replace: + content = content.replace(rule[0], rule[1]) + f = open(path, 'w') + f.write(content) + f.close() + + #helper functions def walk_trans(path, EXCLUDE, endings=[".py"]): -- cgit v1.2.3