From 2f96719ff0b0ea645c66df56bd2a2268e85189b4 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 1 Jul 2015 19:21:01 -0300 Subject: [PATCH] Rename field_mappings -> field_renames --- legacy/scripts/{field_mappings.py => field_renames.py} | 6 +++--- legacy/scripts/migration.py | 4 ++-- legacy/scripts/scrap_original_forms.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename legacy/scripts/{field_mappings.py => field_renames.py} (93%) diff --git a/legacy/scripts/field_mappings.py b/legacy/scripts/field_renames.py similarity index 93% rename from legacy/scripts/field_mappings.py rename to legacy/scripts/field_renames.py index 3e397de6f..6f19adc57 100644 --- a/legacy/scripts/field_mappings.py +++ b/legacy/scripts/field_renames.py @@ -33,7 +33,7 @@ def print_commented_source(model): return new_to_old -field_mappings = OrderedDict() +field_renames = OrderedDict() for app in appconfs: for model in app.models.values(): new_to_old = OrderedDict() @@ -43,7 +43,7 @@ for app in appconfs: new = get_field(line) old = line.split('#')[-1].strip() new_to_old[new] = old - field_mappings[model] = new_to_old + field_renames[model] = new_to_old def check_similarity(): @@ -52,7 +52,7 @@ def check_similarity(): return SequenceMatcher(None, a, b).ratio() different_pairs = defaultdict(list) - for model, new_to_old in field_mappings.items(): + for model, new_to_old in field_renames.items(): for new, old in new_to_old.items(): if similar(new, old) < 0.7: different_pairs[model].append((new, old)) diff --git a/legacy/scripts/migration.py b/legacy/scripts/migration.py index 35a54a933..0a958bd49 100644 --- a/legacy/scripts/migration.py +++ b/legacy/scripts/migration.py @@ -4,7 +4,7 @@ from django.db import connections, models from django.db.models.base import ModelBase from model_mommy import mommy -from field_mappings import field_mappings +from field_renames import field_renames from migration_base import legacy_app, appconfs from parlamentares.models import Parlamentar @@ -126,7 +126,7 @@ def migrate_model(model, to_delete, count_limit=None): for old in old_records: old_pk = get_old_pk(old) new = model() - for new_field, old_field in field_mappings[model].items(): + for new_field, old_field in field_renames[model].items(): value = getattr(old, old_field) model_field = model._meta.get_field(new_field) transform = special_transforms.get(model_field) diff --git a/legacy/scripts/scrap_original_forms.py b/legacy/scripts/scrap_original_forms.py index f43949a7f..a9125c020 100644 --- a/legacy/scripts/scrap_original_forms.py +++ b/legacy/scripts/scrap_original_forms.py @@ -6,7 +6,7 @@ import string from bs4 import BeautifulSoup from bs4.element import NavigableString, Tag -from field_mappings import field_mappings +from field_renames import field_renames from migration import appconfs from utils import listify, getsourcelines @@ -76,7 +76,7 @@ def extract_verbose_names(model): field_names = [f.name for f in model._meta.fields if f.name != 'id'] labels = {} - field_names_to_old = field_mappings[model] + field_names_to_old = field_renames[model] for name in field_names: old_name = field_names_to_old[name] label = names_to_labels.get(old_name, None)