Exemplo n.º 1
0
def write_document_file(doclist, record_module=None):
	import os
	from webnotes.utils import pprint_dict

	global updated_modules

	# module name
	if doclist[0]['doctype'] == 'Module Def':
		module = doclist[0]['name']
	elif doclist[0]['doctype']=='Control Panel':
		module = 'System'
	elif record_module:
		module = record_module
	else:
		module = doclist[0]['module']

	updated_modules.append(module)

	# create the folder
	code_type = doclist[0]['doctype'] in ['DocType','Page','Search Criteria']
	
	# create folder
	folder = create_folder(module, doclist[0]['doctype'], doclist[0]['name'])
	
	# separate code files
	clear_code_fields(doclist, folder, code_type)
		
	# write the data file	
	fname = (code_type and scrub(doclist[0]['name'])) or doclist[0]['name']
	dict_list = [pprint_dict(d) for d in doclist]	
	
	txtfile = open(os.path.join(folder, fname +'.txt'),'w+')	
	txtfile.write('[\n' + ',\n'.join(dict_list) + '\n]')
	txtfile.close()
Exemplo n.º 2
0
def pprint_doclist(doclist, with_comments = 1):
	"""
		Pretty Prints a doclist with common keys separated and comments
	"""
	from webnotes.utils import pprint_dict

	dictlist =[pprint_dict(d) for d in commonify_doclist(doclist, with_comments)]
	title = '# '+doclist[0]['doctype']+', '+doclist[0]['name']
	return title + '\n[\n' + ',\n'.join(dictlist) + '\n]'
Exemplo n.º 3
0
def pprint_doclist(doclist, with_comments=1):
    """
		Pretty Prints a doclist with common keys separated and comments
	"""
    from webnotes.utils import pprint_dict

    dictlist = [pprint_dict(d) for d in commonify_doclist(doclist, with_comments)]
    title = "# " + doclist[0]["doctype"] + ", " + doclist[0]["name"]
    return title + "\n[\n" + ",\n".join(dictlist) + "\n]"
Exemplo n.º 4
0
def pprint_doclist(doclist, with_comments=1):
    """
		Pretty Prints a doclist with common keys separated and comments
	"""
    from webnotes.utils import pprint_dict

    dictlist = [
        pprint_dict(d) for d in commonify_doclist(doclist, with_comments)
    ]
    title = '# ' + doclist[0]['doctype'] + ', ' + doclist[0]['name']
    return title + '\n[\n' + ',\n'.join(dictlist) + '\n]'