Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def get_version(name, conf, **kwargs):
repo = conf.get('bitbucket')
br = conf.get('branch', '')
use_max_tag = conf.getboolean('use_max_tag', False)
ignored_tags = conf.get("ignored_tags", "").split()
sort_version_key = sort_version_keys[conf.get("sort_version_key", "parse_version")]
if use_max_tag:
url = BITBUCKET_MAX_TAG % repo
max_page = conf.getint('max_page', 3)
data = await _get_tags(url, max_page=max_page)
else:
url = BITBUCKET_URL % (repo, br)
async with session.get(url) as res:
data = await res.json()
if use_max_tag:
data = [tag for tag in data if tag not in ignored_tags]
data.sort(key=sort_version_key)
version = data
else:
version = data['values'][0]['date'].split('T', 1)[0].replace('-', '')
return version
async def get_version(name, conf, **kwargs):
sparkle = conf['sparkle']
async with session.get(sparkle) as res:
resp = await res.read()
root = ElementTree.fromstring(resp)
item = root.find('./channel/item[1]/enclosure')
version_string = item.get('{http://www.andymatuschak.org/xml-namespaces/sparkle}shortVersionString')
build_number = item.get('{http://www.andymatuschak.org/xml-namespaces/sparkle}version')
if (version_string and version_string.isdigit()) and (build_number and not build_number.isdigit()):
version_string, build_number = build_number, version_string
version = []
if version_string:
version.append(version_string)
if build_number and (build_number not in version):
async def get_version(name, conf):
repo = conf.get('gcode_hg') or name
url = GCODE_URL % repo
async with session.get(url) as res:
data = await res.text()
m = GCODE_HG_RE.search(data)
if m:
t = time.strptime(m.group(1), '%b %d, %Y')
version = time.strftime('%Y%m%d', t)
else:
logger.error('%s: version not found.', name)
version = None
return name, version
async def _get_tags(url, *, max_page):
ret = []
for _ in range(max_page):
async with session.get(url) as res:
data = await res.json()
ret.extend(x['name'] for x in data['values'])
if 'next' in data:
url = data['next']
else:
break
return ret
}
if token:
headers['Authorization'] = 'token %s' % token
kwargs = {}
if conf.get('proxy'):
kwargs["proxy"] = conf.get("proxy")
if use_max_tag:
return await max_tag(partial(
session.get, headers=headers, **kwargs),
url, name, ignored_tags, include_tags_pattern,
max_page = conf.getint("max_page", 1),
)
async with session.get(url, headers=headers, **kwargs) as res:
logger.debug('X-RateLimit-Remaining',
n=res.headers.get('X-RateLimit-Remaining'))
data = await res.json()
if use_latest_release:
if 'tag_name' not in data:
logger.error('No tag found in upstream repository.',
name=name)
return
version = data['tag_name']
else:
# YYYYMMDD.HHMMSS
version = data[0]['commit']['committer']['date'] \
.rstrip('Z').replace('-', '').replace(':', '').replace('T', '.')
async def get_version(name, conf, **kwargs):
name = conf.get('cratesio') or name
async with session.get(API_URL % name) as res:
data = await res.json()
version = [v['num'] for v in data['versions'] if not v['yanked']][0]
return version