experimental-accounting-api/doc/build/html/_modules/accounting/client.html
Joar Wandborg 36d91dd0b3 [docs] Changed the theme to the Flask theme
I like it because it doesn't allow the text to fill horizontally
over the entire screen.
2013-12-20 16:00:09 +01:00

253 lines
No EOL
29 KiB
HTML

<!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>accounting.client &mdash; Accounting API 0.1-beta documentation</title>
<link rel="stylesheet" href="../../_static/flasky.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-beta',
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="Accounting API 0.1-beta documentation" href="../../index.html" />
<link rel="up" title="Module code" href="../index.html" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</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="../../http-routingtable.html" title="HTTP Routing Table"
>routing table</a> |</li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li><a href="../../index.html">Accounting API 0.1-beta 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 accounting.client</h1><div class="highlight"><pre>
<span class="c"># Part of accounting-api project:</span>
<span class="c"># https://gitorious.org/conservancy/accounting-api</span>
<span class="c"># License: AGPLv3-or-later</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">argparse</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">locale</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="kn">from</span> <span class="nn">decimal</span> <span class="kn">import</span> <span class="n">Decimal</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">from</span> <span class="nn">accounting.models</span> <span class="kn">import</span> <span class="n">Transaction</span><span class="p">,</span> <span class="n">Posting</span><span class="p">,</span> <span class="n">Amount</span>
<span class="kn">from</span> <span class="nn">accounting.transport</span> <span class="kn">import</span> <span class="n">AccountingDecoder</span><span class="p">,</span> <span class="n">AccountingEncoder</span>
<span class="n">locale</span><span class="o">.</span><span class="n">setlocale</span><span class="p">(</span><span class="n">locale</span><span class="o">.</span><span class="n">LC_ALL</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span>
<span class="n">_log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="Client"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client">[docs]</a><span class="k">class</span> <span class="nc">Client</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">json_encoder</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">json_decoder</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="n">host</span> <span class="ow">or</span> <span class="s">&#39;http://localhost:5000&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">json_encoder</span> <span class="o">=</span> <span class="n">json_encoder</span> <span class="ow">or</span> <span class="n">AccountingEncoder</span>
<span class="bp">self</span><span class="o">.</span><span class="n">json_decoder</span> <span class="o">=</span> <span class="n">json_decoder</span> <span class="ow">or</span> <span class="n">AccountingDecoder</span>
<div class="viewcode-block" id="Client.get_balance"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client.get_balance">[docs]</a> <span class="k">def</span> <span class="nf">get_balance</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">balance</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;/balance&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">balance</span><span class="p">[</span><span class="s">&#39;balance_report&#39;</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="Client.get"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client.get">[docs]</a> <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">+</span> <span class="n">path</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_decode_response</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_decode_response</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
<span class="n">response_data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">(</span><span class="n">cls</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">json_decoder</span><span class="p">)</span>
<span class="n">_log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;response_data: </span><span class="si">%s</span><span class="s">&#39;</span><span class="p">,</span> <span class="n">response_data</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response_data</span>
<div class="viewcode-block" id="Client.post"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client.post">[docs]</a> <span class="k">def</span> <span class="nf">post</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">payload</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
<span class="n">kw</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s">&#39;headers&#39;</span><span class="p">:</span> <span class="p">{</span><span class="s">&#39;Content-Type&#39;</span><span class="p">:</span> <span class="s">&#39;application/json&#39;</span><span class="p">}})</span>
<span class="n">kw</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s">&#39;data&#39;</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">payload</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">json_encoder</span><span class="p">)})</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_decode_response</span><span class="p">(</span><span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">+</span> <span class="n">path</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="Client.simple_transaction"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client.simple_transaction">[docs]</a> <span class="k">def</span> <span class="nf">simple_transaction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">from_acc</span><span class="p">,</span> <span class="n">to_acc</span><span class="p">,</span> <span class="n">amount</span><span class="p">,</span> <span class="n">symbol</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">payee</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="k">if</span> <span class="n">symbol</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="c"># Get the currency from the environment locale</span>
<span class="n">symbol</span> <span class="o">=</span> <span class="n">locale</span><span class="o">.</span><span class="n">localeconv</span><span class="p">()[</span><span class="s">&#39;int_curr_symbol&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">Transaction</span><span class="p">(</span>
<span class="n">date</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">(),</span>
<span class="n">payee</span><span class="o">=</span><span class="n">payee</span><span class="p">,</span>
<span class="n">postings</span><span class="o">=</span><span class="p">[</span>
<span class="n">Posting</span><span class="p">(</span><span class="n">account</span><span class="o">=</span><span class="n">from_acc</span><span class="p">,</span>
<span class="n">amount</span><span class="o">=</span><span class="n">Amount</span><span class="p">(</span><span class="n">symbol</span><span class="o">=</span><span class="n">symbol</span><span class="p">,</span> <span class="n">amount</span><span class="o">=-</span><span class="n">amount</span><span class="p">)),</span>
<span class="n">Posting</span><span class="p">(</span><span class="n">account</span><span class="o">=</span><span class="n">to_acc</span><span class="p">,</span>
<span class="n">amount</span><span class="o">=</span><span class="n">Amount</span><span class="p">(</span><span class="n">symbol</span><span class="o">=</span><span class="n">symbol</span><span class="p">,</span> <span class="n">amount</span><span class="o">=</span><span class="n">amount</span><span class="p">))</span>
<span class="p">]</span>
<span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="s">&#39;/transaction&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s">&#39;transactions&#39;</span><span class="p">:</span> <span class="p">[</span><span class="n">t</span><span class="p">]})</span>
</div>
<div class="viewcode-block" id="Client.get_register"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.Client.get_register">[docs]</a> <span class="k">def</span> <span class="nf">get_register</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">register</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;/transaction&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">register</span><span class="p">[</span><span class="s">&#39;transactions&#39;</span><span class="p">]</span>
</div></div>
<div class="viewcode-block" id="print_transactions"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.print_transactions">[docs]</a><span class="k">def</span> <span class="nf">print_transactions</span><span class="p">(</span><span class="n">transactions</span><span class="p">):</span>
<span class="k">for</span> <span class="n">transaction</span> <span class="ow">in</span> <span class="n">transactions</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&#39;{date} {t.payee:.&lt;69}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">date</span><span class="o">=</span><span class="n">transaction</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s">&#39;%Y-%m-</span><span class="si">%d</span><span class="s">&#39;</span><span class="p">),</span>
<span class="n">t</span><span class="o">=</span><span class="n">transaction</span><span class="p">))</span>
<span class="k">for</span> <span class="n">posting</span> <span class="ow">in</span> <span class="n">transaction</span><span class="o">.</span><span class="n">postings</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&#39; &#39;</span> <span class="o">+</span> <span class="n">posting</span><span class="o">.</span><span class="n">account</span> <span class="o">+</span>
<span class="s">&#39; &#39;</span> <span class="o">*</span> <span class="p">(</span><span class="mi">80</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">posting</span><span class="o">.</span><span class="n">account</span><span class="p">)</span> <span class="o">-</span>
<span class="nb">len</span><span class="p">(</span><span class="n">posting</span><span class="o">.</span><span class="n">amount</span><span class="o">.</span><span class="n">symbol</span><span class="p">)</span> <span class="o">-</span>
<span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">posting</span><span class="o">.</span><span class="n">amount</span><span class="o">.</span><span class="n">amount</span><span class="p">))</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span>
<span class="n">posting</span><span class="o">.</span><span class="n">amount</span><span class="o">.</span><span class="n">symbol</span> <span class="o">+</span> <span class="s">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">posting</span><span class="o">.</span><span class="n">amount</span><span class="o">.</span><span class="n">amount</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="print_balance_accounts"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.print_balance_accounts">[docs]</a><span class="k">def</span> <span class="nf">print_balance_accounts</span><span class="p">(</span><span class="n">accounts</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="k">for</span> <span class="n">account</span> <span class="ow">in</span> <span class="n">accounts</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&#39; &#39;</span> <span class="o">*</span> <span class="n">level</span> <span class="o">+</span> <span class="s">&#39; + {account.name}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">account</span><span class="o">=</span><span class="n">account</span><span class="p">)</span> <span class="o">+</span>
<span class="s">&#39; &#39;</span> <span class="o">+</span> <span class="s">&#39;-&#39;</span> <span class="o">*</span> <span class="p">(</span><span class="mi">80</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">account</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> <span class="o">-</span> <span class="n">level</span><span class="p">))</span>
<span class="k">for</span> <span class="n">amount</span> <span class="ow">in</span> <span class="n">account</span><span class="o">.</span><span class="n">amounts</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&#39; &#39;</span> <span class="o">*</span> <span class="n">level</span> <span class="o">+</span> <span class="s">&#39; {amount.symbol} {amount.amount}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">amount</span><span class="o">=</span><span class="n">amount</span><span class="p">))</span>
<span class="n">print_balance_accounts</span><span class="p">(</span><span class="n">account</span><span class="o">.</span><span class="n">accounts</span><span class="p">,</span> <span class="n">level</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="main"><a class="viewcode-back" href="../../api/accounting.html#accounting.client.main">[docs]</a><span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">argv</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">prog</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="k">global</span> <span class="n">HOST</span>
<span class="k">if</span> <span class="n">argv</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">prog</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">argv</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
<span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">prog</span><span class="o">=</span><span class="n">prog</span><span class="p">)</span>
<span class="n">actions</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_subparsers</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s">&#39;Actions&#39;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s">&#39;action&#39;</span><span class="p">)</span>
<span class="n">insert</span> <span class="o">=</span> <span class="n">actions</span><span class="o">.</span><span class="n">add_parser</span><span class="p">(</span><span class="s">&#39;insert&#39;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;in&#39;</span><span class="p">])</span>
<span class="n">insert</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;payee&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s">&#39;The payee line of the transaction&#39;</span><span class="p">)</span>
<span class="n">insert</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;from_account&#39;</span><span class="p">)</span>
<span class="n">insert</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;to_account&#39;</span><span class="p">)</span>
<span class="n">insert</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;amount&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">Decimal</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s">&#39;The amount deducted from from_account and added&#39;</span>
<span class="s">&#39; to to_account&#39;</span><span class="p">)</span>
<span class="n">insert</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-s&#39;</span><span class="p">,</span> <span class="s">&#39;--symbol&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s">&#39;The symbol for the amount, e.g. $ or USD for&#39;</span>
<span class="s">&#39; USD. Defaults to your locale</span><span class="se">\&#39;</span><span class="s">s setting.&#39;</span><span class="p">)</span>
<span class="n">actions</span><span class="o">.</span><span class="n">add_parser</span><span class="p">(</span><span class="s">&#39;balance&#39;</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;bal&#39;</span><span class="p">])</span>
<span class="n">actions</span><span class="o">.</span><span class="n">add_parser</span><span class="p">(</span><span class="s">&#39;register&#39;</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;reg&#39;</span><span class="p">])</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;-v&#39;</span><span class="p">,</span> <span class="s">&#39;--verbosity&#39;</span><span class="p">,</span>
<span class="n">default</span><span class="o">=</span><span class="s">&#39;WARNING&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="p">(</span><span class="s">&#39;Filter logging output. Possible values:&#39;</span> <span class="o">+</span>
<span class="s">&#39; CRITICAL, ERROR, WARNING, INFO, DEBUG&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s">&#39;--host&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">&#39;http://localhost:5000&#39;</span><span class="p">)</span>
<span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">argv</span><span class="p">)</span>
<span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="n">level</span><span class="o">=</span><span class="nb">getattr</span><span class="p">(</span><span class="n">logging</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">verbosity</span><span class="p">))</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">host</span><span class="p">)</span>
<span class="k">if</span> <span class="n">args</span><span class="o">.</span><span class="n">action</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;insert&#39;</span><span class="p">,</span> <span class="s">&#39;in&#39;</span><span class="p">]:</span>
<span class="k">print</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">simple_transaction</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">from_account</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">to_account</span><span class="p">,</span>
<span class="n">args</span><span class="o">.</span><span class="n">amount</span><span class="p">,</span> <span class="n">payee</span><span class="o">=</span><span class="n">args</span><span class="o">.</span><span class="n">payee</span><span class="p">,</span>
<span class="n">symbol</span><span class="o">=</span><span class="n">args</span><span class="o">.</span><span class="n">symbol</span><span class="p">))</span>
<span class="k">elif</span> <span class="n">args</span><span class="o">.</span><span class="n">action</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;balance&#39;</span><span class="p">,</span> <span class="s">&#39;bal&#39;</span><span class="p">]:</span>
<span class="n">print_balance_accounts</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">get_balance</span><span class="p">())</span>
<span class="k">elif</span> <span class="n">args</span><span class="o">.</span><span class="n">action</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;register&#39;</span><span class="p">,</span> <span class="s">&#39;reg&#39;</span><span class="p">]:</span>
<span class="n">print_transactions</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">get_register</span><span class="p">())</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">parser</span><span class="o">.</span><span class="n">print_help</span><span class="p">()</span>
</div>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">main</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/accounting-api-logo.png" alt="Logo"/>
</a></p><h3>Related Topics</h3>
<ul>
<li><a href="../../index.html">Documentation overview</a><ul>
<li><a href="../index.html">Module code</a><ul>
</ul></li>
</ul></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="footer">
&copy; Copyright 2013, Joar Wandborg.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
</body>
</html>