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", )
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()
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
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)