1 Star 0 Fork 121

walkskyer / NetEaseMusic

forked from cosven / FeelUOwn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
models.py 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
cosven 提交于 2015-03-13 02:16 . basic function v0.1
# -*- coding=utf8 -*-
__author__ = 'cosven'
class DataModel(object):
def user(self):
user_model = {
'uid': int,
'username': unicode,
'avatar': unicode
}
return user_model
def music(self):
music_model = {
'id': int,
'name': unicode,
'artists': list,
'album': dict,
'duration': unicode,
'mp3Url': unicode
}
return music_model
def playlist(self):
playlist_model = {
'id': int,
'name': unicode
}
return playlist_model
def set_datamodel_from_data(self, data, datamodel):
"""
before generating model, the data should be validated
requirement: the datastructure of model is similar with standard
:param data: dict, input data
:param type: string, the target model type
"""
# temperarily: no validation check
for key in datamodel:
datamodel[key] = data[key]
return datamodel
def validate(self, data, model_type):
"""
compare data with the standard model, to validate the data basicllay.
1. check those keys which data must contain
:param data: dict type,
:param model: dict type, standard data model. base on the doc
:return: if validated: true
"""
return True
1
https://gitee.com/walkskyer/NetEaseMusic.git
git@gitee.com:walkskyer/NetEaseMusic.git
walkskyer
NetEaseMusic
NetEaseMusic
master

搜索帮助