nephila / djangocms-installer

Console wizard to bootstrap django CMS projects
https://djangocms-installer.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
177 stars 78 forks source link

Installer generates a settings.py that fails pep8 #308

Closed mikemcgowan closed 6 years ago

mikemcgowan commented 7 years ago

Version djangocms-installer==0.9.6 creates a settings.py with several PEP8 violations:

cms/project/settings.py:2:1: E731 do not assign a lambda expression, use a def
cms/project/settings.py:16:1: E402 module level import not at top of file
cms/project/settings.py:53:64: E231 missing whitespace after ','
cms/project/settings.py:57:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:58:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:59:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:60:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:61:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:62:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:63:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:64:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:65:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:66:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:70:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:71:5: E122 continuation line missing indentation or outdented
cms/project/settings.py:124:5: E266 too many leading '#' for block comment
cms/project/settings.py:129:5: E266 too many leading '#' for block comment
cms/project/settings.py:147:5: E266 too many leading '#' for block comment
cms/project/settings.py:170:1: W293 blank line contains whitespace
import os
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for project project.

Generated by 'django-admin startproject' using Django 1.10.7.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')sxrvb@e%&fah4_ym=3n%)1*pw_18(bc9m+s#18+$asf=kxlt4'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'static')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'project', 'static'),
)
SITE_ID = 1

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'project', 'templates'),],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    'django.template.context_processors.i18n',
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.template.context_processors.media',
    'django.template.context_processors.csrf',
    'django.template.context_processors.tz',
    'sekizai.context_processors.sekizai',
    'django.template.context_processors.static',
    'cms.context_processors.cms_settings'
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader'
            ],
        },
    },
]

MIDDLEWARE_CLASSES = (
    'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware'
)

INSTALLED_APPS = (
    'djangocms_admin_style',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'filer',
    'easy_thumbnails',
    'djangocms_column',
    'djangocms_link',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_utils',
    'djangocms_style',
    'djangocms_snippet',
    'djangocms_googlemap',
    'djangocms_video',
    'project'
)

LANGUAGES = (
    ## Customize this
    ('en', gettext('en')),
)

CMS_LANGUAGES = {
    ## Customize this
    1: [
        {
            'public': True,
            'code': 'en',
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'name': gettext('en'),
        },
    ],
    'default': {
        'public': True,
        'hide_untranslated': False,
        'redirect_on_fallback': True,
    },
}

CMS_TEMPLATES = (
    ## Customize this
    ('fullwidth.html', 'Fullwidth'),
    ('sidebar_left.html', 'Sidebar Left'),
    ('sidebar_right.html', 'Sidebar Right')
)

CMS_PERMISSION = True

CMS_PLACEHOLDER_CONF = {}

DATABASES = {
    'default': {
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'HOST': 'pgsql',
        'NAME': 'cms',
        'PASSWORD': 'Wibble123!',
        'PORT': 5432,
        'USER': 'postgres'
    }
}

MIGRATION_MODULES = {

}

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters'
)
yakky commented 6 years ago

Settings.py is generated by doing string.replace on settings.py generated from django-admin startproject to be as forward compatible as possible and reduce the compatibility issues. This leads less than optimal formatting, but has proven quite robust despite the huge changes in settings.py since the inception of this project. As the generated settings.py will need further editing to adapt to the need of each project, I don't see the lack of pep8 compliance as an issue as one can easily reformat themselves according to their codestyle I'm closing this but feel free to add futher considerations