{ "info": { "author": "Thomas Levine", "author_email": "Thomas Levine", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: SQL", "Topic :: Database :: Front-Ends" ], "description": "pytreasuryio\n======\nAccess .. _treasury.io: http://treasury.io from Python.\n\nThis is a package consisting of a single, simple function for submitting ``SQL`` queries to .. _treasury.io: http://treasury.io from ``python``. While you could simply copy-and-paste the function from script-to-script, this makes it quicker and easier to get up and running!\n\nIt also has some helpers to make a Twitter bot from the treasury.io data.\n\nInstallation\n--------\nInstall with pip.::\n\n pip install treasuryio\n\nExample\n---------\n\nBasic query\n~~~~~~~~~\nSend an SQL query and receive a pandas data frame.::\n\n # Operating cash balances for May 22, 2013\n import treasuryio\n sql = 'SELECT * FROM \"t1\" WHERE \"date\" = \\'2013-05-22\\';'\n treasuryio.query(sql)\n\nTwitter bot\n~~~~~~~~~\nWrite a ``~/.twitter.yml`` file.::\n\n consumer_key: oeshaoduhsaousaoeuhts\n consumer_secret: b233tsao-enuhsaoehsunoesudtuhoelaouhs2uo\n access_token: 2349081293-astoehusatoehusaoeustahoeuhh2AOEUTAouhc\n access_token_secret: 9023uonshesuaHONETuoeuoeouo0eOHNEuhOuoeu\n\nDefine a function that produces the text of the tweet, and decorate it with the\n``@treasurio.tweet`` decorator.::\n\n import treasuryio\n import humanize\n import math\n\n MIL = 1e6\n\n # Helpers to humanize numbers / dates\n def human_number(num):\n return humanize.intword(int(math.ceil(num))).lower()\n\n def human_date(date):\n return humanize.naturalday(date).title()\n\n @treasuryio.tweet\n def total_debt_tweet():\n df = treasuryio.query('SELECT date, close_today FROM t3c WHERE (item LIKE \\'%subject to limit%\\' AND year = 2013 AND month >=1) ORDER BY date DESC')\n\n # determine length of DataFrame\n end = len(df)-1\n\n # extract current amount and amount at the beginning of the year\n current_amt = df['close_today'][0]*MIL\n previous_amt = df['close_today'][end]*MIL\n\n # calculate change\n delta = abs(current_amt - previous_amt)\n\n # generate word to represnet the direction of change\n if current_amt > previous_amt:\n change = \"increased\"\n elif current_amt < previous_amt:\n change = \"decreased\"\n\n # humanize values\n # Notice the included ``human_date`` and ``human_number`` functions which simplify these values for you\n current_date = human_date(df['date'][0])\n amt = human_number(current_amt)\n delta = human_number(delta)\n previous_date = human_date(df['date'][end])\n\n # generate tweet\n vals = (current_date, amt, change, previous_date, 'http://treasury.io')\n return \"As of %s, the US Gov is $%s in debt. This amount has %s since %s - %s\" % vals\n\nThen just run it.::\n\n total_debt_tweet()\n\nYou can get fancy by switching the functions that you use.::\n\n import treasuryio\n import random\n\n @treasurio.tweet\n def tweet_a():\n # ...\n\n @treasurio.tweet\n def tweet_b():\n # ...\n\n @treasurio.tweet\n def tweet_c():\n # ...\n\n random.choice([tweet_a, tweet_b, tweet_c])()", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/csvsoundsystem/pytreasuryio.git", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "treasuryio", "package_url": "https://pypi.org/project/treasuryio/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/treasuryio/", "project_urls": { "Homepage": "https://github.com/csvsoundsystem/pytreasuryio.git" }, "release_url": "https://pypi.org/project/treasuryio/0.0.4/", "requires_dist": [ "pandas", "tweepy" ], "requires_python": "", "summary": "Query treasury.io through Python, returning Pandas DataFrames", "version": "0.0.4" }, "last_serial": 2401568, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a163da54ff30e61f4e858effcf1f9887", "sha256": "2c22b4430a13ae3b9c07d980e7e19312ee1138fdac88761d21222d85f3932de9" }, "downloads": -1, "filename": "treasuryio-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a163da54ff30e61f4e858effcf1f9887", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3719, "upload_time": "2013-06-28T18:55:48", "url": "https://files.pythonhosted.org/packages/0a/19/c793e28cd8910b89571d2023d0e4de6c92b6b2028f68c1fc115bb043aab6/treasuryio-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "c87cd62cd942c0118a9c6b122ae2d4a3", "sha256": "5913d9dfe7678963830993d3e776c0d420f9220cabe3ee12f3dba224a6f9921a" }, "downloads": -1, "filename": "treasuryio-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c87cd62cd942c0118a9c6b122ae2d4a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4032, "upload_time": "2013-06-28T19:03:20", "url": "https://files.pythonhosted.org/packages/c7/6b/25eb8c9eed6e6bd25163686ab4c4278872fdf75bad1a49bbaceddf364481/treasuryio-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e18d6bdd39b9958e95b62ce091842571", "sha256": "0056abe8ddda8951866075475619401c4f2ed0163438cb5197ee81c43cb68f57" }, "downloads": -1, "filename": "treasuryio-0.0.3.tar.gz", "has_sig": false, "md5_digest": "e18d6bdd39b9958e95b62ce091842571", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4287, "upload_time": "2013-06-28T20:28:30", "url": "https://files.pythonhosted.org/packages/f9/e9/57e4c4b7c1bdc64bbd7c542d71ae07363dd4d98c9c7880cf2b13f240cd7a/treasuryio-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "3bf7530ab315d1f4280753409006e488", "sha256": "2ab26e0c518ce943bf0b6e29b0dfdf7682f6ab6a8974d5a600a54f3036606330" }, "downloads": -1, "filename": "treasuryio-0.0.4-py2-none-any.whl", "has_sig": false, "md5_digest": "3bf7530ab315d1f4280753409006e488", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6960, "upload_time": "2016-10-15T19:59:45", "url": "https://files.pythonhosted.org/packages/78/ce/4f40c9fe8eb12affff2132d0aa0cc78b62efe912d461a9d12ea5c0c61f79/treasuryio-0.0.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "76b6bbee922990d25c513f28899359f3", "sha256": "dd0a376da309d08c8a8e78b998611fc7ccbcaf1bb609548ef1bbad97f8063164" }, "downloads": -1, "filename": "treasuryio-0.0.4.tar.gz", "has_sig": false, "md5_digest": "76b6bbee922990d25c513f28899359f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4357, "upload_time": "2016-10-15T19:59:48", "url": "https://files.pythonhosted.org/packages/dd/32/bc99c0bc0dc8599e84f4210883e585389f3e2322a92d89a39d7ae82ba67e/treasuryio-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3bf7530ab315d1f4280753409006e488", "sha256": "2ab26e0c518ce943bf0b6e29b0dfdf7682f6ab6a8974d5a600a54f3036606330" }, "downloads": -1, "filename": "treasuryio-0.0.4-py2-none-any.whl", "has_sig": false, "md5_digest": "3bf7530ab315d1f4280753409006e488", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6960, "upload_time": "2016-10-15T19:59:45", "url": "https://files.pythonhosted.org/packages/78/ce/4f40c9fe8eb12affff2132d0aa0cc78b62efe912d461a9d12ea5c0c61f79/treasuryio-0.0.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "76b6bbee922990d25c513f28899359f3", "sha256": "dd0a376da309d08c8a8e78b998611fc7ccbcaf1bb609548ef1bbad97f8063164" }, "downloads": -1, "filename": "treasuryio-0.0.4.tar.gz", "has_sig": false, "md5_digest": "76b6bbee922990d25c513f28899359f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4357, "upload_time": "2016-10-15T19:59:48", "url": "https://files.pythonhosted.org/packages/dd/32/bc99c0bc0dc8599e84f4210883e585389f3e2322a92d89a39d7ae82ba67e/treasuryio-0.0.4.tar.gz" } ] }