本文整理汇总了Python中models.Movie.id方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.id方法的具体用法?Python Movie.id怎么用?Python Movie.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Movie
的用法示例。
在下文中一共展示了Movie.id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_xml
# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import id [as 别名]
def import_xml(file_name):
import xml.etree.cElementTree as et
root = et.ElementTree(file=file_name).getroot()
theaters = root.findall('theaters')[0]
movies = root.findall('movies')[0]
show_times = root.findall('showTimes')[0]
for theater in theaters:
cinema = Cinema(theater.find('name').text,
theater.find('telephone').text,
theater.find('address').find('streetAddress').find('street').text,
theater.find('address').find('city').text,
theater.find('address').find('state').text,
theater.find('address').find('postalCode').text,
theater.find('address').find('country').text,
float(theater.find('longitude').text) if theater.find('longitude').text is not None else None,
float(theater.find('latitude').text) if theater.find('latitude').text is not None else None)
cinema.id = theater.attrib['theaterId']
db.session.add(cinema)
for movie in movies:
mov = Movie(movie.find('officialTitle').text,
movie.find('sinopsis').text if movie.find('sinopsis') is not None else None,
movie.find('format').text,
int(movie.find('runningTime').text) if movie.find('runningTime').text is not None else None,
movie.find('imdb').text if movie.find('imdb') is not None else None,
movie.find('version').text == 'Z',
movie.find('ratings').find('rating').text,
movie.find('cartel').text.split('.')[0] + '.jpg')
mov.id = movie.attrib['movieId']
db.session.add(mov)
for show_time in show_times:
for time in show_time.find('times').findall('time'):
if Movie.query.get(show_time.attrib['movieId']) and Cinema.query.get(show_time.attrib['theaterId']):
showtime = ShowTime(show_time.attrib['theaterId'],
show_time.attrib['movieId'],
time.text[0:2] + ':' + time.text[2:4])
db.session.merge(showtime)
db.session.commit()