Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

clarify the situation with OrderedDict

  • Loading branch information...
commit 4539d8c9cd550bfb4166867d4980de76ea10ee01 1 parent d580d96
@sah sah authored
View
8 monocle/tornado_stack/network/http.py
@@ -3,7 +3,11 @@
# by Steven Hazel
import urlparse
-import ordereddict
+
+try:
+ from collections import OrderedDict
+except ImportError:
+ from ordereddict import OrderedDict
import tornado.httpclient
import tornado.httpserver
@@ -14,7 +18,7 @@
class HttpException(Exception): pass
-HttpHeaders = ordereddict.OrderedDict
+HttpHeaders = OrderedDict
class HttpClient(object):
def __init__(self):
View
14 monocle/twisted_stack/network/http.py
@@ -3,7 +3,11 @@
# by Steven Hazel
import urlparse
-import ordereddict
+
+try:
+ from collections import OrderedDict
+except ImportError:
+ from ordereddict import OrderedDict
from monocle import _o, VERSION
from monocle.deferred import Deferred
@@ -17,7 +21,7 @@
class HttpException(Exception): pass
-class HttpHeaders(ordereddict.OrderedDict): pass
+class HttpHeaders(OrderedDict): pass
class HttpResponse(object):
@@ -34,7 +38,7 @@ def __init__(self):
except AttributeError:
pass
self.code = None
- self.headers = ordereddict.OrderedDict()
+ self.headers = OrderedDict()
self.connect_df = Deferred()
self.response_df = Deferred()
@@ -68,7 +72,7 @@ def _normalize_header_name(self, name):
return self._HEADER_NORMS.get(name.lower(), name)
def _normalize_headers(self, headers):
- return ordereddict.OrderedDict(
+ return OrderedDict(
((self._normalize_header_name(key), value)
for key, value in headers.iteritems()))
@@ -96,7 +100,7 @@ def request(self, url, headers=None, method='GET', body=None):
path = '/' + url.split('/', 3)[3]
if not headers:
- headers = ordereddict.OrderedDict()
+ headers = OrderedDict()
headers = self._normalize_headers(headers)
headers.setdefault('User-Agent', 'monocle/%s' % VERSION)
headers.setdefault('Host', host)
View
6 setup.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import sys
try:
from setuptools import setup
except ImportError:
@@ -6,6 +7,10 @@
from monocle import VERSION
+install_requires = []
+if sys.version_info < (2, 7):
+ install_requires.append('ordereddict')
+
setup(name="monocle",
version=VERSION,
description="An async programming framework with a blocking look-alike syntax",
@@ -23,5 +28,6 @@
'monocle.tornado_stack.network',
'monocle.asyncore_stack',
'monocle.asyncore_stack.network'],
+ install_requires=install_requires,
license='MIT'
)
Please sign in to comment.
Something went wrong with that request. Please try again.