From bdf9099df8c2a4636b0ad0e710b73330877eef37 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 24 Oct 2014 19:59:05 +0200 Subject: Very cleaner, much class, such readable, wow --- banapedia/api/Query.py | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 banapedia/api/Query.py (limited to 'banapedia/api/Query.py') diff --git a/banapedia/api/Query.py b/banapedia/api/Query.py deleted file mode 100644 index 7453df9..0000000 --- a/banapedia/api/Query.py +++ /dev/null @@ -1,23 +0,0 @@ -import urllib.parse -import urllib.request -import json - -__author__ = 'pacien' - - -class Query: - def __init__(self, base_url="", params={}, encoding="utf8"): - self.base_url = base_url - self.params = params - self.encoding = encoding - - def fetch_raw_result(self): - post_query = urllib.parse.urlencode(self.params) - post_query = post_query.encode(self.encoding) - document = urllib.request.urlopen(self.base_url, post_query) - return document.read().decode(self.encoding) - - -class JSONQuery(Query): - def fetch_result(self): - return json.loads(self.fetch_raw_result()) -- cgit v1.2.3