ushlex


Nameushlex JSON
Version 0.99.1 PyPI version JSON
download
home_pagehttps://bitbucket.org/mixmastamyk/ushlex
SummaryReplacement for shlex (that works with unicode) for Python 2.X.
upload_time2018-08-22 15:40:31
maintainer
docs_urlNone
authorMike Miller
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
Inspired by ordereddict,
this is a packaging of an improved shlex module for Python 2 that handles
Unicode properly.

Shlex is "A lexical analyzer class for simple shell-like syntaxes."

If you've found your way here,
you probably already know that the standard shlex doesn't handle Unicode prior
to Python 3
(see `bug 1170 <http://bugs.python.org/issue1170>`_ for details).
Since Python 2.7.3 however,
it accepts unicode objects.
Sadly, it still does not handle non-ascii chars:

.. code-block:: python

    >>> import sys, shlex
    >>> sys.version
    '2.7.5+ ...'
    >>> shlex.split(u'Hello world')
    ['Hello', 'world']

    >>> shlex.split(u'café')
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "/usr/lib/python2.7/shlex.py", line 275, in split
        lex = shlex(s, posix=posix)
      File "/usr/lib/python2.7/shlex.py", line 25, in __init__
        instream = StringIO(instream)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
                         position 3: ordinal not in range(128)


This module *does* handle unicode objects and byte strings under Python 2.x:

.. code-block:: python

    >>> import ushlex as shlex
    >>> shlex.split(u'café')
    [u'caf\xe9']

    >>> shlex.split(u'echo "☺ ☕ ♫"')
    [u'echo', u'\u263a \u2615 \u266b']

    >>> from ushlex import split as shplit
    >>> shplit('echo "hello there"')
    ['echo', 'hello there']

I found these release notes inside::

    # Module and documentation by Eric S. Raymond, 21 Dec 1998
    # Input stacking and error message cleanup added by ESR, March 2000
    # push_source() and pop_source() made explicit by ESR, January 2001.
    # Posix compliance, split(), string arguments, and
    # iterator interface by Gustavo Niemeyer, April 2003.
    # Modified to support Unicode by Colin Walters, Dec 2007


Bugs
------

Packaging-only bugs may be submitted to bitbucket.
*Do not* enter bugs for ushlex itself,
as the packager is not the author.


            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/mixmastamyk/ushlex",
    "name": "ushlex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mike Miller",
    "author_email": "no@reply.com",
    "download_url": "https://files.pythonhosted.org/packages/48/e0/33fa11058c8efc51ba3520ceb85c9fa0c5e42ce414b885fcd5e12132d13b/ushlex-0.99.1.tar.gz",
    "platform": "",
    "description": "\nInspired by ordereddict,\nthis is a packaging of an improved shlex module for Python 2 that handles\nUnicode properly.\n\nShlex is \"A lexical analyzer class for simple shell-like syntaxes.\"\n\nIf you've found your way here,\nyou probably already know that the standard shlex doesn't handle Unicode prior\nto Python 3\n(see `bug 1170 <http://bugs.python.org/issue1170>`_ for details).\nSince Python 2.7.3 however,\nit accepts unicode objects.\nSadly, it still does not handle non-ascii chars:\n\n.. code-block:: python\n\n    >>> import sys, shlex\n    >>> sys.version\n    '2.7.5+ ...'\n    >>> shlex.split(u'Hello world')\n    ['Hello', 'world']\n\n    >>> shlex.split(u'caf\u00e9')\n    Traceback (most recent call last):\n      File \"<input>\", line 1, in <module>\n      File \"/usr/lib/python2.7/shlex.py\", line 275, in split\n        lex = shlex(s, posix=posix)\n      File \"/usr/lib/python2.7/shlex.py\", line 25, in __init__\n        instream = StringIO(instream)\n    UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe9' in\n                         position 3: ordinal not in range(128)\n\n\nThis module *does* handle unicode objects and byte strings under Python 2.x:\n\n.. code-block:: python\n\n    >>> import ushlex as shlex\n    >>> shlex.split(u'caf\u00e9')\n    [u'caf\\xe9']\n\n    >>> shlex.split(u'echo \"\u263a \u2615 \u266b\"')\n    [u'echo', u'\\u263a \\u2615 \\u266b']\n\n    >>> from ushlex import split as shplit\n    >>> shplit('echo \"hello there\"')\n    ['echo', 'hello there']\n\nI found these release notes inside::\n\n    # Module and documentation by Eric S. Raymond, 21 Dec 1998\n    # Input stacking and error message cleanup added by ESR, March 2000\n    # push_source() and pop_source() made explicit by ESR, January 2001.\n    # Posix compliance, split(), string arguments, and\n    # iterator interface by Gustavo Niemeyer, April 2003.\n    # Modified to support Unicode by Colin Walters, Dec 2007\n\n\nBugs\n------\n\nPackaging-only bugs may be submitted to bitbucket.\n*Do not* enter bugs for ushlex itself,\nas the packager is not the author.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Replacement for shlex (that works with unicode) for Python 2.X.",
    "version": "0.99.1",
    "project_urls": {
        "Download": "https://bitbucket.org/mixmastamyk/ushlex/get/default.tar.gz",
        "Homepage": "https://bitbucket.org/mixmastamyk/ushlex"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48e033fa11058c8efc51ba3520ceb85c9fa0c5e42ce414b885fcd5e12132d13b",
                "md5": "16fb530e4cfc589dd615d043f075bfdc",
                "sha256": "6d681561545a9781430d5254eab9a648bade78c82ffd127d56c9228ae8887d46"
            },
            "downloads": -1,
            "filename": "ushlex-0.99.1.tar.gz",
            "has_sig": false,
            "md5_digest": "16fb530e4cfc589dd615d043f075bfdc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4712,
            "upload_time": "2018-08-22T15:40:31",
            "upload_time_iso_8601": "2018-08-22T15:40:31.562692Z",
            "url": "https://files.pythonhosted.org/packages/48/e0/33fa11058c8efc51ba3520ceb85c9fa0c5e42ce414b885fcd5e12132d13b/ushlex-0.99.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2018-08-22 15:40:31",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "mixmastamyk",
    "bitbucket_project": "ushlex",
    "lcname": "ushlex"
}
        
Elapsed time: 0.75484s