本文整理汇总了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.'
示例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
示例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"]
示例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]
示例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
示例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
示例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