Source

eggDiscover / documentation / build / followerslookup.html

Full commit


<!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>Followerslookup &mdash; EggDiscover 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="EggDiscover 0.1 documentation" href="index.html" />
    <link rel="next" title="External apps used in this project" href="externalapps.html" />
    <link rel="prev" title="Installation" href="install.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="externalapps.html" title="External apps used in this project"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="install.html" title="Installation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">EggDiscover 0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="followerslookup">
<h1>Followerslookup<a class="headerlink" href="#followerslookup" title="Permalink to this headline"></a></h1>
<div class="section" id="module-followerslookup.authentication">
<span id="authentication"></span><h2>Authentication<a class="headerlink" href="#module-followerslookup.authentication" title="Permalink to this headline"></a></h2>
<p>This set of utilities get a SocialUserAuth and return a twitter authenticated account.
This account can be used to query the twitter REST API.
To get an authenticated account you can do this :</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="c"># take a UserSocialAuth</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">user</span> <span class="o">=</span> <span class="n">UserSocialAuth</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># launch authentication process</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">user</span> <span class="o">=</span> <span class="n">get_account</span><span class="p">(</span><span class="n">user</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># You can test your account like this : </span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">account</span><span class="o">.</span><span class="n">account</span><span class="o">.</span><span class="n">verify_credentials</span><span class="p">()</span> 
</pre></div>
</div>
<dl class="function">
<dt id="followerslookup.authentication.get_account">
<tt class="descclassname">followerslookup.authentication.</tt><tt class="descname">get_account</tt><big>(</big><em>user</em><big>)</big><a class="reference internal" href="_modules/followerslookup/authentication.html#get_account"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.authentication.get_account" title="Permalink to this definition"></a></dt>
<dd><p>shortcut to get_twitter_account</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"><strong>user</strong> &#8211; a <a class="reference internal" href="social_auth.html#social_auth.models.UserSocialAuth" title="social_auth.models.UserSocialAuth"><tt class="xref py py-class docutils literal"><span class="pre">social_auth.models.UserSocialAuth</span></tt></a> object</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="followerslookup.authentication.get_auth">
<tt class="descclassname">followerslookup.authentication.</tt><tt class="descname">get_auth</tt><big>(</big><em>user</em><big>)</big><a class="reference internal" href="_modules/followerslookup/authentication.html#get_auth"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.authentication.get_auth" title="Permalink to this definition"></a></dt>
<dd><p>Return an auth object</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"><strong>user</strong> &#8211; a <a class="reference internal" href="social_auth.html#social_auth.models.UserSocialAuth" title="social_auth.models.UserSocialAuth"><tt class="xref py py-class docutils literal"><span class="pre">social_auth.models.UserSocialAuth</span></tt></a> object</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="followerslookup.authentication.get_twitter_account">
<tt class="descclassname">followerslookup.authentication.</tt><tt class="descname">get_twitter_account</tt><big>(</big><em>auth</em><big>)</big><a class="reference internal" href="_modules/followerslookup/authentication.html#get_twitter_account"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.authentication.get_twitter_account" title="Permalink to this definition"></a></dt>
<dd><p>Providing an auth object, return a twitter authenticated user</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"><strong>auth</strong> &#8211; a <tt class="xref py py-mod docutils literal"><span class="pre">twitter.Oauth</span></tt> object given by <a class="reference internal" href="#followerslookup.authentication.get_auth" title="followerslookup.authentication.get_auth"><tt class="xref py py-func docutils literal"><span class="pre">get_auth()</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="module-followerslookup.fetching">
<span id="user-fetching"></span><h2>User Fetching<a class="headerlink" href="#module-followerslookup.fetching" title="Permalink to this headline"></a></h2>
<p>Fetching is a set of utilities to query a user followers informations.
You will need an authenticated Twitter Account given by authentication.py
and a twitter account.</p>
<p>the authenticated account will be used to query twitter REST API.
the twitter account will be the account against witch query will be made.
This set of utilities can be used as follow :</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="c"># first get an authenticated account as explained in authentication.py</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># then request the list of followers for a user :</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">followers_ids</span> <span class="o">=</span> <span class="n">get_followers_ids</span><span class="p">(</span><span class="n">account</span><span class="p">,</span> <span class="s">&quot;NicolasSarkozy&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># then get extended informations about these users :</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">followers_infos</span> <span class="o">=</span> <span class="n">get_followers_infos</span><span class="p">(</span><span class="n">account</span><span class="p">,</span> <span class="n">followers_ids</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># you are then free to use the returned list as you see fit.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># you can save it to a database for exemple :</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">save_users</span><span class="p">(</span><span class="s">&quot;NicolasSarcozy&quot;</span><span class="p">,</span><span class="n">followers_infos</span><span class="p">)</span> 
</pre></div>
</div>
<dl class="function">
<dt id="followerslookup.fetching.cleanup">
<tt class="descclassname">followerslookup.fetching.</tt><tt class="descname">cleanup</tt><big>(</big><em>followers_ids</em>, <em>twitter_user</em><big>)</big><a class="headerlink" href="#followerslookup.fetching.cleanup" title="Permalink to this definition"></a></dt>
<dd><p>cleanup look for twitter users no more following a TwitterUser and
delete them from the database</p>
</dd></dl>

<dl class="function">
<dt id="followerslookup.fetching.get_followers_ids">
<tt class="descclassname">followerslookup.fetching.</tt><tt class="descname">get_followers_ids</tt><big>(</big><em>account</em>, <em>user</em><big>)</big><a class="reference internal" href="_modules/followerslookup/fetching.html#get_followers_ids"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.fetching.get_followers_ids" title="Permalink to this definition"></a></dt>
<dd><p>This function will return a list of followers ids. Each request on the twitter API will return 5000 ids.
as we are limited to 350 request per hours. so we can get 17,500,000 ids per hours.</p>
<p>params account : account is an authenticated Twitter account</p>
<p>params user : user is a string. It represent a twitter account.
for exemple, NicolasSarcozy. this twitter account must be a valid twitter account.</p>
</dd></dl>

<dl class="function">
<dt id="followerslookup.fetching.get_followers_infos">
<tt class="descclassname">followerslookup.fetching.</tt><tt class="descname">get_followers_infos</tt><big>(</big><em>account</em>, <em>followers_ids</em>, <em>user</em><big>)</big><a class="reference internal" href="_modules/followerslookup/fetching.html#get_followers_infos"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.fetching.get_followers_infos" title="Permalink to this definition"></a></dt>
<dd><p>This function take a list of user ids and request twitter for extended
informations on these users.  Each request on the twitter API will return
100 users. As we are limited to 350 request per hours.  so we can get 35,000
users per hour.</p>
<p>TODO : do not lookup user already in the database.</p>
</dd></dl>

<dl class="function">
<dt id="followerslookup.fetching.save_user">
<tt class="descclassname">followerslookup.fetching.</tt><tt class="descname">save_user</tt><big>(</big><em>twitter_user</em>, <em>user</em><big>)</big><a class="reference internal" href="_modules/followerslookup/fetching.html#save_user"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.fetching.save_user" title="Permalink to this definition"></a></dt>
<dd><p>First we will check if the user is already in the database.
If the user is in the database, we return this user.</p>
<p>else we parse the user for usefull informations, save him in the database.</p>
<p>finaly, we return the parsed user.</p>
</dd></dl>

<dl class="function">
<dt id="followerslookup.fetching.save_users">
<tt class="descclassname">followerslookup.fetching.</tt><tt class="descname">save_users</tt><big>(</big><em>twitter_user</em>, <em>users</em><big>)</big><a class="reference internal" href="_modules/followerslookup/fetching.html#save_users"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#followerslookup.fetching.save_users" title="Permalink to this definition"></a></dt>
<dd><p>Take a list of users extended informations. These users must be followers of
a twitter account given in parameter. Each user is parsed and saved
in the database.</p>
</dd></dl>

</div>
<div class="section" id="module-followerslookup.models">
<span id="models"></span><h2>Models<a class="headerlink" href="#module-followerslookup.models" title="Permalink to this headline"></a></h2>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Followerslookup</a><ul>
<li><a class="reference internal" href="#module-followerslookup.authentication">Authentication</a></li>
<li><a class="reference internal" href="#module-followerslookup.fetching">User Fetching</a></li>
<li><a class="reference internal" href="#module-followerslookup.models">Models</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="install.html"
                        title="previous chapter">Installation</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="externalapps.html"
                        title="next chapter">External apps used in this project</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/followerslookup.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="externalapps.html" title="External apps used in this project"
             >next</a> |</li>
        <li class="right" >
          <a href="install.html" title="Installation"
             >previous</a> |</li>
        <li><a href="index.html">EggDiscover 0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Yohann Gabory.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>