New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement Python requests for HTTP #111
Comments
FYI - I've started this, should have something to review in a few days |
Still working on it... |
@kwilcox Any progress on this work? I feel like this would greatly help with Python 3, since |
@kwilcox any progress on that issue? I have started to look at what could block a version compatible with both python2 and python3 and the use of urllib2 (splitted in urllib.request and urllib.error in python 3) is problematic. Switching to requests which supports both python2 and 3 with the same interface would greatly help. |
(here's my branch if you want to pull and test locally for now: https://github.com/daf/OWSLib/commits/3.4) |
Thanks! If you need some help or specific tests, please let me know. |
Doctests cause some headaches with the differences between 2 and 3. For instance, here's one I haven't solved yet: ________________________________ [doctest] tests/doctests/namespaces.txt ________________________________
040 # 'om300' does not exist as a namespace, so the below will return nothing
041 >>> ns.get_namespace('om300')
042
043 # CSW 3.1.1 doesn't exist, so the below will return nothing
044 >>> ns.get_versioned_namespace('csw','3.1.1')
045
046
047 Invalid Usage Tests
048
049 >>> ns.get_namespace()
Differences (unified diff with -expected +actual):
@@ -1,3 +1,6 @@
Traceback (most recent call last):
-...
-TypeError: get_namespace() takes exactly 2 arguments (1 given)
+ File "/home/daf/miniconda/envs/owslib3/lib/python3.4/doctest.py", line 1318, in __run
+ compileflags, 1), test.globs)
+ File "<doctest namespaces.txt[16]>", line 1, in <module>
+ ns.get_namespace()
+TypeError: get_namespace() missing 1 required positional argument: 'key' The error text changed (much more helpful in 3!). I'm learning more about doctests as I go, does anyone have a strategy to address something like this to work with 2 and 3 while not mutilating the intent of the doctest (aka, readable instead of "make it pass"). Does doctest support partial ellipsis? Something like a literal |
Wow, turns out you can do partial line ellipsis. Nice. |
Go @daf go! |
For the I should be able to propose a patch soon. |
NB: it doesn't produce regression with python2 according to my tests. |
You can see my patches here: daf#1 I dropped from 32 failed tests in python3 to 16. |
Thanks @Jenselme ! |
cc @kwilcox
To track implementation of Python requests [1] for HTTP support across the codebase
Between GET / POST, authentication, cookies, etc., the requests library [1] would make OWSLib's HTTP request/response patterns minimal, solid, and very easy to
Notes/ideas:
owslib.util.openURL
,owslib.util.http_post
inowslib.util
, as at least stubs (I've seen these in use in downstreams apps)owslib.util.bind_url
could probably be deleted afterwards[1] http://docs.python-requests.org
The text was updated successfully, but these errors were encountered: