def _init_stdlib(): global _decode, _encode from couchdb.utils import import_stdlib json = import_stdlib('json') _decode = lambda string, loads=json.loads: loads(string) _encode = lambda obj, dumps=json.dumps: \ dumps(obj, allow_nan=False, ensure_ascii=False)
from datetime import datetime import errno import socket import time from io import StringIO import sys try: from threading import Lock except ImportError: from dummy_threading import Lock # this import must be before urllib.* import because we must set to import cache # original http package, not our module from couchdb.utils import import_stdlib BadStatusLine, HTTPConnection, HTTPSConnection = import_stdlib('http.client', 'BadStatusLine', 'HTTPConnection', 'HTTPSConnection') import urllib.request, urllib.parse, urllib.error from urllib.parse import urlsplit, urlunsplit from couchdb import json __all__ = ['HTTPError', 'PreconditionFailed', 'ResourceNotFound', 'ResourceConflict', 'ServerError', 'Unauthorized', 'RedirectLimit', 'Session', 'Resource'] __docformat__ = 'restructuredtext en' class HTTPError(Exception): """Base class for errors based on HTTP status codes >= 400."""