Browse Source

Port print statements to python 3

pull/6/head
Marcio Mazza 10 years ago
parent
commit
ea39d59863
  1. 10
      legacy/migration.py
  2. 16
      legacy/scripts/scrap_original_forms.py
  3. 2
      legacy/scripts/study.py

10
legacy/migration.py

@ -80,11 +80,11 @@ def get_renames():
# MIGRATION ################################################################# # MIGRATION #################################################################
def info(msg): def info(msg):
print 'INFO: ' + msg print('INFO: ' + msg)
def warn(msg): def warn(msg):
print 'WARNING! ' + msg print('WARNING! ' + msg)
special_transforms = {} special_transforms = {}
@ -186,10 +186,10 @@ def migrate_model(model, to_delete, count_limit=None):
legacy_model_name = model_renames.get(model, model.__name__) legacy_model_name = model_renames.get(model, model.__name__)
if legacy_model_name.upper() == 'IGNORE': if legacy_model_name.upper() == 'IGNORE':
print 'Model ignored: %s' % model.__name__ print('Model ignored: %s' % model.__name__)
return return
print 'Migrating %s...' % model.__name__ print('Migrating %s...' % model.__name__)
# clear all model entries # clear all model entries
model.objects.all().delete() model.objects.all().delete()
@ -261,4 +261,4 @@ def get_ind_excluido(obj):
def check_app_no_ind_excluido(app): def check_app_no_ind_excluido(app):
for model in app.models.values(): for model in app.models.values():
assert not any(get_ind_excluido(obj) for obj in model.objects.all()) assert not any(get_ind_excluido(obj) for obj in model.objects.all())
print 'OK!' print('OK!')

16
legacy/scripts/scrap_original_forms.py

@ -62,11 +62,11 @@ def get_names_labels(fieldsets):
def print_title_and_fieldsets(model): def print_title_and_fieldsets(model):
title, fieldsets = extract_title_and_fieldsets(model) title, fieldsets = extract_title_and_fieldsets(model)
print '#### %s ####\n' % title print('#### %s ####\n' % title)
for fieldset in fieldsets: for fieldset in fieldsets:
print fieldset['legend'] print(fieldset['legend'])
for line in fieldset['lines']: for line in fieldset['lines']:
print ' ' + ' | '.join('%s : %s' % (id, label) for id, label in line) print(' ' + ' | '.join('%s : %s' % (id, label) for id, label in line))
def extract_verbose_names(model): def extract_verbose_names(model):
@ -159,7 +159,7 @@ def source_with_verbose_names(model):
def print_app_with_verbose_names(app): def print_app_with_verbose_names(app):
print '##################################################################' print('##################################################################')
header = '# -*- coding: utf-8 -*-\n' header = '# -*- coding: utf-8 -*-\n'
for line in getsourcelines(app.models_module): for line in getsourcelines(app.models_module):
if line in ['# -*- coding: utf-8 -*-', if line in ['# -*- coding: utf-8 -*-',
@ -173,14 +173,14 @@ from django.utils.translation import ugettext as _
break break
else: else:
header += line + '\n' header += line + '\n'
print header.strip() print(header.strip())
for model in app.models.values(): for model in app.models.values():
print '\n' print('\n')
for p in source_with_verbose_names(model): for p in source_with_verbose_names(model):
print p print(p)
def list_models_with_no_scrapped_data(app): def list_models_with_no_scrapped_data(app):
for model in app.models.values(): for model in app.models.values():
if not any(extract_verbose_names(model)[:2]): if not any(extract_verbose_names(model)[:2]):
print model.__name__ print(model.__name__)

2
legacy/scripts/study.py

@ -5,6 +5,6 @@ from migration_base import legacy_app
for model in apps.get_app_config('legacy').get_models(): for model in apps.get_app_config('legacy').get_models():
if 'ind_excluido' in [f.name for f in model._meta.fields]: if 'ind_excluido' in [f.name for f in model._meta.fields]:
print model, model.objects.values_list('ind_excluido', flat=True).distinct() print(model, model.objects.values_list('ind_excluido', flat=True).distinct())
legacy_models_without_ind_excluido = [m for m in legacy_app.models.values() if not any(f.name == 'ind_excluido' for f in m._meta.fields)] legacy_models_without_ind_excluido = [m for m in legacy_app.models.values() if not any(f.name == 'ind_excluido' for f in m._meta.fields)]

Loading…
Cancel
Save