208 lines
33 KiB
HTML
208 lines
33 KiB
HTML
<?xml version="1.0" encoding="ascii"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title>lastfm.safelist</title>
|
|
<link rel="stylesheet" href="epydoc.css" type="text/css" />
|
|
<script type="text/javascript" src="epydoc.js"></script>
|
|
</head>
|
|
|
|
<body bgcolor="white" text="black" link="blue" vlink="#204080"
|
|
alink="#204080">
|
|
<!-- ==================== NAVIGATION BAR ==================== -->
|
|
<table class="navbar" border="0" width="100%" cellpadding="0"
|
|
bgcolor="#a0c0ff" cellspacing="0">
|
|
<tr valign="middle">
|
|
<!-- Home link -->
|
|
<th> <a
|
|
href="lastfm-module.html">Home</a> </th>
|
|
|
|
<!-- Tree link -->
|
|
<th> <a
|
|
href="module-tree.html">Trees</a> </th>
|
|
|
|
<!-- Index link -->
|
|
<th> <a
|
|
href="identifier-index.html">Indices</a> </th>
|
|
|
|
<!-- Help link -->
|
|
<th> <a
|
|
href="help.html">Help</a> </th>
|
|
|
|
<!-- Project homepage -->
|
|
<th class="navbar" align="right" width="100%">
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
<tr><th class="navbar" align="center"
|
|
><a class="navbar" target="_top" href="http://code.google.com/p/python-lastfm/">python-lastfm</a></th>
|
|
</tr></table></th>
|
|
</tr>
|
|
</table>
|
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
<tr valign="top">
|
|
<td width="100%">
|
|
<span class="breadcrumbs">
|
|
<a href="lastfm-module.html">Package lastfm</a> ::
|
|
Module safelist
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<table cellpadding="0" cellspacing="0">
|
|
<!-- hide/show private -->
|
|
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
|
|
onclick="toggle_private();">hide private</a>]</span></td></tr>
|
|
<tr><td align="right"><span class="options"
|
|
>[<a href="frames.html" target="_top">frames</a
|
|
>] | <a href="lastfm.safelist-pysrc.html"
|
|
target="_top">no frames</a>]</span></td></tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h1 class="epydoc">Source Code for <a href="lastfm.safelist-module.html" onclick="show_private();">Module lastfm.safelist</a></h1>
|
|
<pre class="py-src">
|
|
<a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-comment">#!/usr/bin/env python</tt> </tt>
|
|
<a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"> </tt>
|
|
<a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-name">__author__</tt> <tt class="py-op">=</tt> <tt class="py-docstring">"Abhinav Sarkar <abhinav@abhinavsarkar.net>"</tt> </tt>
|
|
<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-name">__version__</tt> <tt class="py-op">=</tt> <tt class="py-string">"0.2"</tt> </tt>
|
|
<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-name">__license__</tt> <tt class="py-op">=</tt> <tt class="py-string">"GNU Lesser General Public License"</tt> </tt>
|
|
<a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"> </tt>
|
|
<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
|
|
<a name="SafeList"></a><div id="SafeList-def"><a name="L8"></a><tt class="py-lineno"> 8</tt> <a class="py-toggle" href="#" id="SafeList-toggle" onclick="return toggle('SafeList');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html">SafeList</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="SafeList-expanded"><a name="SafeList.__init__"></a><div id="SafeList.__init__-def"><a name="L9"></a><tt class="py-lineno"> 9</tt> <a class="py-toggle" href="#" id="SafeList.__init__-toggle" onclick="return toggle('SafeList.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">lst</tt><tt class="py-op">,</tt> <tt class="py-param">add_func</tt><tt class="py-op">,</tt> <tt class="py-param">remove_func</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.__init__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.__init__-expanded"><a name="L10"></a><tt class="py-lineno">10</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt> <tt class="py-op">=</tt> <tt class="py-name">lst</tt> </tt>
|
|
<a name="L11"></a><tt class="py-lineno">11</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_add_func</tt> <tt class="py-op">=</tt> <tt class="py-name">add_func</tt> </tt>
|
|
<a name="L12"></a><tt class="py-lineno">12</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_remove_func</tt> <tt class="py-op">=</tt> <tt class="py-name">remove_func</tt> </tt>
|
|
</div><a name="L13"></a><tt class="py-lineno">13</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.add"></a><div id="SafeList.add-def"><a name="L14"></a><tt class="py-lineno">14</tt> <a class="py-toggle" href="#" id="SafeList.add-toggle" onclick="return toggle('SafeList.add');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#add">add</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">lst</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.add-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.add-expanded"><a name="L15"></a><tt class="py-lineno">15</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">lst</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">list</tt><tt class="py-op">,</tt> <tt class="py-name">tuple</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L16"></a><tt class="py-lineno">16</tt> <tt class="py-line"> <tt class="py-name">lst</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">lst</tt><tt class="py-op">]</tt> </tt>
|
|
<a name="L17"></a><tt class="py-lineno">17</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_add_func</tt><tt class="py-op">(</tt><tt class="py-name">lst</tt><tt class="py-op">)</tt> </tt>
|
|
</div><a name="L18"></a><tt class="py-lineno">18</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.remove"></a><div id="SafeList.remove-def"><a name="L19"></a><tt class="py-lineno">19</tt> <a class="py-toggle" href="#" id="SafeList.remove-toggle" onclick="return toggle('SafeList.remove');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#remove">remove</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">lst</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.remove-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.remove-expanded"><a name="L20"></a><tt class="py-lineno">20</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">lst</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">list</tt><tt class="py-op">,</tt> <tt class="py-name">tuple</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L21"></a><tt class="py-lineno">21</tt> <tt class="py-line"> <tt class="py-name">lst</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">lst</tt><tt class="py-op">]</tt> </tt>
|
|
<a name="L22"></a><tt class="py-lineno">22</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-name">l</tt> <tt class="py-keyword">in</tt> <tt class="py-name">lst</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L23"></a><tt class="py-lineno">23</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_remove_func</tt><tt class="py-op">(</tt><tt class="py-name">l</tt><tt class="py-op">)</tt> </tt>
|
|
</div><a name="L24"></a><tt class="py-lineno">24</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.__iter__"></a><div id="SafeList.__iter__-def"><a name="L25"></a><tt class="py-lineno">25</tt> <a class="py-toggle" href="#" id="SafeList.__iter__-toggle" onclick="return toggle('SafeList.__iter__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#__iter__">__iter__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.__iter__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.__iter__-expanded"><a name="L26"></a><tt class="py-lineno">26</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">xrange</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L27"></a><tt class="py-lineno">27</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> </tt>
|
|
</div><a name="L28"></a><tt class="py-lineno">28</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList._tuple_from_slice"></a><div id="SafeList._tuple_from_slice-def"><a name="L29"></a><tt class="py-lineno">29</tt> <a class="py-toggle" href="#" id="SafeList._tuple_from_slice-toggle" onclick="return toggle('SafeList._tuple_from_slice');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#_tuple_from_slice">_tuple_from_slice</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">i</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList._tuple_from_slice-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList._tuple_from_slice-expanded"><a name="L30"></a><tt class="py-lineno">30</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
|
|
<a name="L31"></a><tt class="py-lineno">31</tt> <tt class="py-line"><tt class="py-docstring"> Get (start, end, step) tuple from slice object.</tt> </tt>
|
|
<a name="L32"></a><tt class="py-lineno">32</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
|
|
<a name="L33"></a><tt class="py-lineno">33</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt id="link-0" class="py-name" targets="Variable lastfm.weeklychart.WeeklyChart.start=lastfm.weeklychart.WeeklyChart-class.html#start"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-0', 'start', 'link-0');">start</a></tt><tt class="py-op">,</tt> <tt id="link-1" class="py-name" targets="Variable lastfm.weeklychart.WeeklyChart.end=lastfm.weeklychart.WeeklyChart-class.html#end"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-1', 'end', 'link-1');">end</a></tt><tt class="py-op">,</tt> <tt class="py-name">step</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">i</tt><tt class="py-op">.</tt><tt class="py-name">indices</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L34"></a><tt class="py-lineno">34</tt> <tt class="py-line"> <tt class="py-comment"># Replace (0, -1, 1) with (0, 0, 1) (misfeature in .indices()).</tt> </tt>
|
|
<a name="L35"></a><tt class="py-lineno">35</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">step</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L36"></a><tt class="py-lineno">36</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-2" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-2', 'end', 'link-1');">end</a></tt> <tt class="py-op"><</tt> <tt id="link-3" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-3', 'start', 'link-0');">start</a></tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L37"></a><tt class="py-lineno">37</tt> <tt class="py-line"> <tt id="link-4" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-4', 'end', 'link-1');">end</a></tt> <tt class="py-op">=</tt> <tt id="link-5" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-5', 'start', 'link-0');">start</a></tt> </tt>
|
|
<a name="L38"></a><tt class="py-lineno">38</tt> <tt class="py-line"> <tt class="py-name">step</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
|
|
<a name="L39"></a><tt class="py-lineno">39</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">i</tt><tt class="py-op">.</tt><tt class="py-name">step</tt> <tt class="py-op">==</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L40"></a><tt class="py-lineno">40</tt> <tt class="py-line"> <tt class="py-name">step</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
|
|
<a name="L41"></a><tt class="py-lineno">41</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt id="link-6" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-6', 'start', 'link-0');">start</a></tt><tt class="py-op">,</tt> <tt id="link-7" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-7', 'end', 'link-1');">end</a></tt><tt class="py-op">,</tt> <tt class="py-name">step</tt><tt class="py-op">)</tt> </tt>
|
|
</div><a name="L42"></a><tt class="py-lineno">42</tt> <tt class="py-line"> </tt>
|
|
<a name="L43"></a><tt class="py-lineno">43</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.__getitem__"></a><div id="SafeList.__getitem__-def"><a name="L44"></a><tt class="py-lineno">44</tt> <a class="py-toggle" href="#" id="SafeList.__getitem__-toggle" onclick="return toggle('SafeList.__getitem__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#__getitem__">__getitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">i</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.__getitem__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.__getitem__-expanded"><a name="L45"></a><tt class="py-lineno">45</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">slice</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L46"></a><tt class="py-lineno">46</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt id="link-8" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-8', 'start', 'link-0');">start</a></tt><tt class="py-op">,</tt> <tt id="link-9" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-9', 'end', 'link-1');">end</a></tt><tt class="py-op">,</tt> <tt class="py-name">step</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name" targets="Method lastfm.safelist.SafeList._tuple_from_slice()=lastfm.safelist.SafeList-class.html#_tuple_from_slice"><a title="lastfm.safelist.SafeList._tuple_from_slice" class="py-name" href="#" onclick="return doclink('link-10', '_tuple_from_slice', 'link-10');">_tuple_from_slice</a></tt><tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L47"></a><tt class="py-lineno">47</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">step</tt> <tt class="py-op">==</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L48"></a><tt class="py-lineno">48</tt> <tt class="py-line"> <tt class="py-name">indices</tt> <tt class="py-op">=</tt> <tt class="py-name">xrange</tt><tt class="py-op">(</tt><tt id="link-11" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-11', 'start', 'link-0');">start</a></tt><tt class="py-op">,</tt> <tt id="link-12" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-12', 'end', 'link-1');">end</a></tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L49"></a><tt class="py-lineno">49</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L50"></a><tt class="py-lineno">50</tt> <tt class="py-line"> <tt class="py-name">indices</tt> <tt class="py-op">=</tt> <tt class="py-name">xrange</tt><tt class="py-op">(</tt><tt id="link-13" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.start" class="py-name" href="#" onclick="return doclink('link-13', 'start', 'link-0');">start</a></tt><tt class="py-op">,</tt> <tt id="link-14" class="py-name"><a title="lastfm.weeklychart.WeeklyChart.end" class="py-name" href="#" onclick="return doclink('link-14', 'end', 'link-1');">end</a></tt><tt class="py-op">,</tt> <tt class="py-name">step</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L51"></a><tt class="py-lineno">51</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">indices</tt><tt class="py-op">]</tt> </tt>
|
|
<a name="L52"></a><tt class="py-lineno">52</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L53"></a><tt class="py-lineno">53</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> </tt>
|
|
</div><a name="L54"></a><tt class="py-lineno">54</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.index"></a><div id="SafeList.index-def"><a name="L55"></a><tt class="py-lineno">55</tt> <a class="py-toggle" href="#" id="SafeList.index-toggle" onclick="return toggle('SafeList.index');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#index">index</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">x</tt><tt class="py-op">,</tt> <tt class="py-param">i</tt><tt class="py-op">=</tt><tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-param">j</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.index-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.index-expanded"><a name="L56"></a><tt class="py-lineno">56</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">i</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt> <tt class="py-keyword">or</tt> <tt class="py-name">j</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L57"></a><tt class="py-lineno">57</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">j</tt><tt class="py-op">,</tt> <tt class="py-name">ignore</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="lastfm.safelist.SafeList._tuple_from_slice" class="py-name" href="#" onclick="return doclink('link-15', '_tuple_from_slice', 'link-10');">_tuple_from_slice</a></tt><tt class="py-op">(</tt><tt class="py-name">slice</tt><tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">j</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L58"></a><tt class="py-lineno">58</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">j</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L59"></a><tt class="py-lineno">59</tt> <tt class="py-line"> <tt class="py-name">j</tt> <tt class="py-op">=</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L60"></a><tt class="py-lineno">60</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-name">k</tt> <tt class="py-keyword">in</tt> <tt class="py-name">xrange</tt><tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">,</tt> <tt class="py-name">j</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L61"></a><tt class="py-lineno">61</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-name">k</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-name">x</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L62"></a><tt class="py-lineno">62</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">k</tt> </tt>
|
|
<a name="L63"></a><tt class="py-lineno">63</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-string">'index(x): x not in list'</tt><tt class="py-op">)</tt> </tt>
|
|
</div><a name="L64"></a><tt class="py-lineno">64</tt> <tt class="py-line"> </tt>
|
|
<a name="L65"></a><tt class="py-lineno">65</tt> <tt class="py-line"> <tt class="py-comment"># Define sort() as appropriate for the Python version.</tt> </tt>
|
|
<a name="L66"></a><tt class="py-lineno">66</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">version_info</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-number">3</tt><tt class="py-op">]</tt> <tt class="py-op"><</tt> <tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">,</tt> <tt class="py-number">4</tt><tt class="py-op">,</tt> <tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="SafeList.sort"></a><div id="SafeList.sort-def"><a name="L67"></a><tt class="py-lineno">67</tt> <a class="py-toggle" href="#" id="SafeList.sort-toggle" onclick="return toggle('SafeList.sort');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#sort">sort</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">cmpfunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.sort-collapsed" style="display:none;" pad="++" indent="++++++++++++++++"></div><div id="SafeList.sort-expanded"><a name="L68"></a><tt class="py-lineno">68</tt> <tt class="py-line"> <tt class="py-name">ans</tt> <tt class="py-op">=</tt> <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L69"></a><tt class="py-lineno">69</tt> <tt class="py-line"> <tt class="py-name">ans</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name" targets="Method lastfm.safelist.SafeList.sort()=lastfm.safelist.SafeList-class.html#sort"><a title="lastfm.safelist.SafeList.sort" class="py-name" href="#" onclick="return doclink('link-16', 'sort', 'link-16');">sort</a></tt><tt class="py-op">(</tt><tt class="py-name">cmpfunc</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L70"></a><tt class="py-lineno">70</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">ans</tt> </tt>
|
|
</div><a name="L71"></a><tt class="py-lineno">71</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="SafeList.sort"></a><div id="SafeList.sort-def"><a name="L72"></a><tt class="py-lineno">72</tt> <a class="py-toggle" href="#" id="SafeList.sort-toggle" onclick="return toggle('SafeList.sort');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#sort">sort</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">cmpfunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">reverse</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.sort-collapsed" style="display:none;" pad="++" indent="++++++++++++++++"></div><div id="SafeList.sort-expanded"><a name="L73"></a><tt class="py-lineno">73</tt> <tt class="py-line"> <tt class="py-name">ans</tt> <tt class="py-op">=</tt> <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L74"></a><tt class="py-lineno">74</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">reverse</tt> <tt class="py-op">==</tt> <tt class="py-name">True</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L75"></a><tt class="py-lineno">75</tt> <tt class="py-line"> <tt class="py-name">ans</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name"><a title="lastfm.safelist.SafeList.sort" class="py-name" href="#" onclick="return doclink('link-17', 'sort', 'link-16');">sort</a></tt><tt class="py-op">(</tt><tt class="py-name">cmpfunc</tt><tt class="py-op">,</tt> <tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-name">reverse</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L76"></a><tt class="py-lineno">76</tt> <tt class="py-line"> <tt class="py-keyword">elif</tt> <tt class="py-name">key</tt> <tt class="py-op">!=</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L77"></a><tt class="py-lineno">77</tt> <tt class="py-line"> <tt class="py-name">ans</tt><tt class="py-op">.</tt><tt id="link-18" class="py-name"><a title="lastfm.safelist.SafeList.sort" class="py-name" href="#" onclick="return doclink('link-18', 'sort', 'link-16');">sort</a></tt><tt class="py-op">(</tt><tt class="py-name">cmpfunc</tt><tt class="py-op">,</tt> <tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L78"></a><tt class="py-lineno">78</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
|
|
<a name="L79"></a><tt class="py-lineno">79</tt> <tt class="py-line"> <tt class="py-name">ans</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name"><a title="lastfm.safelist.SafeList.sort" class="py-name" href="#" onclick="return doclink('link-19', 'sort', 'link-16');">sort</a></tt><tt class="py-op">(</tt><tt class="py-name">cmpfunc</tt><tt class="py-op">)</tt> </tt>
|
|
<a name="L80"></a><tt class="py-lineno">80</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">ans</tt> </tt>
|
|
</div><a name="L81"></a><tt class="py-lineno">81</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.__len__"></a><div id="SafeList.__len__-def"><a name="L82"></a><tt class="py-lineno">82</tt> <a class="py-toggle" href="#" id="SafeList.__len__-toggle" onclick="return toggle('SafeList.__len__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#__len__">__len__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.__len__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.__len__-expanded"><a name="L83"></a><tt class="py-lineno">83</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt> </tt>
|
|
</div><a name="L84"></a><tt class="py-lineno">84</tt> <tt class="py-line"> </tt>
|
|
<a name="SafeList.__repr__"></a><div id="SafeList.__repr__-def"><a name="L85"></a><tt class="py-lineno">85</tt> <a class="py-toggle" href="#" id="SafeList.__repr__-toggle" onclick="return toggle('SafeList.__repr__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="lastfm.safelist.SafeList-class.html#__repr__">__repr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
|
|
</div><div id="SafeList.__repr__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="SafeList.__repr__-expanded"><a name="L86"></a><tt class="py-lineno">86</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">repr</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_list</tt><tt class="py-op">)</tt> </tt>
|
|
</div></div><a name="L87"></a><tt class="py-lineno">87</tt> <tt class="py-line"> </tt><script type="text/javascript">
|
|
<!--
|
|
expandto(location.href);
|
|
// -->
|
|
</script>
|
|
</pre>
|
|
<br />
|
|
<!-- ==================== NAVIGATION BAR ==================== -->
|
|
<table class="navbar" border="0" width="100%" cellpadding="0"
|
|
bgcolor="#a0c0ff" cellspacing="0">
|
|
<tr valign="middle">
|
|
<!-- Home link -->
|
|
<th> <a
|
|
href="lastfm-module.html">Home</a> </th>
|
|
|
|
<!-- Tree link -->
|
|
<th> <a
|
|
href="module-tree.html">Trees</a> </th>
|
|
|
|
<!-- Index link -->
|
|
<th> <a
|
|
href="identifier-index.html">Indices</a> </th>
|
|
|
|
<!-- Help link -->
|
|
<th> <a
|
|
href="help.html">Help</a> </th>
|
|
|
|
<!-- Project homepage -->
|
|
<th class="navbar" align="right" width="100%">
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
<tr><th class="navbar" align="center"
|
|
><a class="navbar" target="_top" href="http://code.google.com/p/python-lastfm/">python-lastfm</a></th>
|
|
</tr></table></th>
|
|
</tr>
|
|
</table>
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
|
|
<tr>
|
|
<td align="left" class="footer">
|
|
Generated by Epydoc 3.0.1 on Tue Mar 10 11:14:39 2009
|
|
</td>
|
|
<td align="right" class="footer">
|
|
<a target="mainFrame" href="http://epydoc.sourceforge.net"
|
|
>http://epydoc.sourceforge.net</a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<script type="text/javascript">
|
|
<!--
|
|
// Private objects are initially displayed (because if
|
|
// javascript is turned off then we want them to be
|
|
// visible); but by default, we want to hide them. So hide
|
|
// them unless we have a cookie that says to show them.
|
|
checkCookie();
|
|
// -->
|
|
</script>
|
|
</body>
|
|
</html>
|