def execute(): """ Assuming that some kind of indentation exists: - Find indentation of server custom script - replace indentation with tabs - Add line: class CustomDocType(DocType): - Add tab indented code after this line - Write to file - Delete custom script record """ import os from webnotes.utils import get_site_base_path from core.doctype.custom_script.custom_script import make_custom_server_script_file for name, dt, script in webnotes.conn.sql("""select name, dt, script from `tabCustom Script` where script_type='Server'"""): if script.strip(): script = indent_using_tabs(script) make_custom_server_script_file(dt, script)
def execute(): """ Assuming that some kind of indentation exists: - Find indentation of server custom script - replace indentation with tabs - Add line: class CustomDocType(DocType): - Add tab indented code after this line - Write to file - Delete custom script record """ import os from webnotes.utils import get_site_base_path from core.doctype.custom_script.custom_script import make_custom_server_script_file for name, dt, script in webnotes.conn.sql( """select name, dt, script from `tabCustom Script` where script_type='Server'"""): if script.strip(): script = indent_using_tabs(script) make_custom_server_script_file(dt, script)
def make_custom_server_script(doctype, site=None): from core.doctype.custom_script.custom_script import make_custom_server_script_file webnotes.connect(site=site) make_custom_server_script_file(doctype) webnotes.destroy()