├── django_startproject ├── __init__.py ├── project_template │ ├── myproject │ │ ├── __init__.py │ │ ├── apps │ │ │ └── __init__.py │ │ ├── conf │ │ │ ├── __init__.py │ │ │ ├── dev │ │ │ │ ├── __init__.py │ │ │ │ ├── urls.py │ │ │ │ └── settings.py │ │ │ ├── test │ │ │ │ ├── __init__.py │ │ │ │ ├── urls.py │ │ │ │ └── settings.py │ │ │ ├── common │ │ │ │ ├── __init__.py │ │ │ │ └── urls │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── admin.py │ │ │ ├── local │ │ │ │ ├── __init__.py │ │ │ │ └── example │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── urls.py │ │ │ │ │ └── settings.py │ │ │ ├── urls.py │ │ │ └── settings.py │ │ ├── static │ │ │ └── .gitignore │ │ ├── templates │ │ │ ├── 404.html │ │ │ ├── 500.html │ │ │ └── base.html │ │ └── bin │ │ │ └── manage.py │ ├── .gitignore │ ├── .startproject_boilerplate │ ├── .startproject_defaults │ ├── README │ ├── requirements.pip │ ├── docs │ │ ├── index.rst │ │ ├── deployment.rst │ │ ├── install.rst │ │ ├── Makefile │ │ └── conf.py │ ├── setup.py │ ├── server_configs │ │ └── dev │ │ │ ├── django.wsgi │ │ │ ├── apache.conf │ │ │ └── nginx.conf │ ├── fabfile.py │ └── .pylintrc ├── management.py └── utils.py ├── .gitignore ├── bin └── django-startproject.py ├── README └── setup.py /django_startproject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | django_startproject.egg-info 3 | build 4 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/apps/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/dev/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/static/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/local/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/common/urls/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/local/example/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /django_startproject/project_template/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.pyc 3 | docs/_build/* 4 | uploads 5 | myproject/conf/local/*.py 6 | dev.db 7 | myproject.egg-info 8 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/templates/404.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | Not Found 5 | {% endblock %} -------------------------------------------------------------------------------- /django_startproject/project_template/.startproject_boilerplate: -------------------------------------------------------------------------------- 1 | myproject Project name 2 | myauthor Project author 3 | mydevhost Development server 4 | myrepohost Repository location -------------------------------------------------------------------------------- /django_startproject/project_template/.startproject_defaults: -------------------------------------------------------------------------------- 1 | myproject PROJECT 2 | myauthor Lincoln Loop 3 | mydevhost dev.lincolnloop.com 4 | myrepohost cambridge.lincolnloop.com 5 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import patterns, url, include 2 | 3 | urlpatterns = patterns('', 4 | # project urls here 5 | ) 6 | -------------------------------------------------------------------------------- /bin/django-startproject.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def main(): 4 | from django_startproject.management import start_project 5 | start_project() 6 | 7 | 8 | if __name__ == '__main__': 9 | main() 10 | -------------------------------------------------------------------------------- /django_startproject/project_template/README: -------------------------------------------------------------------------------- 1 | Developer documentation is available in Sphinx format in the docs directory. 2 | 3 | Initial installation instructions (including how to build the documentation as 4 | HTML) can be found in docs/install.rst. 5 | -------------------------------------------------------------------------------- /django_startproject/project_template/requirements.pip: -------------------------------------------------------------------------------- 1 | # This file collects all required third-party applications that are needed 2 | # to run this project. Later you can install all these apps in a row 3 | # using pip. Example:: 4 | # 5 | # pip install -r requirements.pip 6 | 7 | django==1.3 8 | south==0.7.3 9 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/common/urls/admin.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import patterns, include 2 | from django.contrib import admin 3 | 4 | admin.autodiscover() 5 | 6 | urlpatterns = patterns('', 7 | (r'^admin/doc/', include('django.contrib.admindocs.urls')), 8 | (r'^admin/', include(admin.site.urls)), 9 | ) 10 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/dev/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import * 2 | from django.conf import settings 3 | 4 | CONF_MODULE = '%s.conf' % settings.PROJECT_MODULE_NAME 5 | 6 | urlpatterns = patterns('', 7 | (r'', include('%s.urls' % CONF_MODULE)), 8 | (r'', include('%s.common.urls.admin' % CONF_MODULE)), 9 | ) 10 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/test/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import * 2 | from django.conf import settings 3 | 4 | CONF_MODULE = '%s.conf' % settings.PROJECT_MODULE_NAME 5 | 6 | urlpatterns = patterns('', 7 | (r'', include('%s.urls' % CONF_MODULE)), 8 | (r'', include('%s.common.urls.admin' % CONF_MODULE)), 9 | ) 10 | -------------------------------------------------------------------------------- /django_startproject/project_template/docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to myproject's documentation! 2 | ===================================== 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | install 10 | deployment 11 | 12 | Indices and tables 13 | ================== 14 | 15 | * :ref:`genindex` 16 | * :ref:`modindex` 17 | * :ref:`search` 18 | 19 | -------------------------------------------------------------------------------- /django_startproject/project_template/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from setuptools import setup, find_packages 3 | 4 | setup(name='myproject', 5 | version='0.1', 6 | packages=find_packages(), 7 | package_data={'myproject': ['bin/*.*', 'static/*.*', 'templates/*.*']}, 8 | exclude_package_data={'myproject': ['bin/*.pyc']}, 9 | scripts=['myproject/bin/manage.py']) 10 | -------------------------------------------------------------------------------- /django_startproject/project_template/server_configs/dev/django.wsgi: -------------------------------------------------------------------------------- 1 | import os, sys 2 | import site 3 | 4 | site.addsitedir('/opt/webapps/myproject/lib/python2.5/site-packages') 5 | 6 | 7 | sys.stdout = sys.stderr 8 | 9 | os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.conf.local.settings' 10 | 11 | import django.core.handlers.wsgi 12 | 13 | application = django.core.handlers.wsgi.WSGIHandler() 14 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/test/settings.py: -------------------------------------------------------------------------------- 1 | from myproject.conf.settings import * 2 | 3 | DEBUG = False 4 | TEMPLATE_DEBUG = DEBUG 5 | 6 | DATABASES = { 7 | 'default': { 8 | 'ENGINE': 'django.db.backends.sqlite3', 9 | 'NAME': ':memory:', 10 | } 11 | } 12 | ROOT_URLCONF = 'myproject.conf.test.urls' 13 | 14 | INSTALLED_APPS += ('django_nose',) 15 | 16 | TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' 17 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/templates/500.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | {% block head_title %}{% endblock %} 7 | 8 | 9 | 10 | 11 |
12 | Server Error 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/templates/base.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | {% block head_title %}{% endblock %} 7 | 8 | 9 | 10 | 11 |
12 | {% block content %} 13 | {% endblock %} 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/dev/settings.py: -------------------------------------------------------------------------------- 1 | from myproject.conf.settings import * 2 | 3 | DEBUG = True 4 | TEMPLATE_DEBUG = DEBUG 5 | 6 | ROOT_URLCONF = 'myproject.conf.dev.urls' 7 | 8 | DATABASES = { 9 | 'default': { 10 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 11 | 'NAME': 'myproject', 12 | # 'USER': 'dbuser', 13 | # 'PASSWORD': 'dbpassword', 14 | } 15 | } 16 | 17 | INSTALLED_APPS += ( 18 | 'django.contrib.admin', 19 | 'django.contrib.admindocs', 20 | ) 21 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/local/example/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import patterns, include 2 | from django.conf.urls.static import static 3 | from django.conf import settings 4 | 5 | CONF_MODULE = '%s.conf' % settings.PROJECT_MODULE_NAME 6 | 7 | urlpatterns = patterns('', 8 | (r'', include('%s.urls' % CONF_MODULE)), 9 | (r'', include('%s.common.urls.admin' % CONF_MODULE)), 10 | ) 11 | if settings.MEDIA_ROOT: 12 | urlpatterns += static(settings.MEDIA_URL, 13 | document_root=settings.MEDIA_ROOT) 14 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/local/example/settings.py: -------------------------------------------------------------------------------- 1 | from myproject.conf.settings import * 2 | 3 | DEBUG = True 4 | TEMPLATE_DEBUG = DEBUG 5 | 6 | ADMINS = ( 7 | ('You', 'your@email'), 8 | ) 9 | MANAGERS = ADMINS 10 | 11 | DATABASES = { 12 | 'default': { 13 | 'ENGINE': 'django.db.backends.sqlite3', 14 | 'NAME': os.path.join(VAR_ROOT, 'dev.db'), 15 | } 16 | } 17 | 18 | ROOT_URLCONF = '%s.conf.local.urls' % PROJECT_MODULE_NAME 19 | 20 | INSTALLED_APPS += ( 21 | 'django.contrib.admin', 22 | 'django.contrib.admindocs', 23 | ) 24 | -------------------------------------------------------------------------------- /django_startproject/project_template/server_configs/dev/apache.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerName myproject.mydevhost 3 | ServerAdmin webmaster@mydevhost 4 | 5 | ErrorLog /var/log/apache2/myproject.mydevhost.log 6 | 7 | WSGIDaemonProcess myproject user=www-data inactivity-timeout=600 8 | WSGIProcessGroup myproject 9 | WSGIScriptAlias / /opt/webapps/myproject.mydevhost/etc/apache/django.wsgi 10 | 11 | 12 | Order deny,allow 13 | Allow from all 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /django_startproject/project_template/docs/deployment.rst: -------------------------------------------------------------------------------- 1 | Deployment 2 | ========== 3 | 4 | Staging/Development 5 | ------------------- 6 | 7 | `Fabric `_ is used to allow developers to 8 | easily push changes to a previously setup development/staging environment. 9 | To get started, run the following command from within your virtual 10 | environment:: 11 | 12 | pip install fabric==0.9.3 13 | fab --fabfile src/myproject/fabfile.py -l 14 | 15 | This will install Fabric and provide a list of available commands. 16 | 17 | When run from src/myproject, you can just run ``fab [command]`` (i.e. without 18 | the ``-fabfile`` flag). 19 | -------------------------------------------------------------------------------- /django_startproject/project_template/server_configs/dev/nginx.conf: -------------------------------------------------------------------------------- 1 | upstream myproject { 2 | server myproject.mydevhost:9000; 3 | } 4 | 5 | server { 6 | listen 80; 7 | server_name www.myproject.mydevhost; 8 | rewrite ^/(.*) http://myproject.mydevhost/$1 permanent; 9 | } 10 | 11 | server { 12 | listen 80; 13 | server_name myproject.mydevhost; 14 | root /var/www/myproject.mydevhost/; 15 | access_log /var/log/nginx/myproject.mydevhost.access.log; 16 | 17 | location / { 18 | if (-f $request_filename/index.html) { 19 | rewrite (.*) $1/index.html break; 20 | } 21 | if (!-f $request_filename) { 22 | proxy_pass http://myproject; 23 | } 24 | include /etc/nginx/proxy-setup.inc.conf; 25 | } 26 | 27 | # Serve up apache log on dev host. Useful for debugging. 28 | location /apache.log { 29 | alias /var/log/apache2/myproject.mydevhost.log; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /django_startproject/management.py: -------------------------------------------------------------------------------- 1 | from django_startproject import utils 2 | import optparse 3 | import os 4 | import sys 5 | 6 | 7 | TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.realpath(utils.__file__)), 8 | 'project_template') 9 | 10 | 11 | def start_project(): 12 | """ 13 | Copy a project template, replacing boilerplate variables. 14 | 15 | """ 16 | usage = "usage: %prog [options] project_name [base_destination_dir]" 17 | parser = optparse.OptionParser(usage=usage) 18 | parser.add_option('-t', '--template-dir', dest='src_dir', 19 | help='project template directory to use', 20 | default=TEMPLATE_DIR) 21 | options, args = parser.parse_args() 22 | if len(args) not in (1, 2): 23 | parser.print_help() 24 | sys.exit(1) 25 | project_name = args[0] 26 | 27 | src = options.src_dir 28 | if len(args) > 1: 29 | base_dest_dir = args[1] 30 | else: 31 | base_dest_dir = '' 32 | dest = os.path.join(base_dest_dir, project_name) 33 | 34 | # Get any boilerplate replacement variables: 35 | replace = {} 36 | for var, help, default in utils.get_boilerplate(src, project_name): 37 | help = help or var 38 | if default is not None: 39 | prompt = '%s [%s]: ' % (help, default) 40 | else: 41 | prompt = '%s: ' % help 42 | value = None 43 | while not value: 44 | value = raw_input(prompt) or default 45 | replace[var] = value 46 | 47 | utils.copy_template(src, dest, replace) 48 | -------------------------------------------------------------------------------- /django_startproject/project_template/docs/install.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Installation 3 | ================== 4 | 5 | Pre-Requisites 6 | =============== 7 | 8 | * `setuptools `_ 9 | * `virtualenv `_ 10 | 11 | To install all of these system dependencies on a Debian-based system, run:: 12 | 13 | sudo apt-get install python-setuptools 14 | sudo easy_install virtualenv 15 | 16 | 17 | Creating the Virtual Environment 18 | ================================ 19 | 20 | First, create a clean base environment using virtualenv:: 21 | 22 | virtualenv myproject 23 | cd myproject 24 | source bin/activate 25 | 26 | 27 | Installing the Project 28 | ====================== 29 | 30 | Install the requirements and the project source:: 31 | 32 | cd path/to/your/myproject/repository 33 | pip install -r requirements.pip 34 | pip install -e . 35 | 36 | 37 | Configuring a Local Environment 38 | =============================== 39 | 40 | If you're just checking the project out locally, you can copy some example 41 | configuration files to get started quickly:: 42 | 43 | cp myproject/conf/local/example/* myproject/conf/local 44 | manage.py syncdb --migrate 45 | 46 | 47 | Building Documentation 48 | ====================== 49 | 50 | Documentation is available in ``docs`` and can be built into a number of 51 | formats using `Sphinx `_. To get started:: 52 | 53 | pip install Sphinx 54 | cd docs 55 | make html 56 | 57 | This creates the documentation in HTML format at ``docs/_build/html``. 58 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/bin/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | from django import get_version 5 | from django.core.management import execute_from_command_line, LaxOptionParser 6 | from django.core.management.base import BaseCommand 7 | 8 | # Work out the project module name and root directory, assuming that this file 9 | # is located at [project]/bin/manage.py 10 | PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split( 11 | os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) 12 | 13 | # Check that the project module can be imported. 14 | try: 15 | __import__(PROJECT_MODULE_NAME) 16 | except ImportError: 17 | # Couldn't import the project, place it on the Python path and try again. 18 | sys.path.append(PROJECT_DIR) 19 | try: 20 | __import__(PROJECT_MODULE_NAME) 21 | except ImportError: 22 | sys.stderr.write("Error: Can't import the \"%s\" project module." % 23 | PROJECT_MODULE_NAME) 24 | sys.exit(1) 25 | 26 | def has_settings_option(): 27 | parser = LaxOptionParser(usage="%prog subcommand [options] [args]", 28 | version=get_version(), 29 | option_list=BaseCommand.option_list) 30 | try: 31 | options = parser.parse_args(sys.argv[:])[0] 32 | except: 33 | return False # Ignore any option errors at this point. 34 | return bool(options.settings) 35 | 36 | if not has_settings_option() and not 'DJANGO_SETTINGS_MODULE' in os.environ: 37 | settings_module = '%s.conf.local.settings' % PROJECT_MODULE_NAME 38 | os.environ['DJANGO_SETTINGS_MODULE'] = settings_module 39 | 40 | execute_from_command_line() 41 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ============ 2 | StartProject 3 | ============ 4 | 5 | StartProject installs a script which allows the easy creation of a standard 6 | Django project layout based on Lincoln Loop standards. 7 | 8 | 9 | Script usage 10 | ============ 11 | 12 | After installing StartProject, simply run the following command (from within 13 | the directory in where the new project directory should be created):: 14 | 15 | django-startproject.py project_name 16 | 17 | The script will prompt for values to replace boilerplate variables with. These 18 | variables allow for both the file contents and path names to be customized to 19 | this specific project. 20 | 21 | 22 | Using a custom project template 23 | =============================== 24 | 25 | If you would prefer to use a custom project template than the one included in 26 | this application, create your custom project template directory and call the 27 | command script like this:: 28 | 29 | django-startproject.py --template-dir=/your/custom/template project_name 30 | 31 | 32 | Specifying boilerplate variables 33 | -------------------------------- 34 | 35 | Two optional files in the root of the project template directory are used to 36 | determine the boilerplate variables: 37 | 38 | ``.startproject_boilerplate`` 39 | Each line should contain the boilerplate variable (and optionally, a 40 | description of the variable, separated from the variable by white space). 41 | 42 | ``.startproject_defaults`` 43 | Each line should contain a variable and the default value, separated by 44 | whitespace. If the default value contains ``PROJECT``, it is replaced with 45 | the project name. 46 | 47 | See the files included in the project_template directory of StartProject for 48 | an example. 49 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | import os 3 | 4 | 5 | README_FILE = open('README') 6 | try: 7 | LONG_DESCRIPTION = README_FILE.read() 8 | finally: 9 | README_FILE.close() 10 | 11 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) 12 | DATA_DIR = os.path.join(ROOT_DIR, 'django_startproject', 'project_template') 13 | STARTPROJECT_DATA = [] 14 | for path, dirs, filenames in os.walk(DATA_DIR): 15 | # Ignore directories that start with '.' 16 | for i, dir in enumerate(dirs): 17 | if dir.startswith('.'): 18 | del dirs[i] 19 | path = path[len(DATA_DIR) + 1:] 20 | STARTPROJECT_DATA.append(os.path.join('project_template', path, '*.*')) 21 | # Get files starting with '.' too (they are excluded from the *.* glob). 22 | STARTPROJECT_DATA.append(os.path.join('project_template', path, '.*')) 23 | 24 | 25 | setup(name='django-startproject', 26 | version='1.0a', 27 | author='Lincoln Loop', 28 | author_email='info@lincolnloop.com', 29 | description=('Create a Django project layout based on Lincoln Loop ' 30 | 'best practices.'), 31 | long_description=LONG_DESCRIPTION, 32 | packages=['django_startproject'], 33 | package_data={'django_startproject': STARTPROJECT_DATA}, 34 | scripts=['bin/django-startproject.py'], 35 | classifiers=[ 36 | 'Development Status :: 3 - Alpha', 37 | 'Environment :: Web Environment', 38 | 'Framework :: Django', 39 | 'Intended Audience :: Developers', 40 | 'License :: OSI Approved :: MIT License', 41 | 'Operating System :: OS Independent', 42 | 'Programming Language :: Python', 43 | 'Topic :: Software Development :: Libraries :: Python Modules']) 44 | -------------------------------------------------------------------------------- /django_startproject/project_template/fabfile.py: -------------------------------------------------------------------------------- 1 | from fabric.api import env, local, run, require, cd 2 | from fabric.operations import _prefix_commands, _prefix_env_vars 3 | 4 | env.disable_known_hosts = True # always fails for me without this 5 | env.hosts = ['myproject.mydevhost'] 6 | env.root = '/opt/webapps/myproject' 7 | env.proj_root = env.root + '/src/myproject' 8 | env.proj_repo = 'git@github.com:myuser/myrepo.git' 9 | env.pip_file = env.proj_root + '/requirements.pip' 10 | 11 | 12 | def deploy(): 13 | """Update source, update pip requirements, syncdb, restart server""" 14 | update() 15 | update_reqs() 16 | syncdb() 17 | restart() 18 | 19 | 20 | def switch(branch): 21 | """Switch the repo branch which the server is using""" 22 | with cd(env.proj_root): 23 | ve_run('git checkout %s' % branch) 24 | restart() 25 | 26 | 27 | def version(): 28 | """Show last commit to repo on server""" 29 | with cd(env.proj_root): 30 | sshagent_run('git log -1') 31 | 32 | 33 | def restart(): 34 | """Restart Apache process""" 35 | run('touch %s/etc/apache/django.wsgi' % env.root) 36 | 37 | 38 | def update_reqs(): 39 | """Update pip requirements""" 40 | ve_run('yes w | pip install -r %s' % env.pip_file) 41 | 42 | 43 | def update(): 44 | """Updates project source""" 45 | with cd(env.proj_root): 46 | sshagent_run('git pull') 47 | 48 | 49 | def syncdb(): 50 | """Run syncdb (along with any pending south migrations)""" 51 | ve_run('manage.py syncdb --migrate') 52 | 53 | 54 | def clone(): 55 | """Clone the repository for the first time""" 56 | with cd('%s/src' % env.root): 57 | sshagent_run('git clone %s' % env.proj_repo) 58 | ve_run('pip install -e %s' % env.proj_root) 59 | 60 | with cd('%s/myproject/conf/local' % env.proj_root): 61 | run('ln -s ../dev/__init__.py') 62 | run('ln -s ../dev/settings.py') 63 | 64 | 65 | def ve_run(cmd): 66 | """ 67 | Helper function. 68 | Runs a command using the virtualenv environment 69 | """ 70 | require('root') 71 | return sshagent_run('source %s/bin/activate; %s' % (env.root, cmd)) 72 | 73 | 74 | def sshagent_run(cmd): 75 | """ 76 | Helper function. 77 | Runs a command with SSH agent forwarding enabled. 78 | 79 | Note:: Fabric (and paramiko) can't forward your SSH agent. 80 | This helper uses your system's ssh to do so. 81 | """ 82 | # Handle context manager modifications 83 | wrapped_cmd = _prefix_commands(_prefix_env_vars(cmd), 'remote') 84 | try: 85 | host, port = env.host_string.split(':') 86 | return local( 87 | "ssh -p %s -A %s@%s '%s'" % (port, env.user, host, wrapped_cmd) 88 | ) 89 | except ValueError: 90 | return local( 91 | "ssh -A %s@%s '%s'" % (env.user, env.host_string, wrapped_cmd) 92 | ) 93 | -------------------------------------------------------------------------------- /django_startproject/project_template/myproject/conf/settings.py: -------------------------------------------------------------------------------- 1 | # Import global settings to make it easier to extend settings. 2 | from django.conf.global_settings import * 3 | 4 | #============================================================================== 5 | # Generic Django project settings 6 | #============================================================================== 7 | 8 | DEBUG = True 9 | TEMPLATE_DEBUG = DEBUG 10 | 11 | # Local time zone for this installation. Choices can be found here: 12 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 13 | TIME_ZONE = 'America/Chicago' 14 | USE_I18N = True 15 | SITE_ID = 1 16 | 17 | # Make this unique, and don't share it with anybody. 18 | SECRET_KEY = '' 19 | 20 | #============================================================================== 21 | # Calculation of directories relative to the module location 22 | #============================================================================== 23 | import os 24 | import sys 25 | import myproject 26 | 27 | PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split( 28 | os.path.dirname(os.path.realpath(myproject.__file__)) 29 | ) 30 | 31 | PYTHON_BIN = os.path.dirname(sys.executable) 32 | if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')): 33 | # Assume that the presence of 'activate_this.py' in the python bin/ 34 | # directory means that we're running in a virtual environment. Set the 35 | # variable root to $VIRTUALENV/var. 36 | VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var') 37 | if not os.path.exists(VAR_ROOT): 38 | os.mkdir(VAR_ROOT) 39 | else: 40 | # Set the variable root to the local configuration location (which is 41 | # ignored by the repository). 42 | VAR_ROOT = os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'conf', 'local') 43 | 44 | #============================================================================== 45 | # Project URLS and media settings 46 | #============================================================================== 47 | 48 | ROOT_URLCONF = 'myproject.conf.urls' 49 | 50 | LOGIN_URL = '/accounts/login/' 51 | LOGOUT_URL = '/accounts/logout/' 52 | LOGIN_REDIRECT_URL = '/' 53 | 54 | MEDIA_URL = '/uploads/' 55 | STATIC_URL = '/static/' 56 | 57 | STATIC_ROOT = os.path.join(VAR_ROOT, 'static') 58 | #MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads') 59 | 60 | STATICFILES_DIRS = ( 61 | os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'static'), 62 | ) 63 | 64 | #============================================================================== 65 | # Templates 66 | #============================================================================== 67 | 68 | TEMPLATE_DIRS = ( 69 | os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'templates'), 70 | ) 71 | 72 | TEMPLATE_CONTEXT_PROCESSORS += ( 73 | # 'Custom context processors here', 74 | ) 75 | 76 | INSTALLED_APPS = ( 77 | 'django.contrib.auth', 78 | 'django.contrib.contenttypes', 79 | 'django.contrib.sessions', 80 | 'django.contrib.sites', 81 | 'django.contrib.humanize', 82 | 'django.contrib.staticfiles', 83 | 'south', 84 | ) 85 | -------------------------------------------------------------------------------- /django_startproject/project_template/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | 9 | # Internal variables. 10 | PAPEROPT_a4 = -D latex_paper_size=a4 11 | PAPEROPT_letter = -D latex_paper_size=letter 12 | ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 13 | 14 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest 15 | 16 | help: 17 | @echo "Please use \`make ' where is one of" 18 | @echo " html to make standalone HTML files" 19 | @echo " dirhtml to make HTML files named index.html in directories" 20 | @echo " pickle to make pickle files" 21 | @echo " json to make JSON files" 22 | @echo " htmlhelp to make HTML files and a HTML help project" 23 | @echo " qthelp to make HTML files and a qthelp project" 24 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 25 | @echo " changes to make an overview of all changed/added/deprecated items" 26 | @echo " linkcheck to check all external links for integrity" 27 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 28 | 29 | clean: 30 | -rm -rf _build/* 31 | 32 | html: 33 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html 34 | @echo 35 | @echo "Build finished. The HTML pages are in _build/html." 36 | 37 | dirhtml: 38 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml 39 | @echo 40 | @echo "Build finished. The HTML pages are in _build/dirhtml." 41 | 42 | pickle: 43 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle 44 | @echo 45 | @echo "Build finished; now you can process the pickle files." 46 | 47 | json: 48 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json 49 | @echo 50 | @echo "Build finished; now you can process the JSON files." 51 | 52 | htmlhelp: 53 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp 54 | @echo 55 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 56 | ".hhp project file in _build/htmlhelp." 57 | 58 | qthelp: 59 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp 60 | @echo 61 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 62 | ".qhcp project file in _build/qthelp, like this:" 63 | @echo "# qcollectiongenerator _build/qthelp/myproject.qhcp" 64 | @echo "To view the help file:" 65 | @echo "# assistant -collectionFile _build/qthelp/myproject.qhc" 66 | 67 | latex: 68 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex 69 | @echo 70 | @echo "Build finished; the LaTeX files are in _build/latex." 71 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 72 | "run these through (pdf)latex." 73 | 74 | changes: 75 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes 76 | @echo 77 | @echo "The overview file is in _build/changes." 78 | 79 | linkcheck: 80 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck 81 | @echo 82 | @echo "Link check complete; look for any errors in the above output " \ 83 | "or in _build/linkcheck/output.txt." 84 | 85 | doctest: 86 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest 87 | @echo "Testing of doctests in the sources finished, look at the " \ 88 | "results in _build/doctest/output.txt." 89 | -------------------------------------------------------------------------------- /django_startproject/utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import shutil 4 | import stat 5 | from random import choice 6 | 7 | 8 | def copy_template(src, dest, replace=None): 9 | """ 10 | Copy all files in the source path to the destination path. 11 | 12 | To replace boilerplate strings in the source data, pass a dictionary to the 13 | ``replace`` argument where each key is the boilerplate string and the 14 | corresponding value is the string which should replace it. 15 | 16 | The destination file paths are also parsed through the boilerplate 17 | replacements, so directories and file names may also be modified. 18 | 19 | """ 20 | for path, dirs, files in os.walk(src): 21 | relative_path = path[len(src):].lstrip(os.sep) 22 | # Replace boilerplate strings in destination directory. 23 | for old_val, new_val in replace.items(): 24 | relative_path = relative_path.replace(old_val, new_val) 25 | os.mkdir(os.path.join(dest, relative_path)) 26 | for i, subdir in enumerate(dirs): 27 | if subdir.startswith('.'): 28 | del dirs[i] 29 | for filename in files: 30 | if (filename.startswith('.startproject') or 31 | filename.endswith('.pyc')): 32 | continue 33 | src_file_path = os.path.join(path, filename) 34 | # Replace boilerplate strings in destination filename. 35 | for old_val, new_val in replace.items(): 36 | filename = filename.replace(old_val, new_val) 37 | dest_file_path = os.path.join(dest, relative_path, filename) 38 | copy_template_file(src_file_path, dest_file_path, replace) 39 | 40 | 41 | def copy_template_file(src, dest, replace=None): 42 | """ 43 | Copy a source file to a new destination file. 44 | 45 | To replace boilerplate strings in the source data, pass a dictionary to the 46 | ``replace`` argument where each key is the boilerplate string and the 47 | corresponding value is the string which should replace it. 48 | 49 | """ 50 | replace = replace or {} 51 | # Read the data from the source file. 52 | src_file = open(src, 'r') 53 | data = src_file.read() 54 | src_file.close() 55 | # Replace boilerplate strings. 56 | for old_val, new_val in replace.items(): 57 | data = data.replace(old_val, new_val) 58 | 59 | # Generate SECRET_KEY for settings file 60 | secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) 61 | data = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", data) 62 | 63 | # Write the data to the destination file. 64 | dest_file = open(dest, 'w') 65 | dest_file.write(data) 66 | dest_file.close() 67 | # Copy permissions from source file. 68 | shutil.copymode(src, dest) 69 | # Make new file writable. 70 | if os.access(dest, os.W_OK): 71 | st = os.stat(dest) 72 | new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR 73 | os.chmod(dest, new_permissions) 74 | 75 | 76 | def get_boilerplate(path, project_name): 77 | """ 78 | Look for a ``.startproject_boilerplate`` file the given path and parse it. 79 | 80 | Return a list of 3-part tuples, each containing a boilerplate variable, 81 | optional description and default value. 82 | 83 | If no file was found (or no lines contained boilerplate variables), return 84 | an empty list. 85 | 86 | """ 87 | defaults = {} 88 | defaults_path = os.path.join(path, '.startproject_defaults') 89 | if os.path.isfile(defaults_path): 90 | defaults_file = open(defaults_path, 'r') 91 | for line in defaults_file: 92 | match = re.match(r'\s*(\w+)\s*(.*)$', line) 93 | if match: 94 | var, default = match.groups() 95 | defaults[var] = default 96 | boilerplate = [] 97 | boilerplate_path = os.path.join(path, '.startproject_boilerplate') 98 | if os.path.isfile(boilerplate_path): 99 | boilerplate_file = open(boilerplate_path, 'r') 100 | for line in boilerplate_file: 101 | match = re.match(r'\s*(\w+)\s*(.*)$', line) 102 | if match: 103 | var, description = match.groups() 104 | default = defaults.get(var) 105 | boilerplate.append((var, description, default)) 106 | return boilerplate 107 | -------------------------------------------------------------------------------- /django_startproject/project_template/docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # myproject documentation build configuration file, created by 4 | # sphinx-quickstart on Wed Aug 19 10:27:46 2009. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | import datetime 16 | 17 | # If extensions (or modules to document with autodoc) are in another directory, 18 | # add these directories to sys.path here. If the directory is relative to the 19 | # documentation root, use os.path.abspath to make it absolute, like shown here. 20 | #sys.path.append(os.path.abspath('.')) 21 | 22 | # -- General configuration ----------------------------------------------------- 23 | 24 | # Add any Sphinx extension module names here, as strings. They can be extensions 25 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 26 | extensions = ['sphinx.ext.autodoc'] 27 | 28 | # Add any paths that contain templates here, relative to this directory. 29 | templates_path = ['_templates'] 30 | 31 | # The suffix of source filenames. 32 | source_suffix = '.rst' 33 | 34 | # The encoding of source files. 35 | #source_encoding = 'utf-8' 36 | 37 | # The master toctree document. 38 | master_doc = 'index' 39 | 40 | # General information about the project. 41 | project = u'myproject' 42 | copyright = u'%d, myauthor' % datetime.date.today().year 43 | 44 | # The version info for the project you're documenting, acts as replacement for 45 | # |version| and |release|, also used in various other places throughout the 46 | # built documents. 47 | # 48 | # The short X.Y version. 49 | version = '1.0' 50 | # The full version, including alpha/beta/rc tags. 51 | release = '1.0' 52 | 53 | # The language for content autogenerated by Sphinx. Refer to documentation 54 | # for a list of supported languages. 55 | #language = None 56 | 57 | # There are two options for replacing |today|: either, you set today to some 58 | # non-false value, then it is used: 59 | #today = '' 60 | # Else, today_fmt is used as the format for a strftime call. 61 | #today_fmt = '%B %d, %Y' 62 | 63 | # List of documents that shouldn't be included in the build. 64 | #unused_docs = [] 65 | 66 | # List of directories, relative to source directory, that shouldn't be searched 67 | # for source files. 68 | exclude_trees = ['_build'] 69 | 70 | # The reST default role (used for this markup: `text`) to use for all documents. 71 | #default_role = None 72 | 73 | # If true, '()' will be appended to :func: etc. cross-reference text. 74 | #add_function_parentheses = True 75 | 76 | # If true, the current module name will be prepended to all description 77 | # unit titles (such as .. function::). 78 | #add_module_names = True 79 | 80 | # If true, sectionauthor and moduleauthor directives will be shown in the 81 | # output. They are ignored by default. 82 | #show_authors = False 83 | 84 | # The name of the Pygments (syntax highlighting) style to use. 85 | pygments_style = 'sphinx' 86 | 87 | # A list of ignored prefixes for module index sorting. 88 | #modindex_common_prefix = [] 89 | 90 | 91 | # -- Options for HTML output --------------------------------------------------- 92 | 93 | # The theme to use for HTML and HTML Help pages. Major themes that come with 94 | # Sphinx are currently 'default' and 'sphinxdoc'. 95 | html_theme = 'default' 96 | 97 | # Theme options are theme-specific and customize the look and feel of a theme 98 | # further. For a list of options available for each theme, see the 99 | # documentation. 100 | #html_theme_options = {} 101 | 102 | # Add any paths that contain custom themes here, relative to this directory. 103 | #html_theme_path = [] 104 | 105 | # The name for this set of Sphinx documents. If None, it defaults to 106 | # " v documentation". 107 | #html_title = None 108 | 109 | # A shorter title for the navigation bar. Default is the same as html_title. 110 | #html_short_title = None 111 | 112 | # The name of an image file (relative to this directory) to place at the top 113 | # of the sidebar. 114 | #html_logo = None 115 | 116 | # The name of an image file (within the static path) to use as favicon of the 117 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 118 | # pixels large. 119 | #html_favicon = None 120 | 121 | # Add any paths that contain custom static files (such as style sheets) here, 122 | # relative to this directory. They are copied after the builtin static files, 123 | # so a file named "default.css" will overwrite the builtin "default.css". 124 | html_static_path = ['_static'] 125 | 126 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 127 | # using the given strftime format. 128 | #html_last_updated_fmt = '%b %d, %Y' 129 | 130 | # If true, SmartyPants will be used to convert quotes and dashes to 131 | # typographically correct entities. 132 | #html_use_smartypants = True 133 | 134 | # Custom sidebar templates, maps document names to template names. 135 | #html_sidebars = {} 136 | 137 | # Additional templates that should be rendered to pages, maps page names to 138 | # template names. 139 | #html_additional_pages = {} 140 | 141 | # If false, no module index is generated. 142 | #html_use_modindex = True 143 | 144 | # If false, no index is generated. 145 | #html_use_index = True 146 | 147 | # If true, the index is split into individual pages for each letter. 148 | #html_split_index = False 149 | 150 | # If true, links to the reST sources are added to the pages. 151 | #html_show_sourcelink = True 152 | 153 | # If true, an OpenSearch description file will be output, and all pages will 154 | # contain a tag referring to it. The value of this option must be the 155 | # base URL from which the finished HTML is served. 156 | #html_use_opensearch = '' 157 | 158 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). 159 | #html_file_suffix = '' 160 | 161 | # Output file base name for HTML help builder. 162 | htmlhelp_basename = 'myprojectdoc' 163 | 164 | 165 | # -- Options for LaTeX output -------------------------------------------------- 166 | 167 | # The paper size ('letter' or 'a4'). 168 | #latex_paper_size = 'letter' 169 | 170 | # The font size ('10pt', '11pt' or '12pt'). 171 | #latex_font_size = '10pt' 172 | 173 | # Grouping the document tree into LaTeX files. List of tuples 174 | # (source start file, target name, title, author, documentclass [howto/manual]). 175 | latex_documents = [ 176 | ('index', 'myproject.tex', u'myproject Documentation', 177 | u'myauthor', 'manual'), 178 | ] 179 | 180 | # The name of an image file (relative to this directory) to place at the top of 181 | # the title page. 182 | #latex_logo = None 183 | 184 | # For "manual" documents, if this is true, then toplevel headings are parts, 185 | # not chapters. 186 | #latex_use_parts = False 187 | 188 | # Additional stuff for the LaTeX preamble. 189 | #latex_preamble = '' 190 | 191 | # Documents to append as an appendix to all manuals. 192 | #latex_appendices = [] 193 | 194 | # If false, no module index is generated. 195 | #latex_use_modindex = True 196 | -------------------------------------------------------------------------------- /django_startproject/project_template/.pylintrc: -------------------------------------------------------------------------------- 1 | # lint Python modules using external checkers. 2 | # 3 | # This is the main checker controlling the other ones and the reports 4 | # generation. It is itself both a raw checker and an astng checker in order 5 | # to: 6 | # * handle message activation / deactivation at the module level 7 | # * handle some basic but necessary stats'data (number of classes, methods...) 8 | # 9 | [MASTER] 10 | 11 | # Specify a configuration file. 12 | #rcfile= 13 | 14 | # Python code to execute, usually for sys.path manipulation such as 15 | # pygtk.require(). 16 | #init-hook= 17 | 18 | # Profiled execution. 19 | profile=no 20 | 21 | # Add to the black list. It should be a base name, not a 22 | # path. You may set this option multiple times. 23 | ignore=conf 24 | ignore=migrations 25 | 26 | # Pickle collected data for later comparisons. 27 | persistent=yes 28 | 29 | # Set the cache size for astng objects. 30 | cache-size=500 31 | 32 | # List of plugins (as comma separated values of python modules names) to load, 33 | # usually to register additional checkers. 34 | load-plugins= 35 | 36 | 37 | [MESSAGES CONTROL] 38 | 39 | # Enable only checker(s) with the given id(s). This option conflicts with the 40 | # disable-checker option 41 | #enable-checker= 42 | 43 | # Enable all checker(s) except those with the given id(s). This option 44 | # conflicts with the enable-checker option 45 | #disable-checker= 46 | 47 | # Enable all messages in the listed categories (IRCWEF). 48 | #enable-msg-cat= 49 | 50 | # Disable all messages in the listed categories (IRCWEF). 51 | disable-msg-cat=I 52 | 53 | # Enable the message(s) with the given id(s). 54 | #enable-msg= 55 | 56 | # Disable the message(s) with the given id(s). 57 | disable=W0704,W0201,W0142,W0232,R0903,C0301 58 | 59 | 60 | [REPORTS] 61 | 62 | # Set the output format. Available formats are text, parseable, colorized, msvs 63 | # (visual studio) and html 64 | output-format=text 65 | 66 | # Include message's id in output 67 | include-ids=yes 68 | 69 | # Put messages in a separate file for each module / package specified on the 70 | # command line instead of printing them on stdout. Reports (if any) will be 71 | # written in a file name "pylint_global.[txt|html]". 72 | files-output=no 73 | 74 | # Tells wether to display a full report or only the messages 75 | reports=yes 76 | 77 | # Python expression which should return a note less than 10 (10 is the highest 78 | # note). You have access to the variables errors warning, statement which 79 | # respectivly contain the number of errors / warnings messages and the total 80 | # number of statements analyzed. This is used by the global evaluation report 81 | # (R0004). 82 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 83 | 84 | # Add a comment according to your evaluation note. This is used by the global 85 | # evaluation report (R0004). 86 | comment=no 87 | 88 | # Enable the report(s) with the given id(s). 89 | #enable-report= 90 | 91 | # Disable the report(s) with the given id(s). 92 | #disable-report= 93 | 94 | 95 | # checks for : 96 | # * doc strings 97 | # * modules / classes / functions / methods / arguments / variables name 98 | # * number of arguments, local variables, branchs, returns and statements in 99 | # functions, methods 100 | # * required module attributes 101 | # * dangerous default values as arguments 102 | # * redefinition of function / method / class 103 | # * uses of the global statement 104 | # 105 | [BASIC] 106 | 107 | # Required attributes for module, separated by a comma 108 | required-attributes= 109 | 110 | # Regular expression which should only match functions or classes name which do 111 | # not require a docstring 112 | no-docstring-rgx=__.*__|get_absolute_url 113 | 114 | # Regular expression which should only match correct module names 115 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 116 | 117 | # Regular expression which should only match correct module level names 118 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 119 | 120 | # Regular expression which should only match correct class names 121 | class-rgx=[A-Z_][a-zA-Z0-9]+$ 122 | 123 | # Regular expression which should only match correct function names 124 | function-rgx=[a-z_][a-z0-9_]{2,30}$ 125 | 126 | # Regular expression which should only match correct method names 127 | method-rgx=[a-z_][a-z0-9_]{2,30}$ 128 | 129 | # Regular expression which should only match correct instance attribute names 130 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ 131 | 132 | # Regular expression which should only match correct argument names 133 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ 134 | 135 | # Regular expression which should only match correct variable names 136 | variable-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}$) 137 | 138 | # Regular expression which should only match correct list comprehension / 139 | # generator expression variable names 140 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 141 | 142 | # Good variable names which should always be accepted, separated by a comma 143 | good-names=i,j,k,v,qs,urlpatterns,register,p,a,t,r,u,x,f,e,setUp,tearDown 144 | 145 | # Bad variable names which should always be refused, separated by a comma 146 | bad-names=foo,bar,baz,toto,tutu,tata 147 | 148 | # List of builtins function names that should not be used, separated by a comma 149 | bad-functions=map,filter,apply,input 150 | 151 | 152 | # try to find bugs in the code using type inference 153 | # 154 | [TYPECHECK] 155 | 156 | # Tells wether missing members accessed in mixin class should be ignored. A 157 | # mixin class is detected if its name ends with "mixin" (case insensitive). 158 | ignore-mixin-members=yes 159 | 160 | # List of classes names for which member attributes should not be checked 161 | # (useful for classes with attributes dynamicaly set). 162 | ignored-classes=SQLObject 163 | 164 | # When zope mode is activated, add a predefined set of Zope acquired attributes 165 | # to generated-members. 166 | zope=no 167 | 168 | # List of members which are set dynamically and missed by pylint inference 169 | # system, and so shouldn't trigger E0201 when accessed. 170 | generated-members=objects,DoesNotExist,id,pk,_default_manager,_meta 171 | # checks for 172 | # * unused variables / imports 173 | # * undefined variables 174 | # * redefinition of variable from builtins or from an outer scope 175 | # * use of variable before assigment 176 | # 177 | [VARIABLES] 178 | 179 | # Tells wether we should check for unused import in __init__ files. 180 | init-import=no 181 | 182 | # A regular expression matching names used for dummy variables (i.e. not used). 183 | dummy-variables-rgx=_|dummy 184 | 185 | # List of additional names supposed to be defined in builtins. Remember that 186 | # you should avoid to define new builtins when possible. 187 | additional-builtins= 188 | 189 | 190 | # checks for : 191 | # * methods without self as first argument 192 | # * overridden methods signature 193 | # * access only to existant members via self 194 | # * attributes not defined in the __init__ method 195 | # * supported interfaces implementation 196 | # * unreachable code 197 | # 198 | [CLASSES] 199 | 200 | # List of interface methods to ignore, separated by a comma. This is used for 201 | # instance to not check methods defines in Zope's Interface base class. 202 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 203 | 204 | # List of method names used to declare (i.e. assign) instance attributes. 205 | defining-attr-methods=__init__,__new__,setUp 206 | 207 | 208 | # checks for sign of poor/misdesign: 209 | # * number of methods, attributes, local variables... 210 | # * size, complexity of functions, methods 211 | # 212 | [DESIGN] 213 | 214 | # Maximum number of arguments for function / method 215 | max-args=5 216 | 217 | # Maximum number of locals for function / method body 218 | max-locals=15 219 | 220 | # Maximum number of return / yield for function / method body 221 | max-returns=6 222 | 223 | # Maximum number of branch for function / method body 224 | max-branchs=12 225 | 226 | # Maximum number of statements in function / method body 227 | max-statements=50 228 | 229 | # Maximum number of parents for a class (see R0901). 230 | max-parents=7 231 | 232 | # Maximum number of attributes for a class (see R0902). 233 | max-attributes=7 234 | 235 | # Minimum number of public methods for a class (see R0903). 236 | min-public-methods=2 237 | 238 | # Maximum number of public methods for a class (see R0904). 239 | max-public-methods=20 240 | 241 | 242 | # checks for 243 | # * external modules dependencies 244 | # * relative / wildcard imports 245 | # * cyclic imports 246 | # * uses of deprecated modules 247 | # 248 | [IMPORTS] 249 | 250 | # Deprecated modules which should not be used, separated by a comma 251 | deprecated-modules=regsub,string,TERMIOS,Bastion,rexec 252 | 253 | # Create a graph of every (i.e. internal and external) dependencies in the 254 | # given file (report R0402 must not be disabled) 255 | import-graph= 256 | 257 | # Create a graph of external dependencies in the given file (report R0402 must 258 | # not be disabled) 259 | ext-import-graph= 260 | 261 | # Create a graph of internal dependencies in the given file (report R0402 must 262 | # not be disabled) 263 | int-import-graph= 264 | 265 | 266 | # checks for : 267 | # * unauthorized constructions 268 | # * strict indentation 269 | # * line length 270 | # * use of <> instead of != 271 | # 272 | [FORMAT] 273 | 274 | # Maximum number of characters on a single line. 275 | max-line-length=79 276 | 277 | # Maximum number of lines in a module 278 | max-module-lines=1000 279 | 280 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 281 | # tab). 282 | indent-string=' ' 283 | 284 | 285 | # checks for: 286 | # * warning notes in the code like FIXME, XXX 287 | # * PEP 263: source code with non ascii character but no encoding declaration 288 | # 289 | [MISCELLANEOUS] 290 | 291 | # List of note tags to take in consideration, separated by a comma. 292 | notes=FIXME,XXX,TODO 293 | 294 | 295 | # checks for similarities and duplicated code. This computation may be 296 | # memory / CPU intensive, so you should disable it if you experiments some 297 | # problems. 298 | # 299 | [SIMILARITIES] 300 | 301 | # Minimum lines number of a similarity. 302 | min-similarity-lines=4 303 | 304 | # Ignore comments when computing similarities. 305 | ignore-comments=yes 306 | 307 | # Ignore docstrings when computing similarities. 308 | ignore-docstrings=yes 309 | --------------------------------------------------------------------------------