********************
CleanIO Project
********************
CleanIO is a simple project illustrating how to use the yield statement to
make reading and writing text files simple and to remove the clutter and
boilerplate from your mainstream code.
Usage
********
Read a Text File
==================
To read a text file.
1. Add an import statement
``from cleanio import CleanRead``
2. Create an instance of the ``CleanRead`` class and pass it the desired filename or path
``cr = CleanRead(<<file name or path>>)``
3. Accept each line of the file from the generator (e.g. with a ``for`` statement) from the ``clean_read`` method
``for line in cr.clean_read():``
4. When the generator finishes, it will return a ``StopIteration`` exception (which the for statement will handle automatically
The file is opened, read, and closed automatically with no extra boilerplate
needed.
Write a Text File
=====================
To write a text file:
1. Add an import statement.
``from cleanio import CleanWrite``
2. Create an instance of the ``CleanWrite`` class and pass it the desired filename or path.
``cw = CleanWrite(<<file name or path>>)``
3. Send each line of the file to the generator via the ``clean_writeline`` method
``cw.clean_writeline(<<line>>)``
4. When done, notify the generator
``cw.clean_close()``
The file is opened, written, and closed automatically with no extra
boilerplate needed.
Comments
=============
- Read or write as many files as you need.
- This has not been tested with async calls.
- This code has been formatted with the ``blue`` library.
Structure
********************
CleanIO consists of two classes, one for reading a text file and one for
writing a text file.
Each class uses the ``yield`` statement for maintaining the position of the
file and its place in the method. Other "boilerplate" code, such as the
open, starting the generator, and closing is handled automatically in the
class.
Possible Future Enhancements
===============================
There are several possible enhancement to this module that come to mind.
Currently this module is designed to read and write text files. It
could be enhanced to also read and write binary files.
Currently the CleanWrite class assumes it will be getting one line at a
time (without the newline or '\\n' at the end). It could be enhanced to
output partial lines or multiple lines at a time if the user desires to put
the line endings on themselves.
Raw data
{
"_id": null,
"home_page": "https://github.com/deeppunster/CleanIO/",
"name": "CleanIO",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "IO, yield",
"author": "Travis Risner",
"author_email": "cleanio@punmyword.com",
"download_url": "https://files.pythonhosted.org/packages/d1/4b/83c64aefd1acd2f0133205f829c75e4d3a35f5bb87fa987343cbf310ca53/cleanio-0.1.4.tar.gz",
"platform": null,
"description": "********************\nCleanIO Project\n********************\n\nCleanIO is a simple project illustrating how to use the yield statement to\nmake reading and writing text files simple and to remove the clutter and\nboilerplate from your mainstream code.\n\nUsage\n********\n\nRead a Text File\n==================\n\nTo read a text file.\n\n 1. Add an import statement\n\n ``from cleanio import CleanRead``\n\n 2. Create an instance of the ``CleanRead`` class and pass it the desired filename or path\n\n ``cr = CleanRead(<<file name or path>>)``\n\n 3. Accept each line of the file from the generator (e.g. with a ``for`` statement) from the ``clean_read`` method\n\n ``for line in cr.clean_read():``\n\n 4. When the generator finishes, it will return a ``StopIteration`` exception (which the for statement will handle automatically\n\nThe file is opened, read, and closed automatically with no extra boilerplate\nneeded.\n\nWrite a Text File\n=====================\n\nTo write a text file:\n\n 1. Add an import statement.\n\n ``from cleanio import CleanWrite``\n\n 2. Create an instance of the ``CleanWrite`` class and pass it the desired filename or path.\n\n ``cw = CleanWrite(<<file name or path>>)``\n\n 3. Send each line of the file to the generator via the ``clean_writeline`` method\n\n ``cw.clean_writeline(<<line>>)``\n\n 4. When done, notify the generator\n\n ``cw.clean_close()``\n\nThe file is opened, written, and closed automatically with no extra\nboilerplate needed.\n\nComments\n=============\n\n- Read or write as many files as you need.\n- This has not been tested with async calls.\n- This code has been formatted with the ``blue`` library.\n\nStructure\n********************\nCleanIO consists of two classes, one for reading a text file and one for\nwriting a text file.\n\nEach class uses the ``yield`` statement for maintaining the position of the\nfile and its place in the method. Other \"boilerplate\" code, such as the\nopen, starting the generator, and closing is handled automatically in the\nclass.\n\nPossible Future Enhancements\n===============================\n\nThere are several possible enhancement to this module that come to mind.\n\nCurrently this module is designed to read and write text files. It\ncould be enhanced to also read and write binary files.\n\nCurrently the CleanWrite class assumes it will be getting one line at a\ntime (without the newline or '\\\\n' at the end). It could be enhanced to\noutput partial lines or multiple lines at a time if the user desires to put\nthe line endings on themselves.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple IO eliminating the boilerplate.",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/deeppunster/CleanIO/",
"Issues": "https://github.com/deeppunster/CleanIO/issues",
"Repository": "https://github.com/deeppunster/CleanIO/"
},
"split_keywords": [
"io",
" yield"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f2b44659a2a0bad1086fb3f2dc8217225178a2824fb3a25f14af30a816f1704c",
"md5": "a6af1ebeb5cbeafdc25aab231812f89c",
"sha256": "297af38115c248a677b210f6771dfdc356926aacaf14b3cf7a6a8c36fdfc2d03"
},
"downloads": -1,
"filename": "cleanio-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6af1ebeb5cbeafdc25aab231812f89c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4369,
"upload_time": "2024-08-23T07:47:22",
"upload_time_iso_8601": "2024-08-23T07:47:22.604413Z",
"url": "https://files.pythonhosted.org/packages/f2/b4/4659a2a0bad1086fb3f2dc8217225178a2824fb3a25f14af30a816f1704c/cleanio-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d14b83c64aefd1acd2f0133205f829c75e4d3a35f5bb87fa987343cbf310ca53",
"md5": "51ba8fec6a3f42f5d7ada4516629e70c",
"sha256": "cc4bb2ba837c17a8669969f80c0b119e51d349634590644281621499bd322229"
},
"downloads": -1,
"filename": "cleanio-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "51ba8fec6a3f42f5d7ada4516629e70c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3803,
"upload_time": "2024-08-23T07:47:24",
"upload_time_iso_8601": "2024-08-23T07:47:24.147372Z",
"url": "https://files.pythonhosted.org/packages/d1/4b/83c64aefd1acd2f0133205f829c75e4d3a35f5bb87fa987343cbf310ca53/cleanio-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-23 07:47:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "deeppunster",
"github_project": "CleanIO",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "cleanio"
}