Browse Source

Ignore already set verbose_name on source rewrite

pull/6/head
Marcio Mazza 10 years ago
parent
commit
917bfb841e
  1. 8
      legacy/scripts/scrap_original_forms.py

8
legacy/scripts/scrap_original_forms.py

@ -90,7 +90,7 @@ def source_with_verbose_names(model):
source = getsourcelines(model)[0] source = getsourcelines(model)[0]
title, labels, non_matched = extract_verbose_names(model) title, labels, non_matched = extract_verbose_names(model)
field_regex = ' *(.+) = (models\..*)\((.*)\)' field_regex = ' *(.+) = (models\.[^\(]*)\((.*verbose_name=_\(.*\)|.*)\)'
new_lines = [] new_lines = []
class_meta_already_exists = False class_meta_already_exists = False
for line in source[1:]: for line in source[1:]:
@ -102,10 +102,10 @@ def source_with_verbose_names(model):
name, path, args, legacy_name = split(match.groups()) name, path, args, legacy_name = split(match.groups())
if name in labels and 'verbose_name' not in args: if name in labels and 'verbose_name' not in args:
args = [args] if args.strip() else [] args = [args] if args.strip() else []
args.append("verbose_name=_(u'%s')" % labels[name]) args.append(u"verbose_name=_(u'%s')" % labels[name])
args = ', '.join(args) args = u', '.join(args)
new_lines.append( new_lines.append(
(' %s = %s(%s)' % (name, path, args), legacy_name)) (u' %s = %s(%s)' % (name, path, args), legacy_name))
break break
else: else:
if 'class Meta:' in line: if 'class Meta:' in line:

Loading…
Cancel
Save