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

Python modules.get_module_path函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3: get_modules

def get_modules(for_module=None):
	import importlib
	docs = {
		"_label": "Modules"
	}
	if for_module:
		modules = [for_module]
	else:
		modules = webnotes.conn.sql_list("select name from `tabModule Def` order by name")
	
	docs["_toc"] = ["docs.dev.modules." + d for d in modules]
	for m in modules:
		prefix = "docs.dev.modules." + m
		mydocs = docs[m] = {
			"_icon": "th",
			"_label": m,
			"_toc": [
				prefix + ".doctype",
				prefix + ".page",
				prefix + ".py_modules"
			],
			"doctype": get_doctypes(m),
			"page": get_pages(m),
			#"report": {},
			"py_modules": {
				"_label": "Independent Python Modules for " + m,
				"_toc": []
			}
		}
		
		# add stand alone modules
		module_path = get_module_path(m)
		prefix = prefix + ".py_modules."
		for basepath, folders, files in os.walk(module_path):
			for f in files:
				if f.endswith(".py") and \
					(not f.split(".")[0] in os.path.split(basepath)) and \
					(not f.startswith("__")):
				
					module_name = ".".join(os.path.relpath(os.path.join(basepath, f), 
						"../app").split(os.path.sep))[:-3]

					# import module
					try:
						module = importlib.import_module(module_name)
						# create a new namespace for the module
						module_docs = mydocs["py_modules"][f.split(".")[0]] = {}

						# add to toc
						mydocs["py_modules"]["_toc"].append(prefix + f.split(".")[0])

						inspect_object_and_update_docs(module_docs, module)
					except TypeError, e:
						webnotes.errprint("TypeError in importing " + module_name)
					
					module_docs["_label"] = module_name
					module_docs["_function_namespace"] = module_name
		
		update_readme(docs[m], m)
		docs[m]["_gh_source"] = get_gh_url(module_path)
开发者ID:akshayagarwal,项目名称:wnframework,代码行数:60,代码来源:documentation_tool.py


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: import_file

def import_file(module, dt, dn, force=False):
	"""Sync a file from txt if modifed, return false if not updated"""		
	dt, dn = scrub_dt_dn(dt, dn)
	path = os.path.join(get_module_path(module), 
		os.path.join(dt, dn, dn + '.txt'))
		
	return import_file_by_path(path, force)
开发者ID:IPenuelas,项目名称:wnframework,代码行数:7,代码来源:import_file.py


示例10: import_file

def import_file(module, dt, dn, force=False):
	"""Sync a file from txt if modifed, return false if not updated"""
	webnotes.flags.in_import = True
	dt, dn = scrub_dt_dn(dt, dn)
	path = os.path.join(get_module_path(module), 
		os.path.join(dt, dn, dn + '.txt'))
		
	ret = import_file_by_path(path, force)
	webnotes.flags.in_import = False
	return ret
开发者ID:ricardomomm,项目名称:wnframework,代码行数:10,代码来源:import_file.py


示例11: 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


示例12: switch_module

def switch_module(dt, dn, to, frm=None, export=None):
	"""
		Change the module of the given doctype, if export is true, then also export txt and copy
		code files from src
	"""
	webnotes.conn.sql("update `tab"+dt+"` set module=%s where name=%s", (to, dn))

	if export:
		export_doc(dt, dn)

		# copy code files
		if dt in ('DocType', 'Page', 'Report'):
			from_path = os.path.join(get_module_path(frm), scrub(dt), scrub(dn), scrub(dn))
			to_path = os.path.join(get_module_path(to), scrub(dt), scrub(dn), scrub(dn))

			# make dire if exists
			os.system('mkdir -p %s' % os.path.join(get_module_path(to), scrub(dt), scrub(dn)))

			for ext in ('py','js','html','css'):
				os.system('cp %s %s')
开发者ID:Halfnhav,项目名称:wnframework,代码行数:20,代码来源:utils.py


示例13: make_controller_template

	def make_controller_template(self):
		from webnotes.modules import get_doc_path, get_module_path, scrub
		
		pypath = os.path.join(get_doc_path(self.doc.module, 
			self.doc.doctype, self.doc.name), scrub(self.doc.name) + '.py')

		if not os.path.exists(pypath):
			with open(pypath, 'w') as pyfile:
				with open(os.path.join(get_module_path("core"), "doctype", "doctype", 
					"doctype_template.py"), 'r') as srcfile:
					pyfile.write(srcfile.read())
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:11,代码来源:doctype.py


示例14: onload

	def onload(self):
		import os
		from webnotes.modules import get_module_path, scrub
		
		# load content
		try:
			file = open(os.path.join(get_module_path(self.doc.module), 'page', scrub(self.doc.name) + '.html'), 'r')
			self.doc.content = file.read() or ''
			file.close()
		except IOError, e: # no file / permission
			if e.args[0]!=2:
				raise e
开发者ID:cmrajan,项目名称:wnframework,代码行数:12,代码来源:page.py


示例15: update_readme

def update_readme(mydocs, module, doctype=None, name=None):
	if doctype:
		readme_path = os.path.join(get_doc_path(module, doctype, name), "README.md")
	else:
		readme_path = os.path.join(get_module_path(module), "README.md")
	
	mydocs["_intro"] = ""
	
	if os.path.exists(readme_path):
		with open(readme_path, "r") as readmefile:
			mydocs["_intro"] = readmefile.read()
		mydocs["_modified"] = get_timestamp(readme_path)
开发者ID:rohitw1991,项目名称:latestadbwnf,代码行数:12,代码来源:documentation_tool.py


示例16: import_file

def import_file(module, doctype, docname, path=None):
	"imports a given file into the database"
	
	if not path:
		from webnotes.modules import get_module_path
		path = get_module_path(module)
	
	doclist = get_doclist(path, doctype, docname)
	
	if doclist:
		from webnotes.utils.transfer import set_doc
		set_doc(doclist, 1, 1, 1)
开发者ID:umairsy,项目名称:wnframework,代码行数:12,代码来源:import_module.py


示例17: 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


示例18: on_update

	def on_update(self):
		from webnotes.modules.export_module import export_to_files
		from webnotes.modules import get_module_path, scrub
		import os
		from webnotes import defs
		
		if getattr(defs,'developer_mode', 0):
			export_to_files(record_list=[['Page', self.doc.name]])
	
			if self.doc.write_content and self.doc.content:
				file = open(os.path.join(get_module_path(self.doc.module), 'page', scrub(self.doc.name), scrub(self.doc.name) + '.html'), 'w')
				file.write(self.doc.content)
				file.close()
开发者ID:cmrajan,项目名称:wnframework,代码行数:13,代码来源:page.py


示例19: on_update

	def on_update(self):
		import webnotes.defs
		
		if hasattr(webnotes.defs, 'developer_mode') and webnotes.defs.developer_mode:
			from webnotes.modules.export_module import export_to_files	
			from webnotes.modules import get_module_path, scurb
			import os
			
			export_to_files(record_list=[['Stylesheet', self.doc.name]])

			file = open(os.path.join(get_module_path(self.doc.module), 'Stylesheet', scrub(self.doc.name), scrub(self.doc.name) + '.html'), 'w')
			file.write(self.doc.content)
			file.close()	
开发者ID:Vichagserp,项目名称:cimworks,代码行数:13,代码来源:stylesheet.py


示例20: get_folder_paths

def get_folder_paths(modules, record_list):
	import os
	import webnotes
	import fnmatch
	import webnotes.defs
	from webnotes.modules import transfer_types, get_module_path, scrub

	folder_list=[]

	# get the folder list
	if record_list:
		for record in record_list:
			if scrub(record[1]) in ('doctype', 'page', 'search_criteria'):
				record[1], record[2] = scrub(record[1]), scrub(record[2])
			
			folder_list.append(os.path.join(get_module_path(scrub(record[0])), \
				record[1], record[2].replace('/','_')))

	if modules:
		# system modules will be transferred in a predefined order and before all other modules
		sys_mod_ordered_list = ['roles', 'core','application_internal', 'mapper', 'settings']
		all_mod_ordered_list = [t for t in sys_mod_ordered_list if t in modules] + list(set(modules).difference(sys_mod_ordered_list))
				
		for module in all_mod_ordered_list:
			mod_path = get_module_path(module)
			types_list = listfolders(mod_path, 1)
			
			# list of types
			types_list = list(set(types_list).difference(['control_panel']))
			all_transfer_types =[t for t in transfer_types if t in types_list] + list(set(types_list).difference(transfer_types))
			
			# build the folders
			for d in all_transfer_types:
				if d not in  ('files', 'startup', 'patches'):
					# get all folders inside type
					folder_list+=listfolders(os.path.join(mod_path, d))

	return folder_list
开发者ID:umairsy,项目名称:wnframework,代码行数:38,代码来源:import_module.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python modules.reload_doc函数代码示例发布时间:2022-05-26
下一篇:
Python modules.get_doc_path函数代码示例发布时间: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