|
| 1 | +#!/usr/bin/env python |
| 2 | +# encoding: utf-8 |
| 3 | +import argparse |
| 4 | +import loklak |
| 5 | +from pprint import pprint |
| 6 | + |
| 7 | +parser = argparse.ArgumentParser(description="Python wrapper around the loklak API.") |
| 8 | +parser.add_argument('-s', '--search', type=str, help='Search API Wrapper which helps to query loklak for JSON results.') |
| 9 | +parser.add_argument('-t', '--status', action='store_true', help='Status API Wrapper for the loklak status check.') |
| 10 | +parser.add_argument('-st', '--suggest', action='store_true', help='Suggestions API Wrapper , Works better with local loklak instance.') |
| 11 | +parser.add_argument('-c', '--crawler', action='store_true', help='Crawler API Wrapper on Loklak to crawl for tweets for a particular crawl depth.') |
| 12 | +parser.add_argument('-hl', '--hello', action='store_true', help='Loklak status check API.') |
| 13 | +parser.add_argument('-g', '--geocode', help='Geocode API for geolocation based information.') |
| 14 | +parser.add_argument('-p', '--peers', action='store_true', help='Loklak API for peers connected on the distributed network.') |
| 15 | +parser.add_argument('-pg', '--pushgeojson', action='store_true', help='Public API to push geojson objects to the loklak server.') |
| 16 | +parser.add_argument('-u', '--user', help='User API to show twitter user information.') |
| 17 | +parser.add_argument('-m', '--map', action='store_true', help='Map Visualization render using Loklak service.') |
| 18 | +parser.add_argument('-md', '--markdown', action='store_true', help='Markdown conversion API to render markdown as image using Loklak.') |
| 19 | +args = parser.parse_args() |
| 20 | + |
| 21 | +loklak = loklak.Loklak() |
| 22 | +if args.search: |
| 23 | + pprint(loklak.search(args.search)) |
| 24 | +elif args.status: |
| 25 | + pprint(loklak.status()) |
| 26 | +elif args.suggest: |
| 27 | + pass |
| 28 | +elif args.crawler: |
| 29 | + pass |
| 30 | +elif args.hello: |
| 31 | + pprint(loklak.hello()) |
| 32 | +elif args.geocode: |
| 33 | + pprint(loklak.geocode(args.geocode.split(', '))) |
| 34 | +elif args.peers: |
| 35 | + pprint(loklak.peers()) |
| 36 | +elif args.pushgeojson: |
| 37 | + pass |
| 38 | +elif args.user: |
| 39 | + params = args.user.split() |
| 40 | + pprint(loklak.search(*params)) |
| 41 | +elif args.map: |
| 42 | + pass |
| 43 | +elif args.markdown: |
| 44 | + pass |
| 45 | +else: |
| 46 | + print('Choose API method.') |
0 commit comments