This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,012 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Change Log | ||
========== | ||
|
||
v0.1 (2013-01-05) | ||
----------------- | ||
|
||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Yahoo! Weather Terms of Use | ||
|
||
The feeds are provided free of charge for use by individuals and non-profit organizations for personal, non-commercial uses. We ask that you provide attribution to Yahoo! Weather in connection with your use of the feeds. | ||
|
||
If you provide this attribution in text, please use: "Yahoo! Weather." If you provide this attribution with a graphic, please use the Yahoo! Weather logo that we have included in the feed itself. | ||
|
||
We reserve all rights in and to the Yahoo! Weather logo, and your right to use the Yahoo! Weather logo is limited to providing attribution in connection with these RSS feeds. | ||
|
||
Yahoo! also reserves the right to require you to cease distributing these feeds at any time for any reason. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 3fd54a863af1193efdfc3582a2fb3a89 | ||
config: f01ae198554471cb0b2fd1c048840a2e | ||
tags: fbb0d17656682115ca4d033fb2f83ba1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../CHANGES.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Introduction | ||
============ | ||
|
||
This is the documentation for :mod:`yweather`. :mod:`yweather` is a Python module that provides an interface to the `Yahoo! Weather RSS feed <http://developer.yahoo.com/weather/>`_ | ||
|
||
Prerequisites | ||
------------- | ||
|
||
:mod:`yweather` requires Python 2.6, 2.7, or 3 to run. | ||
|
||
Installation | ||
------------ | ||
|
||
There are multiple ways to install :mod:`yweather`. If you are unsure about which method to use, try ``pip``. | ||
|
||
pip (recommended) | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
`pip <http://www.pip-installer.org/>`_ is a tool for installing and managing Python packages. To install :mod:`yweather`, run: | ||
|
||
.. code-block:: bash | ||
|
||
$ pip install yweather | ||
|
||
This will download :mod:`yweather` from `the Python Package Index <http://pypi.python.org/>`_ and install it in your Python's ``site-packages`` directory. | ||
|
||
Tarball Release | ||
~~~~~~~~~~~~~~~ | ||
|
||
1. Download the most recent release from `yweather's PyPi page <http://pypi.python.org/pypi/yweather/>`_. | ||
2. Unpack the tarball. | ||
3. From inside the ``yweather-0.X`` directory, run ``python setup.py install`` | ||
|
||
This will install :mod:`yweather` in your Python's ``site-packages`` directory. | ||
|
||
Install the Development Version | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`yweather's code <https://github.com/tsroten/yweather>`_ is hosted at GitHub. To install the development version, do the following: | ||
|
||
1. Make sure `Git <http://git-scm.org/>`_ is installed. Test if it's installed by running ``git --version`` | ||
2. ``git clone git://github.com/tsroten/yweather.git`` | ||
3. ``pip install -e yweather`` | ||
|
||
This will link the ``yweather`` directory into your ``site-packages`` directory. You can find out where your ``site-packages`` directory is by running: | ||
|
||
.. code-block:: bash | ||
|
||
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" | ||
|
||
Basic Usage | ||
----------- | ||
|
||
.. code-block:: python | ||
|
||
>>> import yweather | ||
>>> client = yweather.Client() | ||
>>> client.fetch_woeid("Oslo, Norway") | ||
'862592' | ||
>>> oslo_weather = client.fetch_weather("862592") | ||
>>> oslo_weather["atmosphere"]["pressure"] | ||
'30.24' | ||
>>> oslo_weather["condition"]["text"] | ||
'Mostly Cloudy' | ||
|
||
This code creates a :class:`yweather.Client` instance that allows you to fetch a location's :term:`WOEID` and weather. The weather data is returned as a :class:`dict <python3:dict>`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
Usage | ||
===== | ||
|
||
Let's learn how to use :mod:`yweather`. | ||
|
||
Create a :class:`~yweather.Client` Object | ||
----------------------------------------- | ||
|
||
:mod:`yweather` consists of a single class, :class:`~yweather.Client`. | ||
|
||
.. code-block:: python | ||
|
||
>>> import yweather | ||
>>> client = yweather.Client() | ||
|
||
By creating an instance of :class:`~yweather.Client`, you've created an object that you can use to fetch location identifiers and weather data from Yahoo! Weather. | ||
|
||
Fetch a Location's :term:`WOEID` | ||
-------------------------------- | ||
|
||
Yahoo! Weather gives every location a unique :term:`WOEID`. In order to fetch weather data from Yahoo!, you must first know the location's :term:`WOEID`. | ||
|
||
.. code-block:: python | ||
|
||
>>> client.fetch_woeid("Beijing, China") | ||
'2151330' | ||
>>> client.fetch_woeid("96734") | ||
'12798281' | ||
>>> client.fetch_woeid("10 South Main Street, Harrisonburg, VA") | ||
'12767058' | ||
|
||
You can retrieve a :term:`WOEID` by passing a general or specific address. The above example used city and country, ZIP code, and complete address. | ||
|
||
Fetch a Location's Weather | ||
-------------------------- | ||
|
||
Once you have a location's :term:`WOEID`, you can use it to fetch the location's weather. Weather data is returned as a :class:`dict <python3:dict>`. Its structure is detailed in :meth:`~yweather.Client.fetch_weather`'s API documentation. | ||
|
||
.. code-block:: python | ||
|
||
>>> beijing_weather = client.fetch_weather("2151330") | ||
>>> beijing_weather["guid"] | ||
'CHXX0008_2013_01_06_7_00_CST' | ||
>>> beijing_weather["description"] | ||
'Yahoo! Weather for Beijing, CN' | ||
>>> beijing_weather["condition"]["temp"] | ||
'28' | ||
|
||
The returned :class:`dict <python3:dict>` contains metadata along with the weather data itself. By default, :term:`United States customary units` are used, but by changing the *metric* argument, you can receive data according to the :term:`metric system`. | ||
|
||
.. code-block:: python | ||
|
||
>>> kailua_weather = client.fetch_weather("12798281", metric=True) | ||
>>> kailua_weather["forecast"][0]["high"] | ||
'25' | ||
>>> kailua_weather["units"]["forecast"]["high"] | ||
'°C' | ||
|
||
The units used for each data value are accessible with the *units* key. | ||
|
||
Using a Location's :term:`LID` | ||
------------------------------ | ||
|
||
Because Yahoo! Weather's data comes from `The Weather Channel <http://www.weather.com>`_, weather data is also accessible via a The Weather Channel :term:`LID`. This provides access to a 5-day forecast versus the 2-day forecast available with a location's :term:`WOEID`. | ||
|
||
.. code-block:: python | ||
|
||
>>> client.fetch_lid("2151330") | ||
'CHXX0008' | ||
>>> beijing_weather = client.fetch_weather("CHXX0008") | ||
>>> len(beijing_weather["forecast"]) | ||
5 | ||
|
||
The :meth:`~yweather.Client.fetch_lid` method takes a :term:`WOEID` and returns a :term:`LID`. You can pass the :term:`LID` to the :meth:`~yweather.Client.fetch_weather` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.