From 2ce562af263196c209299793e5e60dba654da501 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 3 Jun 2012 16:59:57 +0200 Subject: [PATCH] Python3 compatiblity --- nodedb.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nodedb.py b/nodedb.py index 113b480..483545d 100644 --- a/nodedb.py +++ b/nodedb.py @@ -3,7 +3,18 @@ from node import Node from link import Link from bs4 import BeautifulSoup -import urllib + + +# Python2/3 compatiblity hacks +try: + from urllib.request import urlopen +except ImportError: + from urllib import urlopen + +try: + basestring +except NameError: + basestring = str class NodeDB: def __init__(self): @@ -125,7 +136,7 @@ class NodeDB: def import_wikigps(self, url): def fetch_wikitable(url): - f = urllib.urlopen(url) + f = urlopen(url) soup = BeautifulSoup(f)