{ "info": { "author": "cjtx", "author_email": "cjtx.code@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# JustifyText\n#### *for monospaced fonts\n```\nTakes a string and inserts\nspaces between words, until\nline is desired width, like\nyou see here.\n```\n\n### Importing the module and using the function:\n* Option 1:\n```\nfrom justifytext import justify\njustify(text, width)\n\n```\n* Option 2:\n```\nimport justify\njustifytext.justify(text, width)\n```\n\n### Module Requirements/Dependencies:\n* Python code tab = 4 spaces\n* Requires textwrap module\n\n\n### Module Assumptions:\n* Line has at least one space between words (at least in this version).\n* Relies on break_on_long words equalling true in textwrapper. (You could make the change to the textwrapper function call in this module, but at a small enough width you would just get back lines with single words and nothing but spaces on the ends of them, i.e not justified.) \n\n\n### Required positional arguments:\n* text == string to be formatted as list of strings exactly n characters long (You'll have to handle quotes and special characters of course.) \n* width == desired width of the resulting line \n\n### Optional and default arguments: \n\n```\njustify_last_line = False\n```\nThis is the default for handling the final line of the string. Convention is to NOT stretch a few words across the span of the formatted block, but I've included a way to undo that - if that's your kind of thing. For example: \n\n```\n\ttext = \"The end of this bit of text will be these three words.\" \n\n\tjustify(text, 35) \n```\nwill return a list that can iterate over to display: \n```\n\tThe end of this bit of text will be\n\tthese three words.\n```\nwhereas \n```\n\tjustify(text, 35, justify_last_line = True) \n```\nwill return a iterable list that will display: \n```\n\tThe end of this bit of text will be\n\tthese three words.\n```\n### Module Flow: \n\n1.\tAccepts a string (Module seems to ignore \\n, not sure why yet -- I'm very tired. Probably has something to do with textwrap behavior. To preserve a special character, escape it, i.e. '\\\\n'). Otherwise normal string manipulation rules apply, you'll need to handle quotation marks and special characters accordingly. One of the earliest steps in this module puts text through textwrapper, so if your input doesn't raise a textwrapper error there, you should be all right. (Probably). \n\n2. \tBreak into lines no longer than n using textwrap and TextWrapper. See discussion at end of 1. above. \n\n3. \tLoop, starting from the last space (actually, the word before the last space), and walk backward, adding a space between words (on the theory that readers will be less likely to notice extra spaces when reading from left-to-right and encountering them at the end of a line. \n\n4. \tIf a line is still short after adding a space between all words in a line, module will start again at the last space (IOW, it enters a second or third or eighth space - beginning at the end - to reach desired width). \n\n5. \tOnce all lines are exactly n width, return list of lines. Module *could* just print them into a nice block, but I prefer to hand the reformatted text back to you, so you can do with it what you like. To display the reformatted text a simple iterable will do. \n\te.g.: \n```\n\tfor i in returnText:\n\tprint(i)\n```\n# Sample Usage\n\nRaw text: \n```\ntext = \"Now did the Lord say, \\\"First thou pullest the Holy Pin. Then thou must count to three.\nThree shall be the number of the counting and the number of the counting shall be three. Four\nshalt thou not count, neither shalt thou count two, excepting that thou then proceedeth to three.\nFive is right out. Once the number three, being the number of the counting, be reached, then lobbest\nthou the Holy Hand Grenade in the direction of thine foe, who, being naughty in my sight, shall snuff it.\" \n```\nCall: \n```\nx = justify(text, 30) \n```\n\nReturns: \n```\nx = ['Now did the Lord say, \"First', 'thou pullest the Holy Pin.', 'Then thou must count to three.',\n'Three shall be the number of', 'the counting and the number of', 'the counting shall be three.', \n'Four shalt thou not count,', 'neither shalt thou count two,', 'excepting that thou then', 'proceedeth\nto three. Five is', 'right out. Once the number', 'three, being the number of the', 'counting, be\nreached, then', 'lobbest thou the Holy Hand', 'Grenade in the direction of', 'thine foe, who, being \nnaughty', 'in my sight, shall snuff it.'] \n```\nProcess list for justified display: \n\n```\n\tfor i in x: \n\tprint(i) \n```\n\nSample output: \n\n```\n\tNow did the Lord say, \"First\n\tthou pullest the Holy Pin.\n\tThen thou must count to three.\n\tThree shall be the number of\n\tthe counting and the number of\n\tthe counting shall be three.\n\tFour shalt thou not count,\n\tneither shalt thou count two,\n\texcepting that thou then\n\tproceedeth to three. Five is\n\tright out. Once the number\n\tthree, being the number of the\n\tcounting, be reached, then\n\tlobbest thou the Holy Hand\n\tGrenade in the direction of\n\tthine foe, who, being naughty\n\tin my sight, shall snuff it.\n```\n\n### Other/Misc.: \nThis package was prepared per the advice at: https://packaging.python.org \n\nFound bugs? Let me know! \nmailto: cjtx.code@gmail.com\n\n-cjtx / May 27, 2019\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cjtx/JustifyText", "keywords": "justify string format", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "JustifyText", "package_url": "https://pypi.org/project/JustifyText/", "platform": "", "project_url": "https://pypi.org/project/JustifyText/", "project_urls": { "Homepage": "https://github.com/cjtx/JustifyText" }, "release_url": "https://pypi.org/project/JustifyText/0.2.1.post3/", "requires_dist": null, "requires_python": "", "summary": "Returns list of strings *exactly* n width", "version": "0.2.1.post3" }, "last_serial": 5349485, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "16d40f76a1d45925227db2c1a1c816ff", "sha256": "527c1395680ed721164e071df9bd6c57283b91bfbd4df38609df9e1baf5d59e5" }, "downloads": -1, "filename": "JustifyText-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "16d40f76a1d45925227db2c1a1c816ff", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5012, "upload_time": "2019-05-29T03:47:27", "url": "https://files.pythonhosted.org/packages/3a/5d/8bd14cb7609af175efb7bc1e45b750df556f3898a6aa7444b77681777ea0/JustifyText-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ce111a96cb80c53d533d16ebebfc73a", "sha256": "6ff027e7646643d943dd6080b886751d17b54c11841eda3e09e6f5f64432da33" }, "downloads": -1, "filename": "JustifyText-0.2.1.tar.gz", "has_sig": false, "md5_digest": "3ce111a96cb80c53d533d16ebebfc73a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4557, "upload_time": "2019-05-29T03:47:29", "url": "https://files.pythonhosted.org/packages/32/e4/cfcbd1e32c335a1c5433de43fc226c3aa3a9bae844c1016b82b263018fd4/JustifyText-0.2.1.tar.gz" } ], "0.2.1.post1": [ { "comment_text": "", "digests": { "md5": "49a790d59049802105207b84a8cd1b92", "sha256": "4dc7d9ac2d5e29bbb69fd52289bf1b1252a04d5eea7c23c4ca67de45db65ee9c" }, "downloads": -1, "filename": "JustifyText-0.2.1.post1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "49a790d59049802105207b84a8cd1b92", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5082, "upload_time": "2019-05-29T03:57:32", "url": "https://files.pythonhosted.org/packages/d3/36/7eb44bf2d2f58280e8635b3db9dbebcc0131bf17012806d913651899bf9e/JustifyText-0.2.1.post1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3c69412a1c1f7423c365765c9b5049bc", "sha256": "dd2c0c2cab2269a34b2f0b25a4d644b9b4eb0d8d3de0195dbff60b16c0bc5feb" }, "downloads": -1, "filename": "JustifyText-0.2.1.post1.tar.gz", "has_sig": false, "md5_digest": "3c69412a1c1f7423c365765c9b5049bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4569, "upload_time": "2019-05-29T03:57:33", "url": "https://files.pythonhosted.org/packages/b0/d9/8f186a2462e1237e6f15c4def1452d6ca8d0c678300059af2ea5d4c4a6fc/JustifyText-0.2.1.post1.tar.gz" } ], "0.2.1.post2": [ { "comment_text": "", "digests": { "md5": "f91f9c16e7d5e248b7be78f404398a40", "sha256": "ebf14dc438299b3a28cab26d12bc35a3491136b79ccb122b6ae92ce91c5ce26a" }, "downloads": -1, "filename": "JustifyText-0.2.1.post2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f91f9c16e7d5e248b7be78f404398a40", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5088, "upload_time": "2019-05-29T04:03:56", "url": "https://files.pythonhosted.org/packages/90/28/9015ccf7b3a3c183c27d9a1a1f3f2c83aab23e08b6257842321994669500/JustifyText-0.2.1.post2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4ce2ba4457336c23878c2f7cffeec9cf", "sha256": "53530f1829cfb4ff84c567446fae3ec4df6fc2d16d242ca5b06872e41ff6fae1" }, "downloads": -1, "filename": "JustifyText-0.2.1.post2.tar.gz", "has_sig": false, "md5_digest": "4ce2ba4457336c23878c2f7cffeec9cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4463, "upload_time": "2019-05-29T04:03:57", "url": "https://files.pythonhosted.org/packages/97/98/9a864f72e77e549d394134d18fb24754d7f46e866f122a5e70d264b8fc94/JustifyText-0.2.1.post2.tar.gz" } ], "0.2.1.post3": [ { "comment_text": "", "digests": { "md5": "160655d4988039442b72e979bb3535f9", "sha256": "1785e6845dc600c8cb38d1ffcb9d747e78d6ca453605af4cb30688842920fd95" }, "downloads": -1, "filename": "JustifyText-0.2.1.post3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "160655d4988039442b72e979bb3535f9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5116, "upload_time": "2019-06-02T18:05:14", "url": "https://files.pythonhosted.org/packages/4f/34/8c35cde4be22815cade6611141afe0b2dca8ade8de2149bfb7981d647ced/JustifyText-0.2.1.post3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6d526147f59001f28f5d561cad68ed15", "sha256": "cedd8cae2d5e832399560aa7a252efc3fc1fc591ce271b54685026c2ee0483ea" }, "downloads": -1, "filename": "JustifyText-0.2.1.post3.tar.gz", "has_sig": false, "md5_digest": "6d526147f59001f28f5d561cad68ed15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4478, "upload_time": "2019-06-02T18:05:15", "url": "https://files.pythonhosted.org/packages/07/85/2d4f064d6732fb4551fd434c6aacf0bc1b336e156c36394b77cfe9d9c206/JustifyText-0.2.1.post3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "160655d4988039442b72e979bb3535f9", "sha256": "1785e6845dc600c8cb38d1ffcb9d747e78d6ca453605af4cb30688842920fd95" }, "downloads": -1, "filename": "JustifyText-0.2.1.post3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "160655d4988039442b72e979bb3535f9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5116, "upload_time": "2019-06-02T18:05:14", "url": "https://files.pythonhosted.org/packages/4f/34/8c35cde4be22815cade6611141afe0b2dca8ade8de2149bfb7981d647ced/JustifyText-0.2.1.post3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6d526147f59001f28f5d561cad68ed15", "sha256": "cedd8cae2d5e832399560aa7a252efc3fc1fc591ce271b54685026c2ee0483ea" }, "downloads": -1, "filename": "JustifyText-0.2.1.post3.tar.gz", "has_sig": false, "md5_digest": "6d526147f59001f28f5d561cad68ed15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4478, "upload_time": "2019-06-02T18:05:15", "url": "https://files.pythonhosted.org/packages/07/85/2d4f064d6732fb4551fd434c6aacf0bc1b336e156c36394b77cfe9d9c206/JustifyText-0.2.1.post3.tar.gz" } ] }