Permalink
Browse files

Merge branch 'release/v0.1'

  • Loading branch information...
2 parents ae0b7e3 + 7778cf8 commit caec7fc46e7b62483959ff4c8458ae0ea1c8efe3 @tsroten committed Jan 5, 2013
Showing with 3,261 additions and 27 deletions.
  1. +7 −0 CHANGES.txt
  2. +1 −0 MANIFEST.in
  3. +73 −0 README.rst
  4. +9 −0 YAHOO_TERMS.txt
  5. BIN docs/_build/doctrees/api.doctree
  6. BIN docs/_build/doctrees/changes.doctree
  7. BIN docs/_build/doctrees/environment.pickle
  8. BIN docs/_build/doctrees/glossary.doctree
  9. BIN docs/_build/doctrees/index.doctree
  10. BIN docs/_build/doctrees/intro.doctree
  11. BIN docs/_build/doctrees/usage.doctree
  12. +1 −1 docs/_build/html/.buildinfo
  13. +92 −0 docs/_build/html/_modules/index.html
  14. +436 −0 docs/_build/html/_modules/yweather.html
  15. +151 −0 docs/_build/html/_sources/api.txt
  16. +1 −0 docs/_build/html/_sources/changes.txt
  17. +16 −0 docs/_build/html/_sources/glossary.txt
  18. +8 −1 docs/_build/html/_sources/index.txt
  19. +67 −0 docs/_build/html/_sources/intro.txt
  20. +74 −0 docs/_build/html/_sources/usage.txt
  21. +1 −1 docs/_build/html/_static/searchtools.js
  22. +518 −0 docs/_build/html/api.html
  23. +132 −0 docs/_build/html/changes.html
  24. +145 −5 docs/_build/html/genindex.html
  25. +118 −0 docs/_build/html/glossary.html
  26. +48 −8 docs/_build/html/index.html
  27. +187 −0 docs/_build/html/intro.html
  28. BIN docs/_build/html/objects.inv
  29. +114 −0 docs/_build/html/py-modindex.html
  30. +11 −5 docs/_build/html/search.html
  31. +1 −1 docs/_build/html/searchindex.js
  32. +186 −0 docs/_build/html/usage.html
  33. +151 −0 docs/api.rst
  34. +1 −0 docs/changes.rst
  35. +3 −2 docs/conf.py
  36. +16 −0 docs/glossary.rst
  37. +8 −1 docs/index.rst
  38. +67 −0 docs/intro.rst
  39. +74 −0 docs/usage.rst
  40. +3 −2 setup.py
  41. +54 −0 test/data/data_5day.xml
  42. +48 −0 test/data/data_weather.xml
  43. +3 −0 test/data/data_woeid.xml
  44. +94 −0 test/test_yweather.py
  45. +342 −0 yweather.py
View
7 CHANGES.txt
@@ -0,0 +1,7 @@
+Change Log
+==========
+
+v0.1 (2013-01-05)
+-----------------
+
+* Initial release.
View
1 MANIFEST.in
@@ -1,2 +1,3 @@
include *.txt *.rst
recursive-include docs *
+prune docs/_build
View
73 README.rst
@@ -5,3 +5,76 @@ About
-----
yweather is a Python module that provides an interface to the `Yahoo! Weather RSS feed <http://developer.yahoo.com/weather/>`_.
+
+International Support
+---------------------
+
+::
+
+ >>> client.fetch_woeid("Paris, France")
+ '615702'
+ >>> client.fetch_woeid("Seattle, Washington")
+ '2490383'
+
+Location and weather data is not limited to a single country. Fetch data for any location that is available on Yahoo! Weather.
+
+Different countries use different measurement systems (unfortunately). Fetch data according to United States customary units or the metric system.::
+
+ >>> paris_weather = client.fetch_weather("615702", metric=True)
+ >>> seattle_weather = client.fetch_weather("2490383", metric=False)
+
+Data is Returned as a Dict
+--------------------------
+
+::
+
+ >>> norfolk_weather = client.fetch_weather("2460389")
+ >>> norfolk_weather["astronomy"]["sunrise"]
+ '7:18 am'
+ >>> norfolk_weather["condition"]["text"]
+ 'Partly Cloudy'
+
+Weather data is returned as a Python ``dict``, not as an object of a confusing class.
+
+No API Keys or Signup Needed
+----------------------------
+
+Unlike many weather APIs, Yahoo! Weather's RSS feed doesn't require sign ups, API keys, or special authorization to fetch and use their data. All you have to do is follow their `Terms of Use <http://developer.yahoo.com/weather/#terms>`_.
+
+No Manual ID Lookups
+--------------------
+
+::
+
+ >>> client.fetch_woeid("Raleigh, North Carolina")
+ '2478307'
+ >>> client.fetch_lid("2379574")
+ 'USIL0228'
+
+yweather doesn't assume you know location identifiers off the top of your head. You can call the ``fetch_woeid`` or ``fetch_lid`` methods to lookup a location's WOEID or LID. WOEID is Yahoo! Weather's location identifier. LID is The Weather Channel's location identifier.
+
+5-day Forecast Support
+----------------------
+
+::
+
+ >>> london_weather = client.fetch_weather("UKXX0085")
+ >>> len(london_weather["forecast"])
+ 5
+
+By using a The Weather Channel Location ID (LID), you can fetch a location's 5-day weather forecast. A little warning though -- it's using an undocumented API. If you aren't up for it, you can still get the 2-day forecast using a WOEID.
+
+Documentation
+-------------
+
+yweather includes complete and easy-to-read `documentation <https://yweather.readthedocs.org/>`_. Check it out for a gentle introduction or the full API details.
+
+Bug/Issues Tracker
+------------------
+
+yweather uses its `GitHub Issues page <https://github.com/tsroten/yweather/issues>`_ to track bugs, feature requests, and support questions.
+
+License
+-------
+
+yweather is released under the OSI-approved `MIT License <http://opensource.org/licenses/MIT>`_. See the file LICENSE.txt for more information.
View
9 YAHOO_TERMS.txt
@@ -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.
View
BIN docs/_build/doctrees/api.doctree
Binary file not shown.
View
BIN docs/_build/doctrees/changes.doctree
Binary file not shown.
View
BIN docs/_build/doctrees/environment.pickle
Binary file not shown.
View
BIN docs/_build/doctrees/glossary.doctree
Binary file not shown.
View
BIN docs/_build/doctrees/index.doctree
Binary file not shown.
View
BIN docs/_build/doctrees/intro.doctree
Binary file not shown.
View
BIN docs/_build/doctrees/usage.doctree
Binary file not shown.
View
2 docs/_build/html/.buildinfo
@@ -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: 08d949800e18ba00902c9f7e92abe34c
+config: f01ae198554471cb0b2fd1c048840a2e
tags: fbb0d17656682115ca4d033fb2f83ba1
View
92 docs/_build/html/_modules/index.html
@@ -0,0 +1,92 @@
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Overview: module code &mdash; yweather 0.1 documentation</title>
+
+ <link rel="stylesheet" href="../_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '../',
+ VERSION: '0.1',
+ COLLAPSE_INDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="../_static/jquery.js"></script>
+ <script type="text/javascript" src="../_static/underscore.js"></script>
+ <script type="text/javascript" src="../_static/doctools.js"></script>
+ <link rel="top" title="yweather 0.1 documentation" href="../index.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li><a href="../index.html">yweather 0.1 documentation</a> &raquo;</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <h1>All modules for which code is available</h1>
+<ul><li><a href="yweather.html">yweather</a></li>
+</ul>
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="../search.html" method="get">
+ <input type="text" name="q" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li><a href="../index.html">yweather 0.1 documentation</a> &raquo;</li>
+ </ul>
+ </div>
+ <div class="footer">
+ &copy; Copyright 2013, Thomas Roten.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
+ </div>
+ </body>
+</html>
View
436 docs/_build/html/_modules/yweather.html
@@ -0,0 +1,436 @@
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>yweather &mdash; yweather 0.1 documentation</title>
+
+ <link rel="stylesheet" href="../_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '../',
+ VERSION: '0.1',
+ COLLAPSE_INDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="../_static/jquery.js"></script>
+ <script type="text/javascript" src="../_static/underscore.js"></script>
+ <script type="text/javascript" src="../_static/doctools.js"></script>
+ <link rel="top" title="yweather 0.1 documentation" href="../index.html" />
+ <link rel="up" title="Module code" href="index.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li><a href="../index.html">yweather 0.1 documentation</a> &raquo;</li>
+ <li><a href="index.html" accesskey="U">Module code</a> &raquo;</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <h1>Source code for yweather</h1><div class="highlight"><pre>
+<span class="c"># -*- coding: utf-8 -*-</span>
+
+<span class="c">#Copyright (c) 2012-2013 Thomas Roten</span>
+
+<span class="c"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
+<span class="c"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
+<span class="c"># in the Software without restriction, including without limitation the rights</span>
+<span class="c"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
+<span class="c"># copies of the Software, and to permit persons to whom the Software is</span>
+<span class="c"># furnshished to do so, subject to the following conditions:</span>
+
+<span class="c"># The above copyright notice and this permission notice shall be included in</span>
+<span class="c"># all copies or substantial portions of the Software.</span>
+
+<span class="c"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
+<span class="c"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
+<span class="c"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
+<span class="c"># THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
+<span class="c"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span>
+<span class="c"># FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span>
+<span class="c"># DEALINGS IN THE SOFTWARE.</span>
+
+<span class="sd">&quot;&quot;&quot;a Python module that provides an interface to the Yahoo! Weather RSS Feed.</span>
+
+<span class="sd">Classes:</span>
+<span class="sd"> Client: interface with the Yahoo! Weather RSS Feed.</span>
+
+<span class="sd">Constants:</span>
+<span class="sd"> WOEID_LOOKUP_URL: the URL used to fetch a location’s corresponding WOEID.</span>
+<span class="sd"> WEATHER_URL: the URL used to fetch a WOEID&#39;s weather.</span>
+<span class="sd"> LID_LOOKUP_URL: the URL used to fetch a location&#39;s corresponding LID.</span>
+<span class="sd"> LID_WEATHER_URL: the URL used to fetch a LID&#39;s weather.</span>
+<span class="sd"> WEATHER_NS: the XML namespace used in the weather RSS feed.</span>
+<span class="sd"> GEO_NS: the XML namespace used for the lat/long coordinates in the RSS feed.</span>
+<span class="sd"> CONDITION_IMAGE_URL: the URL of an image depicting the current conditions.</span>
+<span class="sd"> UNITS: a dict that maps data names to units.</span>
+
+<span class="sd">&quot;&quot;&quot;</span>
+
+<span class="k">try</span><span class="p">:</span>
+ <span class="kn">from</span> <span class="nn">urllib.request</span> <span class="kn">import</span> <span class="n">urlopen</span>
+ <span class="kn">from</span> <span class="nn">urllib.parse</span> <span class="kn">import</span> <span class="n">quote</span>
+<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
+ <span class="kn">from</span> <span class="nn">urllib2</span> <span class="kn">import</span> <span class="n">urlopen</span>
+ <span class="kn">from</span> <span class="nn">urllib</span> <span class="kn">import</span> <span class="n">quote</span>
+<span class="kn">import</span> <span class="nn">contextlib</span>
+<span class="kn">import</span> <span class="nn">re</span>
+<span class="kn">import</span> <span class="nn">xml.etree.ElementTree</span>
+
+
+<span class="n">WOEID_LOOKUP_URL</span> <span class="o">=</span> <span class="p">(</span><span class="s">&quot;http://locdrop.query.yahoo.com/v1/public/yql?&quot;</span>
+ <span class="s">&quot;q=select%20woeid</span><span class="si">%20f</span><span class="s">rom</span><span class="si">%20lo</span><span class="s">cdrop.placefinder%20&quot;</span>
+ <span class="s">&quot;where%20text=&#39;{0}&#39;&quot;</span><span class="p">)</span>
+<span class="n">WEATHER_URL</span> <span class="o">=</span> <span class="s">&quot;http://weather.yahooapis.com/forecastrss?w={0}&amp;u={1}&quot;</span>
+<span class="n">LID_LOOKUP_URL</span> <span class="o">=</span> <span class="n">WEATHER_URL</span>
+<span class="n">LID_WEATHER_URL</span> <span class="o">=</span> <span class="s">&quot;http://xml.weather.yahoo.com/forecastrss/{0}_{1}.xml&quot;</span>
+<span class="n">WEATHER_NS</span> <span class="o">=</span> <span class="s">&quot;http://xml.weather.yahoo.com/ns/rss/1.0&quot;</span>
+<span class="n">GEO_NS</span> <span class="o">=</span> <span class="s">&quot;http://www.w3.org/2003/01/geo/wgs84_pos#&quot;</span>
+<span class="n">CONDITION_IMAGE_URL</span> <span class="o">=</span> <span class="s">&quot;http://l.yimg.com/a/i/us/we/52/{0}.gif&quot;</span>
+<span class="n">UNITS</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="s">&quot;c&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;wind&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;chill&quot;</span><span class="p">:</span> <span class="s">&quot;°C&quot;</span><span class="p">,</span>
+ <span class="s">&quot;direction&quot;</span><span class="p">:</span> <span class="s">&quot;°&quot;</span><span class="p">,</span>
+ <span class="s">&quot;speed&quot;</span><span class="p">:</span> <span class="s">&quot;km/h&quot;</span><span class="p">},</span>
+ <span class="s">&quot;atmosphere&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;humidity&quot;</span><span class="p">:</span> <span class="s">&quot;%&quot;</span><span class="p">,</span>
+ <span class="s">&quot;visibility&quot;</span><span class="p">:</span> <span class="s">&quot;km&quot;</span><span class="p">,</span>
+ <span class="s">&quot;pressure&quot;</span><span class="p">:</span> <span class="s">&quot;hPa&quot;</span><span class="p">},</span>
+ <span class="s">&quot;condition&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;temp&quot;</span><span class="p">:</span> <span class="s">&quot;°C&quot;</span><span class="p">},</span>
+ <span class="s">&quot;forecast&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;low&quot;</span><span class="p">:</span> <span class="s">&quot;°C&quot;</span><span class="p">,</span>
+ <span class="s">&quot;high&quot;</span><span class="p">:</span> <span class="s">&quot;°C&quot;</span><span class="p">},</span>
+ <span class="p">},</span>
+ <span class="s">&quot;f&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;wind&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;chill&quot;</span><span class="p">:</span> <span class="s">&quot;°F&quot;</span><span class="p">,</span>
+ <span class="s">&quot;direction&quot;</span><span class="p">:</span> <span class="s">&quot;°&quot;</span><span class="p">,</span>
+ <span class="s">&quot;speed&quot;</span><span class="p">:</span> <span class="s">&quot;mph&quot;</span><span class="p">},</span>
+ <span class="s">&quot;atmosphere&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;humidity&quot;</span><span class="p">:</span> <span class="s">&quot;%&quot;</span><span class="p">,</span>
+ <span class="s">&quot;visibility&quot;</span><span class="p">:</span> <span class="s">&quot;mi&quot;</span><span class="p">,</span>
+ <span class="s">&quot;pressure&quot;</span><span class="p">:</span> <span class="s">&quot;psi&quot;</span><span class="p">},</span>
+ <span class="s">&quot;condition&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;temp&quot;</span><span class="p">:</span> <span class="s">&quot;°F&quot;</span><span class="p">},</span>
+ <span class="s">&quot;forecast&quot;</span><span class="p">:</span> <span class="p">{</span>
+ <span class="s">&quot;low&quot;</span><span class="p">:</span> <span class="s">&quot;ˆF&quot;</span><span class="p">,</span>
+ <span class="s">&quot;high&quot;</span><span class="p">:</span> <span class="s">&quot;°F&quot;</span><span class="p">},</span>
+ <span class="p">},</span>
+<span class="p">}</span>
+
+
+<div class="viewcode-block" id="Client"><a class="viewcode-back" href="../api.html#yweather.Client">[docs]</a><span class="k">class</span> <span class="nc">Client</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+
+ <span class="sd">&quot;&quot;&quot;Interface with the Yahoo! Weather RSS feed.</span>
+
+<span class="sd"> Provides methods to search for location data and fetch weather data.</span>
+
+<span class="sd"> Methods:</span>
+<span class="sd"> fetch_lid: fetch a location&#39;s LID.</span>
+<span class="sd"> fetch_woeid: fetch a location&#39;s WOEID.</span>
+<span class="sd"> fetch_weather: fetch a location&#39;s weather.</span>
+
+<span class="sd"> &quot;&quot;&quot;</span>
+
+<div class="viewcode-block" id="Client.fetch_lid"><a class="viewcode-back" href="../api.html#yweather.Client.fetch_lid">[docs]</a> <span class="k">def</span> <span class="nf">fetch_lid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">woeid</span><span class="p">):</span>
+ <span class="sd">&quot;&quot;&quot;Fetch a location&#39;s corresponding LID.</span>
+
+<span class="sd"> Args:</span>
+<span class="sd"> woeid: (string) the location&#39;s WOEID.</span>
+<span class="sd"> </span>
+<span class="sd"> Returns:</span>
+<span class="sd"> a string containing the requested LID or None if the LID could</span>
+<span class="sd"> not be found.</span>
+
+<span class="sd"> Raises:</span>
+<span class="sd"> urllib.error.URLError: urllib.request could not open the URL (Python 3).</span>
+<span class="sd"> urllib2.URLError: urllib2 could not open the URL (Python 2).</span>
+<span class="sd"> xml.etree.ElementTree.ParseError: xml.etree.ElementTree failed to parse</span>
+<span class="sd"> the XML document.</span>
+
+<span class="sd"> &quot;&quot;&quot;</span>
+ <span class="n">rss</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fetch_xml</span><span class="p">(</span><span class="n">LID_LOOKUP_URL</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">woeid</span><span class="p">,</span> <span class="s">&quot;f&quot;</span><span class="p">))</span>
+
+ <span class="c"># We are pulling the LID from the permalink tag in the XML file</span>
+ <span class="c"># returned by Yahoo.</span>
+
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">link</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;channel/link&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+
+ <span class="c"># use regex or string.split</span>
+ <span class="c"># regex assumes the format XXXXNNNN for the LID.</span>
+ <span class="c"># string.split works more general of the context.</span>
+
+ <span class="n">lid</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="s">&quot;[A-Za-z]{4}[0-9]{4}&quot;</span><span class="p">,</span> <span class="n">link</span><span class="p">)</span><span class="o">.</span><span class="n">group</span><span class="p">()</span>
+ <span class="c"># lid = link.split(&quot;/forecast/&quot;)[1].split(&quot;_&quot;)[0]</span>
+
+ <span class="k">return</span> <span class="n">lid</span>
+</div>
+<div class="viewcode-block" id="Client.fetch_weather"><a class="viewcode-back" href="../api.html#yweather.Client.fetch_weather">[docs]</a> <span class="k">def</span> <span class="nf">fetch_weather</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">id</span><span class="p">,</span> <span class="n">metric</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
+ <span class="sd">&quot;&quot;&quot;Fetch a location&#39;s weather.</span>
+
+<span class="sd"> *id* can be either a WOEID or LID. The weather data returned for each is</span>
+<span class="sd"> identical except that the WOEID returns a 2-day forecast and the LID</span>
+<span class="sd"> returns a 5-day forecast. The LID uses an undocumented API, so use it</span>
+<span class="sd"> at your own risk.</span>
+
+<span class="sd"> Args:</span>
+<span class="sd"> id: (string) the location&#39;s WOEID or LID.</span>
+<span class="sd"> metric: (bool) return metric data; defaults to False.</span>
+
+<span class="sd"> Returns:</span>
+<span class="sd"> a dict containing the location&#39;s weather data or None if</span>
+<span class="sd"> the weather data couldn&#39;t be fetched.</span>
+
+<span class="sd"> Raises:</span>
+<span class="sd"> urllib.error.URLError: urllib.request could not open the URL (Python 3).</span>
+<span class="sd"> urllib2.URLError: urllib2 could not open the URL (Python 2).</span>
+<span class="sd"> xml.etree.ElementTree.ParseError: xml.etree.ElementTree failed to parse</span>
+<span class="sd"> the XML document.</span>
+
+<span class="sd"> &quot;&quot;&quot;</span>
+
+ <span class="n">units</span> <span class="o">=</span> <span class="s">&quot;c&quot;</span> <span class="k">if</span> <span class="n">metric</span> <span class="k">else</span> <span class="s">&quot;f&quot;</span>
+
+ <span class="c"># WOEID is a 32-bit integer, while LID is XXXXNNNN, where X is a letter</span>
+ <span class="c"># and N is a number. So, we pick the URL to use based on whether or not</span>
+ <span class="c"># the *id* begins with a letter.</span>
+
+ <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&quot;^[A-Za-z]&quot;</span><span class="p">,</span> <span class="nb">id</span><span class="p">):</span>
+ <span class="n">url</span> <span class="o">=</span> <span class="n">LID_WEATHER_URL</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span> <span class="n">units</span><span class="p">)</span>
+ <span class="k">else</span><span class="p">:</span>
+ <span class="n">url</span> <span class="o">=</span> <span class="n">WEATHER_URL</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span> <span class="n">units</span><span class="p">)</span>
+
+ <span class="n">rss</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fetch_xml</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
+
+ <span class="k">if</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;channel/item/title&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">text</span> <span class="o">==</span> <span class="s">&quot;City not found&quot;</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+
+ <span class="c"># xml_items details which tags should be read and what their</span>
+ <span class="c"># destination dict key should be. These tags don&#39;t appear</span>
+ <span class="c"># multiple times.</span>
+ <span class="c"># {XML tag: [ElementTree access method, dict key]}</span>
+
+ <span class="n">xml_items</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="s">&quot;channel/title&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;title&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/link&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;link&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/language&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;language&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/description&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;description&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/lastBuildDate&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;lastBuildDate&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/ttl&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;ttl&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/image/url&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;logo&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/item/guid&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s">&quot;text&quot;</span><span class="p">,</span> <span class="s">&quot;guid&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/{</span><span class="si">%s</span><span class="s">}location&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">:</span>
+ <span class="p">[</span><span class="s">&quot;attrib&quot;</span><span class="p">,</span> <span class="s">&quot;location&quot;</span><span class="p">],</span>
+ <span class="c"># &quot;channel/{%s}units&quot; % WEATHER_NS:</span>
+ <span class="c"># [&quot;attrib&quot;, &quot;units&quot;],</span>
+ <span class="s">&quot;channel/{</span><span class="si">%s</span><span class="s">}wind&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">:</span>
+ <span class="p">[</span><span class="s">&quot;attrib&quot;</span><span class="p">,</span> <span class="s">&quot;wind&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/{</span><span class="si">%s</span><span class="s">}atmosphere&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">:</span>
+ <span class="p">[</span><span class="s">&quot;attrib&quot;</span><span class="p">,</span> <span class="s">&quot;atmosphere&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/{</span><span class="si">%s</span><span class="s">}astronomy&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">:</span>
+ <span class="p">[</span><span class="s">&quot;attrib&quot;</span><span class="p">,</span> <span class="s">&quot;astronomy&quot;</span><span class="p">],</span>
+ <span class="s">&quot;channel/item/{</span><span class="si">%s</span><span class="s">}condition&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">:</span>
+ <span class="p">[</span><span class="s">&quot;attrib&quot;</span><span class="p">,</span> <span class="s">&quot;condition&quot;</span><span class="p">],</span>
+ <span class="p">}</span>
+ <span class="n">weather</span> <span class="o">=</span> <span class="p">{}</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;units&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">UNITS</span><span class="p">[</span><span class="n">units</span><span class="p">]</span>
+
+ <span class="k">for</span> <span class="p">(</span><span class="n">tag</span><span class="p">,</span> <span class="n">meta</span><span class="p">)</span> <span class="ow">in</span> <span class="n">xml_items</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
+ <span class="k">if</span> <span class="n">meta</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s">&quot;text&quot;</span><span class="p">:</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="n">meta</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">tag</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="n">meta</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="bp">None</span>
+ <span class="k">elif</span> <span class="n">meta</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s">&quot;attrib&quot;</span><span class="p">:</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="n">meta</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">tag</span><span class="p">)</span><span class="o">.</span><span class="n">attrib</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="n">meta</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="bp">None</span>
+ <span class="k">else</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="n">meta</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="bp">None</span>
+
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">image_url</span> <span class="o">=</span> <span class="n">CONDITION_IMAGE_URL</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">weather</span><span class="p">[</span><span class="s">&quot;condition&quot;</span><span class="p">][</span><span class="s">&quot;code&quot;</span><span class="p">])</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;condition&quot;</span><span class="p">][</span><span class="s">&quot;image&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">image_url</span>
+ <span class="k">except</span> <span class="p">(</span><span class="ne">AttributeError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">):</span>
+ <span class="k">pass</span>
+
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">state</span> <span class="o">=</span> <span class="n">weather</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;rising&quot;</span><span class="p">]</span>
+ <span class="k">if</span> <span class="n">state</span> <span class="o">==</span> <span class="s">&quot;0&quot;</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;state&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&quot;steady&quot;</span>
+ <span class="k">elif</span> <span class="n">state</span> <span class="o">==</span> <span class="s">&quot;1&quot;</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;state&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&quot;rising&quot;</span>
+ <span class="k">elif</span> <span class="n">state</span> <span class="o">==</span> <span class="s">&quot;2&quot;</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;state&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&quot;falling&quot;</span>
+ <span class="k">else</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;state&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span>
+ <span class="k">except</span> <span class="p">(</span><span class="ne">AttributeError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">):</span>
+ <span class="k">pass</span>
+
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;forecast&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">rss</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span>
+ <span class="s">&quot;channel/item/{</span><span class="si">%s</span><span class="s">}forecast&quot;</span> <span class="o">%</span> <span class="n">WEATHER_NS</span><span class="p">):</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;forecast&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">attrib</span><span class="p">)</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;forecast&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span>
+
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;geo&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;geo&quot;</span><span class="p">][</span><span class="s">&quot;lat&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span>
+ <span class="s">&quot;channel/item/{</span><span class="si">%s</span><span class="s">}lat&quot;</span> <span class="o">%</span> <span class="n">GEO_NS</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;geo&quot;</span><span class="p">][</span><span class="s">&quot;long&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span>
+ <span class="s">&quot;channel/item/{</span><span class="si">%s</span><span class="s">}long&quot;</span> <span class="o">%</span> <span class="n">GEO_NS</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;geo&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span>
+
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;wind&quot;</span><span class="p">][</span><span class="s">&quot;compass&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_degrees_to_direction</span><span class="p">(</span>
+ <span class="n">weather</span><span class="p">[</span><span class="s">&quot;wind&quot;</span><span class="p">][</span><span class="s">&quot;direction&quot;</span><span class="p">])</span>
+ <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
+ <span class="k">pass</span>
+
+ <span class="k">return</span> <span class="n">weather</span>
+</div>
+<div class="viewcode-block" id="Client.fetch_woeid"><a class="viewcode-back" href="../api.html#yweather.Client.fetch_woeid">[docs]</a> <span class="k">def</span> <span class="nf">fetch_woeid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">location</span><span class="p">):</span>
+ <span class="sd">&quot;&quot;&quot;Fetch a location&#39;s corresponding WOEID.</span>
+
+<span class="sd"> Args:</span>
+<span class="sd"> location: (string) a location (e.g. 23454 or Berlin, Germany).</span>
+
+<span class="sd"> Returns:</span>
+<span class="sd"> a string containing the location&#39;s corresponding WOEID or None if</span>
+<span class="sd"> the WOEID could not be found.</span>
+
+<span class="sd"> Raises:</span>
+<span class="sd"> urllib.error.URLError: urllib.request could not open the URL (Python 3).</span>
+<span class="sd"> urllib2.URLError: urllib2 could not open the URL (Python 2).</span>
+<span class="sd"> xml.etree.ElementTree.ParseError: xml.etree.ElementTree failed to parse</span>
+<span class="sd"> the XML document.</span>
+
+<span class="sd"> &quot;&quot;&quot;</span>
+ <span class="n">rss</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fetch_xml</span><span class="p">(</span>
+ <span class="n">WOEID_LOOKUP_URL</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">quote</span><span class="p">(</span><span class="n">location</span><span class="p">)))</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">woeid</span> <span class="o">=</span> <span class="n">rss</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;results/Result/woeid&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
+ <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+ <span class="k">return</span> <span class="n">woeid</span>
+</div>
+ <span class="k">def</span> <span class="nf">_degrees_to_direction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">degrees</span><span class="p">):</span>
+ <span class="sd">&quot;&quot;&quot;Convert wind direction from degrees to compass direction.&quot;&quot;&quot;</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">degrees</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">degrees</span><span class="p">)</span>
+ <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+ <span class="k">if</span> <span class="n">degrees</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">degrees</span> <span class="o">&gt;</span> <span class="mi">360</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+ <span class="k">if</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">11.25</span> <span class="ow">or</span> <span class="n">degrees</span> <span class="o">&gt;=</span> <span class="mf">348.76</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;N&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">33.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;NNE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">56.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;NE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">78.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;ENE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">101.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;E&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">123.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;ESE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">146.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;SE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">168.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;SSE&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">191.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;S&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">213.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;SSW&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">236.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;SW&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">258.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;WSW&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">281.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;W&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">303.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;WNW&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">326.25</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;NW&quot;</span>
+ <span class="k">elif</span> <span class="n">degrees</span> <span class="o">&lt;=</span> <span class="mf">348.75</span><span class="p">:</span>
+ <span class="k">return</span> <span class="s">&quot;NNW&quot;</span>
+ <span class="k">else</span><span class="p">:</span>
+ <span class="k">return</span> <span class="bp">None</span>
+
+ <span class="k">def</span> <span class="nf">_fetch_xml</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">url</span><span class="p">):</span>
+ <span class="sd">&quot;&quot;&quot;Fetch a url and parse the document&#39;s XML.&quot;&quot;&quot;</span>
+ <span class="k">with</span> <span class="n">contextlib</span><span class="o">.</span><span class="n">closing</span><span class="p">(</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">))</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
+ <span class="k">return</span> <span class="n">xml</span><span class="o">.</span><span class="n">etree</span><span class="o">.</span><span class="n">ElementTree</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">f</span><span class="p">)</span><span class="o">.</span><span class="n">getroot</span><span class="p">()</span></div>
+</pre></div>
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="../search.html" method="get">
+ <input type="text" name="q" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li><a href="../index.html">yweather 0.1 documentation</a> &raquo;</li>
+ <li><a href="index.html" >Module code</a> &raquo;</li>
+ </ul>
+ </div>
+ <div class="footer">
+ &copy; Copyright 2013, Thomas Roten.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
+ </div>
+ </body>
+</html>
View
151 docs/_build/html/_sources/api.txt
@@ -0,0 +1,151 @@
+API
+===
+
+.. py:module:: yweather
+
+.. data:: WOEID_LOOKUP_URL
+
+ The URL used to fetch a location's corresponding :term:`WOEID`.
+
+.. data:: WEATHER_URL
+
+ The URL used to fetch a :term:`WOEID`'s weather.
+
+.. data:: LID_LOOKUP_URL
+
+ The URL used to fetch a location's corresponding :term:`LID`.
+
+.. data:: LID_WEATHER_URL
+
+ The URL used to fetch a :term:`LID`'s weather.
+
+.. data:: WEATHER_NS
+
+ The XML namespace used in the weather RSS feed.
+
+.. data:: GEO_NS
+
+ The XML namespace used for the lat/long coordinates in the RSS feed.
+
+.. data:: CONDITION_IMAGE_URL
+
+ The URL of an image depicting the current conditions.
+
+.. data:: UNITS
+
+ A :class:`dict <python3:dict>` that maps data names to units.
+
+.. class:: Client()
+
+ Interface with the Yahoo! Weather RSS feed. Provides methods to search for location data and fetch weather data.
+
+ .. method:: fetch_lid(woeid)
+
+ Fetch a location's corresponding :term:`LID`.
+
+ :param woeid: the location's :term:`WOEID`.
+ :type woeid: :mod:`string <python3:string>`
+ :returns: a :mod:`string <python3:string>` containing the requested :term:`LID` or :data:`None <python3:None>` if the :term:`LID` could not be found.
+ :raises urllib.error.URLError: :mod:`urllib.request <python3:urllib.request>` could not open the URL (Python 3).
+ :raises urllib2.URLError: :mod:`urllib2 <python2:urllib2>` could not open the URL (Python 2).
+ :raises xml.etree.ElementTree.ParseError: :mod:`xml.etree.ElementTree <python3:xml.etree.ElementTree>` failed to parse the XML document.
+
+ .. method:: fetch_weather(id[, metric=False])
+
+ Fetch a location's weather.
+
+ *id* can be either a :term:`WOEID` or :term:`LID`. The weather data returned for each is identical except that the :term:`WOEID` returns a 2-day forecast and the :term:`LID` returns a 5-day forecast. The :term:`LID` uses an undocumented API, so use it at your own risk.
+
+ The returned data is a :class:`dict <python3:dict>` with the requested weather data. It loosely follows the `Yahoo! Weather RSS feed response structure <http://developer.yahoo.com/weather/#response>`_, but has some noticeable differences. The following table outlines the data structure.
+
+ ============== ========== ============ =====
+ Keys .. .. Value
+ ============== ========== ============ =====
+ title The title of the feed, which includes the location city. For example "Yahoo! Weather - Sunnyvale, CA".
+ link The URL of the forecast for this location.
+ language The language of the weather forecast, for example, en-us for US English.
+ description The overall description of the feed including the location, for example "Yahoo! Weather for Sunnyvale, CA".
+ lastBuildDate The last time the feed was updated. For example, Fri, 04 Jan 2013 6:56 am PST.
+ ttl Time to Live; how long in minutes this feed should be cached.
+ logo The URL for the Yahoo! Weather logo associated with this feed.
+ guid Unique identifier for the forecast, made up of the location ID, the date, and the time.
+ location city city name
+ location region state, territory, or region, if given.
+ location country two-character country code
+ geo lat The latitude of the location.
+ geo long The longitude of the location.
+ units wind chill °F or °C
+ units wind direction °
+ units wind speed mph or km/h
+ units atmosphere humidity %
+ units atmosphere visbility mi or km
+ units atmosphere pressure psi or hPa
+ units condition temp °F or °C
+ units forecast low °F or °C
+ units forecast high °F or °C
+ wind chill wind chill in degrees
+ wind direction wind direction, in degrees
+ wind compass wind direction, according to a compass. For example, NNW, SE, or W.
+ wind speed wind speed in mph or km/h
+ atmosphere humidity humidity, in percent
+ atmosphere visibility visibility, in mi or km.
+ atmosphere pressure barometric pressure in psi or hPa.
+ atmosphere rising state of the barometric pressure as a number: 0 (steady), 1 (rising), or 2 (falling).
+ atmosphere state state of the barometric pressure as text: steady, rising, or falling.
+ astronomy sunrise today's sunrise time. The time is in a local time format of "h:mm am/pm", for example "7:02 am"
+ astronomy sunset today's sunset time. The time is in a local time format of "h:mm am/pm", for example "4:51 pm".
+ condition text a textual description of conditions, for example, "Partly Cloudy"
+ condition code the condition code for this forecast. Yahoo! Weather's developer network lists the `possible values <http://developer.yahoo.com/weather/#codes>`_.
+ condition image the URL of an image that depicts the current conditions (clouds, sun, rain, etc.).
+ condition temp the current temperature in °F or °C
+ condition date the current date and time for which this forecast applies. For example, Fri, 04 Jan 2013 6:56 am PST.
+ forecast contains a :class:`list <python3:list>`, where each item is a :class:`dict <python3:dict>` that contains the weather forecast for a specific day.
+ -- day day of the week to which this forecast applies. Possible values are Mon Tue Wed Thu Fri Sat Sun
+ -- date the date to which this forecast applies. The date is in "dd Mmm yyyy" format, for example "3 Nov 2005"
+ -- low the forecasted low temperature for this day in °F or °C
+ -- high the forecasted high temperature for this day in °F or °C
+ -- text a textual description of conditions, for example, "Partly Cloudy"
+ -- code the condition code for this forecast. Yahoo! Weather's developer network lists the `possible values <http://developer.yahoo.com/weather/#codes>`_.
+ ============== ========== ============ =====
+
+ The differences between this data structure and Yahoo! Weather's are:
+ * *units* breaks down the data units further and uses more helpful key names.
+ * *logo* represents the RSS feed's ``<image>`` tag.
+ * *guid* was moved to the top level.
+ * *condition* has the *image* key, which provides easy access to a URL of an image depicting the current sky conditions.
+ * *atmosphere* has the *state* key, which gives a textual description of the barometric pressure state.
+ * *geo* is now a :class:`dict <python3:dict>` with *lat* and *long* keys.
+ * *wind* includes the *compass* key, which provides wind direction according to a compass (e.g. NNW, SE, or W).
+
+ Example usage of the returned :class:`dict <python3:dict>`:
+
+ .. code-block:: python
+
+ >>> print result["wind"]["compass"]
+ NNW
+ >>> print result["atmosphere"]["pressure"], result["units"]["atmosphere"]["pressure"]
+ 29.95 psi
+ >>> print len(result["forecast"])
+ 2
+ >>> print result["forecast"][0]["text"]
+ Partly Cloudy
+
+ :param id: the location's :term:`WOEID` or :term:`LID`.
+ :type id: :mod:`string <python3:string>`
+ :param metric: return metric data; defaults to :data:`False <python3:False>`.
+ :type metric: :func:`bool <python3:bool>`
+ :returns: a :class:`dict <python3:dict>` containing the location's weather data or :data:`None <python3:None>` if the weather data couldn't be fetched.
+ :raises urllib.error.URLError: :mod:`urllib.request <python3:urllib.request>` could not open the URL (Python 3).
+ :raises urllib2.URLError: :mod:`urllib2 <python2:urllib2>` could not open the URL (Python 2).
+ :raises xml.etree.ElementTree.ParseError: :mod:`xml.etree.ElementTree <python3:xml.etree.ElementTree>` failed to parse the XML document.
+
+ .. method:: fetch_woeid(location)
+
+ Fetch a location's corresponding :term:`WOEID`.
+
+ :param location: a location (e.g. 23454 or Berlin, Germany).
+ :type location: :mod:`string <python3:string>`
+ :returns: a :mod:`string <python3:string>` containing the requested :term:`WOEID` or :data:`None <python3:None>` if the :term:`WOEID` could not be found.
+ :raises urllib.error.URLError: :mod:`urllib.request <python3:urllib.request>` could not open the URL (Python 3).
+ :raises urllib2.URLError: :mod:`urllib2 <python2:urllib2>` could not open the URL (Python 2).
+ :raises xml.etree.ElementTree.ParseError: :mod:`xml.etree.ElementTree <python3:xml.etree.ElementTree>` failed to parse the XML document.
View
1 docs/_build/html/_sources/changes.txt
@@ -0,0 +1 @@
+.. include:: ../CHANGES.txt
View
16 docs/_build/html/_sources/glossary.txt
@@ -0,0 +1,16 @@
+Glossary
+========
+
+.. glossary::
+
+ LID
+ Location ID. The Weather Channel uses these to identify locations around the world. Because Yahoo! Weather gets their weather data from The Weather Channel, the Location ID can be used on Yahoo's RSS Feed to gain access to a 5-day weather forecast. Note: this usage is undocumented.
+
+ metric system
+ The metric system is a system of measurement that is used around the world (in all but three countries). It is often considered to be synonymous with the `International System of Units <http://en.wikipedia.org/wiki/International_System_of_Units>`_. Some example units include grams and meters. See `Wikipedia's article <http://en.wikipedia.org/wiki/Metric_system>`_ for more information.
+
+ United States customary units
+ A system of measurements commonly used across the United States. Some example units include miles, pounds, and inches. See `Wikipedia's article <http://en.wikipedia.org/wiki/United_States_customary_units>`_ for more information.
+
+ WOEID
+ Where On Earth IDentifier. Yahoo! GeoPlanet uses these 32-bit identifiers to reference spatial entities around the world. See `Yahoo! GeoPlanet's Key Concepts <http://developer.yahoo.com/geo/geoplanet/guide/concepts.html#woeids>`_ for more information.
View
9 docs/_build/html/_sources/index.txt
@@ -3,11 +3,18 @@ Welcome to yweather's documentation!
:mod:`yweather` is a Python module that provides an interface to the `Yahoo! Weather RSS feed <http://developer.yahoo.com/weather/>`_.
-Contents:
+:mod:`yweather` Documentation
+-----------------------------
.. toctree::
:maxdepth: 2
+ intro
+ usage
+ api
+ changes
+ glossary
+
Indices and tables
View
67 docs/_build/html/_sources/intro.txt
@@ -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>`.
+
View
74 docs/_build/html/_sources/usage.txt
@@ -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.
View
2 docs/_build/html/_static/searchtools.js
@@ -301,7 +301,7 @@ var Search = {
},
query : function(query) {
- var stopwords = ["in","to","not","or","if","into","are","for","on","is","of","as","at","was","the","near","but","it","will","their","this","and","with","there","that","such","these","then","by","they","a","be","no"];
+ var stopwords = ["with","into","such","was","at","as","these","their","and","are","to","not","by","the","then","no","it","be","they","there","will","but","if","near","a","of","for","that","on","or","is","this","in"];
// Stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
View
518 docs/_build/html/api.html
@@ -0,0 +1,518 @@
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>API &mdash; yweather 0.1 documentation</title>
+
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.1',
+ COLLAPSE_INDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/underscore.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="yweather 0.1 documentation" href="index.html" />
+ <link rel="next" title="Change Log" href="changes.html" />
+ <link rel="prev" title="Usage" href="usage.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li class="right" >
+ <a href="changes.html" title="Change Log"
+ accesskey="N">next</a> |</li>
+ <li class="right" >
+ <a href="usage.html" title="Usage"
+ accesskey="P">previous</a> |</li>
+ <li><a href="index.html">yweather 0.1 documentation</a> &raquo;</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="module-yweather">
+<span id="api"></span><h1>API<a class="headerlink" href="#module-yweather" title="Permalink to this headline">¶</a></h1>
+<dl class="data">
+<dt id="yweather.WOEID_LOOKUP_URL">
+<tt class="descclassname">yweather.</tt><tt class="descname">WOEID_LOOKUP_URL</tt><a class="headerlink" href="#yweather.WOEID_LOOKUP_URL" title="Permalink to this definition">¶</a></dt>
+<dd><p>The URL used to fetch a location&#8217;s corresponding <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a>.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.WEATHER_URL">
+<tt class="descclassname">yweather.</tt><tt class="descname">WEATHER_URL</tt><a class="headerlink" href="#yweather.WEATHER_URL" title="Permalink to this definition">¶</a></dt>
+<dd><p>The URL used to fetch a <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a>&#8216;s weather.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.LID_LOOKUP_URL">
+<tt class="descclassname">yweather.</tt><tt class="descname">LID_LOOKUP_URL</tt><a class="headerlink" href="#yweather.LID_LOOKUP_URL" title="Permalink to this definition">¶</a></dt>
+<dd><p>The URL used to fetch a location&#8217;s corresponding <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a>.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.LID_WEATHER_URL">
+<tt class="descclassname">yweather.</tt><tt class="descname">LID_WEATHER_URL</tt><a class="headerlink" href="#yweather.LID_WEATHER_URL" title="Permalink to this definition">¶</a></dt>
+<dd><p>The URL used to fetch a <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a>&#8216;s weather.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.WEATHER_NS">
+<tt class="descclassname">yweather.</tt><tt class="descname">WEATHER_NS</tt><a class="headerlink" href="#yweather.WEATHER_NS" title="Permalink to this definition">¶</a></dt>
+<dd><p>The XML namespace used in the weather RSS feed.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.GEO_NS">
+<tt class="descclassname">yweather.</tt><tt class="descname">GEO_NS</tt><a class="headerlink" href="#yweather.GEO_NS" title="Permalink to this definition">¶</a></dt>
+<dd><p>The XML namespace used for the lat/long coordinates in the RSS feed.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.CONDITION_IMAGE_URL">
+<tt class="descclassname">yweather.</tt><tt class="descname">CONDITION_IMAGE_URL</tt><a class="headerlink" href="#yweather.CONDITION_IMAGE_URL" title="Permalink to this definition">¶</a></dt>
+<dd><p>The URL of an image depicting the current conditions.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="yweather.UNITS">
+<tt class="descclassname">yweather.</tt><tt class="descname">UNITS</tt><a class="headerlink" href="#yweather.UNITS" title="Permalink to this definition">¶</a></dt>
+<dd><p>A <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> that maps data names to units.</p>
+</dd></dl>
+
+<dl class="class">
+<dt id="yweather.Client">
+<em class="property">class </em><tt class="descclassname">yweather.</tt><tt class="descname">Client</tt><a class="reference internal" href="_modules/yweather.html#Client"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#yweather.Client" title="Permalink to this definition">¶</a></dt>
+<dd><p>Interface with the Yahoo! Weather RSS feed. Provides methods to search for location data and fetch weather data.</p>
+<dl class="method">
+<dt id="yweather.Client.fetch_lid">
+<tt class="descname">fetch_lid</tt><big>(</big><em>woeid</em><big>)</big><a class="reference internal" href="_modules/yweather.html#Client.fetch_lid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#yweather.Client.fetch_lid" title="Permalink to this definition">¶</a></dt>
+<dd><p>Fetch a location&#8217;s corresponding <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a>.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>woeid</strong> (<a class="reference external" href="http://docs.python.org/3.3/library/string.html#string" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a>) &#8211; the location&#8217;s <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a>.</p>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">a <a class="reference external" href="http://docs.python.org/3.3/library/string.html#string" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a> containing the requested <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a> or <a class="reference external" href="http://docs.python.org/3.3/library/constants.html#None" title="(in Python v3.3)"><tt class="xref py py-data docutils literal"><span class="pre">None</span></tt></a> if the <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a> could not be found.</p>
+</td>
+</tr>
+<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
+<li><a class="reference external" href="http://docs.python.org/3.3/library/urllib.error.html#urllib.error.URLError" title="(in Python v3.3)"><strong>urllib.error.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/urllib.request.html#urllib.request" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib.request</span></tt></a> could not open the URL (Python 3).</li>
+<li><a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2.URLError" title="(in Python v2.7)"><strong>urllib2.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2" title="(in Python v2.7)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib2</span></tt></a> could not open the URL (Python 2).</li>
+<li><strong>xml.etree.ElementTree.ParseError</strong> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/xml.etree.elementtree.html#xml.etree.ElementTree" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">xml.etree.ElementTree</span></tt></a> failed to parse the XML document.</li>
+</ul>
+</td>
+</tr>
+</tbody>
+</table>
+</dd></dl>
+
+<dl class="method">
+<dt id="yweather.Client.fetch_weather">
+<tt class="descname">fetch_weather</tt><big>(</big><em>id</em><span class="optional">[</span>, <em>metric=False</em><span class="optional">]</span><big>)</big><a class="reference internal" href="_modules/yweather.html#Client.fetch_weather"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#yweather.Client.fetch_weather" title="Permalink to this definition">¶</a></dt>
+<dd><p>Fetch a location&#8217;s weather.</p>
+<p><em>id</em> can be either a <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a> or <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a>. The weather data returned for each is identical except that the <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a> returns a 2-day forecast and the <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a> returns a 5-day forecast. The <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a> uses an undocumented API, so use it at your own risk.</p>
+<p>The returned data is a <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> with the requested weather data. It loosely follows the <a class="reference external" href="http://developer.yahoo.com/weather/#response">Yahoo! Weather RSS feed response structure</a>, but has some noticeable differences. The following table outlines the data structure.</p>
+<table border="1" class="docutils">
+<colgroup>
+<col width="8%" />
+<col width="5%" />
+<col width="7%" />
+<col width="80%" />
+</colgroup>
+<thead valign="bottom">
+<tr class="row-odd"><th class="head">Keys</th>
+<th class="head"></th>
+<th class="head"></th>
+<th class="head">Value</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr class="row-even"><td>title</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The title of the feed, which includes the location city. For example &#8220;Yahoo! Weather - Sunnyvale, CA&#8221;.</td>
+</tr>
+<tr class="row-odd"><td>link</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The URL of the forecast for this location.</td>
+</tr>
+<tr class="row-even"><td>language</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The language of the weather forecast, for example, en-us for US English.</td>
+</tr>
+<tr class="row-odd"><td>description</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The overall description of the feed including the location, for example &#8220;Yahoo! Weather for Sunnyvale, CA&#8221;.</td>
+</tr>
+<tr class="row-even"><td>lastBuildDate</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The last time the feed was updated. For example, Fri, 04 Jan 2013 6:56 am PST.</td>
+</tr>
+<tr class="row-odd"><td>ttl</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>Time to Live; how long in minutes this feed should be cached.</td>
+</tr>
+<tr class="row-even"><td>logo</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>The URL for the Yahoo! Weather logo associated with this feed.</td>
+</tr>
+<tr class="row-odd"><td>guid</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>Unique identifier for the forecast, made up of the location ID, the date, and the time.</td>
+</tr>
+<tr class="row-even"><td>location</td>
+<td>city</td>
+<td>&nbsp;</td>
+<td>city name</td>
+</tr>
+<tr class="row-odd"><td>location</td>
+<td>region</td>
+<td>&nbsp;</td>
+<td>state, territory, or region, if given.</td>
+</tr>
+<tr class="row-even"><td>location</td>
+<td>country</td>
+<td>&nbsp;</td>
+<td>two-character country code</td>
+</tr>
+<tr class="row-odd"><td>geo</td>
+<td>lat</td>
+<td>&nbsp;</td>
+<td>The latitude of the location.</td>
+</tr>
+<tr class="row-even"><td>geo</td>
+<td>long</td>
+<td>&nbsp;</td>
+<td>The longitude of the location.</td>
+</tr>
+<tr class="row-odd"><td>units</td>
+<td>wind</td>
+<td>chill</td>
+<td>°F or °C</td>
+</tr>
+<tr class="row-even"><td>units</td>
+<td>wind</td>
+<td>direction</td>
+<td>°</td>
+</tr>
+<tr class="row-odd"><td>units</td>
+<td>wind</td>
+<td>speed</td>
+<td>mph or km/h</td>
+</tr>
+<tr class="row-even"><td>units</td>
+<td>atmosphere</td>
+<td>humidity</td>
+<td>%</td>
+</tr>
+<tr class="row-odd"><td>units</td>
+<td>atmosphere</td>
+<td>visbility</td>
+<td>mi or km</td>
+</tr>
+<tr class="row-even"><td>units</td>
+<td>atmosphere</td>
+<td>pressure</td>
+<td>psi or hPa</td>
+</tr>
+<tr class="row-odd"><td>units</td>
+<td>condition</td>
+<td>temp</td>
+<td>°F or °C</td>
+</tr>
+<tr class="row-even"><td>units</td>
+<td>forecast</td>
+<td>low</td>
+<td>°F or °C</td>
+</tr>
+<tr class="row-odd"><td>units</td>
+<td>forecast</td>
+<td>high</td>
+<td>°F or °C</td>
+</tr>
+<tr class="row-even"><td>wind</td>
+<td>chill</td>
+<td>&nbsp;</td>
+<td>wind chill in degrees</td>
+</tr>
+<tr class="row-odd"><td>wind</td>
+<td>direction</td>
+<td>&nbsp;</td>
+<td>wind direction, in degrees</td>
+</tr>
+<tr class="row-even"><td>wind</td>
+<td>compass</td>
+<td>&nbsp;</td>
+<td>wind direction, according to a compass. For example, NNW, SE, or W.</td>
+</tr>
+<tr class="row-odd"><td>wind</td>
+<td>speed</td>
+<td>&nbsp;</td>
+<td>wind speed in mph or km/h</td>
+</tr>
+<tr class="row-even"><td>atmosphere</td>
+<td>humidity</td>
+<td>&nbsp;</td>
+<td>humidity, in percent</td>
+</tr>
+<tr class="row-odd"><td>atmosphere</td>
+<td>visibility</td>
+<td>&nbsp;</td>
+<td>visibility, in mi or km.</td>
+</tr>
+<tr class="row-even"><td>atmosphere</td>
+<td>pressure</td>
+<td>&nbsp;</td>
+<td>barometric pressure in psi or hPa.</td>
+</tr>
+<tr class="row-odd"><td>atmosphere</td>
+<td>rising</td>
+<td>&nbsp;</td>
+<td>state of the barometric pressure as a number: 0 (steady), 1 (rising), or 2 (falling).</td>
+</tr>
+<tr class="row-even"><td>atmosphere</td>
+<td>state</td>
+<td>&nbsp;</td>
+<td>state of the barometric pressure as text: steady, rising, or falling.</td>
+</tr>
+<tr class="row-odd"><td>astronomy</td>
+<td>sunrise</td>
+<td>&nbsp;</td>
+<td>today&#8217;s sunrise time. The time is in a local time format of &#8220;h:mm am/pm&#8221;, for example &#8220;7:02 am&#8221;</td>
+</tr>
+<tr class="row-even"><td>astronomy</td>
+<td>sunset</td>
+<td>&nbsp;</td>
+<td>today&#8217;s sunset time. The time is in a local time format of &#8220;h:mm am/pm&#8221;, for example &#8220;4:51 pm&#8221;.</td>
+</tr>
+<tr class="row-odd"><td>condition</td>
+<td>text</td>
+<td>&nbsp;</td>
+<td>a textual description of conditions, for example, &#8220;Partly Cloudy&#8221;</td>
+</tr>
+<tr class="row-even"><td>condition</td>
+<td>code</td>
+<td>&nbsp;</td>
+<td>the condition code for this forecast. Yahoo! Weather&#8217;s developer network lists the <a class="reference external" href="http://developer.yahoo.com/weather/#codes">possible values</a>.</td>
+</tr>
+<tr class="row-odd"><td>condition</td>
+<td>image</td>
+<td>&nbsp;</td>
+<td>the URL of an image that depicts the current conditions (clouds, sun, rain, etc.).</td>
+</tr>
+<tr class="row-even"><td>condition</td>
+<td>temp</td>
+<td>&nbsp;</td>
+<td>the current temperature in °F or °C</td>
+</tr>
+<tr class="row-odd"><td>condition</td>
+<td>date</td>
+<td>&nbsp;</td>
+<td>the current date and time for which this forecast applies. For example, Fri, 04 Jan 2013 6:56 am PST.</td>
+</tr>
+<tr class="row-even"><td>forecast</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>contains a <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#list" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">list</span></tt></a>, where each item is a <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> that contains the weather forecast for a specific day.</td>
+</tr>
+<tr class="row-odd"><td>&#8211;</td>
+<td>day</td>
+<td>&nbsp;</td>
+<td>day of the week to which this forecast applies. Possible values are Mon Tue Wed Thu Fri Sat Sun</td>
+</tr>
+<tr class="row-even"><td>&#8211;</td>
+<td>date</td>
+<td>&nbsp;</td>
+<td>the date to which this forecast applies. The date is in &#8220;dd Mmm yyyy&#8221; format, for example &#8220;3 Nov 2005&#8221;</td>
+</tr>
+<tr class="row-odd"><td>&#8211;</td>
+<td>low</td>
+<td>&nbsp;</td>
+<td>the forecasted low temperature for this day in °F or °C</td>
+</tr>
+<tr class="row-even"><td>&#8211;</td>
+<td>high</td>
+<td>&nbsp;</td>
+<td>the forecasted high temperature for this day in °F or °C</td>
+</tr>
+<tr class="row-odd"><td>&#8211;</td>
+<td>text</td>
+<td>&nbsp;</td>
+<td>a textual description of conditions, for example, &#8220;Partly Cloudy&#8221;</td>
+</tr>
+<tr class="row-even"><td>&#8211;</td>
+<td>code</td>
+<td>&nbsp;</td>
+<td>the condition code for this forecast. Yahoo! Weather&#8217;s developer network lists the <a class="reference external" href="http://developer.yahoo.com/weather/#codes">possible values</a>.</td>
+</tr>
+</tbody>
+</table>
+<dl class="docutils">
+<dt>The differences between this data structure and Yahoo! Weather&#8217;s are:</dt>
+<dd><ul class="first last simple">
+<li><em>units</em> breaks down the data units further and uses more helpful key names.</li>
+<li><em>logo</em> represents the RSS feed&#8217;s <tt class="docutils literal"><span class="pre">&lt;image&gt;</span></tt> tag.</li>
+<li><em>guid</em> was moved to the top level.</li>
+<li><em>condition</em> has the <em>image</em> key, which provides easy access to a URL of an image depicting the current sky conditions.</li>
+<li><em>atmosphere</em> has the <em>state</em> key, which gives a textual description of the barometric pressure state.</li>
+<li><em>geo</em> is now a <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> with <em>lat</em> and <em>long</em> keys.</li>
+<li><em>wind</em> includes the <em>compass</em> key, which provides wind direction according to a compass (e.g. NNW, SE, or W).</li>
+</ul>
+</dd>
+</dl>
+<p>Example usage of the returned <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a>:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">result</span><span class="p">[</span><span class="s">&quot;wind&quot;</span><span class="p">][</span><span class="s">&quot;compass&quot;</span><span class="p">]</span>
+<span class="go">NNW</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">result</span><span class="p">[</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;pressure&quot;</span><span class="p">],</span> <span class="n">result</span><span class="p">[</span><span class="s">&quot;units&quot;</span><span class="p">][</span><span class="s">&quot;atmosphere&quot;</span><span class="p">][</span><span class="s">&quot;pressure&quot;</span><span class="p">]</span>
+<span class="go">29.95 psi</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="nb">len</span><span class="p">(</span><span class="n">result</span><span class="p">[</span><span class="s">&quot;forecast&quot;</span><span class="p">])</span>
+<span class="go">2</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">result</span><span class="p">[</span><span class="s">&quot;forecast&quot;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s">&quot;text&quot;</span><span class="p">]</span>
+<span class="go">Partly Cloudy</span>
+</pre></div>
+</div>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>id</strong> (<a class="reference external" href="http://docs.python.org/3.3/library/string.html#string" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a>) &#8211; the location&#8217;s <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a> or <a class="reference internal" href="glossary.html#term-lid"><em class="xref std std-term">LID</em></a>.</li>
+<li><strong>metric</strong> (<a class="reference external" href="http://docs.python.org/3.3/library/functions.html#bool" title="(in Python v3.3)"><tt class="xref py py-func docutils literal"><span class="pre">bool</span></tt></a>) &#8211; return metric data; defaults to <a class="reference external" href="http://docs.python.org/3.3/library/constants.html#False" title="(in Python v3.3)"><tt class="xref py py-data docutils literal"><span class="pre">False</span></tt></a>.</li>
+</ul>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">a <a class="reference external" href="http://docs.python.org/3.3/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> containing the location&#8217;s weather data or <a class="reference external" href="http://docs.python.org/3.3/library/constants.html#None" title="(in Python v3.3)"><tt class="xref py py-data docutils literal"><span class="pre">None</span></tt></a> if the weather data couldn&#8217;t be fetched.</p>
+</td>
+</tr>
+<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
+<li><a class="reference external" href="http://docs.python.org/3.3/library/urllib.error.html#urllib.error.URLError" title="(in Python v3.3)"><strong>urllib.error.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/urllib.request.html#urllib.request" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib.request</span></tt></a> could not open the URL (Python 3).</li>
+<li><a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2.URLError" title="(in Python v2.7)"><strong>urllib2.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2" title="(in Python v2.7)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib2</span></tt></a> could not open the URL (Python 2).</li>
+<li><strong>xml.etree.ElementTree.ParseError</strong> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/xml.etree.elementtree.html#xml.etree.ElementTree" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">xml.etree.ElementTree</span></tt></a> failed to parse the XML document.</li>
+</ul>
+</td>
+</tr>
+</tbody>
+</table>
+</dd></dl>
+
+<dl class="method">
+<dt id="yweather.Client.fetch_woeid">
+<tt class="descname">fetch_woeid</tt><big>(</big><em>location</em><big>)</big><a class="reference internal" href="_modules/yweather.html#Client.fetch_woeid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#yweather.Client.fetch_woeid" title="Permalink to this definition">¶</a></dt>
+<dd><p>Fetch a location&#8217;s corresponding <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a>.</p>
+<table class="docutils field-list" frame="void" rules="none">
+<col class="field-name" />
+<col class="field-body" />
+<tbody valign="top">
+<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>location</strong> (<a class="reference external" href="http://docs.python.org/3.3/library/string.html#string" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a>) &#8211; a location (e.g. 23454 or Berlin, Germany).</p>
+</td>
+</tr>
+<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">a <a class="reference external" href="http://docs.python.org/3.3/library/string.html#string" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">string</span></tt></a> containing the requested <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a> or <a class="reference external" href="http://docs.python.org/3.3/library/constants.html#None" title="(in Python v3.3)"><tt class="xref py py-data docutils literal"><span class="pre">None</span></tt></a> if the <a class="reference internal" href="glossary.html#term-woeid"><em class="xref std std-term">WOEID</em></a> could not be found.</p>
+</td>
+</tr>
+<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
+<li><a class="reference external" href="http://docs.python.org/3.3/library/urllib.error.html#urllib.error.URLError" title="(in Python v3.3)"><strong>urllib.error.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/urllib.request.html#urllib.request" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib.request</span></tt></a> could not open the URL (Python 3).</li>
+<li><a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2.URLError" title="(in Python v2.7)"><strong>urllib2.URLError</strong></a> &#8211; <a class="reference external" href="http://docs.python.org/2.7/library/urllib2.html#urllib2" title="(in Python v2.7)"><tt class="xref py py-mod docutils literal"><span class="pre">urllib2</span></tt></a> could not open the URL (Python 2).</li>
+<li><strong>xml.etree.ElementTree.ParseError</strong> &#8211; <a class="reference external" href="http://docs.python.org/3.3/library/xml.etree.elementtree.html#xml.etree.ElementTree" title="(in Python v3.3)"><tt class="xref py py-mod docutils literal"><span class="pre">xml.etree.ElementTree</span></tt></a> failed to parse the XML document.</li>
+</ul>
+</td>
+</tr>
+</tbody>
+</table>
+</dd></dl>
+
+</dd></dl>
+
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h4>Previous topic</h4>
+ <p class="topless"><a href="usage.html"
+ title="previous chapter">Usage</a></p>
+ <h4>Next topic</h4>
+ <p class="topless"><a href="changes.html"
+ title="next chapter">Change Log</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/api.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+<div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li class="right" >
+ <a href="changes.html" title="Change Log"
+ >next</a> |</li>
+ <li class="right" >
+ <a href="usage.html" title="Usage"
+ >