{ "info": { "author": "Yoshio Iwamoto", "author_email": "yoshiodeveloper@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Utilities" ], "description": "# yrequests\n\nA very simple module for HTTP/1.1 requests. It is based on python-requests module.\n\n## What and Why\n\nyrequest is just wrapper for [requests](http://docs.python-requests.org) functions, but it handles connection and HTTP errors silently.\n\n## How to use\n\n```python\nfrom yrequests import YRequests\nreq = YRequests() # you can pass \"headers\" (dict) or a \"timeout\" (secs) too\nresult = req.get('http://url.com/a/b/c', params={'q': 'apple'})\nif result['ok']:\n print(result['text']) # If you except a JSON uses result['json']\n # ...and other stuffs when everything is fine\nelse:\n # Connections, HTTP and general errors\n print(result['error']) # or result['status_code']\n # and other stuffs when an error occurs\n```\n\nYou can also use `post`, `put`, `delete`, `head` and `options`. These (HTTP) methods receive the same parameters of [requests](http://docs.python-requests.org) module. If you need instructions of how requests module works take a look at: http://docs.python-requests.org/en/master/user/quickstart/\n\n## Installing\n\nTo install yrequests just use pip.\n\n```\npip install yrequests\n```\n\n## YRequests class\n\n**YRequests(timeout=60, headers=None)**\n - timeout: Default timeout (seconds) for all requests.\n - headers: Default headers (`dict`) for all requests.\n\n**YRequests.get(url, \\*args, \\*\\*kwargs)**\n**YRequests.post(url, \\*args, \\*\\*kwargs)**\n**YRequests.delete(url, \\*args, \\*\\*kwargs)**\n**YRequests.put(url, \\*args, \\*\\*kwargs)**\n**YRequests.head(url, \\*args, \\*\\*kwargs)**\n**YRequests.options(url, \\*args, \\*\\*kwargs)**\nMake a request using the respective HTTP method. The `args` and `kwargs` are passed to the respective `requests.`.\n- url: The URL.\n- args, kwargs: passed to *requests* module (as *requests.get(url, \\*args, \\*\\*kwargs)*)\n- Returns a `dict` with the result. See Result above for more details.\n\nTo know how these methods work take a look at [requests documentation](http://docs.python-requests.org/en/master/user/quickstart/).\n\n## Result\n\nThe methods `get`, `post`, `put`, `delete`, `head` and `options` returns a `dict` object:\n\n```python\nresult = {\n 'ok': ,\n 'error': ,\n 'error_type': ,\n 'response': ,\n 'headers': ,\n 'status_code': ,\n 'content_type': ,\n 'text': ,\n 'json': ,\n}\n```\n\nResult keys:\n - ok: True if everything is fine. Always check this value.\n - error: Textual error (when *ok* is False).\n - error_type: A string with the error type:\n - general: General error.\n - connection: DNS problem, connection refused, etc. The only exception is timed out that has its own code (above).\n - timeout: Connection timed out.\n - http: HTTP errors like 404, 403, 500, etc.\n - json: \"Content-Type\" header is indicated as JSON but the content is not a valid JSON.\n - response: A response object (same of *requests* module). You can use as fallback to check informations that are not handled by this class.\n - headers: Dictionary with the response headers (same of *requests.response.headers* module).\n - status_code: Integer of HTTP status code (200, 404, 500, etc).\n - content_type: The *Content-Type* header value.\n - text: The content of response (if any). It's always unicode.\n - json: A dictionary of the content if the \"Content-Type\" header is indicated as JSON.\n\n## Other example\n\nThis example makes a request on Facebook Graph API.\n\n```python\nfrom yrequests import YRequests\n\ndef get_facebook_me(req):\n params = {'fields': 'id,name', 'access_token': 'XXXxxx...'}\n # Note that the \"get\" method uses \"user-agent\" and \"extra-header\" headers.\n result = req.get('https://graph.facebook.com/me', params=params, headers={'extra-header': 'other-header-value'})\n if not result['ok']:\n print(result['error'])\n return {}\n data = result['json']\n print('My name is %(name)s, my Facebook ID is %(id)s' % data)\n return data\n\n# YRequests only accepts two optional parameters: headers and timeout\nreq = YRequests(headers={'user-agent': 'BugBot/1.0'}, timeout=30)\nuser_dict = get_facebook_me(req)\n```\n\n## Contributing\n\nIf you found a bug, typo or bad coding you can contribute to this project!\nSend a pull request or contact yoshiodeveloper@gmail.com.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yoshiodeveloper/yrequests", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "yrequests", "package_url": "https://pypi.org/project/yrequests/", "platform": "", "project_url": "https://pypi.org/project/yrequests/", "project_urls": { "Bug Reports": "https://github.com/yoshiodeveloper/yrequests/issues", "Homepage": "https://github.com/yoshiodeveloper/yrequests", "Source": "https://github.com/yoshiodeveloper/yrequests" }, "release_url": "https://pypi.org/project/yrequests/0.1.0/", "requires_dist": [ "requests", "future; python_version < \"3\"" ], "requires_python": "", "summary": "A very simple module for HTTP/1.1 requests.", "version": "0.1.0" }, "last_serial": 4008339, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "8e32cef7cc2e67d1b03a1b6d629db01e", "sha256": "7085326ad30edbb44c9039aed86ea5dab42967c5c20d7d961382cdee7864f6e6" }, "downloads": -1, "filename": "yrequests-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e32cef7cc2e67d1b03a1b6d629db01e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6399, "upload_time": "2018-06-27T17:45:44", "url": "https://files.pythonhosted.org/packages/1a/a8/3bd78d7d2d9306a245deab91cb68fe8a02761e631b06a960f31aa557d2db/yrequests-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ef16f671839ebfda878c6b5c2686e308", "sha256": "76c15e121b25fc897159f0289c11046f2873c3b68e5078294d1208a680104b0f" }, "downloads": -1, "filename": "yrequests-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ef16f671839ebfda878c6b5c2686e308", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6007, "upload_time": "2018-06-27T17:45:45", "url": "https://files.pythonhosted.org/packages/21/22/d6d70254ce8462057f77f2f20291c8fb9371b4c8ed93c1a18a9b8c0477fa/yrequests-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8e32cef7cc2e67d1b03a1b6d629db01e", "sha256": "7085326ad30edbb44c9039aed86ea5dab42967c5c20d7d961382cdee7864f6e6" }, "downloads": -1, "filename": "yrequests-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e32cef7cc2e67d1b03a1b6d629db01e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6399, "upload_time": "2018-06-27T17:45:44", "url": "https://files.pythonhosted.org/packages/1a/a8/3bd78d7d2d9306a245deab91cb68fe8a02761e631b06a960f31aa557d2db/yrequests-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ef16f671839ebfda878c6b5c2686e308", "sha256": "76c15e121b25fc897159f0289c11046f2873c3b68e5078294d1208a680104b0f" }, "downloads": -1, "filename": "yrequests-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ef16f671839ebfda878c6b5c2686e308", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6007, "upload_time": "2018-06-27T17:45:45", "url": "https://files.pythonhosted.org/packages/21/22/d6d70254ce8462057f77f2f20291c8fb9371b4c8ed93c1a18a9b8c0477fa/yrequests-0.1.0.tar.gz" } ] }