Commits

Colin Copeland committed effb5b3

add setup.py and command to run

Comments (0)

Files changed (3)

+Copyright (c) 2008-2010, Caktus Consulting Group, LLC
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+* Neither the name of the Caktus Consulting Group, LLC nor the names of its
+contributors may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bin/django-caktus.py

+#!/usr/bin/env python
+
+import os
+import sys
+import subprocess
+from optparse import OptionParser
+
+from caktus_django_template import template
+
+
+usage = """usage: %prog <project-name>"""
+parser = OptionParser(usage=usage)
+
+
+def main():
+    (options, pos_args) = parser.parse_args()
+    if len(pos_args) < 1:
+        parser.print_help()
+        sys.exit(-1)
+    cwd = os.getcwd()
+    project_name = pos_args[0]
+    project_dir = os.path.join(cwd, project_name)
+    # add trailing slash to copy contents of template directory
+    template_dir = os.path.abspath(os.path.dirname(template.__file__)) + '/'
+    subprocess.check_call(['rsync', '-avq', template_dir, project_dir])
+    update_template(project_dir, project_name)
+
+
+def update_template(project_dir, project_name):
+    for path, dirs, files in os.walk(project_dir):
+        for file_name in files:
+            file_path = os.path.join(path, file_name)
+            with open(file_path, 'r+') as f:
+                data = f.read()
+                data = data.replace('PROJECT_NAME', project_name)
+                f.seek(0)
+                f.write(data)
+                f.truncate()
+
+
+if __name__ == '__main__':
+    main()
+from setuptools import setup, find_packages
+
+packages = find_packages()
+# packages.remove('sample_project')
+setup(
+    name='caktus-django-template',
+    version='0.0.1',
+    author='Caktus Consulting Group',
+    author_email='solutions@caktusgroup.com',
+    packages=find_packages(),
+    include_package_data=True,
+    exclude_package_data={
+        '': ['*.sql', '*.pyc'],
+    },
+    url='',
+    license='LICENSE.txt',
+    description='',
+    long_description=open('README.rst').read(),
+    scripts=[
+        'bin/django-caktus.py',
+    ],
+)