{ "info": { "author": "Cesar Lopez Ramirez", "author_email": "cesar.lopez@somenergia.coop", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "somenergia-utils\n================\n\nThis module includes different Python modules and scripts ubiquiously\nused on scripts in SomEnergia cooperative but with no entity by\nthemselves to have their own repository.\n\n- ``venv``: run a command under a Python virtual enviroment\n- ``sql2csv.py``: script to run parametrized sql queries and get the\n result as (tab separated) csv.\n- ``dbutils.py``: module with db related functions\n\n - ``fetchNs``: a generator that wraps db cursors to fetch objects\n with attributes instead of psycopg arrays\n - ``nsList``: uses the former to build a list of such object (slower\n but maybe convinient)\n - ``csvTable``: turns the results of a query into a tab separated\n table with proper header names\n\n- ``sheetfetcher.py``: convenience class to retrieve data from gdrive\n spreadshets\n- ``trace``: quickly enable and disable tracing function calling by\n decorating them with ``@trace``\n- ``testutils``: module with common test utilities\n\n - ``testutils.assertNsEqual``: structure equality assertion using\n sorted key yaml dumps\n - ``testutils.destructiveTest``: decorator to avoid running\n destructive tests in production\n\n``venv`` script\n---------------\n\nThis script is useful to run Python scripts under a given virtual\nenvironment. It is specially useful to run Python scripts from crontab\nlines.\n\n.. code:: bash\n\n usage: venv /PATH/TO/PYTHON/VIRTUALENV COMMAND [PARAM1 [PARAM2...]]\n\n``sql2csv.py`` script\n---------------------\n\nRuns an SQL file and outputs the result of the query as tabulator\nseparated csv.a\n\nYou can provide query parameters either as yamlfile or as commandline\noptions.\n\n.. code:: bash\n\n sql2csv.py [] [-- [-- ..] ]\n\n``dbutils`` Python module\n-------------------------\n\nConvenient cursor wrappers to make the database access code more\nreadable.\n\nExample:\n\n.. code:: python\n\n import psycopg2, dbutils\n db = psycopg2.connect(**dbconfiguration)\n with db.cursor() as cursor :\n cursor.execute(\"SELECT name, age FROM people\")\n for person as dbutils.fetchNs(cursor):\n if person.age < 21: continue\n print(\"{name} is {age} years old\".format(person))\n\n``sheetfetcher`` Python module\n------------------------------\n\nConvenient wraper for gdrive.\n\n.. code:: python\n\n from sheetfetcher import SheetFetcher\n\n fetcher = SheetFetcher(\n documentName='My Document',\n credentialFilename='drive-certificate.json',\n )\n table = fetcher.get_range(\"My Sheet\", \"A2:F12\")\n fulltable = fetcher.get_fullsheet(\"My Sheet\")\n\n- Document selectors can be either an uri or the title\n- Sheet selectors can be either an index, a name or an id.\n- Range selectors can be either a named range, index tuple or a \"A2:F5\"\n coordinates.\n- You should `Create a certificate and grant it access to the\n document `__\n\ntrace\n-----\n\nThis decorator is a fast helper to trace calls to functions and methods.\nIt will show the name of the functions the values of the parameters and\nthe returned values.\n\n.. code:: python\n\n from trace import trace\n\n @trace\n def factorial(n):\n if n<1: return 1\n return n*factorial(n-1)\n\n factorial(8)\n\n ('> factorial', (8,))\n ('> factorial', (7,))\n ('> factorial', (6,))\n ('> factorial', (5,))\n ('> factorial', (4,))\n ('> factorial', (3,))\n ('> factorial', (2,))\n ('> factorial', (1,))\n ('> factorial', (0,))\n ('< factorial', (0,), '->', 1)\n ('< factorial', (1,), '->', 1)\n ('< factorial', (2,), '->', 2)\n ('< factorial', (3,), '->', 6)\n ('< factorial', (4,), '->', 24)\n ('< factorial', (5,), '->', 120)\n ('< factorial', (6,), '->', 720)\n ('< factorial', (7,), '->', 5040)\n ('< factorial', (8,), '->', 40320)\n\n``testutils.assertNsEqual``\n---------------------------\n\nAllows to assert equality on json/yaml like structures combining dicts,\nlists, numbers, strings, dates... The comparision is done on the YAML\noutput so that differences are spoted as text diffs. Also keys in dicts\nare alphabetically sorted.\n\n``testutils.destructiveTest``\n-----------------------------\n\nAn utility to avoid running destrutive tests in production. It is a\ndecorator that checks wheter the erp configured in ``dbconfig`` has the\ntesting flag and skips the test if it doesn't.\n\nThe script ``enable_destructive_test.py`` is also provided to set/unset\nthat testing flag which is not defined by default.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Som-Energia/somenergia-utils", "keywords": "", "license": "GNU General Public License v3 or later (GPLv3+)", "maintainer": "", "maintainer_email": "", "name": "somutils", "package_url": "https://pypi.org/project/somutils/", "platform": "", "project_url": "https://pypi.org/project/somutils/", "project_urls": { "Homepage": "https://github.com/Som-Energia/somenergia-utils" }, "release_url": "https://pypi.org/project/somutils/1.5.2/", "requires_dist": null, "requires_python": "", "summary": "Tools we use at Somenergia and can be useful", "version": "1.5.2" }, "last_serial": 5923613, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "b59dc6734c09b79722888c72a282f3e0", "sha256": "5e5914c16a3688b5d2206fe095bd520e8fe639acee9250fe58f842ef25d72a9d" }, "downloads": -1, "filename": "somutils-1.0.tar.gz", "has_sig": false, "md5_digest": "b59dc6734c09b79722888c72a282f3e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3727, "upload_time": "2016-04-12T15:56:39", "url": "https://files.pythonhosted.org/packages/0f/fa/815d8798a9b825b4e3728126505b4814eacab4118f6c674c86eaa4c8981d/somutils-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "e28b30a784f654f6a7f0a3ff781a512a", "sha256": "2d5f72975e51c294373ecf92897b352c9982eb580c269686223c734e693b7316" }, "downloads": -1, "filename": "somutils-1.1.tar.gz", "has_sig": false, "md5_digest": "e28b30a784f654f6a7f0a3ff781a512a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4439, "upload_time": "2016-04-19T07:47:47", "url": "https://files.pythonhosted.org/packages/c1/2c/0a04b6a3c261961201a9053699444e502882ca4f3237ce02e3b1df86a312/somutils-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "396d439ba30a8903e19e8cb0002c29a9", "sha256": "e35784b40a29014767f3b19ac584eceb3983b17e395e9bbe6aae397d3c04c2b2" }, "downloads": -1, "filename": "somutils-1.2.tar.gz", "has_sig": false, "md5_digest": "396d439ba30a8903e19e8cb0002c29a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4561, "upload_time": "2016-04-29T08:13:14", "url": "https://files.pythonhosted.org/packages/f5/ef/a5738a4da94ccb8c562ec22a593a54298db67de031adee49267362a04ef5/somutils-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "67f5d1022e44e4b6fb7e292bb13beb1f", "sha256": "bdf853f64e22d942f61406ff297dd03b16a21b9d7f59df17655e04d1d2d711ef" }, "downloads": -1, "filename": "somutils-1.3.tar.gz", "has_sig": false, "md5_digest": "67f5d1022e44e4b6fb7e292bb13beb1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4542, "upload_time": "2016-06-09T16:18:16", "url": "https://files.pythonhosted.org/packages/e9/ca/a0ba5c9bf59d5d390f0275b8ca49edd50662ce29b38b75fa265e8b889cd8/somutils-1.3.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "025273907532590200ca41ab23c25f9b", "sha256": "b822d7fe8362ae27b5f1cb9df45e2f0a0ebf5e304dec5eb9b164ab6a6a36b90c" }, "downloads": -1, "filename": "somutils-1.5.tar.gz", "has_sig": false, "md5_digest": "025273907532590200ca41ab23c25f9b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6517, "upload_time": "2019-09-06T07:32:25", "url": "https://files.pythonhosted.org/packages/23/0d/698b315f5686c16bb65377088263a376aa9c8e20f2e2694348da44ba796b/somutils-1.5.tar.gz" } ], "1.5.2": [ { "comment_text": "", "digests": { "md5": "202e0cff3a0f3976cb6d5915beb40e3d", "sha256": "18a5dd7fedf8e6532806486a74fc4023eb50971c10550785276cf4494c7db7d8" }, "downloads": -1, "filename": "somutils-1.5.2.tar.gz", "has_sig": false, "md5_digest": "202e0cff3a0f3976cb6d5915beb40e3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7004, "upload_time": "2019-10-03T13:56:15", "url": "https://files.pythonhosted.org/packages/4a/b6/fd616edb7f22643bac46fc5c218f64fe3328f8fbb7a443cd27246077f30e/somutils-1.5.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "202e0cff3a0f3976cb6d5915beb40e3d", "sha256": "18a5dd7fedf8e6532806486a74fc4023eb50971c10550785276cf4494c7db7d8" }, "downloads": -1, "filename": "somutils-1.5.2.tar.gz", "has_sig": false, "md5_digest": "202e0cff3a0f3976cb6d5915beb40e3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7004, "upload_time": "2019-10-03T13:56:15", "url": "https://files.pythonhosted.org/packages/4a/b6/fd616edb7f22643bac46fc5c218f64fe3328f8fbb7a443cd27246077f30e/somutils-1.5.2.tar.gz" } ] }