shared.processing¶
processing.py
This module provides functions to process Tableau Workbook (TWB/TWBX) files, extracting and analyzing data sources, fields, and their dependencies. It includes context managers for suppressing console output and functionality for visualizing field dependencies.
Key Functionalities:
This application processes Tableau workbooks to extract data sources and fields, generates visual representations of field dependencies, and manages output file organization and logging.
Usage:
The process_twb function serves as the main entry point, taking a file path and optional parameters for output handling and execution context.
- shared.processing.process_twb(filepath, output_folder=None, is_executable=True, fPNG=True, stop_event=None, user_id=None)¶
Process a Tableau Workbook (TWB/TWBX) file to extract and analyze data sources, fields, and their dependencies.
This function reads a TWB file, extracts data sources and field information, processes field attributes, and computes dependencies among fields and sheets. It generates visual representations of field dependencies if specified and saves output files to the specified upload folder.
- Parameters:
filepath (str) – Path to the Tableau workbook (TWB*) file to be processed.
output_folder (str, optional) – Directory where output files will be saved if not running as an executable. Defaults to None.
is_executable (bool, optional) – Whether the function is being run as an executable script. Defaults to True.
fPNG (bool, optional) – Whether to generate PNG images in addition to SVGs.
stop_event (threading.Event, optional) – Signal used for cooperative cancellation. When set, processing stops gracefully. Defaults to None.
user_id (str, optional) – Unique session or user identifier used to isolate per-user processing state, progress tracking, and output paths when running in a multi-user environment. Defaults to None.
- Returns:
Generates output files and updates per-user progress tracking data.
- Return type:
None
- shared.processing.suppress_stdout()¶
Temporarily suppress console output.
- Yields:
None – Suppresses console output for the following commands (e.g., when opening a workbook).
Notes
Source: http://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/