Browse Source

Attacked pep8

Rafał Pitoń 11 years ago
parent
commit
1028731898

+ 2 - 1
misago/conf/dbsettings.py

@@ -35,6 +35,8 @@ class DBSettings(object):
         return data
         return data
 
 
     def get_lazy_setting(self, setting):
     def get_lazy_setting(self, setting):
+        from misago.conf.models import Setting
+
         try:
         try:
             if self._settings[setting]['is_lazy']:
             if self._settings[setting]['is_lazy']:
                 return Setting.objects.get(setting=setting).value
                 return Setting.objects.get(setting=setting).value
@@ -43,7 +45,6 @@ class DBSettings(object):
         except (KeyError, Setting.DoesNotExist):
         except (KeyError, Setting.DoesNotExist):
             raise AttributeError("Setting %s is undefined" % setting)
             raise AttributeError("Setting %s is undefined" % setting)
 
 
-
     def __getattr__(self, attr):
     def __getattr__(self, attr):
         try:
         try:
             return self._settings[attr]['value']
             return self._settings[attr]['value']

+ 4 - 4
misago/conf/defaults.py

@@ -37,7 +37,7 @@ MISAGO_BASE_DIR = os.path.dirname(os.path.dirname(__file__))
 PIPELINE_CSS = {
 PIPELINE_CSS = {
     'misago': {
     'misago': {
         'source_filenames': (
         'source_filenames': (
-          'misago/css/style.less',
+            'misago/css/style.less',
         ),
         ),
         'output_filename': 'misago.css',
         'output_filename': 'misago.css',
     },
     },
@@ -46,8 +46,8 @@ PIPELINE_CSS = {
 PIPELINE_JS = {
 PIPELINE_JS = {
     'misago': {
     'misago': {
         'source_filenames': (
         'source_filenames': (
-          'misago/js/jquery.js',
-          'misago/js/bootstrap.js',
+            'misago/js/jquery.js',
+            'misago/js/bootstrap.js',
         ),
         ),
         'output_filename': 'misago.js',
         'output_filename': 'misago.js',
     }
     }
@@ -56,7 +56,7 @@ PIPELINE_JS = {
 STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
 STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
 
 
 PIPELINE_COMPILERS = (
 PIPELINE_COMPILERS = (
-  'pipeline.compilers.less.LessCompiler',
+    'pipeline.compilers.less.LessCompiler',
 )
 )
 
 
 PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
 PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

+ 1 - 0
misago/conf/migrationutils.py

@@ -86,5 +86,6 @@ def migrate_settings_group(orm, group_fixture, old_group_key=None):
 
 
         setting.save()
         setting.save()
 
 
+
 def delete_settings_cache():
 def delete_settings_cache():
     default_cache.delete(CACHE_KEY)
     default_cache.delete(CACHE_KEY)

+ 1 - 1
misago/conf/models.py

@@ -38,7 +38,7 @@ class Setting(models.Model):
 
 
     @value.setter
     @value.setter
     def value(self, new_value):
     def value(self, new_value):
-        if new_value != None:
+        if new_value is not None:
             self.dry_value = hydrators.dehydrate_value(self.python_type,
             self.dry_value = hydrators.dehydrate_value(self.python_type,
                                                        new_value)
                                                        new_value)
         else:
         else:

+ 18 - 18
misago/conf/tests/test_migrationutils.py

@@ -37,24 +37,24 @@ class DBConfMigrationUtilsTests(TestCase):
             'name': "Test settings",
             'name': "Test settings",
             'description': "Those are test settings.",
             'description': "Those are test settings.",
             'settings': (
             'settings': (
-                            {
-                            'setting': 'fish_name',
-                            'name': "Fish's name",
-                            'value': "Eric",
-                            'field_extra': {
-                                           'min_length': 2,
-                                           'max_length': 255
-                                           },
-                            },
-                            {
-                            'setting': 'fish_license_no',
-                            'name': "Fish's license number",
-                            'default_value': '123-456',
-                            'field_extra': {
-                                           'max_length': 255
-                                           },
-                            },
-                        )
+                {
+                'setting': 'fish_name',
+                'name': "Fish's name",
+                'value': "Eric",
+                'field_extra': {
+                       'min_length': 2,
+                       'max_length': 255
+                    },
+                },
+                {
+                'setting': 'fish_license_no',
+                'name': "Fish's license number",
+                'default_value': '123-456',
+                'field_extra': {
+                        'max_length': 255
+                    },
+                },
+            )
         }
         }
 
 
         migrationutils.migrate_settings_group(self.orm, self.test_group)
         migrationutils.migrate_settings_group(self.orm, self.test_group)

+ 0 - 1
misago/conf/tests/test_models.py

@@ -13,7 +13,6 @@ class SettingModelTests(TestCase):
         self.assertEqual(setting_model.value,
         self.assertEqual(setting_model.value,
                          ['Arthur', 'Lancelot', 'Patsy'])
                          ['Arthur', 'Lancelot', 'Patsy'])
 
 
-
         setting_model = Setting(python_type='list',
         setting_model = Setting(python_type='list',
                                 default_value='Arthur,Patsy')
                                 default_value='Arthur,Patsy')
         self.assertEqual(setting_model.value,
         self.assertEqual(setting_model.value,

+ 36 - 35
misago/core/migrations/0002_db_settings.py

@@ -14,41 +14,42 @@ class Migration(DataMigration):
         migrate_settings_group(
         migrate_settings_group(
             orm,
             orm,
             {
             {
-            'key': 'basic',
-            'name': _("Basic forum settings"),
-            'description': _("Those settings control most basic properties of "
-                             "your forum like it's name or description."),
-            'settings': (
-                            {
-                            'setting': 'forum_name',
-                            'name': _("Forum name"),
-                            'value': "Misago",
-                            'field_extra': {
-                                           'min_length': 2,
-                                           'max_length': 255
-                                           },
-                            },
-                            {
-                            'setting': 'forum_index_title',
-                            'name': _("Forum index title"),
-                            'description': _("You may set custon title on "
-                                             "forum index by typing it here."),
-                            'legend': _("Forum index"),
-                            'field_extra': {
-                                           'max_length': 255
-                                           },
-                            },
-                            {
-                            'setting': 'forum_index_meta_description',
-                            'name': _("Forum index Meta Description"),
-                            'description': _("Short description of your forum "
-                                             "for internet crawlers."),
-                            'field_extra': {
-                                           'max_length': 255
-                                           },
-                            },
-                        )
-            })
+                'key': 'basic',
+                'name': _("Basic forum settings"),
+                'description': _("Those settings control most basic properties of "
+                                 "your forum like it's name or description."),
+                'settings': (
+                    {
+                        'setting': 'forum_name',
+                        'name': _("Forum name"),
+                        'value': "Misago",
+                        'field_extra': {
+                            'min_length': 2,
+                            'max_length': 255
+                        },
+                    },
+                    {
+                        'setting': 'forum_index_title',
+                        'name': _("Forum index title"),
+                        'description': _("You may set custon title on "
+                                         "forum index by typing it here."),
+                        'legend': _("Forum index"),
+                        'field_extra': {
+                            'max_length': 255
+                        },
+                    },
+                    {
+                        'setting': 'forum_index_meta_description',
+                        'name': _("Forum index Meta Description"),
+                        'description': _("Short description of your forum "
+                                         "for internet crawlers."),
+                        'field_extra': {
+                            'max_length': 255
+                        },
+                    },
+                )
+            },
+            )
 
 
 
 
     def backwards(self, orm):
     def backwards(self, orm):

+ 0 - 1
misago/core/tests/test_migrationutils.py

@@ -84,4 +84,3 @@ class CacheBusterUtilsTests(TestCase):
 
 
         with self.assertRaises(ValueError):
         with self.assertRaises(ValueError):
             migrationutils.cachebuster_unregister_cache(self.orm, cache_name)
             migrationutils.cachebuster_unregister_cache(self.orm, cache_name)
-

+ 1 - 1
runtests.py

@@ -16,7 +16,7 @@ def runtests():
             settings_file = py_file.read().replace("{{ project_name }}",
             settings_file = py_file.read().replace("{{ project_name }}",
                                                    "testproject")
                                                    "testproject")
             settings_file = settings_file.replace("{{ secret_key }}",
             settings_file = settings_file.replace("{{ secret_key }}",
-                                                   "t3stpr0j3ct")
+                                                  "t3stpr0j3ct")
 
 
         with open(settings_path, "w") as py_file:
         with open(settings_path, "w") as py_file:
             py_file.write(settings_file)
             py_file.write(settings_file)