Skip to content

Instantly share code, notes, and snippets.

diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
index a072b1e..2763b98 100644
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -20,7 +20,7 @@ class _Toolkit(object):
'_', # i18n translation
'ungettext', # i18n translation (plural forms)
'c', # template context
- 'h', # template helpers
+ #'h', # template helpers
@wardi
wardi / inventory_dl.py
Created May 10, 2017 18:46
Download and strip newlines and double quotes from OD inventory dataset
#!/usr/bin/env python2
import requests
import csv
URL = 'http://open.canada.ca/data/dataset/4ed351cf-95d8-4c10-97ac-6b3511f359b7/resource/d0df95a8-31a9-46c9-853b-6952819ec7b4/download/inventory.csv'
OUTPUT = 'inventory-stripped.csv'
r = requests.get(URL, stream=True)
out = csv.writer(open(OUTPUT, 'wb'))
for row in csv.reader(r.raw):
"""
Answers to shopping list, generation, iteration, decoration exercises posted
"""
def shopping_list():
"""
Exercise: shopping list
using while True: and input() create a shopping list interface allowing a user to enter multiple items then type DONE to exit

Retrieve Records

Access this data through the CKAN Datastore API with resource_id="b076ced6-ef48-45b8-8db2-dd7d27c11fe2"

The CKAN API uses a JSON-RPC style, where you post a JSON object and receive another JSON object in response.

Retrieving records requires an API key. Your API key is shown on your profile page.

Do not include your API key in any code shared with other people. Use a configuration file or environment variable to let each user input their own key when they use your tool. Your API key is equivalent to your password and may be used to perform any action your user can on this site. All actions made with your API key will be logged as actions you performed. Example:

@wardi
wardi / urlsafe3.py
Created February 19, 2020 17:32
url-safe string functions
# -*- coding: utf-8 -*-
import re
def url_part_escape(orig):
"""
simple encoding for url-parts where all non-alphanumerics are
wrapped in e.g. _xxyyzz_ blocks w/hex UTF-8 xx, yy, zz values
used for safely including arbitrary unicode as part of a url path