Commits

Waldemar Kornewald  committed d4f2296

pep8 cleanup

  • Participants
  • Parent commits f9175cf

Comments (0)

Files changed (12)

     compiler_module = __name__.rsplit('.', 1)[0] + '.compiler'
 
     DEFAULT_MAX_DIGITS = 16
+
     def value_to_db_decimal(self, value, max_digits, decimal_places):
-        if value is None: 
+        if value is None:
             return None
         sign = value < 0 and u'-' or u''
         if sign: 
     def flush(self):
         """Helper function to remove the current datastore and re-open the stubs"""
         if self.remote:
-            import random, string
+            import random
+            import string
             code = ''.join([random.choice(string.ascii_letters) for x in range(4)])
             print '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
             print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'

File db/compiler.py

                 key_type_error = 'Lookup values on primary keys have to be' \
                                  'a string or an integer.'
                 if lookup_type == 'range':
-                    if isinstance(value,(list, tuple)) and not(isinstance(
-                            value[0], (basestring, int, long)) and \
+                    if isinstance(value, (list, tuple)) and not (
+                            isinstance(value[0], (basestring, int, long)) and
                             isinstance(value[1], (basestring, int, long))):
                         raise DatabaseError(key_type_error)
-                elif not isinstance(value,(basestring, int, long)):
+                elif not isinstance(value, (basestring, int, long)):
                     raise DatabaseError(key_type_error)
                 # for lookup type range we have to deal with a list
                 if lookup_type == 'range':
 
 def set_cursor(queryset, start=None, end=None):
     queryset = queryset.all()
+
     class CursorQuery(CursorQueryMixin, queryset.query.__class__):
         pass
+
     queryset.query = queryset.query.clone(klass=CursorQuery)
     if start is not None:
         start = Cursor.from_websafe_string(start)
 from email.MIMEBase import MIMEBase
-
 from django.core.mail.backends.base import BaseEmailBackend
 from django.core.mail import EmailMultiAlternatives
 from django.core.exceptions import ImproperlyConfigured
-
 from google.appengine.api import mail as aeemail
 
 def _send_deferred(message):

File main/main.py

     run_wsgi_app(application)
 
 def profile_main(func):
-    import logging, cProfile, pstats, random, StringIO
+    from cStringIO import StringIO
+    import cProfile
+    import logging
+    import pstats
+    import random
     only_forced_profile = getattr(settings, 'ONLY_FORCED_PROFILE', False)
     profile_percentage = getattr(settings, 'PROFILE_PERCENTAGE', None)
     if (only_forced_profile and
 
     prof = cProfile.Profile()
     prof = prof.runctx('func()', globals(), locals())
-    stream = StringIO.StringIO()
+    stream = StringIO()
     stats = pstats.Stats(prof, stream=stream)
     sort_by = getattr(settings, 'SORT_PROFILE_RESULTS_BY', 'time')
     if not isinstance(sort_by, (list, tuple)):

File tests/backend.py

 class BackendTest(TestCase):
     def test_model_forms(self):
         from django import forms
+
         class F(forms.ModelForm):
             class Meta:
                 model = A

File tests/decimals.py

 D = Decimal
 
 class DecimalTest(TestCase):
-    DECIMALS =  D("12345.6789"), D("5"), D("345.67"), D("45.6"), D("2345.678"),
+    DECIMALS = D("12345.6789"), D("5"), D("345.67"), D("45.6"), D("2345.678")
 
     def setUp(self):
         for d in self.DECIMALS:
-          DecimalModel(decimal=d).save()
+            DecimalModel(decimal=d).save()
 
     def test_filter(self):
         d = DecimalModel.objects.get(decimal=D("5.0"))

File tests/field_db_conversion.py

         for name, gae_db_type in [('long_text', Text),
                 ('indexed_text', unicode), ('xml', Text),
                 ('text', unicode), ('ip_address', unicode), ('slug', unicode),
-                ('email', unicode),('comma_seperated_integer', unicode),
+                ('email', unicode), ('comma_seperated_integer', unicode),
                 ('url', unicode), ('time', datetime.datetime),
                 ('datetime', datetime.datetime), ('date', datetime.datetime),
                 ('floating_point', float), ('boolean', bool),

File tests/field_options.py

             entity.pk))
         self.assertTrue(gae_entity is not None)
         self.assertEquals(gae_entity.key().name(), u'app-engine@scholardocs.com')
-        
+
         # check if default values are set correctly on the db level,
         # primary_key field is not stored at the db level
         for field in FieldsWithOptionsModel._meta.local_fields:

File tests/filter.py

         datetime.datetime(2010, 12, 31, 23, 59, 59, 999999),
         datetime.datetime(2011, 1, 1, 0, 0, 0, 0),
         datetime.datetime(2013, 7, 28, 22, 30, 20, 50)]
-    
+
     def setUp(self):
         for index, (float, email, datetime_value) in enumerate(zip(FilterTest.floats,
                 FilterTest.emails, FilterTest.datetimes)):
         self.assertEquals(sorted([entity.email for entity in
                             FieldsWithOptionsModel.objects.filter(
                             foreign_key__gt=2)]),
-                            ['rasengan@naruto.com', 'rinnengan@sage.de', ])
+                            ['rasengan@naruto.com', 'rinnengan@sage.de'])
 
         # and with instance
         ordered_instance = OrderedModel.objects.get(priority=1)
         self.assertEquals(sorted([entity.email for entity in
                             FieldsWithOptionsModel.objects.filter(
                             foreign_key__gt=ordered_instance)]),
-                            ['rasengan@naruto.com', 'rinnengan@sage.de', ])
-
+                            ['rasengan@naruto.com', 'rinnengan@sage.de'])
 
     def test_lt(self):
         # test lt on float
                             FieldsWithOptionsModel.objects.filter(
                             time__lt=self.last_save_time).order_by('time')],
                             ['app-engine@scholardocs.com', 'sharingan@uchias.com',
-                            'rinnengan@sage.de',])
+                             'rinnengan@sage.de'])
 
         # test ForeignKeys with id
         self.assertEquals(sorted([entity.email for entity in
                             foreign_key__lt=ordered_instance)]),
                             ['app-engine@scholardocs.com', 'sharingan@uchias.com'])
 
-
     def test_gte(self):
         # test gte on float
         self.assertEquals([entity.floating_point for entity in
 #        self.assertEquals(FieldsWithOptionsModel.objects.filter(
 #            foreign_key__isnull=True).count(), 1)
 
-
     def test_exclude(self):
         self.assertEquals([entity.email for entity in
                             FieldsWithOptionsModel.objects.all().exclude(
         self.assertEquals(sorted([entity.email for entity in
                             FieldsWithOptionsModel.objects.all().exclude(
                             foreign_key__gt=ordered_instance)]),
-                            ['app-engine@scholardocs.com', 'sharingan@uchias.com',])
+                            ['app-engine@scholardocs.com', 'sharingan@uchias.com'])
 
     def test_exclude_pk(self):
         self.assertEquals([entity.pk for entity in
         self.assertEquals([entity.email for entity in
                           FieldsWithOptionsModel.objects.all().order_by(
                             'email')[::2]],
-                          ['app-engine@scholardocs.com', 'rinnengan@sage.de',])
+                          ['app-engine@scholardocs.com', 'rinnengan@sage.de'])
 
     def test_cursor(self):
         results = list(FieldsWithOptionsModel.objects.all())
         Post(writer=1, order=3).save()
         Post(writer=2, order=4).save()
         Post(writer=2, order=5).save()
-        posts = Post.objects.filter(writer__in= [1,2]).order_by('order')
+        posts = Post.objects.filter(writer__in=[1, 2]).order_by('order')
         orders = [post.order for post in posts]
         self.assertEqual(orders, range(1, 6))
-        posts = Post.objects.filter(writer__in= [1,2]).order_by('-order')
+        posts = Post.objects.filter(writer__in=[1, 2]).order_by('-order')
         orders = [post.order for post in posts]
         self.assertEqual(orders, range(5, 0, -1))
 
         self.assertEquals([entity.floating_point for entity in
                           FieldsWithOptionsModel.objects.filter(
                           floating_point__range=(2.6, 9.1)).
-                          order_by('floating_point')], [2.6, 5.3, 9.1,])
+                          order_by('floating_point')], [2.6, 5.3, 9.1])
 
         # test range on pk
         self.assertEquals([entity.pk for entity in
                           FieldsWithOptionsModel.objects.filter(
                           pk__range=('app-engine@scholardocs.com', 'rinnengan@sage.de')).
-                          order_by('pk')], ['app-engine@scholardocs.com',
-                          'rasengan@naruto.com', 'rinnengan@sage.de',])
+                          order_by('pk')],
+                          ['app-engine@scholardocs.com',
+                           'rasengan@naruto.com', 'rinnengan@sage.de'])
 
         # test range on date/datetime objects
         start_time = datetime.time(self.last_save_time.hour,
                             FieldsWithOptionsModel.objects.filter(
                             time__range=(start_time, self.last_save_time)).order_by('time')],
                             ['app-engine@scholardocs.com', 'sharingan@uchias.com',
-                            'rinnengan@sage.de', 'rasengan@naruto.com',])
+                             'rinnengan@sage.de', 'rasengan@naruto.com'])
 
     def test_date(self):
         # test year on date range boundaries
                             DateTimeModel.objects.filter(
                             datetime__year=2010).order_by('datetime')],
                             [datetime.datetime(2010, 1, 1, 0, 0, 0, 0),
-                             datetime.datetime(2010, 12, 31, 23, 59, 59, 999999),])
+                             datetime.datetime(2010, 12, 31, 23, 59, 59, 999999)])
 
         # test year on non boundary date
         self.assertEquals([entity.datetime for entity in
                             DateTimeModel.objects.filter(
                             datetime__year=2013).order_by('datetime')],
-                            [datetime.datetime(2013, 7, 28, 22, 30, 20, 50),])
+                            [datetime.datetime(2013, 7, 28, 22, 30, 20, 50)])
 
     def test_auto_now(self):
         time.sleep(0.1)

File tests/order.py

                           priorities)
 
     # TODO: test multiple orders
-

File tests/testmodels.py

     date = models.DateField(auto_now_add=True)
     time = models.TimeField()
     floating_point = models.FloatField(null=True)
-    boolean = models.BooleanField() # default is False
+    boolean = models.BooleanField()
     null_boolean = models.NullBooleanField(default=True)
     text = models.CharField(default='Hallo', max_length=10)
     email = models.EmailField(default='app-engine@scholardocs.com', primary_key=True)