2013-12-17 08:42:53 +00:00
< !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 — Accounting API 0.1-beta documentation< / title >
2013-12-20 15:00:09 +00:00
< link rel = "stylesheet" href = "../../_static/flasky.css" type = "text/css" / >
2013-12-17 08:42:53 +00:00
< 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" / >
2013-12-20 15:00:09 +00:00
< link rel = "up" title = "Module code" href = "../index.html" / >
< meta name = "viewport" content = "width=device-width, initial-scale=0.9, maximum-scale=0.9" >
2013-12-17 08:42:53 +00:00
< / head >
< body >
2013-12-20 15:00:09 +00:00
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-18 21:46:19 +00:00
< li class = "right" >
< a href = "../../http-routingtable.html" title = "HTTP Routing Table"
>routing table< / a > |< / li >
2013-12-17 08:42:53 +00:00
< 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 > » < / li >
2013-12-20 15:00:09 +00:00
< li > < a href = "../index.html" accesskey = "U" > Module code< / a > » < / li >
2013-12-17 08:42:53 +00:00
< / 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 >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< span class = "kn" > import< / span > < span class = "nn" > locale< / span >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< 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" > ' ' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< 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" > ' http://localhost:5000' < / 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" > ' /balance' < / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > balance< / span > < span class = "p" > [< / span > < span class = "s" > ' balance_report' < / 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" > ' response_data: < / span > < span class = "si" > %s< / span > < span class = "s" > ' < / 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" > ' headers' < / span > < span class = "p" > :< / span > < span class = "p" > {< / span > < span class = "s" > ' Content-Type' < / span > < span class = "p" > :< / span > < span class = "s" > ' application/json' < / 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" > ' data' < / 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 >
2013-12-20 15:00:09 +00:00
< 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" > ' int_curr_symbol' < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > strip< / span > < span class = "p" > ()< / span >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< span class = "n" > payee< / span > < span class = "o" > =< / span > < span class = "n" > payee< / span > < span class = "p" > ,< / span >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< 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" > ' /transaction' < / span > < span class = "p" > ,< / span > < span class = "p" > {< / span > < span class = "s" > ' transactions' < / 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 >
2013-12-20 15:00:09 +00:00
< 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" > ' /transaction' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "k" > return< / span > < span class = "n" > register< / span > < span class = "p" > [< / span > < span class = "s" > ' transactions' < / span > < span class = "p" > ]< / span >
2013-12-17 08:42:53 +00:00
< / 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" > ' {date} {t.payee:.< 69}' < / 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" > ' %Y-%m-< / span > < span class = "si" > %d< / span > < span class = "s" > ' < / 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" > ' ' < / span > < span class = "o" > +< / span > < span class = "n" > posting< / span > < span class = "o" > .< / span > < span class = "n" > account< / span > < span class = "o" > +< / span >
2013-12-20 15:00:09 +00:00
< span class = "s" > ' ' < / 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" > ' ' < / 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 >
2013-12-17 08:42:53 +00:00
< / 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" > ' ' < / span > < span class = "o" > *< / span > < span class = "n" > level< / span > < span class = "o" > +< / span > < span class = "s" > ' + {account.name}' < / 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" > ' ' < / span > < span class = "o" > +< / span > < span class = "s" > ' -' < / 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 >
2013-12-20 15:00:09 +00:00
2013-12-17 08:42:53 +00:00
< 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" > ' ' < / span > < span class = "o" > *< / span > < span class = "n" > level< / span > < span class = "o" > +< / span > < span class = "s" > ' {amount.symbol} {amount.amount}' < / 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 >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< / 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" > ' Actions' < / span > < span class = "p" > ,< / span > < span class = "n" > dest< / span > < span class = "o" > =< / span > < span class = "s" > ' action' < / 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" > ' insert' < / span > < span class = "p" > ,< / span >
< span class = "n" > aliases< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' in' < / span > < span class = "p" > ])< / span >
2013-12-20 15:00:09 +00:00
< span class = "n" > insert< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' payee' < / span > < span class = "p" > ,< / span >
< span class = "n" > help< / span > < span class = "o" > =< / span > < span class = "s" > ' The payee line of the transaction' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
< span class = "n" > insert< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' from_account' < / 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" > ' to_account' < / span > < span class = "p" > )< / span >
2013-12-20 15:00:09 +00:00
< span class = "n" > insert< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' amount' < / 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" > ' The amount deducted from from_account and added' < / span >
< span class = "s" > ' to to_account' < / 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" > ' -s' < / span > < span class = "p" > ,< / span > < span class = "s" > ' --symbol' < / span > < span class = "p" > ,< / span >
< span class = "n" > help< / span > < span class = "o" > =< / span > < span class = "s" > ' The symbol for the amount, e.g. $ or USD for' < / span >
< span class = "s" > ' USD. Defaults to your locale< / span > < span class = "se" > \' < / span > < span class = "s" > s setting.' < / span > < span class = "p" > )< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "n" > actions< / span > < span class = "o" > .< / span > < span class = "n" > add_parser< / span > < span class = "p" > (< / span > < span class = "s" > ' balance' < / span > < span class = "p" > ,< / span > < span class = "n" > aliases< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' bal' < / span > < span class = "p" > ])< / span >
2013-12-17 08:42:53 +00:00
2013-12-20 15:00:09 +00:00
< span class = "n" > actions< / span > < span class = "o" > .< / span > < span class = "n" > add_parser< / span > < span class = "p" > (< / span > < span class = "s" > ' register' < / span > < span class = "p" > ,< / span > < span class = "n" > aliases< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' reg' < / span > < span class = "p" > ])< / span >
2013-12-17 08:42:53 +00:00
< span class = "n" > parser< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' -v' < / span > < span class = "p" > ,< / span > < span class = "s" > ' --verbosity' < / span > < span class = "p" > ,< / span >
< span class = "n" > default< / span > < span class = "o" > =< / span > < span class = "s" > ' WARNING' < / span > < span class = "p" > ,< / span >
< span class = "n" > help< / span > < span class = "o" > =< / span > < span class = "p" > (< / span > < span class = "s" > ' Filter logging output. Possible values:' < / span > < span class = "o" > +< / span >
2013-12-20 15:00:09 +00:00
< span class = "s" > ' CRITICAL, ERROR, WARNING, INFO, DEBUG' < / span > < span class = "p" > ))< / span >
2013-12-17 08:42:53 +00:00
< span class = "n" > parser< / span > < span class = "o" > .< / span > < span class = "n" > add_argument< / span > < span class = "p" > (< / span > < span class = "s" > ' --host' < / span > < span class = "p" > ,< / span > < span class = "n" > default< / span > < span class = "o" > =< / span > < span class = "s" > ' http://localhost:5000' < / 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" > ' insert' < / span > < span class = "p" > ,< / span > < span class = "s" > ' in' < / 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 >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< 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" > ' balance' < / span > < span class = "p" > ,< / span > < span class = "s" > ' bal' < / 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" > ' register' < / span > < span class = "p" > ,< / span > < span class = "s" > ' reg' < / 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" > ' __main__' < / 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" >
2013-12-20 15:00:09 +00:00
< 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 >
2013-12-17 08:42:53 +00:00
< 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 >
2013-12-20 15:00:09 +00:00
< div class = "footer" >
© Copyright 2013, Joar Wandborg.
Created using < a href = "http://sphinx.pocoo.org/" > Sphinx< / a > .
< / div >
2013-12-17 08:42:53 +00:00
< / body >
< / html >