note代码什么

note代码什么,第1张

Note类属于polymorphism.music包纤做

handle_uploaded_json_file

# 需要导入模块: from models import Note [as 别名]

# 或者: from models.Note import note [as 别名]

def handle_uploaded_json_file(f, user):

def convert_date(str_date):

new_str = str_date.replace('+00:00','')

try:

new_dt = datetime.strptime(new_str, '%Y-%m-%d %H:%M:%S.%f')

except ValueError:

new_dt = datetime.strptime(new_str, '%Y-%m-%d %H:%M:%S')

return new_dt

with open('notes.json', 'wb+') as destination:

for chunk in f.chunks():

destination.write(chunk)

f.close()

with open('notes.json', 'r') as fh:

json_data = json.load(fh)

fh.close()

version, notes = json_data

# for user in User.objects.all():

# if not Folder.)objects.filter(user = user, name = "Main").exists():

# folder = Folder(name="Main", user = user)

# folder.save()

# if not Folder.objects.filter(user = user, name = ")Trash").exists():

# folder = Folder(name="Trash", user = u)ser)

# folder.save()

for note in notes:

created_at = convert_date(note['created_at'])

title = note['睁卖title']

username = note['user']

# TODO: If user is blank we need to assign to a default user. For now just skip.

# Its technically a database integrity violation anyway.

if username is None: continue

user = User.objects.get(username = username)

if not Note.objects.filter(title = title,

created_at = created_at).exists():

new_note = Note()

new_note.title = title

new_note.created_at = created_at

new_note.modified_at = convert_date(note['modified_at'])

new_note.note_type = note['悉竖逗post_type']

new_note.note = note['note']

foldr = note['folder']

try:

folder = Folder.objects.get(name = foldr, user = user)

except Folder.DoesNotExist:

folder = Folder(name = foldr, user = user)

folder.save()

new_note.folder = folder

new_note.user = user

new_note.save()

.note文件是notability软件导出的返亩!

note格式是notability软件使用导出的格式,想无缝替换打开,但没有ipad设备,敬戚如可以使用其他软件漏稿森打开。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12281731.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存