str2type


Namestr2type JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/geowurster/str2type
SummaryConvert a string representation of an int, float, None, True, False, or JSON to its native type. For None, True, and False, case is irrelevant.
upload_time2015-04-28 18:56:33
maintainerNone
docs_urlNone
authorKevin Wurster
requires_pythonNone
licenseNew BSD License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ========
str2type
========

Convert the string representation of a Python type to its native type.

.. image:: https://travis-ci.org/geowurster/str2type.svg?branch=master
    :target: https://travis-ci.org/geowurster/str2type?branch=master

.. image:: https://coveralls.io/repos/geowurster/str2type/badge.svg?branch=master
    :target: https://coveralls.io/r/geowurster/str2type?branch=master


Why?
====

When building commandline utilities the syntax ``--arg key=val`` is useful,
especially when ``key`` and ``val`` will be used as ``Class(key=val)`` internally.
This module was built specifically to be used with the CLI framework `click <http://click.pocoo.org/>`_, and the
included extensions play nicely, but the ``str2type.str2type()`` function can be
used elsewhere.


Examples
========

See the ``examples`` directory for `click integration examples <https://github.com/mitsuhiko/click>`_.  Everything else is primarily handled
by a single function:

.. code-block:: python

    >>> from str2type import str2type
    >>> print(str2type("1.23"))
    1.23
    >>> print(str2type("1.")
    1.0
    >>> print(str2type(".2"))
    0.2
    >>> print(str2type("None"))
    None
    >>> print(str2type('String'))
    'String'


Supported Types
===============

Only the standard builtin Python types plus JSON strings are supported:

- ``int``
- ``float``
- ``None``
- ``True``
- ``False``
- ``JSON``



Installing
==========

Via pip:

.. code-block:: console

    $ pip install str2type

From master branch:

.. code-block:: console

    $ git clone https://github.com/geowurster/str2type
    $ cd str2type
    $ pip install .


Developing
==========

Install:

.. code-block:: console

    $ pip install virtualenv
    $ git clone https://github.com/geowurster/str2type
    $ cd str2type
    $ virtualenv venv
    $ source venv/bin/activate
    $ pip install -r requirements-dev.txt -e .
    $ nosetests --with-coverage
    $ pep8 --max-line-length=95 str2type

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/geowurster/str2type",
    "name": "str2type",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Kevin Wurster",
    "author_email": "wursterk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/30/28/cf1f21ab9e42161fa61298b39ab34b4c7882e680424739484a1380b61d5f/str2type-0.4.1.tar.gz",
    "platform": null,
    "description": "========\nstr2type\n========\n\nConvert the string representation of a Python type to its native type.\n\n.. image:: https://travis-ci.org/geowurster/str2type.svg?branch=master\n    :target: https://travis-ci.org/geowurster/str2type?branch=master\n\n.. image:: https://coveralls.io/repos/geowurster/str2type/badge.svg?branch=master\n    :target: https://coveralls.io/r/geowurster/str2type?branch=master\n\n\nWhy?\n====\n\nWhen building commandline utilities the syntax ``--arg key=val`` is useful,\nespecially when ``key`` and ``val`` will be used as ``Class(key=val)`` internally.\nThis module was built specifically to be used with the CLI framework `click <http://click.pocoo.org/>`_, and the\nincluded extensions play nicely, but the ``str2type.str2type()`` function can be\nused elsewhere.\n\n\nExamples\n========\n\nSee the ``examples`` directory for `click integration examples <https://github.com/mitsuhiko/click>`_.  Everything else is primarily handled\nby a single function:\n\n.. code-block:: python\n\n    >>> from str2type import str2type\n    >>> print(str2type(\"1.23\"))\n    1.23\n    >>> print(str2type(\"1.\")\n    1.0\n    >>> print(str2type(\".2\"))\n    0.2\n    >>> print(str2type(\"None\"))\n    None\n    >>> print(str2type('String'))\n    'String'\n\n\nSupported Types\n===============\n\nOnly the standard builtin Python types plus JSON strings are supported:\n\n- ``int``\n- ``float``\n- ``None``\n- ``True``\n- ``False``\n- ``JSON``\n\n\n\nInstalling\n==========\n\nVia pip:\n\n.. code-block:: console\n\n    $ pip install str2type\n\nFrom master branch:\n\n.. code-block:: console\n\n    $ git clone https://github.com/geowurster/str2type\n    $ cd str2type\n    $ pip install .\n\n\nDeveloping\n==========\n\nInstall:\n\n.. code-block:: console\n\n    $ pip install virtualenv\n    $ git clone https://github.com/geowurster/str2type\n    $ cd str2type\n    $ virtualenv venv\n    $ source venv/bin/activate\n    $ pip install -r requirements-dev.txt -e .\n    $ nosetests --with-coverage\n    $ pep8 --max-line-length=95 str2type\n",
    "bugtrack_url": null,
    "license": "New BSD License",
    "summary": "Convert a string representation of an int, float, None, True, False, or JSON to its native type.  For None, True, and False, case is irrelevant.",
    "version": "0.4.1",
    "project_urls": {
        "Homepage": "https://github.com/geowurster/str2type"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3028cf1f21ab9e42161fa61298b39ab34b4c7882e680424739484a1380b61d5f",
                "md5": "8f02c42ca866161c54b498779411384c",
                "sha256": "f0682f079c225ff88006b12fa37f64e121c2b9e2d538a4611e4ef4a3ef982c05"
            },
            "downloads": -1,
            "filename": "str2type-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8f02c42ca866161c54b498779411384c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7206,
            "upload_time": "2015-04-28T18:56:33",
            "upload_time_iso_8601": "2015-04-28T18:56:33.805612Z",
            "url": "https://files.pythonhosted.org/packages/30/28/cf1f21ab9e42161fa61298b39ab34b4c7882e680424739484a1380b61d5f/str2type-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2015-04-28 18:56:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "geowurster",
    "github_project": "str2type",
    "github_not_found": true,
    "lcname": "str2type"
}
        
Elapsed time: 0.23178s