{"id":3521,"library":"jaraco-text","title":"Jaraco Text Utilities","description":"jaraco.text is a Python library offering a collection of various text manipulation utilities, including advanced text wrapping, line joining, block indentation, symbol substitution, and more. It is actively maintained with a regular release cadence, currently at version 4.2.0.","status":"active","version":"4.2.0","language":"python","source_language":"en","source_url":"https://github.com/jaraco/jaraco.text","tags":["text-processing","string-manipulation","utilities"],"install":[{"cmd":"pip install jaraco.text","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Many core functions are directly importable from the top-level `jaraco.text` package, not nested modules.","wrong":"import jaraco.text.wrap","symbol":"wrap","correct":"from jaraco.text import wrap"},{"note":"`join_lines` is part of the `join` submodule, which is itself a submodule of `jaraco.text`.","wrong":"from jaraco.text import join_lines","symbol":"join_lines","correct":"from jaraco.text.join import join_lines"},{"note":"`ellipsis_middle` resides in the `compress` submodule.","wrong":"from jaraco.text import ellipsis_middle","symbol":"ellipsis_middle","correct":"from jaraco.text.compress import ellipsis_middle"}],"quickstart":{"code":"from jaraco.text import wrap\nfrom jaraco.text.join import join_lines\nfrom jaraco.text.compress import ellipsis_middle\n\n# Example 1: Custom text wrapping with indentation\nlong_text = \"This is a very long paragraph that demonstrates the custom wrapping functionality provided by jaraco.text. It can handle various widths and indentation levels.\" \nwrapped = wrap(long_text, width=40, indent=4)\nprint(\"--- Wrapped Text ---\")\nprint(wrapped)\n\n# Example 2: Joining lines, preserving relative indentation\nlines_to_join = [\n    \"  First indented line\",\n    \"    Second deeper line\",\n    \"Third top-level line\"\n]\njoined = join_lines(lines_to_join)\nprint(\"\\n--- Joined Lines ---\")\nprint(joined)\n\n# Example 3: Shorten string with ellipsis in the middle\nvery_long_string = \"The quick brown fox jumps over the lazy dog and then takes a nap under the shade tree.\"\nshortened = ellipsis_middle(very_long_string, max_len=30)\nprint(\"\\n--- Ellipsis Middle ---\")\nprint(shortened)\n","lang":"python","description":"This quickstart demonstrates three common utilities from jaraco.text: `wrap` for custom text wrapping, `join_lines` for combining lines while preserving indentation, and `ellipsis_middle` for shortening long strings by placing an ellipsis in the center."},"warnings":[{"fix":"Upgrade to Python 3.9+ or pin `jaraco.text<4` in your project dependencies.","message":"Version 4.0.0 and above dropped support for Python versions older than 3.9. Users on Python 3.8 or earlier must use jaraco.text version 3.x.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Be mindful of which `wrap` function you are importing and using. If you intend to use `textwrap.wrap`, explicitly import `from textwrap import wrap`.","message":"The `wrap` function in `jaraco.text` is distinct from the standard library's `textwrap.wrap`. While similar in concept, it has different parameters (e.g., `indent` instead of `initial_indent`/`subsequent_indent`) and may behave differently.","severity":"gotcha","affected_versions":"All"},{"fix":"Consult the documentation or source code to find the correct import path for the specific utility you need. For example, `from jaraco.text.join import join_lines`.","message":"Many utilities like `join_lines` or `ellipsis_middle` are nested within submodules (e.g., `jaraco.text.join`, `jaraco.text.compress`) and must be imported from their specific paths, not directly from `jaraco.text`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'4.2.0':41 'activ':31 'advanc':18 'block':23 'cadenc':37 'collect':11 'current':38 'includ':17 'indent':24 'jaraco':1 'jaraco.text':4 'join':22 'librari':8 'line':21 'maintain':32 'manipul':15,47 'offer':9 'process':44 'python':7 'regular':35 'releas':36 'string':46 'string-manipul':45 'substitut':26 'symbol':25 'text':2,14,19,43 'text-process':42 'util':3,16,48 'various':13 'version':40 'wrap':20","created_at":"2026-04-11T17:33:10.389509+00:00","updated_at":"2026-04-16T15:50:37.266528+00:00","problems":[{"fix":"Upgrade PyInstaller to a version that includes the necessary hook for `jaraco.text` (e.g., PyInstaller 4.0 or newer), or ensure `pyinstaller-hooks-contrib` is installed and updated.","cause":"This error typically occurs when using PyInstaller, which fails to correctly bundle the data files (like 'Lorem ipsum.txt') associated with the 'jaraco.text' library into the generated executable.","error":"FileNotFoundError: 'Lorem ipsum.txt' resource not found in 'jaraco.text'"},{"fix":"Downgrade `setuptools` to a compatible version (e.g., `setuptools==70.3.0` as a known workaround) or upgrade both `setuptools` and `jaraco.text` to versions where this incompatibility has been resolved.","cause":"This issue often stems from compatibility problems between certain versions of `setuptools` (which may vend a copy of `jaraco.text`) and the installed `jaraco.text` library, leading to `pkg_resources` attempting to import a function that has changed or been removed.","error":"ImportError: cannot import name 'drop_comment' from 'jaraco.text'"},{"fix":"Install the package using pip (`pip install jaraco.text`), ensure your virtual environment is activated, or verify that your application bundler (e.g., PyInstaller, py2app) is correctly configured to include 'jaraco.text'.","cause":"This error means the Python interpreter cannot find the 'jaraco.text' package, either because it's not installed in the active environment, or there's a problem with package managers or bundlers like `py2app` or `setuptools` not correctly including it.","error":"ModuleNotFoundError: No module named 'jaraco.text'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jaraco/jaraco.text","docs":null,"changelog":null,"pypi":"https://pypi.org/project/jaraco-text/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}