source: derez/setup.py @ a9efeee01195f5d32c2e19458622a30f523cbe24

Revision a9efeee01195f5d32c2e19458622a30f523cbe24, 1.9 KB checked in by Luper Rouch <flupke@…>, 2 years ago (diff)

derez: moving to production

  • Property mode set to 100755
Line 
1#!/usr/bin/env python
2
3import os
4import subprocess
5from setuptools import setup, find_packages, Command
6
7
8def run(*args, **kwargs):
9    """Run a command"""
10    defaults = {"stdout": subprocess.PIPE}
11    defaults.update(kwargs)
12    print " ".join(args)
13    process = subprocess.Popen(args, **defaults)
14    return process.wait()
15
16
17def walk(iterator, path="."):
18    """Iterator version of os.walk()"""
19    # Cache os.walk result to allow modification of the current path in
20    # commands
21    cache = list(os.walk(os.path.abspath(path)))
22    for directory in cache:
23        if ".svn" not in directory[0]:
24            for item in iterator(directory):
25                yield item
26
27
28def localized_directories(directory):
29    dirpath, dirnames, filenames = directory
30    if "locale" in dirnames:
31        yield os.path.join(dirpath)
32
33
34class NoOptionsCommand(Command):
35    user_options = []
36
37    def initialize_options(self):
38        pass
39    def finalize_options(self):
40        pass
41
42
43class MakeMessages(NoOptionsCommand):
44    description = "create django's language files from source"
45   
46    def run(self):
47        for dir in walk(localized_directories):
48            run("django-admin.py", "makemessages", "-a", cwd=dir)
49            run("django-admin.py", "makemessages", "-d", "djangojs", "-a", 
50                    cwd=dir)
51
52
53class CompileMessages(NoOptionsCommand):
54    description = "compile django's language files"
55
56    def run(self):
57        for dir in walk(localized_directories):
58            run("django-admin.py", "compilemessages", cwd=dir)
59
60
61
62setup(
63    name = "derez",
64    version = 0.1,
65    author = "Luper Rouch",
66    author_email = "luper.rouch@gmail.com",
67
68    packages = find_packages(),   
69
70    cmdclass = {
71        # Update language files from the source files
72        "makemessages": MakeMessages,
73        # Compile language files
74        "compilemessages": CompileMessages,
75    },
76)
Note: See TracBrowser for help on using the repository browser.