A Python package for organizing and visualizing list hierarchies.
Project description
SetPrint - Simplify Formatting and Display of High-Dimensional Data!
SetPrint is a Python library designed to easily format and display multi-dimensional data in lists.
Even for data structures with mixed dimensions, you no longer need to manually adjust spaces or formatting. It automatically achieves beautiful formatting!
Documentation
Features
- Support for Flexible Data Structures: Automatically formats multi-dimensional lists and mixed data structures.
- Great for Debugging: Organizes and displays the structure and contents of data during execution in an easy-to-understand way.
- Flexible Formatting: Visually organizes data hierarchy and content with guided formatting.
Methods
-
set_listMethod-
The
set_listmethod of the SetPrint class provides a feature to easily format and output multi-dimensional lists and complex data structures in a visually comprehensible format.
Using this method enables optimal formatting tailored to the dimensions of the data. -
Parameters
-
guide(bool): Enables or disables the guide display.- If
True, outputs a guide containing dimension and index information.
- If
-
keep_start(int): The dimension where flattening begins.- Example:
keep_start=1expands the first dimension in the Y direction.
- Example:
-
keeplen(int): The range of dimensions to flatten.- Dimensions outside the specified range are boxed in the X direction.
-
-
Return Values
input_list: The original list before formatting.grid_slice: A list containing the formatted text information, with each line stored individually. It can be written directly to a text file to check the results.grid_block: A list maintaining the block-shaped format of the structured data.block_Xlines_data: Data used for displaying detailed indices with theGuidePrintfunction.
Relationship Between
keep_startand Data FormattingThe
keep_startparameter specifies the dimension where formatting begins and organizes data in the most suitable format based on its structure and use case. Below are examples of howkeep_startvalues affect formatting and their corresponding data types.Recommended Settings
-
keep_start=1- Use Case: Data expanding in the Y direction (e.g., logs or image data).
- Description: Formats data along the first dimension in the Y direction while maintaining the X direction as-is.
- Example (Debug Log):
logs = [ ["Value", 30, "is", "less than", 50], [["Action", "Process"], ["Details", "Valid range"]], [["Value", 90], ["Condition", ["greater than", 50]], ["Action", "Alert"]], ]
- Formatted Result:
Formatted Log: ================================================================================================================================= | ►list [ Value ------ ------- 30 --------- ----------- ------------ -- is ------ ----- less than 50 ] | | ►list [ ►list { Action Process ) ►list { Details Valid range ------------ -- ) ----- ------ ----- --------- -- ] | | ►list [ ►list { Value 90 ) ►list { Condition ►list { greater than 50 ) ) ►list { Action Alert ) --------- -- ] | ================================================================================================================================= - Execution Example:
from setprint import SetPrint # Format and display the data list_data = SetPrint(logs) set_datas = list_data.set_list(guide=False, keep_start=1, keeplen=10) print("\nFormatted Log:") for line in set_datas['grid_slice']: print(line[:-1]) # Output formatted log
-
keep_start=2- Use Case: Information divided in the X direction (e.g., tabular data).
- Description: Formats data along the second dimension in the X direction, emphasizing separation in the Y direction.
- Example (Tabular Data):
data = [ ["Name", "Age", "Country"], ["Alice", 30, "USA"], ["Bob", 25, "UK"] ]
- Formatted Result:
Formatted Table: ==================================== {} | {n} | |-----------------------------| : : | data_type: <class 'list'> | | data_type: <class 'list'> | | data_type: <class 'list'> | ==================================== {0} | [0]{n} | |-----------------------------| : : | Name | | Age | | Country | ==================================== {1} | [1]{n} | |-----------------------------| : : | Alice | | 30 | | USA | ==================================== {2} | [2]{n} | |-----------------------------| : : | Bob | | 25 | | UK | ==================================== - Execution Example:
list_data = SetPrint(data) set_datas = list_data.set_list(guide=True, keep_start=2) for line in set_datas['grid_slice']: print(line[:-1])
-
keep_start=3-
Use Case: Data separated in both Y and X directions (e.g., matrices or 3D arrays).
-
Description: Organizes data based on the third dimension, retaining overall structure while arranging information in both Y and X directions.
-
Example Input Data:
data = [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]
-
Formatted Result:
Formatted Matrix: ==================================== {} | {n} | |-----------------------------| : : | data_type: <class 'list'> | | data_type: <class 'list'> | ================================================================ {0} | [0]{n} | [0][0]{n} | [0][1]{n} | |-----------------------------|-------------|-------------| : : : : | data_type: <class 'list'> | 1 | 3 | | data_type: <class 'list'> | 2 | 4 | ================================================================ {1} | [1]{n} | [1][0]{n} | [1][1]{n} | |-----------------------------|-------------|-------------| : : : : | data_type: <class 'list'> | 5 | 7 | | data_type: <class 'list'> | 6 | 8 | ================================================================ -
Execution Example:
list_data = SetPrint(data) set_datas = list_data.set_list(guide=False, keep_start=3, keeplen=10) print("\nFormatted Log:") for line in set_datas['grid_slice']: print(line[:-1]) # Output formatted log
-
-
-
SetPrint.pick_guideprint(output_path)
pick_guideprintoperates as follows:- Move between blocks: Use the
f,h,g, andtkeys to navigate between different blocks. - Move within a block: Use the
a,d,s, andwkeys to navigate within the current block. - Directions: ← → ↓ ↑
Displayed Information:
index: The index of the currently selected data (e.g.,{y}[x0][x1][x2]).value: The value stored in the currently selected index. The value is displayed in green, and the data type is displayed in blue.
Parameters
The
pick_guideprintfunction accepts the following parameter:output_path: (Required) The path to the linked text file.
Execution Example
• python# from setprint import SetPrint # list_data = setprint( `list` ) # list_data.SET_list(guide=True,keep_start=1,keeplen=10) list_data.pick_guideprint( 'output_path' )
Execution Result
• txt_file►list { [0][0] [0][1] [0][2] --------- --------- [0][3] --------- ----- ------------ ------------ ------ ------ ) ------------------------------- ┏ ┓ ------------------------------------------------------------------------------------- ►list { [1][0] [1][1] ►list { [1][2][0] [1][2][1] ) [1][3] --------- ----- ------------ ------------ ------ ------ ) ------------------------------- ┗ ┛ ------------------------------------------------------------------------------------- ►list { [2][0] [2][1] [2][2] --------- --------- ►list { [2][3][0] ►list { [2][3][1][0] [2][3][1][1] ) ) [2][4] [2][5] ) ►list { [3][0] [3][1] [3][2] --------- --------- [3][3] --------- ----- ------------ ------------ [3][4] ------ ) [4] ------ ------ ------ --------- --------- ------ --------- ----- ------------ ------------ ------ ------• terminalindex \ {1}[2][0] value \ [1][2][0] : str - Move between blocks: Use the
-
SetPrint.bloks_border_print()
A function that allows you to create boxes, like the output result of
setlist, and input strings into them.Parameters
All_blocks: (Required) A list array containing the content to be displayed.line_title: (Required) The titles of the blocks in the Y-direction.guide: (Required) Specifies whether to include titles. AcceptsTrueorFalse.
Example of
All_blocksStorage''' # 1D corresponds to the Y-direction (blocks: rows) # 2D corresponds to the X-direction # 3D corresponds to the Y-direction (content: rows) ! All storage locations must be in the third dimension. ''' Column 1 Column 2 Column 3 All_blocks = [ 1step[ ['block_title','1line','2line'], ['1_2','1_txt','2_txt'] ] 2step[ ['2_1','1_data','2_data'], ['2_2','1_line','2_line','3_line'], ['2_3','1_txt','2_txt']] 3step[ ['3_1','1_txt','2_txt']] ] line_title = ['1step','2step','3step']
A visual representation of the relationship | between the output result and `All_blocks` | Output Result | [ | | Column 1 Column 2 Column 3 | ======================================== | ===================================== _____ [ |["block_title",|["1_2", | | {1step} | block_title | 1_2 | |---------------|------------| | |---------------|----------| : : : | : : : | '1line', | '1_txt', | | | 1line | 1_txt | | '2line' ], | '2_txt' ], | ], | | 2line | 2_txt | | ===================================================== | =============================================== _____ [ |["2-1", |["2-2", |["2_3", | | {2step} | 2_1 | 2_2 | 2_3 | |---------------|------------|-----------| | |---------------|----------|---------| : : : : | : : : : | '1_data', | '1_line', | '1_txt', | | | 1_data | 1_line | 1_txt | | '2_data' ], | '2_line', | '2_txt' ],| | | 2_data | 2_line | 2_txt | | | '3_line' ],| | ], | | | 3_line | | | ===================================================== | =============================================== _____ [ |["3-1", | | {3step} | 3_1 | |---------------| | |---------------| : : | : : | '1_txt', | | | 1_txt | | '2_txt' ], | ] | | 2_txt | | =========================== | ========================== ]Return Value
grid_slice: A list containing the formatted text information. Each line is stored individually, allowing it to be directly written to a text file for review.
Execution Example
• python# from setprint import SetPrint list_data = setprint( `All_blocks` ) grid_slice = blocks_border_print(line_title = line_title, guide=True): with open('output_path','w') as f: for line in grid_slice: f.write(line)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file setprint-0.1.13.tar.gz.
File metadata
- Download URL: setprint-0.1.13.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aefede29e9d501830f24f941ce6de0bdccc5fe5a0f9fe612e7c3b21b3f6b973a
|
|
| MD5 |
271ddc55a7c200b76cf8957de5b5f8ba
|
|
| BLAKE2b-256 |
4feb4b228d76bf2c8a0666fe79e05cbb98392af641ac25fbde43ef047fb93fb9
|
File details
Details for the file setprint-0.1.13-py3-none-any.whl.
File metadata
- Download URL: setprint-0.1.13-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc8fac59c00224eacb04daf032f5d98699201af2111fbc713d2c84fcab968e88
|
|
| MD5 |
ddb04a8ff68d91a70a531b041e32f902
|
|
| BLAKE2b-256 |
9963235ead6a636bbd61cbf91605de4e2d66e26182d031e96b5b33632acd8b3e
|