本文整理汇总了Python中models.Folder.create方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.create方法的具体用法?Python Folder.create怎么用?Python Folder.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_vin
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import create [as 别名]
def create_vin(request):
topics = ['NBA']
for fld in topics:
logging.info('Entra en bucle para %s' % fld)
directory = "media/%s" % fld
root = Folder.create(fld,request.user.profile,None,'/media/example_folder.png')
root.save()
for serie in os.listdir(directory):
logging.info('Entra en bucle series para %s' % serie)
if not serie.startswith('.'):
s = Folder.create(serie,request.user.profile,root,None)
s.pic = None #TODO revisar codigo inutil
for season in os.listdir(directory+'/'+serie):
if not season.startswith('.'):
if fld == 'NBA':
pic = '/media/example_folder.png'
else:
pic = '/'+directory+'/'+serie+'/'+season+'/season.jpeg'
if s.pic == None:
s.pic = pic
s.save()
ss = Folder.create(season,request.user.profile,s,pic)
ss.save()
for episode in os.listdir(directory+'/'+serie+'/'+season+'/'):
if not episode.startswith('.') and '.jpeg' not in episode:
# if fld == 'NBA':
# pic = '/media/example_folder.png'
# else:
# pic = '/'+directory+'/'+serie+'/'+season+'/season.jpeg'
url = open(directory+'/'+serie+'/'+season+'/'+episode,'r').readline()
if url.__len__ > 0:
c = Card.create(episode,url,ss)
if fld == 'NBA':
c.pic = fld+'/'+serie+'/'+season +'/'+ episode+'.jpeg'
c.save()
示例2: folders
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import create [as 别名]
def folders():
if request.method == 'POST':
req = request.get_json()
try:
f = Folder.create(name=req['name'])
f.save()
return jsonify(message='OK'), 201
except peewee.IntegrityError as e:
print e
return jsonify(message='error'), 409
if request.method == 'GET':
folders = Folder.select()
items = [x.name for x in folders]
return jsonify(message='OK', items=items)
示例3: import_data
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import create [as 别名]
def import_data(request, parent, data):
"""
Transform json file into vincula objects
Every key of the json input will be transformed to a folder, and every
value to links (Even arrays).
Maximum depth allowed is 1, for security reasons, at the moment.
"""
# if not isinstance(data, dict):
# data = json.loads(data)
for folder, cards in data.iteritems():
f_parent = Folder.create(folder, request.user.profile, parent, '/media/example_folder.png')
f_parent.save()
for name, url in cards.iteritems():
card = Card.create(name, url, f_parent)
card.save()
return True