• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python modules.scrub函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webnotes.modules.scrub函数的典型用法代码示例。如果您正苦于以下问题:Python scrub函数的具体用法?Python scrub怎么用?Python scrub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了scrub函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_page_path

def get_page_path(page_name, module):
	"""get path of the page html file"""
	import os
	import conf
	from webnotes.modules import scrub
	return os.path.join(conf.modules_path, 'erpnext', scrub(module), \
		'page', scrub(page_name), scrub(page_name) + '.html')
开发者ID:NorrWing,项目名称:wnframework,代码行数:7,代码来源:page.py


示例2: get_server_obj

def get_server_obj(doc, doclist = [], basedoctype = ''):
	"""
	Returns the instantiated `DocType` object. Will also manage caching & compiling
	"""
	# for test
	import webnotes
	from webnotes.modules import scrub

	# get doctype details
	module = webnotes.conn.get_value('DocType', doc.doctype, 'module')
	
	# no module specified (must be really old), can't get code so quit
	if not module:
		return
		
	module = scrub(module)
	dt = scrub(doc.doctype)

	try:
		module = __import__('%s.doctype.%s.%s' % (module, dt, dt), fromlist=[''])
		DocType = getattr(module, 'DocType')
	except ImportError, e:
		from webnotes.utils import cint
		if not cint(webnotes.conn.get_value("DocType", doc.doctype, "custom")):
			raise e
		
		class DocType:
			def __init__(self, d, dl):
				self.doc, self.doclist = d, dl
开发者ID:masums,项目名称:wnframework,代码行数:29,代码来源:code.py


示例3: run

def run(report_name, filters=None):
	report = webnotes.doc("Report", report_name)
	
	if filters and isinstance(filters, basestring):
		filters = json.loads(filters)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query, filters)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)(filters or {})
	
	result = get_filtered_data(report.ref_doctype, columns, result)
	
	if cint(report.add_total_row) and result:
		result = add_total_row(result, columns)
	
	return {
		"result": result,
		"columns": columns
	}
开发者ID:ricardomomm,项目名称:wnframework,代码行数:34,代码来源:query_report.py


示例4: get_pages

def get_pages(m):
	import importlib
	pages = webnotes.conn.sql_list("""select name from tabPage where module=%s""", m)
	prefix = "docs.dev.modules." + m + ".page."
	docs = {
		"_icon": "file-alt",
		"_label": "Pages",
		"_toc": [prefix + d for d in pages]
	}
	for p in pages:
		page = webnotes.doc("Page", p)
		mydocs = docs[p] = {
			"_label": page.title or p,
			"_type": "page",
		}
		update_readme(mydocs, m, "page", p)
		mydocs["_modified"] = page.modified

		# controller
		page_name = scrub(p)
		try:
			page_controller = importlib.import_module(scrub(m) + ".page." +  page_name + "." + page_name)
			inspect_object_and_update_docs(mydocs, page_controller)
		except ImportError, e:
			pass
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:25,代码来源:documentation_tool.py


示例5: get_page_js

def get_page_js(page, module=None):
	"""
	Returns the js code of a page. Will replace $import (page) or $import(module.page)
	with the code from the file
	"""
	import webnotes, os
	from webnotes.modules import scrub, get_module_path

	if type(page)==str:
		page_name = page
	else:
		page_name, module = page.name, page.module

	code = get_js_code(os.path.join(get_module_path(module), 'page', scrub(page_name), scrub(page_name)))
		
	if not code and type(page)!=str:
		code = page.script
	
	# compile for import
	if code and code.strip():
		import re
		p = re.compile('\$import\( (?P<name> [^)]*) \)', re.VERBOSE)
	
		code = p.sub(sub_get_page_js, code)

	return code
开发者ID:umairsy,项目名称:wnframework,代码行数:26,代码来源:compress.py


示例6: get_code

def get_code(module, dt, dn, extn, fieldname=None):
	from webnotes.modules import scrub, get_module_path
	import os, webnotes
	
	# get module (if required)
	if not module:
		module = webnotes.conn.get_value(dt, dn, 'module')

	# no module, quit
	if not module:
		return ''
	
	# file names
	if dt in ('Page','Doctype'):
		dt, dn = scrub(dt), scrub(dn)

	# get file name
	fname = dn + '.' + extn

	# code
	code = ''
	try:
		file = open(os.path.join(get_module_path(scrub(module)), dt, dn, fname), 'r')
		code = file.read()
		file.close()	
	except IOError, e:
		# no file, try from db
		if fieldname:
			code = webnotes.conn.get_value(dt, dn, fieldname)
开发者ID:ricardomomm,项目名称:wnframework,代码行数:29,代码来源:code.py


示例7: get_from_files

	def get_from_files(self, doc):
		"""
			Loads page info from files in module
		"""
		from webnotes.modules import get_module_path, scrub
		import os
		
		path = os.path.join(get_module_path(doc.module), 'page', scrub(doc.name))

		# script
		fpath = os.path.join(path, scrub(doc.name) + '.js')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				doc.fields['__script'] = f.read()

		# css
		fpath = os.path.join(path, scrub(doc.name) + '.css')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				doc.style = f.read()
		
		# html
		fpath = os.path.join(path, scrub(doc.name) + '.html')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				doc.content = f.read()
开发者ID:IPenuelas,项目名称:wnframework,代码行数:26,代码来源:page.py


示例8: get_from_files

	def get_from_files(self):
		"""
			Loads page info from files in module
		"""
		from webnotes.modules import get_module_path, scrub
		import os
		
		path = os.path.join(get_module_path(self.doc.module), 'page', scrub(self.doc.name))

		# script
		fpath = os.path.join(path, scrub(self.doc.name) + '.js')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				self.doc.script = f.read()

		# css
		fpath = os.path.join(path, scrub(self.doc.name) + '.css')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				self.doc.style = f.read()
		
		# html
		fpath = os.path.join(path, scrub(self.doc.name) + '.html')
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				self.doc.content = f.read()
				
		if webnotes.lang != 'en':
			from webnotes.translate import update_lang_js
			self.doc.script = update_lang_js(self.doc.script, path)
开发者ID:alvz,项目名称:wnframework,代码行数:30,代码来源:page.py


示例9: run

def run(report_name):
	report = webnotes.doc("Report", report_name)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		from webnotes.modules import scrub
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)()
	
	return {
		"result": result,
		"columns": columns
	}
开发者ID:jacara,项目名称:erpclone,代码行数:27,代码来源:query_report.py


示例10: get_code

def get_code(module, dt, dn, extn, is_static=None, fieldname=None):
	from webnotes.modules import scrub, get_module_path
	import os, webnotes
	
	# get module (if required)
	if not module:
		module = webnotes.conn.sql("select module from `tab%s` where name=%s" % (dt,'%s'),dn)[0][0]

	# no module, quit
	if not module:
		return ''
	
	# file names
	if scrub(dt) in ('page','doctype','search_criteria'):
		dt, dn = scrub(dt), scrub(dn)

	# get file name
	fname = dn + '.' + extn
	if is_static:
		fname = dn + '_static.' + extn

	# code
	code = ''
	try:
		file = open(os.path.join(get_module_path(scrub(module)), dt, dn, fname), 'r')
		code = file.read()
		file.close()	
	except IOError, e:
		# no file, try from db
		if fieldname:
			code = webnotes.conn.get_value(dt, dn, fieldname)
开发者ID:cmrajan,项目名称:wnframework,代码行数:31,代码来源:code.py


示例11: load_doctype_module

def load_doctype_module(doctype, module, prefix=""):
	from webnotes.modules import scrub
	_doctype, _module = scrub(doctype), scrub(module)
	try:
		module = __import__(get_module_name(doctype, module, prefix), fromlist=[''])
		return module
	except ImportError, e:
		return None
开发者ID:alvz,项目名称:wnframework,代码行数:8,代码来源:code.py


示例12: load_doctype_module

def load_doctype_module(doctype, module, prefix=""):
	import webnotes
	from webnotes.modules import scrub
	_doctype, _module = scrub(doctype), scrub(module)
	try:
		module = __import__(get_module_name(doctype, module, prefix), fromlist=[''])
		return module
	except ImportError, e:
		# webnotes.errprint(webnotes.getTraceback())
		return None
开发者ID:frank1638,项目名称:wnframework,代码行数:10,代码来源:code.py


示例13: get_path

def get_path(module, doctype, docname, plugin=None, extn="py"):
	from webnotes.modules import scrub
	import os
	
	if not module: module = webnotes.conn.get_value(doctype, docname, "module")
	if not plugin: plugin = get_plugin_name(doctype, docname)
	
	# site_abs_path/plugins/module/doctype/docname/docname.py
	return os.path.join(get_plugin_path(scrub(plugin)), scrub(module),
		scrub(doctype), scrub(docname), scrub(docname) + "." + extn)
开发者ID:Halfnhav,项目名称:wnframework,代码行数:10,代码来源:plugins.py


示例14: get_script

def get_script(report_name):
	report = webnotes.doc("Report", report_name)

	script_path = os.path.join(get_module_path(webnotes.conn.get_value("DocType", report.ref_doctype, "module")),
		"report", scrub(report.name), scrub(report.name) + ".js") 
	
	if os.path.exists(script_path):
		with open(script_path, "r") as script:
			return script.read()
	else:
		return "wn.query_reports['%s']={}" % report_name
开发者ID:alvz,项目名称:wnframework,代码行数:11,代码来源:query_report.py


示例15: rename_export

	def rename_export(self, old_name):
				
		# export the folders
		self.export_doc()
		import os, shutil
		from webnotes.modules import get_module_path, scrub
		
		path = os.path.join(get_module_path(self.doc.module), 'search_criteria', scrub(old_name))
		
		# copy py/js files
		self.copy_file(path, scrub(old_name), '.py')
		self.copy_file(path, scrub(old_name), '.js')
		self.copy_file(path, scrub(old_name), '.sql')
开发者ID:Vichagserp,项目名称:cimworks,代码行数:13,代码来源:search_criteria.py


示例16: diff_ref_db

def diff_ref_db():
	"""get diff using database as reference"""
	from webnotes.modules import scrub
	for dt in dt_map:
		# get all main docs
		for doc in webnotes.conn.sql("""select * from `tab%s`""" % dt, as_dict=1):
			# get file for this doc
			doc['doctype'] = dt
			path = os.path.join(webnotes.defs.modules_path, scrub(doc['module']), \
				scrub(dt), scrub(doc['name']), scrub(doc['name']) + '.txt')
				
			if os.path.exists(path):
				with open(path, 'r') as txtfile:
					target = peval_doclist(txtfile.read())					
			else:
				target = [None,]
			
			doc_diff(doc, target[0])
			
			# do diff for child records
			if target[0] and dt_map[dt].keys():
				for child_dt in dt_map[dt]:					

					# for each child type, we need to create
					# a key (e.g. fieldname, label) based mapping of child records in 
					# txt files
					child_key_map = {}
					keys = dt_map[dt][child_dt]
					for target_d in target:
						if target_d['doctype'] == child_dt:
							for key in keys:
								if target_d.get(key):
									child_key_map[target_d.get(key)] = target_d
									break

					for d in webnotes.conn.sql("""select * from `tab%s` where 
						parent=%s and docstatus<2""" % (child_dt, '%s'), doc['name'], as_dict=1):

						source_key = None
						d['doctype'] = child_dt
						for key in keys:
							if d.get(key):
								source_key = d.get(key)
								break
						
						# only if a key is found
						if source_key:
							doc_diff(d, child_key_map.get(source_key), source_key)
				

	print_stats()
开发者ID:beliezer,项目名称:wnframework,代码行数:51,代码来源:diff.py


示例17: on_update

	def on_update(self):
		"""
			Writes the .txt for this page and if write_content is checked,
			it will write out a .html file
		"""
		import conf
		from webnotes.modules.import_file import in_import
		if not in_import and getattr(conf,'developer_mode', 0) and self.doc.standard=='Yes':
			from webnotes.modules.export_file import export_to_files
			from webnotes.modules import get_module_path, scrub
			import os
			export_to_files(record_list=[['Page', self.doc.name]])
	
			# write files
			path = os.path.join(get_module_path(self.doc.module), 'page', scrub(self.doc.name), scrub(self.doc.name))
								
			# js
			if not os.path.exists(path + '.js'):
				with open(path + '.js', 'w') as f:
					f.write("""wn.pages['%s'].onload = function(wrapper) { 
	wn.ui.make_app_page({
		parent: wrapper,
		title: '%s',
		single_column: true
	});					
}""" % (self.doc.name, self.doc.title))
开发者ID:alvz,项目名称:wnframework,代码行数:26,代码来源:page.py


示例18: upload

def upload():
    from webnotes.utils.datautils import read_csv_content_from_uploaded_file
    from webnotes.modules import scrub

    rows = read_csv_content_from_uploaded_file()
    if not rows:
        msg = [_("Please select a csv file")]
        return {"messages": msg, "error": msg}
    columns = [scrub(f) for f in rows[4]]
    columns[0] = "name"
    columns[3] = "att_date"
    ret = []
    error = False

    from webnotes.utils.datautils import check_record, import_doc

    doctype_dl = webnotes.get_doctype("Attendance")

    for i, row in enumerate(rows[5:]):
        if not row:
            continue
        row_idx = i + 5
        d = webnotes._dict(zip(columns, row))
        d["doctype"] = "Attendance"
        if d.name:
            d["docstatus"] = webnotes.conn.get_value("Attendance", d.name, "docstatus")

        try:
            check_record(d, doctype_dl=doctype_dl)
            ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
        except Exception, e:
            error = True
            ret.append("Error for row (#%d) %s : %s" % (row_idx, len(row) > 1 and row[1] or "", cstr(e)))
            webnotes.errprint(webnotes.getTraceback())
开发者ID:bindscha,项目名称:erpnext-fork,代码行数:34,代码来源:upload_attendance.py


示例19: copy_file

	def copy_file(self, path, old_name, extn):
		import os
		from webnotes.modules import get_module_path, scrub

		if os.path.exists(os.path.join(path, old_name + extn)):
			os.system('cp %s %s' % (os.path.join(path, old_name + extn), \
			os.path.join(get_module_path(self.doc.module), 'search_criteria', scrub(self.doc.name), scrub(self.doc.name) + extn)))
开发者ID:Vichagserp,项目名称:cimworks,代码行数:7,代码来源:search_criteria.py


示例20: write_document_file

def write_document_file(doclist, record_module=None):
	"""
		Write a doclist to file, can optionally specify module name
	"""
	import os
	from webnotes.model.utils import pprint_doclist

	module = get_module_name(doclist, record_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']
	txtfile = open(os.path.join(folder, fname +'.txt'),'w+')
	txtfile.write(pprint_doclist(doclist))
	#dict_list = [pprint_dict(d) for d in doclist]	
	#txtfile.write('[\n' + ',\n'.join(dict_list) + '\n]')
	txtfile.close()
开发者ID:NorrWing,项目名称:wnframework,代码行数:25,代码来源:export_module.py



注:本文中的webnotes.modules.scrub函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python module_manager.reload_doc函数代码示例发布时间:2022-05-26
下一篇:
Python modules.reload_doc函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap