当前位置: 首页>>代码示例>>Python>>正文


Python Document.file_name方法代码示例

本文整理汇总了Python中webnotes.model.doc.Document.file_name方法的典型用法代码示例。如果您正苦于以下问题:Python Document.file_name方法的具体用法?Python Document.file_name怎么用?Python Document.file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webnotes.model.doc.Document的用法示例。


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

示例1: upload_many

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
    def upload_many(self,form):
        import os
        # from file browser
        if form.getvalue('form_name') == 'File Browser':
            if form.getvalue('filedata'):
                i = form['filedata']

                #creat file data                
                fd = Document('File Data')
                fd.blob_content = i.file.read()
                fd.file_name = i.filename
                
                file_det = form.getvalue('file_det').split('~~')
                
                if(file_det[0] == 'NIL'):
                    file_desc = ''
                else:
                    file_desc = file_det[0]
                
                if(file_det[1] == 'NIL'):
                    file_grp = ''
                    return 'File Group is mandatory.'
                    raise Exception
                else:
                    file_grp = file_det[1]
                
                if "" in fd.file_name:
                  fd.file_name = fd.file_name.split("")[-1]
                if '/' in fd.file_name:
                  fd.file_name = fd.file_name.split('/')[-1]
                fd.save(1)
                
                f = Document('File')
                f.file_list = fd.file_name + ',' + fd.name
                f.file_name = fd.file_name
                f.description = file_desc
                f.file_group = file_grp
                f.save(1)
                
                ret = {
                    'name'  :   f.name,
                    'file_name' :   f.file_name
                }
                    
                return ret
            else:
                return 'No file found.'
        else:
            return 'No file found.'
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:51,代码来源:file_browser_control.py

示例2: save_file

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
def save_file(fname, content, module=None):
	from webnotes.model.doc import Document
	from filecmp import cmp

	check_max_file_size(content)
	new_fname = write_file(content)

	# some browsers return the full path
	if '\\' in fname:
		fname = fname.split('\\')[-1]
	if '/' in fname:
		fname = fname.split('/')[-1]
		
	# we use - for versions, so remove them from the name!
	fname = fname.replace('-', '')

	fpath = os.path.join(get_files_path(), fname)
	if os.path.exists(fpath) and cmp(fpath, new_fname):
		# remove new file, already exists!
		os.remove(new_fname)
		return fname
	else:
		# generate the ID (?)
		f = Document('File Data')
		f.file_name = fname
		f.save(1)
		# rename new file
		os.rename(new_fname, os.path.join(get_files_path(), f.name))
		return f.name
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:31,代码来源:file_manager.py

示例3: attach_file_test

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
def attach_file_test(html_,path_data):
	import easywebdav
	a=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_server'",as_list=1)
        if a:
                webdav = easywebdav.connect(a[0][0],username='swapnil',password='swapnil')
		import io
                name=path_data[0]
                path=cstr(path_data[0]).replace("/","")
                f = io.open("files/"+path+".html", 'w', encoding='utf8')
                f.write(html_)
                f.close()

                s=auth()
                if s[0]=="Done":
                        dms_path=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_path'",as_list=1)
                        check_status=webnotes.conn.sql("select file_url from `tabFile Data` where file_url='"+dms_path[0][0]+path_data[1]+"/"+path+".html"+"'",as_list=1)
                        if not check_status:
				webdav.upload("files/"+path+".html",'/doxbox/OwlWebDav/index.php/'+path_data[1]+"/"+path+".html")
                                file_attach=Document("File Data")
                                file_attach.file_name="files/"+path+".html"
                                file_attach.attached_to_doctype=path_data[2]
                                file_attach.file_url=dms_path[0][0]+path_data[1]+"/"+path+".html"
                                file_attach.attached_to_name=name
                                file_attach.save()
                                os.remove("files/"+path+".html")
                                return "File Save Sucessfully"
                        else:
                                return "File Already Exist"
                else:
                        return s[1]
        else:
                return ["Error","Server is not defined"]
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:34,代码来源:journal_voucher.py

示例4: attach_file

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
def attach_file(a,path_data):
		import easywebdav
                #path=self.file_name(path_data[0])
                #html_file= open(path[0],"w")
                import io
		html_=a
                name=path_data[0]
                path=cstr(path_data[0]).replace("/","")
                f = io.open("files/"+path+".html", 'w', encoding='utf8')
                f.write(a)
                f.close()
                s=auth()
                if s[0]=="Done":
			path_name=create_path(nowdate(),path_data[1],s[1])
			check_status=sql("select file_url from `tabFile Data` where file_url='"+path_name+"/"+path+".html"+"'",as_list=1)
			if not check_status:
                        	document_attach("files/"+path+".html",path_name+"/"+path+".html",s[1],"upload")
                        	file_attach=Document("File Data")
                        	file_attach.file_name="files/"+path+".html"
                        	file_attach.attached_to_doctype=path_data[2]
                        	file_attach.file_url=path_name+"/"+path+".html"
                        	file_attach.attached_to_name=name
                        	file_attach.save()
				os.remove("files/"+path+".html")
                        	return path_name+"/"+path+".html"
			else:
				return "File Already Exist"
                else:
                        return s[1]
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:31,代码来源:cgi.py

示例5: create_new_file

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
 def create_new_file(self,arg):
     arg = eval(arg)
     
     f = Document('File')
     f.file_name = arg['file_name']
     f.description = arg['desc']
     f.type = arg['type']
     f.file_group = arg['file_grp']
     f_obj = get_obj(doc=f)
     f_obj.validate()
     f_obj.doc.save(1)
     msgprint('Created a New File')
     ret = {
         'name'  :   f_obj.doc.name,
         'label' :   f_obj.doc.file_name
     }
     return ret
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:19,代码来源:file_browser_control.py

示例6: save_file

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
def save_file(fname, content, module=None):
    from webnotes.model.doc import Document

    # some browsers return the full path
    if "\\" in fname:
        fname = fname.split("\\")[-1]
    if "/" in fname:
        fname = fname.split("/")[-1]

        # generate the ID (?)
    f = Document("File Data")
    f.file_name = fname
    if module:
        f.module = module
    f.save(1)

    write_file(f.name, content)

    return f.name
开发者ID:beliezer,项目名称:wnframework,代码行数:21,代码来源:file_manager.py

示例7: save_file

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import file_name [as 别名]
def save_file(fname, content, module=None):
	import webnotes
	from webnotes.model.doc import Document

	# some browsers return the full path
	if '\\' in fname:
		fname = fname.split('\\')[-1]
	if '/' in fname:
		fname = fname.split('/')[-1]

	# generate the ID (?)
	f = Document('File Data')
	f.file_name = fname
	if module:
		f.module = module
	f.save(1)
	
	write_file(f.name, content)

	return f.name
开发者ID:Vichagserp,项目名称:cimworks,代码行数:22,代码来源:file_manager.py


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