Skip to content

Instantly share code, notes, and snippets.

@ri5h
Created September 28, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ri5h/b782298b1375dc4262351f4df27541fd to your computer and use it in GitHub Desktop.
Save ri5h/b782298b1375dc4262351f4df27541fd to your computer and use it in GitHub Desktop.
Read package info from packagist
# Read the latest version available from packagist
finalRes = []
for package in reqPack:
finalPackageResult = {
'name': package
}
# Try to get info from packagist (works with or w/o repo)
url = 'https://repo.packagist.org/packages/' + package + '.json'
jsonMetaRes = requests.get(url)
if jsonMetaRes.status_code != 200:
finalPackageResult['msg'] = 'packagist error for url: ' + url
finalPackageResult['status'] = 'failed'
finalRes.append(finalPackageResult)
continue
jsonMeta = jsonMetaRes.json()['package']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment