Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adjusted inspectdb management command to yield PEP 8-compliant output…

… barring Django Coding Style exceptions.
  • Loading branch information...
commit 298a2b577ffbe7f8ed00588694c792ac9adcefbe 1 parent bc7668e
Justin Turner Arthur JustinTArthur authored timgraham committed
11 django/core/management/commands/inspectdb.py
View
@@ -50,12 +50,13 @@ def handle_inspection(self, options):
yield "from __future__ import unicode_literals"
yield ''
yield 'from %s import models' % self.db_module
- yield ''
known_models = []
for table_name in connection.introspection.table_names(cursor):
if table_name_filter is not None and callable(table_name_filter):
if not table_name_filter(table_name):
continue
+ yield ''
+ yield ''
yield 'class %s(models.Model):' % table2model(table_name)
known_models.append(table2model(table_name))
try:
@@ -134,7 +135,7 @@ def handle_inspection(self, options):
for k, v in extra_params.items()])
field_desc += ')'
if comment_notes:
- field_desc += ' # ' + ' '.join(comment_notes)
+ field_desc += ' # ' + ' '.join(comment_notes)
yield ' %s' % field_desc
for meta_line in self.get_meta(table_name):
yield meta_line
@@ -239,7 +240,7 @@ def get_meta(self, table_name):
to construct the inner Meta class for the model corresponding
to the given database table name.
"""
- return [" class Meta:",
+ return ["",
+ " class Meta:",
" managed = False",
- " db_table = '%s'" % table_name,
- ""]
+ " db_table = '%s'" % table_name]
4 tests/inspectdb/tests.py
View
@@ -45,7 +45,7 @@ def assertFieldType(name, definition):
self.assertEqual(definition, out_def)
if not connection.features.can_introspect_autofield:
- assertFieldType('id', "models.IntegerField(primary_key=True) # AutoField?")
+ assertFieldType('id', "models.IntegerField(primary_key=True) # AutoField?")
assertFieldType('big_int_field', "models.BigIntegerField()")
if connection.vendor == 'mysql':
# No native boolean type on MySQL
@@ -60,7 +60,7 @@ def assertFieldType(name, definition):
assertFieldType('date_time_field', "models.DateTimeField()")
if connection.vendor == 'sqlite':
# Guessed arguments, see #5014
- assertFieldType('decimal_field', "models.DecimalField(max_digits=10, decimal_places=5) "
+ assertFieldType('decimal_field', "models.DecimalField(max_digits=10, decimal_places=5) "
"# max_digits and decimal_places have been guessed, as this database handles decimal fields as float")
else:
assertFieldType('decimal_field', "models.DecimalField(max_digits=6, decimal_places=1)")
Please sign in to comment.
Something went wrong with that request. Please try again.