本文整理匯總了Python中dipper.models.Dataset.Dataset.set_version_by_num方法的典型用法代碼示例。如果您正苦於以下問題:Python Dataset.set_version_by_num方法的具體用法?Python Dataset.set_version_by_num怎麽用?Python Dataset.set_version_by_num使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dipper.models.Dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.set_version_by_num方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: WormBase
# 需要導入模塊: from dipper.models.Dataset import Dataset [as 別名]
# 或者: from dipper.models.Dataset.Dataset import set_version_by_num [as 別名]
#.........這裏部分代碼省略.........
# update the dataset object with details about this resource
# NO LICENSE for this resource
self.dataset = Dataset(
'wormbase', 'WormBase', 'http://www.wormbase.org', None, None,
'http://www.wormbase.org/about/policies#012')
self.version_num = None
return
def fetch(self, is_dl_forced=False):
# figure out the version number by probing the "current_release",
# then edit the file dict accordingly
# connect to wormbase ftp
current_dev_release_dir = \
'pub/wormbase/releases/current-development-release'
ftp = FTP('ftp.wormbase.org')
ftp.login()
ftp.cwd(current_dev_release_dir)
# the current release dir is a redirect to a versioned release.
# pull that from the pwd.
pwd = ftp.pwd()
ftp.quit()
wsver = re.search(r'releases\/(WS\d+)', pwd)
if wsver is None or len(wsver.groups()) < 1:
logger.error(
"Couldn't figure out version number from FTP site. Exiting.")
exit(1)
else:
self.update_wsnum_in_files(wsver.group(1))
self.dataset.set_version_by_num(self.version_num)
# fetch all the files
self.get_files(is_dl_forced)
return
def update_wsnum_in_files(self, vernum):
"""
With the given version number ```vernum```,
update the source's version number, and replace in the file hashmap.
We also save the "letter" for the version
to maintain the version number.
:param vernum:
:return:
"""
self.version_num = vernum
# replace the WSNUMBER in the url paths with the real WS###
for f in self.files:
url = self.files[f].get('url')
url = re.sub(r'WSNUMBER', self.version_num, url)
self.files[f]['url'] = url
logger.debug(
"Replacing WSNUMBER in %s with %s", f, self.version_num)
# also the letter file - keep this so we know the version number
self.files['letter']['file'] = re.sub(r'WSNUMBER',
self.version_num,
self.files['letter']['file'])
return
def parse(self, limit=None):
if limit is not None:
logger.info("Only parsing first %s rows of each file", limit)