From 9eb903038144e6823f7857d180788a01e33b0da8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 3 Sep 2020 08:42:42 +0530 Subject: [PATCH] fix(minor): move get_source_value to data_migration_mapper --- .../data_migration_mapping/data_migration_mapping.py | 8 +++++++- .../doctype/data_migration_run/data_migration_run.py | 3 ++- frappe/utils/data.py | 7 ------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frappe/data_migration/doctype/data_migration_mapping/data_migration_mapping.py b/frappe/data_migration/doctype/data_migration_mapping/data_migration_mapping.py index e89282885f..b346864f02 100644 --- a/frappe/data_migration/doctype/data_migration_mapping/data_migration_mapping.py +++ b/frappe/data_migration/doctype/data_migration_mapping/data_migration_mapping.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document -from frappe.utils import get_source_value class DataMigrationMapping(Document): def get_filters(self): @@ -70,3 +69,10 @@ def get_value_from_fieldname(field_map, fieldname_field, doc): else: value = get_source_value(doc, field_name) return value + +def get_source_value(source, key): + '''Get value from source (object or dict) based on key''' + if isinstance(source, dict): + return source.get(key) + else: + return getattr(source, key) diff --git a/frappe/data_migration/doctype/data_migration_run/data_migration_run.py b/frappe/data_migration/doctype/data_migration_run/data_migration_run.py index b2ce4606f8..473acfb3d0 100644 --- a/frappe/data_migration/doctype/data_migration_run/data_migration_run.py +++ b/frappe/data_migration/doctype/data_migration_run/data_migration_run.py @@ -6,7 +6,8 @@ from __future__ import unicode_literals import frappe, json, math from frappe.model.document import Document from frappe import _ -from frappe.utils import get_source_value, cstr +from frappe.utils import cstr +from frappe.data_migration.doctype.data_migration_mapping.data_migration_mapping import get_source_value class DataMigrationRun(Document): def run(self): diff --git a/frappe/utils/data.py b/frappe/utils/data.py index fd5c838b57..8dad5f3e92 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -1226,13 +1226,6 @@ def md_to_html(markdown_text): return html -def get_source_value(source, key): - '''Get value from source (object or dict) based on key''' - if isinstance(source, dict): - return source.get(key) - else: - return getattr(source, key) - def is_subset(list_a, list_b): '''Returns whether list_a is a subset of list_b''' return len(list(set(list_a) & set(list_b))) == len(list_a)