From 9257aa01a6c70f06966dbaf1fb5398c7caab16b9 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 23 Sep 2014 12:00:13 +0200 Subject: [PATCH] drop ffhlwiki and mkmap --- ffhlwiki.py | 93 ----------------------------------------------------- mkmap.sh | 15 --------- 2 files changed, 108 deletions(-) delete mode 100755 ffhlwiki.py delete mode 100755 mkmap.sh diff --git a/ffhlwiki.py b/ffhlwiki.py deleted file mode 100755 index c1ba01e..0000000 --- a/ffhlwiki.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 - -import json -import argparse -from itertools import zip_longest -from urllib.request import urlopen -from bs4 import BeautifulSoup - -def import_wikigps(url): - def fetch_wikitable(url): - f = urlopen(url) - - soup = BeautifulSoup(f) - - table = soup.find_all("table")[0] - - rows = table.find_all("tr") - - headers = [] - - data = [] - - def maybe_strip(x): - if isinstance(x.string, str): - return x.string.strip() - else: - return "" - - for row in rows: - tds = list([maybe_strip(x) for x in row.find_all("td")]) - ths = list([maybe_strip(x) for x in row.find_all("th")]) - - if any(tds): - data.append(tds) - - if any(ths): - headers = ths - - nodes = [] - - for d in data: - nodes.append(dict(zip(headers, d))) - - return nodes - - nodes = fetch_wikitable(url) - - aliases = {} - - for node in nodes: - try: - node['MAC'] = node['MAC'].split(',') - except KeyError: - pass - - try: - node['GPS'] = node['GPS'].split(',') - except KeyError: - pass - - try: - node['Knotenname'] = node['Knotenname'].split(',') - except KeyError: - pass - - nodes = zip_longest(node['MAC'], node['GPS'], node['Knotenname']) - - for data in nodes: - alias = {} - - mac = data[0].strip() - - if data[1]: - alias['gps'] = data[1].strip() - - if data[2]: - alias['name'] = data[2].strip() - - aliases[mac] = alias - - return aliases - -parser = argparse.ArgumentParser() - -parser.add_argument('url', help='wiki URL') - -args = parser.parse_args() - -options = vars(args) - -aliases = import_wikigps(options['url']) - -print(json.dumps(aliases)) diff --git a/mkmap.sh b/mkmap.sh deleted file mode 100755 index ce3b162..0000000 --- a/mkmap.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -DEST=$1 - - -[ "$DEST" ] || exit 1 - -cd "$(dirname "$0")"/ - -./ffhlwiki.py http://freifunk.metameute.de/wiki/Knoten > aliases_hl.json -./ffhlwiki.py http://freifunk.metameute.de/wiki/Moelln:Knoten > aliases_moelln.json - -./bat2nodes.py -A -a aliases.json -a aliases_hl.json -a aliases_moelln.json -d $DEST