in mozdownload/scraper.py [0:0]
def get_build_info_for_date(self, date, build_index=None):
"""Return the build information for a given date."""
url = urljoin(self.base_url, self.monthly_build_list_regex)
has_time = date and date.time() and date.strftime('%H-%M-%S') != '00-00-00'
self.logger.info('Retrieving list of builds from %s' % url)
parser = self._create_directory_parser(url)
regex = APPLICATION_REGEX[self.application] % {
'DATE': date.strftime('%Y-%m-%d'),
'BRANCH': self.branch,
# ensure to select the correct subfolder for localized builds
'L10N': '(-l10n)?' if self.locale_build else '',
'PLATFORM': '' if self.application not in ('fenix') else '-' + self.platform
}
parser.entries = parser.filter(regex)
parser.entries = parser.filter(self.is_build_dir)
if has_time:
# If a time is included in the date, use it to determine the
# build's index
regex = r'.*%s.*' % date.strftime('%H-%M-%S')
parser.entries = parser.filter(regex)
if not parser.entries:
date_format = '%Y-%m-%d-%H-%M-%S' if has_time else '%Y-%m-%d'
message = 'Folder for builds on %s has not been found' % \
self.date.strftime(date_format)
raise errors.NotFoundError(message, url)
# If no index has been given, set it to the last build of the day.
self.show_matching_builds(parser.entries)
# If no index has been given, set it to the last build of the day.
if build_index is None:
# Find the most recent non-empty entry.
build_index = len(parser.entries)
for build in reversed(parser.entries):
build_index -= 1
if not build_index or self.is_build_dir(build):
break
if build_index >= len(parser.entries):
raise errors.NotFoundError('Specified build number has not been found ', url)
self.logger.info('Selected build: %s' % parser.entries[build_index])
return (parser.entries, build_index)