python-hostlist is a Python module designed for parsing and expanding hostlist strings (e.g., 'host[01-03],host[05,07]'). It can expand such strings into a list of individual hostnames and also compress a list of hostnames back into a compact hostlist string. The library is actively maintained, with releases typically driven by bug fixes or minor feature additions.
pip install python-hostlistVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic expansion and compression of hostlist strings, and checking for hostlist validity.
Ensure your environment uses Python 3.6 or newer. Upgrade your Python interpreter if necessary.
Rewrite your code to use `hostlist.expand_hostlist()` and process the resulting list, or use `hostlist.compress_hostlist()` for the inverse operation. There are no direct replacements for these specific functions.
Always sort your list of hostnames before passing it to `hostlist.compress_hostlist()`, e.g., `hostlist.compress_hostlist(sorted(my_hostnames))`.
Always validate input strings using `hostlist.is_hostlist()` or wrap calls to `expand_hostlist()` in a `try...except hostlist.HostlistFormatException` block to handle malformed input gracefully.
Change `import python_hostlist` to `import hostlist`.
Review the hostlist string for syntax errors. Ensure ranges are numeric (e.g., `host[01-03]`) and separators are correct. Consider using `hostlist.is_hostlist()` to pre-validate inputs.
Sort the list of hostnames before passing it to the compression function: `hostlist.compress_hostlist(sorted(my_hostnames))`.
No dependency data recorded yet.