python-textops3


Namepython-textops3 JSON
Version 3.2.1 PyPI version JSON
download
home_pagehttps://github.com/elapouya/python-textops3
SummaryPython text operations module
upload_time2022-04-25 12:09:51
maintainer
docs_urlNone
authorEric Lapouyade
requires_python
licenseLGPL 2.1
keywords textops
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===============
Getting started
===============

| python-textops3 provides many text operations at string level, list level or whole text level.
| These operations can be chained with a 'dotted' or 'piped' notation.
| Chained operations are stored into a single lazy object, they will be executed only when an input text will be provided.

Install
-------

To install::

    pip install python-textops3

Overview
--------

The usual way to use textops is something like below. IMPORTANT : Note that textops library redefines
the python **bitwise OR** operator '|' in order to use it as a 'pipe' like in a Unix shell::

   from textops import *

   result = "an input text" | my().chained().operations()

   or

   for result_item in "an input text" | my().chained().operations():
      do_something(result_item)

   or

   myops = my().chained().operations()
   # and later in the code, use them :
   result = myops("an input text")
   or
   result = "an input text" | myops

An "input text" can be :

   * a simple string,
   * a multi-line string (one string having newlines),
   * a list of strings,
   * a strings generator,
   * a list of lists (useful when you cut lines into columns),
   * a list of dicts (useful when you parse a line).

So one can do::

   >>> 'line1line2line3' | grep('2').tolist()
   ['line1line2line3']
   >>> 'line1\nline2\nline3' | grep('2').tolist()
   ['line2']
   >>> ['line1','line2','line3'] | grep('2').tolist()
   ['line2']
   >>> [['line','1'],['line','2'],['line','3']] | grep('2').tolist()
   [['line', '2']]
   >>> [{'line':1},{'line':'2'},{'line':3}] | grep('2').tolist()
   [{'line': '2'}]

Examples
--------

Piped then dotted notation (recommended)::

   >>> print('this is an error\nthis is a warning' | grepi('error').first().upper())
   THIS IS AN ERROR

You could use the pipe everywhere (internally a little less optimized, but looks like shell)::

   >>> print('this is an error\nthis is a warning' | grepi('error') | first() | strop.upper())
   THIS IS AN ERROR

To execute an operation directly from strings, lists or dicts *with the dotted notation*,
you must use textops Extended types : ``StrExt``, ``ListExt`` or ``DictExt``::

   >>> s = StrExt('this is an error\nthis is a warning')
   >>> print(s.grepi('error').first().upper())
   THIS IS AN ERROR

Documentation
-------------

Please, `read documentation here : <http://python-textops3.readthedocs.org>`_

News
====

3.2.1 (2022-03-31)
------------------
* add Python 3.10 support

3.1.0 (2020-06-25)
------------------
* add TupleExt
* DictExt now support pickle

3.0.8 (2019-10-08)
------------------
* add encoding & encoding_errors arguments to cat()

3.0.7 (2019-10-01)
------------------
* add separators argument to parse_smart()

3.0.6 (2019-09-25)
------------------
* add key_filter argument to parse_smart()

3.0.5 (2019-06-14)
------------------
* add decode_bytes()

3.0.3 (2018-11-07)
------------------

* Migrate from python 2 to python 3





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/elapouya/python-textops3",
    "name": "python-textops3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "textops",
    "author": "Eric Lapouyade",
    "author_email": "elapouya@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6d/ba/116d6220c6e844bb64c9af9f97dabdff1a07b23449b4ae651e78e7a984dd/python-textops3-3.2.1.tar.gz",
    "platform": null,
    "description": "===============\nGetting started\n===============\n\n| python-textops3 provides many text operations at string level, list level or whole text level.\n| These operations can be chained with a 'dotted' or 'piped' notation.\n| Chained operations are stored into a single lazy object, they will be executed only when an input text will be provided.\n\nInstall\n-------\n\nTo install::\n\n    pip install python-textops3\n\nOverview\n--------\n\nThe usual way to use textops is something like below. IMPORTANT : Note that textops library redefines\nthe python **bitwise OR** operator '|' in order to use it as a 'pipe' like in a Unix shell::\n\n   from textops import *\n\n   result = \"an input text\" | my().chained().operations()\n\n   or\n\n   for result_item in \"an input text\" | my().chained().operations():\n      do_something(result_item)\n\n   or\n\n   myops = my().chained().operations()\n   # and later in the code, use them :\n   result = myops(\"an input text\")\n   or\n   result = \"an input text\" | myops\n\nAn \"input text\" can be :\n\n   * a simple string,\n   * a multi-line string (one string having newlines),\n   * a list of strings,\n   * a strings generator,\n   * a list of lists (useful when you cut lines into columns),\n   * a list of dicts (useful when you parse a line).\n\nSo one can do::\n\n   >>> 'line1line2line3' | grep('2').tolist()\n   ['line1line2line3']\n   >>> 'line1\\nline2\\nline3' | grep('2').tolist()\n   ['line2']\n   >>> ['line1','line2','line3'] | grep('2').tolist()\n   ['line2']\n   >>> [['line','1'],['line','2'],['line','3']] | grep('2').tolist()\n   [['line', '2']]\n   >>> [{'line':1},{'line':'2'},{'line':3}] | grep('2').tolist()\n   [{'line': '2'}]\n\nExamples\n--------\n\nPiped then dotted notation (recommended)::\n\n   >>> print('this is an error\\nthis is a warning' | grepi('error').first().upper())\n   THIS IS AN ERROR\n\nYou could use the pipe everywhere (internally a little less optimized, but looks like shell)::\n\n   >>> print('this is an error\\nthis is a warning' | grepi('error') | first() | strop.upper())\n   THIS IS AN ERROR\n\nTo execute an operation directly from strings, lists or dicts *with the dotted notation*,\nyou must use textops Extended types : ``StrExt``, ``ListExt`` or ``DictExt``::\n\n   >>> s = StrExt('this is an error\\nthis is a warning')\n   >>> print(s.grepi('error').first().upper())\n   THIS IS AN ERROR\n\nDocumentation\n-------------\n\nPlease, `read documentation here : <http://python-textops3.readthedocs.org>`_\n\nNews\n====\n\n3.2.1 (2022-03-31)\n------------------\n* add Python 3.10 support\n\n3.1.0 (2020-06-25)\n------------------\n* add TupleExt\n* DictExt now support pickle\n\n3.0.8 (2019-10-08)\n------------------\n* add encoding & encoding_errors arguments to cat()\n\n3.0.7 (2019-10-01)\n------------------\n* add separators argument to parse_smart()\n\n3.0.6 (2019-09-25)\n------------------\n* add key_filter argument to parse_smart()\n\n3.0.5 (2019-06-14)\n------------------\n* add decode_bytes()\n\n3.0.3 (2018-11-07)\n------------------\n\n* Migrate from python 2 to python 3\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL 2.1",
    "summary": "Python text operations module",
    "version": "3.2.1",
    "split_keywords": [
        "textops"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c5a0f03be7363710c519b1874cfd525e66a05d24da7c710c9634d6d5568efa5",
                "md5": "f044e1450e61b867ad19f2bca1e6eff5",
                "sha256": "da9c5358d132e4d90b52792d0e9bcee81f5f03f5320b4456f2429588f1cd7903"
            },
            "downloads": -1,
            "filename": "python_textops3-3.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f044e1450e61b867ad19f2bca1e6eff5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 62155,
            "upload_time": "2022-04-25T12:09:49",
            "upload_time_iso_8601": "2022-04-25T12:09:49.955723Z",
            "url": "https://files.pythonhosted.org/packages/1c/5a/0f03be7363710c519b1874cfd525e66a05d24da7c710c9634d6d5568efa5/python_textops3-3.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6dba116d6220c6e844bb64c9af9f97dabdff1a07b23449b4ae651e78e7a984dd",
                "md5": "9fea8ea35142652437c9aba2c8551350",
                "sha256": "b99768eda465a333bfd61ac75fafc71044f1d4d8fc67568d8e0163316805f39d"
            },
            "downloads": -1,
            "filename": "python-textops3-3.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9fea8ea35142652437c9aba2c8551350",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 89927,
            "upload_time": "2022-04-25T12:09:51",
            "upload_time_iso_8601": "2022-04-25T12:09:51.820223Z",
            "url": "https://files.pythonhosted.org/packages/6d/ba/116d6220c6e844bb64c9af9f97dabdff1a07b23449b4ae651e78e7a984dd/python-textops3-3.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-04-25 12:09:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "elapouya",
    "github_project": "python-textops3",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-textops3"
}
        
Elapsed time: 0.03053s