mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
magic-removal: Fixed negligible indentation errors.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2771 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a5afa8af63
commit
6ec3a4d9ee
@ -17,11 +17,11 @@ DOT = '.'
|
|||||||
|
|
||||||
def paginator_number(cl,i):
|
def paginator_number(cl,i):
|
||||||
if i == DOT:
|
if i == DOT:
|
||||||
return '... '
|
return '... '
|
||||||
elif i == cl.page_num:
|
elif i == cl.page_num:
|
||||||
return '<span class="this-page">%d</span> ' % (i+1)
|
return '<span class="this-page">%d</span> ' % (i+1)
|
||||||
else:
|
else:
|
||||||
return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
|
return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
|
||||||
paginator_number = register.simple_tag(paginator_number)
|
paginator_number = register.simple_tag(paginator_number)
|
||||||
|
|
||||||
def pagination(cl):
|
def pagination(cl):
|
||||||
@ -167,7 +167,7 @@ def items_for_result(cl, result):
|
|||||||
else:
|
else:
|
||||||
result_repr = escape(str(field_val))
|
result_repr = escape(str(field_val))
|
||||||
if result_repr == '':
|
if result_repr == '':
|
||||||
result_repr = ' '
|
result_repr = ' '
|
||||||
if first: # First column is a special case
|
if first: # First column is a special case
|
||||||
first = False
|
first = False
|
||||||
url = cl.url_for_result(result)
|
url = cl.url_for_result(result)
|
||||||
|
@ -102,7 +102,7 @@ class FieldWrapper(object):
|
|||||||
return self.field.blank and ' class="optional"' or ''
|
return self.field.blank and ' class="optional"' or ''
|
||||||
|
|
||||||
def use_raw_id_admin(self):
|
def use_raw_id_admin(self):
|
||||||
return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
|
return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
|
||||||
and self.field.rel.raw_id_admin
|
and self.field.rel.raw_id_admin
|
||||||
|
|
||||||
class FormFieldCollectionWrapper(object):
|
class FormFieldCollectionWrapper(object):
|
||||||
@ -183,7 +183,7 @@ auto_populated_field_script = register.simple_tag(auto_populated_field_script)
|
|||||||
def filter_interface_script_maybe(bound_field):
|
def filter_interface_script_maybe(bound_field):
|
||||||
f = bound_field.field
|
f = bound_field.field
|
||||||
if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface:
|
if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface:
|
||||||
return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
|
return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
|
||||||
' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (
|
' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (
|
||||||
f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX)
|
f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX)
|
||||||
else:
|
else:
|
||||||
|
@ -32,7 +32,7 @@ class ModPythonRequest(http.HttpRequest):
|
|||||||
|
|
||||||
def _get_request(self):
|
def _get_request(self):
|
||||||
if not hasattr(self, '_request'):
|
if not hasattr(self, '_request'):
|
||||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||||
return self._request
|
return self._request
|
||||||
|
|
||||||
def _get_get(self):
|
def _get_get(self):
|
||||||
|
@ -79,7 +79,7 @@ class WSGIRequest(http.HttpRequest):
|
|||||||
|
|
||||||
def _get_request(self):
|
def _get_request(self):
|
||||||
if not hasattr(self, '_request'):
|
if not hasattr(self, '_request'):
|
||||||
self._request = datastructures.MergeDict(self.POST, self.GET)
|
self._request = datastructures.MergeDict(self.POST, self.GET)
|
||||||
return self._request
|
return self._request
|
||||||
|
|
||||||
def _get_get(self):
|
def _get_get(self):
|
||||||
|
@ -159,15 +159,15 @@ def _get_sql_model_create(klass, models_already_seen=set()):
|
|||||||
if f.primary_key:
|
if f.primary_key:
|
||||||
field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
|
field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
|
||||||
if f.rel:
|
if f.rel:
|
||||||
if f.rel.to in models_already_seen:
|
if f.rel.to in models_already_seen:
|
||||||
field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \
|
field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \
|
||||||
style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \
|
style.SQL_TABLE(backend.quote_name(f.rel.to._meta.db_table)) + ' (' + \
|
||||||
style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')'
|
style.SQL_FIELD(backend.quote_name(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# We haven't yet created the table to which this field
|
# We haven't yet created the table to which this field
|
||||||
# is related, so save it for later.
|
# is related, so save it for later.
|
||||||
pr = pending_references.setdefault(f.rel.to, []).append((klass, f))
|
pr = pending_references.setdefault(f.rel.to, []).append((klass, f))
|
||||||
table_output.append(' '.join(field_output))
|
table_output.append(' '.join(field_output))
|
||||||
if opts.order_with_respect_to:
|
if opts.order_with_respect_to:
|
||||||
table_output.append(style.SQL_FIELD(backend.quote_name('_order')) + ' ' + \
|
table_output.append(style.SQL_FIELD(backend.quote_name('_order')) + ' ' + \
|
||||||
@ -836,7 +836,7 @@ def get_validation_errors(outfile, app=None):
|
|||||||
if f.rel:
|
if f.rel:
|
||||||
rel_opts = f.rel.to._meta
|
rel_opts = f.rel.to._meta
|
||||||
if f.rel.to not in models.get_models():
|
if f.rel.to not in models.get_models():
|
||||||
e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name))
|
e.add(opts, "'%s' has relation with uninstalled model %s" % (f.name, rel_opts.object_name))
|
||||||
|
|
||||||
rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
|
rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()
|
||||||
for r in rel_opts.fields:
|
for r in rel_opts.fields:
|
||||||
|
@ -383,7 +383,7 @@ class ServerHandler:
|
|||||||
assert type(data) is StringType,"write() argument must be string"
|
assert type(data) is StringType,"write() argument must be string"
|
||||||
|
|
||||||
if not self.status:
|
if not self.status:
|
||||||
raise AssertionError("write() before start_response()")
|
raise AssertionError("write() before start_response()")
|
||||||
|
|
||||||
elif not self.headers_sent:
|
elif not self.headers_sent:
|
||||||
# Before the first output, send the stored headers
|
# Before the first output, send the stored headers
|
||||||
|
@ -305,9 +305,9 @@ class Field(object):
|
|||||||
|
|
||||||
def _get_val_from_obj(self, obj):
|
def _get_val_from_obj(self, obj):
|
||||||
if obj:
|
if obj:
|
||||||
return getattr(obj, self.attname)
|
return getattr(obj, self.attname)
|
||||||
else:
|
else:
|
||||||
return self.get_default()
|
return self.get_default()
|
||||||
|
|
||||||
def flatten_data(self, follow, obj=None):
|
def flatten_data(self, follow, obj=None):
|
||||||
"""
|
"""
|
||||||
@ -577,7 +577,7 @@ class FileField(Field):
|
|||||||
dispatcher.connect(self.delete_file, signal=signals.post_delete, sender=cls)
|
dispatcher.connect(self.delete_file, signal=signals.post_delete, sender=cls)
|
||||||
|
|
||||||
def delete_file(self, instance):
|
def delete_file(self, instance):
|
||||||
if getattr(instance, self.attname):
|
if getattr(instance, self.attname):
|
||||||
file_name = getattr(instance, 'get_%s_filename' % self.name)()
|
file_name = getattr(instance, 'get_%s_filename' % self.name)()
|
||||||
# If the file exists and no other object of this type references it,
|
# If the file exists and no other object of this type references it,
|
||||||
# delete it from the filesystem.
|
# delete it from the filesystem.
|
||||||
|
@ -539,7 +539,7 @@ class OneToOneField(RelatedField, IntegerField):
|
|||||||
def contribute_to_related_class(self, cls, related):
|
def contribute_to_related_class(self, cls, related):
|
||||||
setattr(cls, related.get_accessor_name(), SingleRelatedObjectDescriptor(related))
|
setattr(cls, related.get_accessor_name(), SingleRelatedObjectDescriptor(related))
|
||||||
if not cls._meta.one_to_one_field:
|
if not cls._meta.one_to_one_field:
|
||||||
cls._meta.one_to_one_field = self
|
cls._meta.one_to_one_field = self
|
||||||
|
|
||||||
class ManyToManyField(RelatedField, Field):
|
class ManyToManyField(RelatedField, Field):
|
||||||
def __init__(self, to, **kwargs):
|
def __init__(self, to, **kwargs):
|
||||||
@ -613,16 +613,16 @@ class ManyToManyField(RelatedField, Field):
|
|||||||
if obj:
|
if obj:
|
||||||
instance_ids = [instance._get_pk_val() for instance in getattr(obj, self.name).all()]
|
instance_ids = [instance._get_pk_val() for instance in getattr(obj, self.name).all()]
|
||||||
if self.rel.raw_id_admin:
|
if self.rel.raw_id_admin:
|
||||||
new_data[self.name] = ",".join([str(id) for id in instance_ids])
|
new_data[self.name] = ",".join([str(id) for id in instance_ids])
|
||||||
else:
|
else:
|
||||||
new_data[self.name] = instance_ids
|
new_data[self.name] = instance_ids
|
||||||
else:
|
else:
|
||||||
# In required many-to-many fields with only one available choice,
|
# In required many-to-many fields with only one available choice,
|
||||||
# select that one available choice.
|
# select that one available choice.
|
||||||
if not self.blank and not self.rel.edit_inline and not self.rel.raw_id_admin:
|
if not self.blank and not self.rel.edit_inline and not self.rel.raw_id_admin:
|
||||||
choices_list = self.get_choices_default()
|
choices_list = self.get_choices_default()
|
||||||
if len(choices_list) == 1:
|
if len(choices_list) == 1:
|
||||||
new_data[self.name] = [choices_list[0][0]]
|
new_data[self.name] = [choices_list[0][0]]
|
||||||
return new_data
|
return new_data
|
||||||
|
|
||||||
def contribute_to_class(self, cls, name):
|
def contribute_to_class(self, cls, name):
|
||||||
|
@ -239,7 +239,7 @@ class AdminFieldSet(object):
|
|||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "FieldSet: (%s, %s)" % (self.name, self.field_lines)
|
return "FieldSet: (%s, %s)" % (self.name, self.field_lines)
|
||||||
|
|
||||||
def bind(self, field_mapping, original, bound_field_set_class):
|
def bind(self, field_mapping, original, bound_field_set_class):
|
||||||
return bound_field_set_class(self, field_mapping, original)
|
return bound_field_set_class(self, field_mapping, original)
|
||||||
|
@ -52,9 +52,9 @@ class RelatedObject(object):
|
|||||||
|
|
||||||
count = len(objects) + self.field.rel.num_extra_on_change
|
count = len(objects) + self.field.rel.num_extra_on_change
|
||||||
if self.field.rel.min_num_in_admin:
|
if self.field.rel.min_num_in_admin:
|
||||||
count = max(count, self.field.rel.min_num_in_admin)
|
count = max(count, self.field.rel.min_num_in_admin)
|
||||||
if self.field.rel.max_num_in_admin:
|
if self.field.rel.max_num_in_admin:
|
||||||
count = min(count, self.field.rel.max_num_in_admin)
|
count = min(count, self.field.rel.max_num_in_admin)
|
||||||
|
|
||||||
change = count - len(objects)
|
change = count - len(objects)
|
||||||
if change > 0:
|
if change > 0:
|
||||||
|
@ -327,10 +327,10 @@ class FormField:
|
|||||||
new_data.setlist(name, converted_data)
|
new_data.setlist(name, converted_data)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
#individual fields deal with None values themselves
|
#individual fields deal with None values themselves
|
||||||
new_data.setlist(name, [self.__class__.html2python(None)])
|
new_data.setlist(name, [self.__class__.html2python(None)])
|
||||||
except EmptyValue:
|
except EmptyValue:
|
||||||
new_data.setlist(name, [])
|
new_data.setlist(name, [])
|
||||||
|
|
||||||
|
|
||||||
def run_validator(self, new_data, validator):
|
def run_validator(self, new_data, validator):
|
||||||
@ -348,7 +348,7 @@ class FormField:
|
|||||||
try:
|
try:
|
||||||
for validator in self.validator_list:
|
for validator in self.validator_list:
|
||||||
try:
|
try:
|
||||||
self.run_validator(new_data, validator)
|
self.run_validator(new_data, validator)
|
||||||
except validators.ValidationError, e:
|
except validators.ValidationError, e:
|
||||||
errors.setdefault(self.field_name, []).extend(e.messages)
|
errors.setdefault(self.field_name, []).extend(e.messages)
|
||||||
# If a CriticalValidationError is raised, ignore any other ValidationErrors
|
# If a CriticalValidationError is raised, ignore any other ValidationErrors
|
||||||
|
@ -198,7 +198,7 @@ class DebugLexer(Lexer):
|
|||||||
upto = end
|
upto = end
|
||||||
last_bit = self.template_string[upto:]
|
last_bit = self.template_string[upto:]
|
||||||
if last_bit:
|
if last_bit:
|
||||||
token_tups.append( (last_bit, (upto, upto + len(last_bit))) )
|
token_tups.append( (last_bit, (upto, upto + len(last_bit))) )
|
||||||
return [self.create_token(tok, (self.origin, loc)) for tok, loc in token_tups]
|
return [self.create_token(tok, (self.origin, loc)) for tok, loc in token_tups]
|
||||||
|
|
||||||
def create_token(self, token_string, source):
|
def create_token(self, token_string, source):
|
||||||
@ -245,7 +245,7 @@ class Parser(object):
|
|||||||
compiled_result = compile_func(self, token)
|
compiled_result = compile_func(self, token)
|
||||||
except TemplateSyntaxError, e:
|
except TemplateSyntaxError, e:
|
||||||
if not self.compile_function_error(token, e):
|
if not self.compile_function_error(token, e):
|
||||||
raise
|
raise
|
||||||
self.extend_nodelist(nodelist, compiled_result, token)
|
self.extend_nodelist(nodelist, compiled_result, token)
|
||||||
self.exit_command()
|
self.exit_command()
|
||||||
if parse_until:
|
if parse_until:
|
||||||
@ -731,7 +731,7 @@ class VariableNode(Node):
|
|||||||
class DebugVariableNode(VariableNode):
|
class DebugVariableNode(VariableNode):
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
try:
|
try:
|
||||||
output = self.filter_expression.resolve(context)
|
output = self.filter_expression.resolve(context)
|
||||||
except TemplateSyntaxError, e:
|
except TemplateSyntaxError, e:
|
||||||
if not hasattr(e, 'source'):
|
if not hasattr(e, 'source'):
|
||||||
e.source = self.source
|
e.source = self.source
|
||||||
|
@ -86,7 +86,7 @@ class ConstantIncludeNode(Node):
|
|||||||
self.template = t
|
self.template = t
|
||||||
except:
|
except:
|
||||||
if settings.TEMPLATE_DEBUG:
|
if settings.TEMPLATE_DEBUG:
|
||||||
raise
|
raise
|
||||||
self.template = None
|
self.template = None
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
@ -100,16 +100,16 @@ class IncludeNode(Node):
|
|||||||
self.template_name = template_name
|
self.template_name = template_name
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
try:
|
try:
|
||||||
template_name = resolve_variable(self.template_name, context)
|
template_name = resolve_variable(self.template_name, context)
|
||||||
t = get_template(template_name)
|
t = get_template(template_name)
|
||||||
return t.render(context)
|
return t.render(context)
|
||||||
except TemplateSyntaxError, e:
|
except TemplateSyntaxError, e:
|
||||||
if settings.TEMPLATE_DEBUG:
|
if settings.TEMPLATE_DEBUG:
|
||||||
raise
|
raise
|
||||||
return ''
|
return ''
|
||||||
except:
|
except:
|
||||||
return '' # Fail silently for invalid included templates.
|
return '' # Fail silently for invalid included templates.
|
||||||
|
|
||||||
def do_block(parser, token):
|
def do_block(parser, token):
|
||||||
"""
|
"""
|
||||||
|
@ -24,14 +24,14 @@ def lazy(func, *resultclasses):
|
|||||||
# the evaluation and store the result. Afterwards, the result
|
# the evaluation and store the result. Afterwards, the result
|
||||||
# is delivered directly. So the result is memoized.
|
# is delivered directly. So the result is memoized.
|
||||||
def __init__(self, args, kw):
|
def __init__(self, args, kw):
|
||||||
self.__func = func
|
self.__func = func
|
||||||
self.__args = args
|
self.__args = args
|
||||||
self.__kw = kw
|
self.__kw = kw
|
||||||
self.__dispatch = {}
|
self.__dispatch = {}
|
||||||
for resultclass in resultclasses:
|
for resultclass in resultclasses:
|
||||||
self.__dispatch[resultclass] = {}
|
self.__dispatch[resultclass] = {}
|
||||||
for (k, v) in resultclass.__dict__.items():
|
for (k, v) in resultclass.__dict__.items():
|
||||||
setattr(self, k, self.__promise__(resultclass, k, v))
|
setattr(self, k, self.__promise__(resultclass, k, v))
|
||||||
|
|
||||||
def __promise__(self, klass, funcname, func):
|
def __promise__(self, klass, funcname, func):
|
||||||
# Builds a wrapper around some magic method and registers that magic
|
# Builds a wrapper around some magic method and registers that magic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user