diff options
author | Stefano <l.stickell@yahoo.it> | 2013-07-21 16:34:49 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-07-21 16:34:49 +0200 |
commit | fedd36444a815442f94b1d3f908a4242d721d613 (patch) | |
tree | 8b02095a0b4f3c6b57340253fa6db29f4c0f266a /pavement.py | |
parent | Fixed PEP 8 violations in Crypters (diff) | |
download | pyload-fedd36444a815442f94b1d3f908a4242d721d613.tar.xz |
Paver task to automatically fix module imports
Diffstat (limited to 'pavement.py')
-rw-r--r-- | pavement.py | 24 |
1 files changed, 24 insertions, 0 deletions
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"]): |