### Install enlighten with pip Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/install.rst Use pip to install the enlighten library. This is the standard method for Python package installation. ```console $ pip install enlighten ``` -------------------------------- ### Setup for NotebookManager Tests Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Imports necessary libraries and configures the environment for testing the NotebookManager. It includes setting up coverage tracking. ```python """ Notebook for testing NotebookManager """ # Setup import sys import os import coverage # Set path so this works for running live cwd = os.getcwd() if os.path.basename(cwd) == 'tests': project_dir = os.path.dirname(cwd) sys.path.insert(1, project_dir) else: project_dir = cwd # Start coverage, should be before imports cov = coverage.Coverage( data_file=os.path.join(project_dir, '.coverage.notebook'), config_file=os.path.join(project_dir, 'setup.cfg') ) cov.start() # pylint: disable=wrong-import-position from enlighten import get_manager, NotebookManager # noqa: E402 ``` -------------------------------- ### Multicolored Progress Bar for Service Initialization Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Illustrates a multicolored progress bar for tracking service startup stages (initializing, starting, started) with dynamic color transitions and detailed status fields. ```python import random import time import enlighten services = 100 bar_format = u'{desc}{desc_pad}{percentage_2:3.0f}%|{bar}|' + \ u' {count_2:{len_total}d}/{total:d} ' + \ u'[{elapsed}<{eta_2}, {rate_2:.2f}{unit_pad}{unit}/s]' manager = enlighten.get_manager() initializing = manager.counter(total=services, desc='Starting', unit='services', color='red', bar_format=bar_format) starting = initializing.add_subcounter('yellow') started = initializing.add_subcounter('green', all_fields=True) while started.count < services: remaining = services - initializing.count if remaining: num = random.randint(0, min(4, remaining)) initializing.update(num) ready = initializing.count - initializing.subcount if ready: num = random.randint(0, min(3, ready)) starting.update_from(initializing, num) if starting.count: num = random.randint(0, min(2, starting.count)) started.update_from(starting, num) ``` -------------------------------- ### Simplified Manager Initialization with Configuration Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This example demonstrates using the `enlighten.get_manager` function for a more concise way to initialize the manager, respecting configuration for stream and counter usage. ```python import enlighten # Example configuration object config = {'stream': None, # Defaults to sys.__stdout__ 'useCounter': False} manager = enlighten.get_manager(stream=config['stream'], enabled=config['useCounter']) ``` -------------------------------- ### Install enlighten with apt-get on Debian/Ubuntu Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/install.rst Install the Python 3 enlighten package using apt-get. This command is suitable for Debian and Ubuntu-based systems. ```console $ apt-get install python3-enlighten ``` -------------------------------- ### Install enlighten with dnf on Fedora/EL8 Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/install.rst Install the Python 3 enlighten package using dnf. Ensure EPEL repositories are configured for EL8 systems. ```console $ dnf install python3-enlighten ``` -------------------------------- ### Install enlighten with conda Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/install.rst Install the enlighten library from the conda-forge channel using the conda package manager. ```console $ conda install -c conda-forge enlighten ``` -------------------------------- ### Using Manager and Counter as Context Managers Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This snippet illustrates how to use both `enlighten.Manager` and `enlighten.Counter` as context managers for automatic setup and teardown of progress bars. ```python import enlighten SPLINES = 100 with enlighten.Manager() as manager: with manager.counter(total=SPLINES, desc='Reticulating:', unit='splines') as retic: for num in range(1, SPLINES + 1): time.sleep(.1) retic.update() ``` -------------------------------- ### Basic Refreshing Progress Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst Provides a simple example of a refreshing progress bar using Enlighten. This pattern is suitable for basic progress indication where automatic TTY updates are not desired or available. ```python import enlighten import time manager = enlighten.get_manager(enabled=False) pbar = manager.counter(desc='Progress', total=10) print() for num in range(10): time.sleep(0.2) pbar.update() print(f'\r{pbar}', end='', flush=True) print() ``` -------------------------------- ### Progress Bar with Human-Readable Numeric Prefixes Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This example shows how to use human-readable SI/IEC prefixes for numeric fields (like count, total, rate) in a progress bar's format string, enabling easier interpretation of large numbers. ```python import time import random import enlighten size = random.uniform(1.0, 10.0) * 2 ** 20 # 1-10 MiB (float) chunk_size = 64 * 1024 # 64 KiB bar_format = '{desc}{desc_pad}{percentage:3.0f}%|{bar}| ' \ '{count:!.2j}{unit} / {total:!.2j}{unit} ' \ '[{elapsed}<{eta}, {rate:!.2j}{unit}/s]' manager = enlighten.get_manager() pbar = manager.counter(total=size, desc='Downloading', unit='B', bar_format=bar_format) bytes_left = size while bytes_left: time.sleep(random.uniform(0.05, 0.15)) next_chunk = min(chunk_size, bytes_left) pbar.update(next_chunk) bytes_left -= next_chunk ``` -------------------------------- ### Get Enlighten Manager Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Create a manager instance to handle terminal output for progress bars. Managers are disabled if the output stream is not a TTY. ```python import enlighten manager = enlighten.get_manager() ``` -------------------------------- ### Automatic Counter Update with Iterables Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This example shows how to automatically update a progress bar by calling a `Counter` instance with one or more iterables. The counter increments for each yielded item. ```python import time import enlighten flock1 = ['Harry', 'Sally', 'Randy', 'Mandy', 'Danny', 'Joe'] flock2 = ['Punchy', 'Kicky', 'Spotty', 'Touchy', 'Brenda'] total = len(flock1) + len(flock2) manager = enlighten.Manager() pbar = manager.counter(total=total, desc='Counting Sheep', unit='sheep') for sheep in pbar(flock1, flock2): time.sleep(0.2) print('%s: Baaa' % sheep) ``` -------------------------------- ### Colorized Progress Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Apply color to a progress bar by setting the 'color' keyword argument during initialization. This example uses 'red'. ```python import time import enlighten manager = enlighten.get_manager() counter = manager.counter(total=100, desc='Colorized', unit='ticks', color='red') for num in range(100): time.sleep(0.1) # Simulate work counter.update() ``` -------------------------------- ### Multicolored Progress Bar for Service Startup Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Monitors a multi-stage process like service startup, where items transition through different states (red, yellow, green) over time. It leverages subcounter fields like percentage_2, count_2, eta_2, and rate_2 for detailed tracking. ```python import random import time import enlighten services = 100 bar_format = u'{desc}{desc_pad}{percentage_2:3.0f}%|{bar}|' + \ u' {count_2:{len_total}d}/{total:d} ' + \ u'[{elapsed}<{eta_2}, {rate_2:.2f}{unit_pad}{unit}/s]' manager = enlighten.get_manager() initializing = manager.counter(total=services, desc='Starting', unit='services', color='red', bar_format=bar_format) starting = initializing.add_subcounter('yellow') started = initializing.add_subcounter('green', all_fields=True) while started.count < services: remaining = services - initializing.count if remaining: num = random.randint(0, min(4, remaining)) initializing.update(num) ready = initializing.count - initializing.subcount if ready: num = random.randint(0, min(3, ready)) starting.update_from(initializing, num) if starting.count: num = random.randint(0, min(2, starting.count)) started.update_from(starting, num) time.sleep(random.uniform(0.1, 0.5)) # Random processing time ``` -------------------------------- ### Test Standard NotebookManager Usage Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Demonstrates the basic usage of NotebookManager, including creating a counter, updating it, and stopping the manager. ```python # test_standard # Test standard manager manager = NotebookManager() ctr = manager.counter(total=100) ctr.update(force=True) manager.stop() ``` -------------------------------- ### Test NotebookManager Initialization Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Verifies that get_manager() correctly returns an instance of NotebookManager when run within a notebook environment. ```python # test_get_manager # Test we get the right manager when running in a notebook manager = get_manager() assert isinstance(manager, NotebookManager) assert repr(manager) == 'NotebookManager()' ``` -------------------------------- ### Progress Bar with Formatting and Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Demonstrates using counter formatting and the color capabilities of the underlying Blessed library for advanced customization of progress bar appearance. ```python import enlighten manager = enlighten.get_manager() ``` -------------------------------- ### Test Disabled NotebookManager Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Shows how to initialize NotebookManager with `enabled=False` and confirms that updates and writes are ignored. ```python # test_disabled # Test manager disabled manager = NotebookManager(enabled=False) ctr = manager.counter(total=100) ctr.update(force=True) manager.write('We should never see this') manager.stop() ``` -------------------------------- ### Test NotebookManager Style Conversion to HTML Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Demonstrates how NotebookManager converts various terminal style codes (colors, bold, underline, etc.) into HTML for display in a notebook. ```python # test_styles # Styles converted to HTML manager = NotebookManager() term = manager.term status = manager.status_bar(' '.join(( 'normal', term.blue_on_aquamarine('blue_on_aquamarine'), term.aquamarine_on_blue('aquamarine_on_blue'), term.color(90)('color_90'), term.on_color(90)('on_color_90'), term.italic_bright_red('italics_red'), term.on_bright_blue('on_bright_blue'), term.blink('blink'), term.bold('bold'), term.bold('') , # Empty span will be ignored term.underline('underline'), term.reverse('unsupported_reverse'), term.move(5, 6) + 'unsupported_move', term.normal + 'ignore_unmatched_normal', term.link('https://pypi.org/project/enlighten/', 'enlighten'), ))) ``` -------------------------------- ### Enlighten Counter with Custom Format Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst Demonstrates creating a counter with a custom format string. This is useful for displaying progress in a human-readable way, such as time durations. ```python import enlighten counter_format = 'Trying to get to sleep: {count:.2h} sheep' manager = enlighten.get_manager() counter = manager.counter(counter_format=counter_format) counter.count = 0.0 for num in range(10000000): counter.update() ``` -------------------------------- ### Basic Color Formatting Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Applies predefined colors and backgrounds to progress bar text. ```python bar_format = manager.term.red(std_bar_format) ``` ```python bar_format = manager.term.red_on_white(std_bar_format) ``` ```python bar_format = manager.term.peru_on_seagreen(std_bar_format) ``` -------------------------------- ### Basic Progress Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Create a simple progress bar with a total count and description. The bar updates with each iteration of the loop. ```python import time import enlighten manager = enlighten.get_manager() pbar = manager.counter(total=100, desc='Basic', unit='ticks') for num in range(100): time.sleep(0.1) # Simulate work pbar.update() ``` -------------------------------- ### Apply Color to Select Parts Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies different colors to specific parts of the bar format string, such as the description and percentage. ```python bar_format = manager.term.red(u'{desc}') + u'{desc_pad}' + \ manager.term.blue(u'{percentage:3.0f}%') + u'|{bar}|' ``` -------------------------------- ### Test Advanced NotebookManager Use Case Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Illustrates a more complex scenario with multiple counters ('Ticks' and 'Tocks') having different configurations and being updated within a loop. ```python # test_advanced # More advanced use case manager = NotebookManager() ticks = manager.counter(total=10, desc='Ticks', unit='ticks', color='red', min_delta=0) tocks = manager.counter(total=5, desc='Tocks', unit='tocks', color='blue', position=3, min_delta=0) for num in range(10): ticks.update() if not num % 2: tocks.update() manager.stop() ``` -------------------------------- ### Enable/Disable Counter based on Configuration and TTY Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This snippet shows how to conditionally enable a progress counter based on a configuration setting and whether the output stream is a TTY. It demonstrates manual creation of the manager. ```python import sys import enlighten # Example configuration object config = {'stream': sys.stdout, 'useCounter': False} enableCounter = config['useCounter'] and stream.isatty() manager = enlighten.Manager(stream=config['stream'], enabled=enableCounter) ``` -------------------------------- ### Basic Status Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Create a status bar to display relatively static information. It can be updated with new messages and styled with colors. ```python import enlighten import time manager = enlighten.get_manager() status_bar = manager.status_bar('Static Message', color='white_on_red', justify=enlighten.Justify.CENTER) time.sleep(1) status_bar.update('Updated static message') time.sleep(1) ``` -------------------------------- ### Standard Progress Bar Format Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Defines a standard format string for a progress bar, including description, percentage, bar, count, elapsed time, ETA, and rate. ```python import enlighten manager = enlighten.get_manager() # Standard bar format std_bar_format = u'{desc}{desc_pad}{percentage:3.0f}%|{bar}| ' + \ u'{count:{len_total}d}/{total:d} ' + \ u'[{elapsed}<{eta}, {rate:.2f}{unit_pad}{unit}/s]' ``` -------------------------------- ### Manually Format Counter Output Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst Shows how to retrieve the formatted string of a counter using the .format() method. This is useful when you need to manually control where the progress output appears, such as writing to a file or a different stream. ```python import enlighten manager = enlighten.get_manager(enabled=False) pbar = manager.counter(desc='Progress', total=10) pbar.update() print(pbar.format(width=100)) ``` -------------------------------- ### Create a Colorized Progress Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Creates a progress bar with a specified color. The bar updates to simulate progress. ```python import time import enlighten manager = enlighten.get_manager() counter = manager.counter(total=100, desc='Colorized', unit='ticks', color='red') for num in range(100): time.sleep(0.1) # Simulate work counter.update() ``` -------------------------------- ### Apply RGB Text and Background Colors Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies both a custom RGB background and a custom RGB text color to the standard bar format. ```python bar_format = manager.term.on_color_rgb(255, 190, 195)(std_bar_format) bar_format = manager.term.color_rgb(2, 5, 128)(bar_format) ``` -------------------------------- ### Multiple Progress Bars Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Create and manage multiple progress bars simultaneously. Each bar can have its own description and unit. ```python import time import enlighten manager = enlighten.get_manager() ticks = manager.counter(total=100, desc='Ticks', unit='ticks') tocks = manager.counter(total=20, desc='Tocks', unit='tocks') for num in range(100): time.sleep(0.1) # Simulate work print(num) ticks.update() if not num % 5: tocks.update() manager.stop() ``` -------------------------------- ### Standard Bar Format Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Defines the default format for progress bar display, including percentage, elapsed time, and rate. ```python std_bar_format = u'{desc}{desc_pad}{percentage:3.0f}%|{bar}| ' + \ u'{count:{len_total}d}/{total:d} ' + \ u'[{elapsed}<{eta}, {rate:.2f}{unit_pad}{unit}/s]' ``` -------------------------------- ### enlighten.StatusBar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Represents a status bar for displaying progress. ```APIDOC ## enlighten.StatusBar ### Description Represents a status bar for displaying progress, typically used in terminal applications. ### Members - **count**: int - The current count of the status bar. - **elapsed**: float - The elapsed time in seconds. - **position**: int - The current position of the status bar in the manager. ``` -------------------------------- ### RGB Color Formatting Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Applies custom RGB colors for text and background in progress bars. ```python bar_format = manager.term.color_rgb(2, 5, 128)(std_bar_format) ``` ```python bar_format = manager.term.on_color_rgb(255, 190, 195)(std_bar_format) ``` ```python bar_format = manager.term.on_color_rgb(255, 190, 195)(std_bar_format) bar_format = manager.term.color_rgb(2, 5, 128)(bar_format) ``` -------------------------------- ### Formatted Status Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Create a status bar using a format string with dynamic variables. Variables can be updated to change the displayed information. ```python import enlighten import time manager = enlighten.get_manager() status_format = '{program}{fill}Stage: {stage}{fill} Status {status}' status_bar = manager.status_bar(status_format=status_format, color='bold_slategray', program='Demo', stage='Loading', status='OKAY') time.sleep(1) status_bar.update(stage='Initializing', status='OKAY') time.sleep(1) status_bar.update(status='FAIL') ``` -------------------------------- ### Apply Peru on Sea Green Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies a specific X11 color combination (peru on seagreen) to the standard bar format. ```python bar_format = manager.term.peru_on_seagreen(std_bar_format) ``` -------------------------------- ### Manually Print Counter as String Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst Illustrates using a counter object directly in a print statement. When coerced to a string, the counter object automatically calls its .format() method with default arguments, providing a convenient shortcut for manual output. ```python import enlighten manager = enlighten.get_manager(enabled=False) pbar = manager.counter(desc='Progress', total=10) pbar.update() print(pbar) ``` -------------------------------- ### enlighten.Justify Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Enum for text justification. ```APIDOC ## enlighten.Justify ### Description An enumeration class providing constants for text justification (e.g., LEFT, RIGHT, CENTER). ``` -------------------------------- ### Apply Red on White Background Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies red text on a white background to the standard bar format. ```python bar_format = manager.term.red_on_white(std_bar_format) ``` -------------------------------- ### Test Writing Bare Message without Flush Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Tests the `write` method of NotebookManager with `flush=False`, verifying the output is stored correctly without immediate display. ```python # test_bare_no_flush # Test write bare message, no flush manager = NotebookManager() manager.write('test message', flush=False) # pylint: disable=protected-access assert manager._output[0] == '
test message
' ``` -------------------------------- ### Test NotebookManager Stop with No Counters Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Ensures that calling the `stop` method on a NotebookManager instance that has no active counters executes without errors. ```python # test_stop_no_counters # Test stop succeeds when there are no counters manager = NotebookManager() manager.stop() ``` -------------------------------- ### enlighten.Counter Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Represents a single progress counter. ```APIDOC ## enlighten.Counter ### Description Represents a single progress counter, used for tracking the progress of a task. ### Members - **count**: int - The current count of the counter. - **elapsed**: float - The elapsed time in seconds. - **position**: int - The current position of the counter in the manager. ``` -------------------------------- ### Apply RGB Background Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies a custom RGB background color to the standard bar format. ```python bar_format = manager.term.on_color_rgb(255, 190, 195)(std_bar_format) ``` -------------------------------- ### Apply Color to Counter Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies a specified bar format, potentially with colors, to an Enlighten counter. ```python ticks = manager.counter(total=100, desc='Ticks', unit='ticks', bar_format=bar_format) ``` -------------------------------- ### Updating Counter with User-Defined Fields Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/patterns.rst This snippet demonstrates how to include and update user-defined fields (like 'source') within a progress bar's format and updates. Fields are persistent and only need updating when they change. ```python import enlighten import random import time bar_format = u'{desc}{desc_pad}{source} {percentage:3.0f}%|{bar}| ' + \ u'{count:{len_total}d}/{total:d} ' + \ u'[{elapsed}<{eta}, {rate:.2f}{unit_pad}{unit}/s]' manager = enlighten.get_manager(bar_format=bar_format) bar = manager.counter(total=100, desc='Loading', unit='files', source='server.a') for num in range(100): time.sleep(0.1) # Simulate work if not num % 5: bar.update(source=random.choice(['server.a', 'server.b', 'server.c'])) else: bar.update() ``` -------------------------------- ### Counter Progress Bar Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Use a counter as a progress bar when the total is not specified or when the count exceeds the total. This format is used by default if 'total' is None. ```python import time import enlighten manager = enlighten.get_manager() counter = manager.counter(desc='Basic', unit='ticks') for num in range(100): time.sleep(0.1) # Simulate work counter.update() ``` -------------------------------- ### Multicolored Progress Bar for Test Tracking Source: https://github.com/rockhopper-technologies/enlighten/blob/main/README.rst Tracks multiple categories (success, failures, errors) within a single progress bar, useful for test suites. It utilizes specific fields like count_0, count_1, and count_2 for each category. ```python import random import time import enlighten bar_format = u'{desc}{desc_pad}{percentage:3.0f}%|{bar}| ' + \ u'S:{count_0:{len_total}d} ' + \ u'F:{count_2:{len_total}d} ' + \ u'E:{count_1:{len_total}d} ' + \ u'[{elapsed}<{eta}, {rate:.2f}{unit_pad}{unit}/s]' manager = enlighten.get_manager() success = manager.counter(total=100, desc='Testing', unit='tests', color='green', bar_format=bar_format) errors = success.add_subcounter('white') failures = success.add_subcounter('red') while success.count < 100: time.sleep(random.uniform(0.1, 0.3)) # Random processing time result = random.randint(0, 10) if result == 7: errors.update() if result in (5, 6): failures.update() else: success.update() ``` -------------------------------- ### Apply RGB Text Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies a custom RGB text color to the standard bar format. ```python bar_format = manager.term.color_rgb(2, 5, 128)(std_bar_format) ``` -------------------------------- ### Cleanup Coverage Data Source: https://github.com/rockhopper-technologies/enlighten/blob/main/tests/test_notebook_manager.ipynb Stops the coverage tracking and saves the collected data to a file. ```python # Cleanup cov.stop() cov.save() ``` -------------------------------- ### enlighten.format_time Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Formats a time duration into a human-readable string. ```APIDOC ## enlighten.format_time(seconds) ### Description Formats a time duration in seconds into a human-readable string (e.g., '1h 2m 3s'). ### Parameters #### Arguments - **seconds** (float or int) - The duration in seconds to format. ``` -------------------------------- ### Apply Red Text Color Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Applies red text color to the standard bar format using terminal color capabilities. ```python bar_format = manager.term.red(std_bar_format) ``` -------------------------------- ### Multicolored Progress Bar for Test Status Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/examples.rst Demonstrates a multicolored progress bar to track test outcomes (success, failures, errors) with distinct colors and counts. ```python import random import time import enlighten bar_format = u'{desc}{desc_pad}{percentage:3.0f}%|{bar}| ' + \ u'S:{count_0:{len_total}d} ' + \ u'F:{count_2:{len_total}d} ' + \ u'E:{count_1:{len_total}d} ' + \ u'[{elapsed}<{eta}, {rate:.2f}{unit_pad}{unit}/s]' manager = enlighten.get_manager() success = manager.counter(total=100, desc='Testing', unit='tests', color='green', bar_format=bar_format) errors = success.add_subcounter('white') failures = success.add_subcounter('red') while success.count < 100: time.sleep(random.uniform(0.1, 0.3)) # Random processing time result = random.randint(0, 10) if result == 7: errors.update() if result in (5, 6): failures.update() else: success.update() ``` -------------------------------- ### enlighten.get_manager Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Returns an instance of the Manager class, which is used to manage progress counters. ```APIDOC ## enlighten.get_manager(stream=None, counter_class=Counter, **kwargs) ### Description Returns an instance of the Manager class, which is used to manage progress counters. ### Parameters #### Keyword Arguments - **stream** (file-like object, optional) - The stream to write progress updates to. Defaults to `sys.stderr`. - **counter_class** (class, optional) - The class to use for creating counters. Defaults to `enlighten.Counter`. - **kwargs** - Additional keyword arguments to pass to the Manager constructor. ``` -------------------------------- ### enlighten.SubCounter Source: https://github.com/rockhopper-technologies/enlighten/blob/main/doc/api.rst Represents a sub-counter within a larger progress counter. ```APIDOC ## enlighten.SubCounter ### Description Represents a sub-counter, which is a nested progress counter within a parent counter. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.