Skip to content

Instantly share code, notes, and snippets.

@niconoe
Created October 6, 2021 08:14
Show Gist options
  • Save niconoe/5273bd16a371d509329253cd90406aab to your computer and use it in GitHub Desktop.
Save niconoe/5273bd16a371d509329253cd90406aab to your computer and use it in GitHub Desktop.
import requests
def get_json_from_url(url):
"""Small helper"""
res = requests.get(url)
data = res.json()
return data
def get_resource_for_dp(resource_for_export):
resource_for_dp = resource_for_export.copy()
resource_for_dp["schema"] = get_json_from_url(resource_for_export["schema"])
return resource_for_dp
camtrapDPVersion = "0.1.6"
_deploymentResourceForExport = {
# add here other properties
"schema": f"https://raw.githubusercontent.com/tdwg/camtrap-dp/{camtrapDPVersion}/deployments-table-schema.json"
}
_deploymentResourceForDataPackage = get_resource_for_dp(_deploymentResourceForExport)
# at this stage, _deploymentResourceForExport is good for the export and _deploymentResourceForDataPackage can be
# passed to add_resource()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment