Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Misc formatting changes

  • Loading branch information...
commit d5977aa431a4e36a72317da076833b5c54290ca3 1 parent 0132b58
@coordt coordt authored
View
47 create_app.py
@@ -1,13 +1,16 @@
#!/usr/bin/env python
-import os, random, subprocess, sys
+import os
+import random
+import subprocess
+import sys
-HAS_VENV = bool(subprocess.Popen(['which','virtualenv'], stdout=subprocess.PIPE).communicate()[0])
+HAS_VENV = bool(subprocess.Popen(['which', 'virtualenv'], stdout=subprocess.PIPE).communicate()[0])
if not HAS_VENV:
print "virtualenv is required to run this script. Please install it with\n easy_install virtualenv\n\nor\n\n pip virtualenv"
sys.exit(1)
-HAS_VENVW = bool(subprocess.Popen(['which','virtualenvwrapper.sh'], stdout=subprocess.PIPE).communicate()[0])
+HAS_VENVW = bool(subprocess.Popen(['which', 'virtualenvwrapper.sh'], stdout=subprocess.PIPE).communicate()[0])
if not HAS_VENVW:
print "virtualenvwrapper is required to run this script. Please install it with\n easy_install virtualenvwrapper\n\nor\n\n pip virtualenvwrapper"
sys.exit(1)
@@ -24,18 +27,20 @@
'.hg',
)
+
def replace(repl, text):
text = text.replace('/gitignore', '/.gitignore')
for key, value in repl.iteritems():
text = text.replace('$$$$%s$$$$' % (key,), value)
return text
+
def main(repl, dest, templ_dir):
try:
os.makedirs(dest)
except OSError:
pass
-
+
for root, dirs, files in os.walk(templ_dir):
for filename in files:
source_fn = os.path.join(root, filename)
@@ -54,10 +59,10 @@ def main(repl, dest, templ_dir):
data = replace(repl, data)
open(dest_fn, 'w').write(data)
os.chmod(dest_fn, os.stat(source_fn)[0])
-
+
print "Making the virtual environment (%s)..." % repl['VIRTENV']
create_env_cmds = [
- 'source virtualenvwrapper.sh',
+ 'source virtualenvwrapper.sh',
'cd %s' % dest,
'mkvirtualenv --no-site-packages --distribute %s' % repl['VIRTENV'],
'easy_install pip'
@@ -66,11 +71,11 @@ def main(repl, dest, templ_dir):
'source virtualenvwrapper.sh',
'cat > $WORKON_HOME/%s/bin/postactivate '\
'<<END\n#!/bin/bash/\ncd %s\nEND\n'\
- 'chmod +x $WORKON_HOME/%s/bin/postactivate' % (repl['VIRTENV'], dest,repl['VIRTENV'])
+ 'chmod +x $WORKON_HOME/%s/bin/postactivate' % (repl['VIRTENV'], dest, repl['VIRTENV'])
]
subprocess.call([';'.join(create_env_cmds)], env=os.environ, executable='/bin/bash', shell=True)
subprocess.call([';'.join(create_pa_cmd)], env=os.environ, executable='/bin/bash', shell=True)
-
+
print "Now type: workon %s" % repl['VIRTENV']
if __name__ == '__main__':
@@ -85,7 +90,7 @@ def main(repl, dest, templ_dir):
parser.add_option("-d", "--dest", dest="destination", help="Where to put the new application. Relative paths are recognized.")
parser.add_option("-t", "--template", dest="template", help="The application template to use as a basis for the new application.")
(options, args) = parser.parse_args()
-
+
repl = {
'APP_NAME': None,
'PKG_NAME': None,
@@ -95,23 +100,23 @@ def main(repl, dest, templ_dir):
}
dest_dir = None
templ_dir = None
-
+
cur_user = os.getlogin()
-
+
if options.app_name:
repl['APP_NAME'] = options.app_name
elif len(args) > 0:
repl['APP_NAME'] = args[0]
-
+
while not repl['APP_NAME']:
repl['APP_NAME'] = raw_input('Application name: ')
-
+
if options.pkg_name:
repl['PKG_NAME'] = options.pkg_name
while not repl['PKG_NAME']:
- default_name = repl['APP_NAME'].replace('django-', '').replace('-','_')
+ default_name = repl['APP_NAME'].replace('django-', '').replace('-', '_')
repl['PKG_NAME'] = raw_input('Package Name [%s]:' % default_name) or default_name
-
+
if options.author:
repl['AUTHOR'] = options.author
while not repl['AUTHOR']:
@@ -121,20 +126,20 @@ def main(repl, dest, templ_dir):
repl['AUTHOR_EMAIL'] = options.author_email
while not repl['AUTHOR_EMAIL']:
repl['AUTHOR_EMAIL'] = raw_input('Author\'s Email: ')
-
+
if options.url:
repl['URL'] = options.url
while not repl['URL']:
repl['URL'] = raw_input('Project Page URL: ')
-
+
repl['SECRET_KEY'] = ''.join([random.choice(CHARS) for i in xrange(50)])
-
+
if options.destination:
dest_dir = options.destination
-
+
while not dest_dir:
dest_dir = raw_input('Destination directory [%s]: ' % (os.getcwd(),)) or os.getcwd()
- dest_dir = os.path.realpath(os.path.expanduser(dest_dir))
+ dest_dir = os.path.realpath(os.path.expanduser(dest_dir))
dest = os.path.join(dest_dir, repl['APP_NAME'])
if options.template:
@@ -146,7 +151,7 @@ def main(repl, dest, templ_dir):
templ_dir = os.path.realpath(os.path.expanduser(templ_dir))
if templ_dir[-1] != '/':
templ_dir = templ_dir + "/"
-
+
if options.VIRTENV:
repl['VIRTENV'] = options.VIRTENV
else:
View
2  skel/MANIFEST.in
@@ -7,3 +7,5 @@ recursive-include $$$$PKG_NAME$$$$/templates *
include LICENSE
include README
include *.txt
+
+prune example/
View
0  skel/README → skel/README.rst
File renamed without changes
View
6 skel/doc_src/index.rst
@@ -1,6 +1,6 @@
-==============================
-$$$$APP_NAME$$$$'s v |version|
-==============================
+============================
+$$$$APP_NAME$$$$ v |version|
+============================
About
=====
View
33 skel/doc_src/reference/models.rst
@@ -0,0 +1,33 @@
+===============
+Model Reference
+===============
+
+ModelName
+=========
+
+.. py:class:: ModelName
+
+ .. py:attribute:: parent
+
+ :py:class:`TreeForeignKey` ``(self)``
+
+ The category's parent category. Leave this blank for an root category.
+
+ .. py:attribute:: name
+
+ **Required** ``CharField(100)``
+
+ The name of the category.
+
+ .. py:attribute:: slug
+
+ **Required** ``SlugField``
+
+ URL-friendly title. It is automatically generated from the title.
+
+ .. py:attribute:: active
+
+ **Required** ``BooleanField`` *default:* ``True``
+
+ Is this item active. If it is inactive, all children are set to inactive as well.
+
View
2  skel/doc_src/reference/settings.rst
@@ -1,3 +1,3 @@
-
+========
Settings
========
View
9 skel/example/settings.py
@@ -83,13 +83,6 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'g2_39yupn*6j4p*cg2%w643jiq-1n_annua*%i8+rq0dx9p=$n'
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.load_template_source',
- 'django.template.loaders.app_directories.load_template_source',
-# 'django.template.loaders.eggs.load_template_source',
-)
-
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@@ -104,6 +97,7 @@
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
+ os.path.join(PROJ_ROOT, 'templates'),
)
INSTALLED_APPS = (
@@ -115,4 +109,5 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'$$$$PKG_NAME$$$$',
+ 'simpleapp',
)
View
0  skel/example/simpleapp/__init__.py
No changes.
View
10 skel/example/simpleapp/admin.py
@@ -0,0 +1,10 @@
+from django.contrib import admin
+
+from .models import SimpleModel
+
+class SimpleModelAdmin(admin.ModelAdmin):
+ list_display = ('name', )
+ prepopulated_fields = {'slug': ('name',)}
+ search_fields = ('name',)
+
+admin.site.register(SimpleModel, SimpleModelAdmin)
View
20 skel/example/simpleapp/models.py
@@ -0,0 +1,20 @@
+from django.db import models
+
+class SimpleModel(models.Model):
+ """
+ (SimpleModel description)
+ """
+
+ name = models.CharField(max_length=255)
+ slug = models.SlugField(unique=True)
+ description = models.TextField(blank=True)
+ created = models.DateTimeField(auto_now_add=True)
+ updated = models.DateTimeField(auto_now=True)
+
+ def __unicode__(self):
+ return self.name
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('simplemodel_detail_view_name', [str(self.id)])
+
View
0  skel/example/simpleapp/templates/simpleapp/simplemodel_detail.html
No changes.
View
0  skel/example/simpleapp/templates/simpleapp/simplemodel_list.html
No changes.
View
12 skel/example/simpleapp/urls.py
@@ -0,0 +1,12 @@
+from django.conf.urls.defaults import *
+
+from .models import SimpleModel
+
+urlpatterns = patterns('django.views.generic.list_detail',
+ url(r'^$', 'object_list', {
+ 'queryset': SimpleModel.objects.all(),
+ }, name="simplemodel_list"),
+ (r'^(?P<slug>[\w-]+)/', 'object_detail', {
+ 'queryset': SimpleModel.objects.all(),
+ }, name="simplemodel_detail")
+)
View
12 skel/example/templates/base.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>$$$$APP_NAME$$$$</title>
+</head>
+<body>
+{% block content %}
+{% endblock %}
+</body>
+</html>
View
2  skel/example/urls.py
@@ -5,7 +5,7 @@
admin.autodiscover()
urlpatterns = patterns('',
- (r'^$$$$PKG_NAME$$$$/', include('$$$$PKG_NAME$$$$.urls')),
+ # (r'^$$$$PKG_NAME$$$$/', include('$$$$PKG_NAME$$$$.urls')),
(r'^admin/', include(admin.site.urls)),
)
View
28 skel/setup.py
@@ -1,6 +1,7 @@
import os
from setuptools import setup, find_packages
+
def read_file(filename):
"""Read a file into a string"""
path = os.path.abspath(os.path.dirname(__file__))
@@ -9,10 +10,11 @@ def read_file(filename):
return open(filepath).read()
except IOError:
return ''
-
+
+
def get_readme():
"""Return the README file contents. Supports text,rst, and markdown"""
- for name in ('README','README.rst','README.md'):
+ for name in ('README', 'README.rst', 'README.md'):
if os.path.exists(name):
return read_file(name)
return ''
@@ -21,17 +23,17 @@ def get_readme():
DESC = " ".join(__import__('$$$$PKG_NAME$$$$').__doc__.splitlines()).strip()
setup(
- name = "$$$$APP_NAME$$$$",
- version = __import__('$$$$PKG_NAME$$$$').get_version().replace(' ', '-'),
- url = '$$$$URL$$$$',
- author = '$$$$AUTHOR$$$$',
- author_email = '$$$$AUTHOR_EMAIL$$$$',
- description = DESC,
- long_description = get_readme(),
- packages = find_packages(),
- include_package_data = True,
- install_requires = read_file('requirements.txt'),
- classifiers = [
+ name="$$$$APP_NAME$$$$",
+ version=__import__('$$$$PKG_NAME$$$$').get_version().replace(' ', '-'),
+ url='$$$$URL$$$$',
+ author='$$$$AUTHOR$$$$',
+ author_email='$$$$AUTHOR_EMAIL$$$$',
+ description=DESC,
+ long_description=get_readme(),
+ packages=find_packages(),
+ include_package_data=True,
+ install_requires=read_file('requirements.txt'),
+ classifiers=[
'License :: OSI Approved :: Apache Software License',
'Framework :: Django',
],
Please sign in to comment.
Something went wrong with that request. Please try again.