本文整理汇总了Python中pyshop.models.Release.author方法的典型用法代码示例。如果您正苦于以下问题:Python Release.author方法的具体用法?Python Release.author怎么用?Python Release.author使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyshop.models.Release
的用法示例。
在下文中一共展示了Release.author方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_release
# 需要导入模块: from pyshop.models import Release [as 别名]
# 或者: from pyshop.models.Release import author [as 别名]
def _create_release(self, package, data):
release = Release(package=package,
summary=data.get('summary'),
version=data.get('version'),
stable_version=data.get('stable_version'),
home_page=data.get('home_page'),
license=data.get('license'),
description=data.get('description'),
keywords=data.get('keywords'),
platform=data.get('platform'),
download_url=data.get('download_url'),
bugtrack_url=data.get('bugtrack_url'),
docs_url=data.get('docs_url'),
)
if data.get('author'):
author = User.by_login(self.session, data['author'], local=False)
if not author:
author = User(login=data['author'],
local=False,
email=data.get('author_email'))
self.session.add(author)
release.author = author
self.session.flush()
if data.get('maintainer'):
maintainer = User.by_login(self.session, data['maintainer'],
local=False)
if not maintainer:
maintainer = User(login=data['maintainer'],
local=False,
email=data.get('maintainer_email'))
self.session.add(maintainer)
release.maintainer = maintainer
self.session.flush()
for name in data.get('classifiers', []):
classifier = Classifier.by_name(self.session, name)
while classifier:
release.classifiers.append(classifier)
if classifier not in package.classifiers:
package.classifiers.append(classifier)
classifier = classifier.parent
self.session.flush()
return release
示例2: _create_release
# 需要导入模块: from pyshop.models import Release [as 别名]
# 或者: from pyshop.models.Release import author [as 别名]
def _create_release(self, package, data, session_users):
log.info('Create release {0} for package {1}'.format(
data.get('version'), package.name))
data = self._to_unicode(data)
release = Release(package=package,
summary=data.get('summary'),
version=data.get('version'),
stable_version=data.get('stable_version'),
home_page=data.get('home_page'),
license=data.get('license'),
description=data.get('description'),
keywords=data.get('keywords'),
platform=data.get('platform'),
download_url=data.get('download_url'),
bugtrack_url=data.get('bugtrack_url'),
docs_url=data.get('docs_url'),
)
if data.get('author'):
log.info('Looking for author {0}'.format(data['author']))
if _sanitize(data['author']) in session_users:
author = session_users[_sanitize(data['author'])]
else:
author = User.by_login(self.session, data['author'],
local=False)
if not author:
log.info('Author {0} not found, creating'.format(
data['author']))
author = User(login=data['author'],
local=False,
email=data.get('author_email'))
self.session.add(author)
session_users[_sanitize(data['author'])] = author
release.author = author
self.session.flush()
if data.get('maintainer'):
log.info('Looking for maintainer {0}'.format(data['maintainer']))
if _sanitize(data['maintainer']) in session_users:
maintainer = session_users[_sanitize(data['maintainer'])]
else:
maintainer = User.by_login(self.session, data['maintainer'],
local=False)
if not maintainer:
log.info('Maintainer not found, creating user {0}'
''.format(data['maintainer']))
maintainer = User(login=data['maintainer'],
local=False,
email=data.get('maintainer_email'))
self.session.add(maintainer)
session_users[_sanitize(data['maintainer'])] = maintainer
release.maintainer = maintainer
self.session.flush()
for name in data.get('classifiers', []):
classifier = Classifier.by_name(self.session, name.decode('utf-8'),
create_if_not_exists=True)
while classifier:
if classifier not in release.classifiers:
release.classifiers.append(classifier)
if classifier not in package.classifiers:
package.classifiers.append(classifier)
classifier = classifier.parent
self.session.flush()
return release