<commit_before>#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

from urllib2 import urlopen
from sys import exit
import json
from pprint import pprint

try:
    import sensitive
except ImportError:
    print "Det verkar inte finnas en sensitive.py i din katalog. Läs installationsinstruktionerna."
    exit(1)

searchstring = 'vårsta'
urltemplate = r'https://api.sl.se/api2/typeahead.json?key=%s&searchstring=%s'
url = urltemplate % (sensitive.sl_platsuppslag,searchstring)

print url
jsonresponse = urlopen(url).read().decode('iso-8859-1')
dictresponse = json.loads(jsonresponse)
pprint(dictresponse)
<commit_msg>Completed module for SL Platsuppslag.<commit_after>#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

from api import API,cli

api = API(r'https://api.sl.se/api2/typeahead.json',{
    'key' : {'required':True,'description':"Din API-nyckel."},
    'searchstring' : {'required':True,'description':"Söksträngen."},
    'stationsonly' : {'required':False,'domain':bool,'default':True,'description':"Om \"True\" returneras endast hållplatser."},
    'maxresults' : {'required':False,'domain':set(range(50+1)),'default':10,'description':"Maximalt antal resultat som önskas."},
})

if __name__ == '__main__':
    cli(api,"Wrapper för API:et SL Platsuppslag.")

{'fraction_non_alphanumeric': 0.16679904686258937, 'fraction_numerical': 0.015885623510722795, 'mean_word_length': 5.428571428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5587247', 'n_tokens_mistral': 445, 'n_tokens_neox': 432, 'n_words': 87}