Merge pull request #11405 from rmehta/move-get-source

fix(minor): move get_source_value to data_migration_mapper
This commit is contained in:
Rushabh Mehta 2020-09-03 10:29:53 +05:30 committed by GitHub
commit f6a486a487
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -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)

View file

@ -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):

View file

@ -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)