PEP8 cleanup.

This commit is contained in:
Josh Washburne 2017-12-28 14:44:01 -05:00
parent 2a5c8e02e0
commit 29f7834921
3 changed files with 17 additions and 12 deletions

View file

@ -8,9 +8,10 @@ from .models import Setting
def generate_password(length=32):
possible_characters = string.ascii_letters + string.digits + string.punctuation
chars = string.ascii_letters + string.digits + string.punctuation
rng = random.SystemRandom()
return ''.join([rng.choice(possible_characters) for i in range(length)])
return ''.join([rng.choice(chars) for i in range(length)])
def get_len(rawqueryset):
"""
@ -19,17 +20,21 @@ def get_len(rawqueryset):
"""
def __len__(self):
params = ['{}'.format(p) for p in self.params]
sql = 'SELECT COUNT(*) FROM (' + rawqueryset.raw_query.format(tuple(params)) + ') B;'
sql = ''.join(('SELECT COUNT(*) FROM (',
rawqueryset.raw_query.format(tuple(params)),
') B;'))
cursor = connection.cursor()
cursor.execute(sql)
row = cursor.fetchone()
return row[0]
return __len__
def get_setting(name):
setting = Setting.objects.get(name=name)
return setting.get()
def set_setting(name, value, setting_type=None):
setting_types = {'Integer': 0, 'Float': 1, 'String': 2, 'Bool': 3}
try:
@ -44,6 +49,6 @@ def set_setting(name, value, setting_type=None):
setting_type=setting_types[setting_type],
data=str(value))
else:
error_msg = 'New settings need a type (Integer, Float, String, Bool)'
error_msg = 'New settings need type (Integer, Float, String, Bool)'
raise TypeError(error_msg)
return

View file

@ -8,9 +8,9 @@ CONFIG_DIR = os.path.dirname(SETTINGS_DIR)
PROJECT_DIR = os.path.dirname(CONFIG_DIR)
BASE_DIR = os.path.dirname(PROJECT_DIR)
###
### Django-specific settings
###
#
# Django-specific settings
#
AUTH_PASSWORD_VALIDATORS = [
{
@ -88,9 +88,9 @@ USE_TZ = True
WSGI_APPLICATION = 'savepointradio.wsgi.application'
###
### Radio-specific settings
###
#
# Radio-specific settings
#
RADIO_DJ_EMAIL = config('RADIO_DJ_EMAIL', default='dj@radiostation.net')