Skip to content

Commit

Permalink
added organizations method, fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Oct 19, 2016
1 parent d51effa commit 094c829
Show file tree
Hide file tree
Showing 17 changed files with 374 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Changelog
--------------------
- Download methods much improved (#16) (#27) thanks @jlegind @stijnvanhoey @peterdesmet !
- MULTIPOLYGON now supported in `geometry` parameter (#35)
- Fixed docs for `occurrences.get`, and `occurrences.get_verbatim` and
demo that used occurrence keys that no longer exist in GBIF (#39)
- Fixed docs for `occurrences.get`, and `occurrences.get_verbatim`,
`occurrences.get_fragment` and demo that used occurrence keys that no longer
exist in GBIF (#39)
- xxx (#xx)
- xxx (#xx)
- xxx (#xx)
Expand Down
Binary file modified docs/_build/doctrees/changelog_link.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/registry.doctree
Binary file not shown.
1 change: 1 addition & 0 deletions docs/_build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ <h1>All modules for which code is available</h1>
<li><a href="pygbif/registry/installations.html">pygbif.registry.installations</a></li>
<li><a href="pygbif/registry/networks.html">pygbif.registry.networks</a></li>
<li><a href="pygbif/registry/nodes.html">pygbif.registry.nodes</a></li>
<li><a href="pygbif/registry/organizations.html">pygbif.registry.organizations</a></li>
<li><a href="pygbif/species/name_parser.html">pygbif.species.name_parser</a></li>
<li><a href="pygbif/species/names.html">pygbif.species.names</a></li>
</ul>
Expand Down
253 changes: 253 additions & 0 deletions docs/_build/html/_modules/pygbif/registry/organizations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>pygbif.registry.organizations &mdash; pygbif 0.1.6.0 documentation</title>















<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />





<link rel="top" title="pygbif 0.1.6.0 documentation" href="../../../index.html"/>
<link rel="up" title="Module code" href="../../index.html"/>


<script src="../../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

<div class="wy-grid-for-nav">


<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">



<a href="../../../index.html" class="icon icon-home"> pygbif



</a>




<div class="version">
0.1.6.0
</div>




<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>


</div>

<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">



<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../occurrences.html">occurrences module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../registry.html">registry module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../species.html">species module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../changelog_link.html">Changelog</a></li>
</ul>



</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">


<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">pygbif</a>
</nav>



<div class="wy-nav-content">
<div class="rst-content">






<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html">Docs</a> &raquo;</li>

<li><a href="../../index.html">Module code</a> &raquo;</li>

<li>pygbif.registry.organizations</li>
<li class="wy-breadcrumbs-aside">



</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for pygbif.registry.organizations</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">..gbifutils</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">.registry_utils</span> <span class="kn">import</span> <span class="o">*</span>

<span class="k">def</span> <span class="nf">organizations</span><span class="p">(</span><span class="n">data</span> <span class="o">=</span> <span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">uuid</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span> <span class="n">query</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span> <span class="n">identifier</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span>
<span class="n">identifierType</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span> <span class="n">limit</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> <span class="n">start</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> organizations metadata.</span>

<span class="sd"> :param data: [str] The type of data to get. Default is all data. If not ``all``, then one</span>
<span class="sd"> or more of ``contact``, ``endpoint``, ``identifier``, ``tag``, ``machineTag``,</span>
<span class="sd"> ``comment``, ``hostedDataset``, ``ownedDataset``, ``deleted``, ``pending``,</span>
<span class="sd"> ``nonPublishing``.</span>
<span class="sd"> :param uuid: [str] UUID of the data node provider. This must be specified if data</span>
<span class="sd"> is anything other than ``all``.</span>
<span class="sd"> :param query: [str] Query nodes. Only used when ``data=&#39;all&#39;``. Ignored otherwise.</span>

<span class="sd"> References: http://www.gbif.org/developer/registry#organizations</span>

<span class="sd"> Usage::</span>

<span class="sd"> from pygbif import registry</span>
<span class="sd"> registry.organizations(limit=5)</span>
<span class="sd"> registry.organizations(query=&quot;france&quot;)</span>
<span class="sd"> registry.organizations(uuid=&quot;e2e717bf-551a-4917-bdc9-4fa0f342c530&quot;)</span>
<span class="sd"> registry.organizations(data=&#39;contact&#39;, uuid=&quot;e2e717bf-551a-4917-bdc9-4fa0f342c530&quot;)</span>
<span class="sd"> registry.organizations(data=&#39;endpoint&#39;, uuid=&quot;e2e717bf-551a-4917-bdc9-4fa0f342c530&quot;)</span>
<span class="sd"> registry.organizations(data=&#39;deleted&#39;)</span>
<span class="sd"> registry.organizations(data=&#39;deleted&#39;, limit=2)</span>
<span class="sd"> registry.organizations(data=[&#39;deleted&#39;,&#39;nonPublishing&#39;], limit=2)</span>
<span class="sd"> registry.organizations(identifierType=&#39;DOI&#39;, limit=2)</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;q&#39;</span><span class="p">:</span> <span class="n">query</span><span class="p">,</span> <span class="s1">&#39;limit&#39;</span><span class="p">:</span> <span class="n">limit</span><span class="p">,</span> <span class="s1">&#39;offset&#39;</span><span class="p">:</span> <span class="n">start</span><span class="p">}</span>
<span class="n">data_choices</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="s1">&#39;contact&#39;</span><span class="p">,</span> <span class="s1">&#39;endpoint&#39;</span><span class="p">,</span>
<span class="s1">&#39;identifier&#39;</span><span class="p">,</span> <span class="s1">&#39;tag&#39;</span><span class="p">,</span> <span class="s1">&#39;machineTag&#39;</span><span class="p">,</span> <span class="s1">&#39;comment&#39;</span><span class="p">,</span> <span class="s1">&#39;hostedDataset&#39;</span><span class="p">,</span>
<span class="s1">&#39;ownedDataset&#39;</span><span class="p">,</span> <span class="s1">&#39;deleted&#39;</span><span class="p">,</span> <span class="s1">&#39;pending&#39;</span><span class="p">,</span> <span class="s1">&#39;nonPublishing&#39;</span><span class="p">]</span>
<span class="n">check_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">data_choices</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">getdata</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">uuid</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">nouuid</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="s1">&#39;deleted&#39;</span><span class="p">,</span> <span class="s1">&#39;pending&#39;</span><span class="p">,</span> <span class="s1">&#39;nonPublishing&#39;</span><span class="p">]</span>
<span class="k">if</span> <span class="n">x</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">nouuid</span> <span class="ow">and</span> <span class="n">uuid</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">stop</span><span class="p">(</span><span class="s1">&#39;You must specify a uuid if data does not equal &quot;all&quot; and data does not equal one of &#39;</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">nouuid</span><span class="p">))</span>

<span class="k">if</span> <span class="n">uuid</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">gbif_baseurl</span> <span class="o">+</span> <span class="s1">&#39;organization&#39;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">gbif_baseurl</span> <span class="o">+</span> <span class="s1">&#39;organization/&#39;</span> <span class="o">+</span> <span class="n">x</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">gbif_baseurl</span> <span class="o">+</span> <span class="s1">&#39;organization/&#39;</span> <span class="o">+</span> <span class="n">uuid</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">gbif_baseurl</span> <span class="o">+</span> <span class="s1">&#39;organization/&#39;</span> <span class="o">+</span> <span class="n">uuid</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">x</span>

<span class="n">res</span> <span class="o">=</span> <span class="n">gbif_GET</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">return</span> <span class="p">{</span><span class="s1">&#39;meta&#39;</span><span class="p">:</span> <span class="n">get_meta</span><span class="p">(</span><span class="n">res</span><span class="p">),</span> <span class="s1">&#39;data&#39;</span><span class="p">:</span> <span class="n">parse_results</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="n">uuid</span><span class="p">)}</span>

<span class="k">if</span> <span class="n">len2</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">return</span> <span class="n">getdata</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">uuid</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">getdata</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">uuid</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
</pre></div>

</div>
</div>
<footer>


<hr/>

<div role="contentinfo">
<p>
&copy; Copyright 2016, Scott Chamberlain.

</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.

</footer>

</div>
</div>

</section>

</div>





<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../../',
VERSION:'0.1.6.0',
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>





<script type="text/javascript" src="../../../_static/js/theme.js"></script>




<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>


</body>
</html>
1 change: 1 addition & 0 deletions docs/_build/html/_sources/registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ registry module
.. automethod:: registry.installations
.. automethod:: registry.networks
.. automethod:: registry.nodes
.. automethod:: registry.organizations
5 changes: 3 additions & 2 deletions docs/_build/html/changelog_link.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ <h2>0.2.0 (2016-10-18)<a class="headerlink" href="#id1" title="Permalink to this
<ul class="simple">
<li>Download methods much improved (#16) (#27) thanks &#64;jlegind &#64;stijnvanhoey &#64;peterdesmet !</li>
<li>MULTIPOLYGON now supported in <cite>geometry</cite> parameter (#35)</li>
<li>Fixed docs for <cite>occurrences.get</cite>, and <cite>occurrences.get_verbatim</cite> and</li>
<li>Fixed docs for <cite>occurrences.get</cite>, and <cite>occurrences.get_verbatim</cite>,</li>
</ul>
<p>demo that used occurrence keys that no longer exist in GBIF (#39)
<p><cite>occurrences.get_fragment</cite> and demo that used occurrence keys that no longer
exist in GBIF (#39)
- xxx (#xx)
- xxx (#xx)
- xxx (#xx)
Expand Down
11 changes: 11 additions & 0 deletions docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ <h1 id="index">Index</h1>
| <a href="#G"><strong>G</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#O"><strong>O</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#S"><strong>S</strong></a>

Expand Down Expand Up @@ -266,6 +267,16 @@ <h2 id="N">N</h2>
</dl></td>
</tr></table>

<h2 id="O">O</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>

<dt><a href="registry.html#pygbif.registry.organizations">organizations() (pygbif.registry method)</a>
</dt>

</dl></td>
</tr></table>

<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h1>Python Module Index</h1>
<tr>
<td></td>
<td>
<a href="occurrences.html#module-pygbif"><code class="xref">pygbif</code></a></td><td>
<a href="registry.html#module-pygbif"><code class="xref">pygbif</code></a></td><td>
<em></em></td></tr>
</table>

Expand Down

0 comments on commit 094c829

Please sign in to comment.