Merge pull request #6993 from zerodhatech/fixtures

export fixtures of a specific app
This commit is contained in:
Rushabh Mehta 2019-02-28 13:01:21 +05:30 committed by GitHub
commit abfb44a047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -223,15 +223,16 @@ def export_csv(context, doctype, path):
frappe.destroy()
@click.command('export-fixtures')
@click.option('--app', default=None, help='Export fixtures of a specific app')
@pass_context
def export_fixtures(context):
def export_fixtures(context, app=None):
"Export fixtures"
from frappe.utils.fixtures import export_fixtures
for site in context.sites:
try:
frappe.init(site=site)
frappe.connect()
export_fixtures()
export_fixtures(app=app)
finally:
frappe.destroy()

View file

@ -50,9 +50,13 @@ def import_custom_scripts(app):
"script": script
}).insert()
def export_fixtures():
def export_fixtures(app=None):
"""Export fixtures as JSON to `[app]/fixtures`"""
for app in frappe.get_installed_apps():
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