Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
add flake8 quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ezwang committed Dec 20, 2019
1 parent 21b588e commit 636cc8f
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 38 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ raven = "*"
requests = "*"
staticgenerator = "*"
Django = "==1.11.23"
flake8-quotes = "*"

[requires]
python_version = "3"
45 changes: 43 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
from django.core.management import execute_from_command_line


if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
execute_from_command_line(sys.argv)
32 changes: 16 additions & 16 deletions media/js/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,45 @@


def main():
usage = "usage: %prog [file1..fileN]"
usage = 'usage: %prog [file1..fileN]'
description = """With no file paths given this script will automatically
compress all jQuery-based files of the admin app. Requires the Google Closure
Compiler library and Java version 6 or later."""
parser = optparse.OptionParser(usage, description=description)
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
help="path to Closure Compiler jar file")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
parser.add_option('-c', dest='compiler', default='~/bin/compiler.jar',
help='path to Closure Compiler jar file')
parser.add_option('-v', '--verbose',
action='store_true', dest='verbose')
parser.add_option('-q', '--quiet',
action='store_false', dest='verbose')
(options, args) = parser.parse_args()

compiler = os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit(
"Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
'Google Closure compiler jar file %s not found. Please use the -c option to specify the path.' % compiler)

if not args:
if options.verbose:
sys.stdout.write(
"No filenames given; defaulting to admin scripts\n")
'No filenames given; defaulting to admin scripts\n')
args = [os.path.join(here, f) for f in [
"actions.js", "collapse.js", "inlines.js", "prepopulate.js"]]
'actions.js', 'collapse.js', 'inlines.js', 'prepopulate.js']]

for arg in args:
if not arg.endswith(".js"):
arg = arg + ".js"
if not arg.endswith('.js'):
arg = arg + '.js'
to_compress = os.path.expanduser(arg)
if os.path.exists(to_compress):
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
cmd = "java -jar %s --js %s --js_output_file %s" % (
to_compress_min = '%s.min.js' % ''.join(arg.rsplit('.js'))
cmd = 'java -jar %s --js %s --js_output_file %s' % (
compiler, to_compress, to_compress_min)
if options.verbose:
sys.stdout.write("Running: %s\n" % cmd)
sys.stdout.write('Running: %s\n' % cmd)
subprocess.call(cmd.split())
else:
sys.stdout.write(
"File %s not found. Sure it exists?\n" % to_compress)
'File %s not found. Sure it exists?\n' % to_compress)


if __name__ == '__main__':
Expand Down
36 changes: 18 additions & 18 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
BASE_DIR = os.path.dirname(os.path.abspath(__file__))

# For hitting the API
DOMAIN = os.getenv("DOMAIN", "http://localhost:8000/api/")
DOMAIN = os.getenv('DOMAIN', 'http://localhost:8000/api/')
# Otherwise, weird bugs occur wherever DOMAIN is used.
assert DOMAIN.endswith("/")
assert DOMAIN.endswith('/')

DEBUG = os.getenv("DEBUG", 'True') == 'True'
DEBUG = os.getenv('DEBUG', 'True') == 'True'

# Used for the /chrome/api proxy endpoint
PROXY_TOKEN = os.getenv("PROXY_TOKEN", None)
PROXY_TOKEN = os.getenv('PROXY_TOKEN', None)

ALLOWED_HOSTS = ["127.0.0.1", "localhost", "[::1]",
"penncoursereview.com", "www.penncoursereview.com",
"api.penncoursereview.com"]
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '[::1]',
'penncoursereview.com', 'www.penncoursereview.com',
'api.penncoursereview.com']

API_HOST = "api.penncoursereview.com"
API_HOST = 'api.penncoursereview.com'

DISPLAY_NAME = os.getenv("API_DISPLAY_NAME", "/")
DISPLAY_NAME = os.getenv('API_DISPLAY_NAME', '/')

# Ensure DISPLAY_NAME is never used relatively by beginning with forward slash
assert DISPLAY_NAME.startswith("/")
assert DISPLAY_NAME.startswith('/')

# making template path relative to allow for modular development
# thanks http://komunitasweb.com/2010/06/relative-path-for-your-django-project/
Expand All @@ -35,9 +35,9 @@

# Necessary for `courses/management/commands/importfromisc.py` and
# `courses/management/commands/mergeprofs.py`
IMPORT_DATABASE_NAME = os.getenv("API_IMPORT_DATABASE_NAME", "old_pcr_2011b")
IMPORT_DATABASE_USER = os.getenv("API_IMPORT_DATABASE_USER", "pcr-daemon")
IMPORT_DATABASE_PWD = os.getenv("API_IMPORT_DATABASE_PWD")
IMPORT_DATABASE_NAME = os.getenv('API_IMPORT_DATABASE_NAME', 'old_pcr_2011b')
IMPORT_DATABASE_USER = os.getenv('API_IMPORT_DATABASE_USER', 'pcr-daemon')
IMPORT_DATABASE_PWD = os.getenv('API_IMPORT_DATABASE_PWD')

DATABASES = {
'default': {
Expand All @@ -48,8 +48,8 @@

DATABASES['default'].update(dj_database_url.config(conn_max_age=600))

if DATABASES["default"]["ENGINE"].endswith("mysql"):
DATABASES["default"]["OPTIONS"] = {
if DATABASES['default']['ENGINE'].endswith('mysql'):
DATABASES['default']['OPTIONS'] = {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
}

Expand Down Expand Up @@ -89,12 +89,12 @@

# Path to local staticfiles
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
os.path.join(BASE_DIR, 'static')
]

# Make this unique, and don't share it with anybody.
SECRET_KEY = os.getenv("SECRET_KEY", 'kwb0pv&py&-&rzw4li@+%o9e)krlmk576)u)m)m_#)@oho(d9^')
assert SECRET_KEY, "No secret key provided"
SECRET_KEY = os.getenv('SECRET_KEY', 'kwb0pv&py&-&rzw4li@+%o9e)krlmk576)u)m)m_#)@oho(d9^')
assert SECRET_KEY, 'No secret key provided!'

MIDDLEWARE_CLASSES = (
'api.middleware.ApiHostMiddleware',
Expand Down

0 comments on commit 636cc8f

Please sign in to comment.