コード例 #1
0
ファイル: fixtures.py プロジェクト: erpnext-tm/frappe
def export_fixtures(app=None):
    """Export fixtures as JSON to `[app]/fixtures`"""
    if app:
        apps = [app]
    else:
        apps = frappe.get_installed_apps()
    for app in apps:
        for fixture in frappe.get_hooks("fixtures", app_name=app):
            filters = None
            or_filters = None
            if isinstance(fixture, dict):
                filters = fixture.get("filters")
                or_filters = fixture.get("or_filters")
                fixture = fixture.get("doctype") or fixture.get("dt")
            print("Exporting {0} app {1} filters {2}".format(
                fixture, app, (filters if filters else or_filters)))
            if not os.path.exists(frappe.get_app_path(app, "fixtures")):
                os.mkdir(frappe.get_app_path(app, "fixtures"))

            export_json(
                fixture,
                frappe.get_app_path(app, "fixtures",
                                    frappe.scrub(fixture) + ".json"),
                filters=filters,
                or_filters=or_filters,
                order_by="idx asc, creation asc",
            )
コード例 #2
0
ファイル: utils.py プロジェクト: yered1/frappe
def export_json(context, doctype, path, name=None):
	"Export doclist as json to the given path, use '-' as name for Singles."
	from frappe.core.doctype.data_import import data_import
	for site in context.sites:
		try:
			frappe.init(site=site)
			frappe.connect()
			data_import.export_json(doctype, path, name=name)
		finally:
			frappe.destroy()
コード例 #3
0
ファイル: utils.py プロジェクト: ESS-LLP/frappe
def export_json(context, doctype, path, name=None):
	"Export doclist as json to the given path, use '-' as name for Singles."
	from frappe.core.doctype.data_import import data_import
	for site in context.sites:
		try:
			frappe.init(site=site)
			frappe.connect()
			data_import.export_json(doctype, path, name=name)
		finally:
			frappe.destroy()
コード例 #4
0
def export_json(context, doctype, path, name=None):
    "Export doclist as json to the given path, use '-' as name for Singles."
    from frappe.core.doctype.data_import.data_import import export_json
    for site in context.sites:
        try:
            frappe.init(site=site)
            frappe.connect()
            export_json(doctype, path, name=name)
        finally:
            frappe.destroy()
    if not context.sites:
        raise SiteNotSpecifiedError
コード例 #5
0
ファイル: fixtures.py プロジェクト: ESS-LLP/frappe
def export_fixtures():
	"""Export fixtures as JSON to `[app]/fixtures`"""
	for app in frappe.get_installed_apps():
		for fixture in frappe.get_hooks("fixtures", app_name=app):
			filters = None
			or_filters = None
			if isinstance(fixture, dict):
				filters = fixture.get("filters")
				or_filters = fixture.get("or_filters")
				fixture = fixture.get("doctype") or fixture.get("dt")
			print("Exporting {0} app {1} filters {2}".format(fixture, app, (filters if filters else or_filters)))
			if not os.path.exists(frappe.get_app_path(app, "fixtures")):
				os.mkdir(frappe.get_app_path(app, "fixtures"))

			export_json(fixture, frappe.get_app_path(app, "fixtures", frappe.scrub(fixture) + ".json"), filters=filters, or_filters=or_filters)