Skip to content

Instantly share code, notes, and snippets.

@sfaleron sfaleron/queryver.py
Last active Nov 2, 2017

Embed
What would you like to do?
Check the current version of maven artifacts at jcenter
# Query the current version of maven artifacts at jcenter
# Current favorites:
#
# org=org.jetbrains.kotlin pkg=kotlin-runtime
# org=io.kotlintest pkg=kotlintest
# org=no.tornado pkg=tornadofx
import requests
url = 'https://api.bintray.com/search/packages/maven'
aliases = {'pkg':'a', 'org': 'g'}
_defaults = {
'repo' : 'jcenter'
}
def query(**kwargs):
kwargs.update(_defaults)
for k,v in kwargs.items():
if k in aliases:
del kwargs[k]
kwargs[aliases[k]]=v
req = requests.get(url, params=kwargs)
if req.status_code == 200:
return req.json()[0]['versions'][0]
return ''
if __name__ == '__main__':
import sys
try:
ans = query(**dict([i.split('=') for i in sys.argv[1:]]))
except:
ans = ''
print(ans if ans else 'Request failed!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.