Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
135 changes: 135 additions & 0 deletions 2025R1_SP1/primemesh-25-r1/add-header-to-tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import os
import sys
import argparse


def remove_column_table(input_table):
# Split input table into rows
rows = input_table.strip().split('\n')

# Create a new array for modified table
modified_rows = []

# Add the new header row
modified_rows.append("| Name |")

# invert row[0] and row[1]
temp = rows[0]
rows[0] = rows[1]
rows[1] = temp


# Skip the second row of the original table
# We don't include it in the modified table

# Add remaining rows from the original table, starting from index 2
for i in range(0, len(rows)):
# Split the current row by the '|' character
columns = rows[i].strip().split('|')

# Extract the content of the first column
name_column = columns[1].strip()

# Add the content of the first column to the modified row
modified_rows.append("| " + name_column + " |")

# Construct the modified table string
modified_table = '\n'.join(modified_rows)

return modified_table

def process_md_table(input_table):
# Split input table into rows
rows = input_table.strip().split('\n')

# Create a new array for modified table
modified_rows = ["| Name | Description |"]

# Add the second row of the original table
modified_rows.append(rows[1])

# Add the first row of the original table
modified_rows.append(rows[0])

# Add remaining rows from the original table, starting from index 2
for i in range(2, len(rows)):
modified_rows.append(rows[i])

# Construct the modified table string
modified_table = '\n'.join(modified_rows)

return modified_table

def process_md_files(folder_path):
# Traverse the directory structure recursively
for root, dirs, files in os.walk(folder_path):
for file in files:
# Check if the file is a Markdown file
if file.endswith(".md"):
file_path = os.path.join(root, file)
print("Processing:", file_path)
# Read the input file
with open(file_path, 'r', encoding='utf-8') as file:
file_content = file.read()

# Split the file content by at least one newline character
tables = file_content.split('\n\n')

# Process each potential Markdown table found in the file
modified_tables = []

# Check if all items of column 2 are empty
for table in tables:
# Check if the potential table is actually a Markdown table
if table.strip().startswith('|'):
# Check if the table has two columns with an empty column (first row only)
rows = table.strip().split('\n')
is2ColumnTable = False
for i in range(0, len(rows)):
if i==1:
continue
if rows[i].count('|') == 3:
s = rows[i].split('|')[2]
if all(char.isspace() or char == '\t' for char in s):
print("Found 1 column table")
else:
print("Found 2 column table")
is2ColumnTable = True

if rows[0].count('|') > 3:
print("Found >2 column table")
elif is2ColumnTable == True:
# Process the MD table
modified_table = process_md_table(table)
elif is2ColumnTable == False:
# Remove the empty column from the table
modified_table = remove_column_table(table)
else:
modified_table = table

modified_tables.append(modified_table)

# Join the modified tables back into the file content
modified_content = '\n\n'.join(modified_tables)

# Write the modified content back to the input file
with open(file_path, 'w', encoding='utf-8') as file:
file.write(modified_content)

print("File '{}' has been updated with corrected tables.".format(file_path))

if __name__ == "__main__":
# Check if the folder path is provided


# Get the folder path from command line argument
#folder_path = sys.argv[1]

parser = argparse.ArgumentParser(description="Add headers to tables in Markdown files.")
parser.add_argument("--input_folder", help="Path to the folder of Markdown files")
args = parser.parse_args()

folder_path = args.input_folder

# Process all Markdown files in the folder and its subfolders
process_md_files(folder_path)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddLabelResults.error_code

<a id="ansys.meshing.prime.AddLabelResults.error_code"></a>

#### *property* AddLabelResults.error_code *: [ErrorCode](ansys.meshing.prime.ErrorCode.md#ansys.meshing.prime.ErrorCode)*

Error code associated with the add label operation.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AddLabelResults

<a id="ansys.meshing.prime.AddLabelResults"></a>

### *class* ansys.meshing.prime.AddLabelResults(model=None, error_code=None, json_data=None, \*\*kwargs)

Results associated with the add label operation.

* **Parameters:**

**model: Model**
: Model to create a `AddLabelResults` object with default parameters.

**error_code: ErrorCode, optional**
: Error code associated with the add label operation.

**json_data: dict, optional**
: JSON dictionary to create a `AddLabelResults` object with provided parameters.

### Examples

```pycon
>>> add_label_results = prime.AddLabelResults(model = model)
```

<!-- !! processed by numpydoc !! -->

### Methods

| Name | Description |
|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [`AddLabelResults.print_default`](ansys.meshing.prime.AddLabelResults.print_default.md#ansys.meshing.prime.AddLabelResults.print_default)() | Print the default values of `AddLabelResults` object. |
| [`AddLabelResults.set_default`](ansys.meshing.prime.AddLabelResults.set_default.md#ansys.meshing.prime.AddLabelResults.set_default)([error_code]) | Set the default values of the `AddLabelResults` object. |

### Attributes

| Name | Description |
|------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| [`AddLabelResults.error_code`](ansys.meshing.prime.AddLabelResults.error_code.md#ansys.meshing.prime.AddLabelResults.error_code) | Error code associated with the add label operation. |
<!-- vale on -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# print_default

<a id="ansys.meshing.prime.AddLabelResults.print_default"></a>

#### *static* AddLabelResults.print_default()

Print the default values of `AddLabelResults` object.

### Examples

```pycon
>>> AddLabelResults.print_default()
```

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# set_default

<a id="ansys.meshing.prime.AddLabelResults.set_default"></a>

#### *static* AddLabelResults.set_default(error_code=None)

Set the default values of the `AddLabelResults` object.

* **Parameters:**

**error_code: ErrorCode, optional**
: Error code associated with the add label operation.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddThicknessParams.fix_intersections

<a id="ansys.meshing.prime.AddThicknessParams.fix_intersections"></a>

#### *property* AddThicknessParams.fix_intersections *: [bool](https://docs.python.org/3.11/library/functions.html#bool)*

Fix intersections in concave regions.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# AddThicknessParams

<a id="ansys.meshing.prime.AddThicknessParams"></a>

### *class* ansys.meshing.prime.AddThicknessParams(model=None, thickness=None, reverse_face_normal=None, suggested_part_name=None, fix_intersections=None, json_data=None, \*\*kwargs)

Parameters to add thickness for a given plane.

* **Parameters:**

**model: Model**
: Model to create a `AddThicknessParams` object with default parameters.

**thickness: float, optional**
: To assign the offset distance of inflation.

**reverse_face_normal: bool, optional**
: To assign the direction of inflation.

**suggested_part_name: str, optional**
: Suggested part name for created patching surfaces.

**fix_intersections: bool, optional**
: Fix intersections in concave regions.

**json_data: dict, optional**
: JSON dictionary to create a `AddThicknessParams` object with provided parameters.

### Examples

```pycon
>>> add_thickness_params = prime.AddThicknessParams(model = model)
```

<!-- !! processed by numpydoc !! -->

### Methods

| Name | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`AddThicknessParams.print_default`](ansys.meshing.prime.AddThicknessParams.print_default.md#ansys.meshing.prime.AddThicknessParams.print_default)() | Print the default values of `AddThicknessParams` object. |
| [`AddThicknessParams.set_default`](ansys.meshing.prime.AddThicknessParams.set_default.md#ansys.meshing.prime.AddThicknessParams.set_default)([thickness, ...]) | Set the default values of the `AddThicknessParams` object. |

### Attributes

| Name | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [`AddThicknessParams.fix_intersections`](ansys.meshing.prime.AddThicknessParams.fix_intersections.md#ansys.meshing.prime.AddThicknessParams.fix_intersections) | Fix intersections in concave regions. |
| [`AddThicknessParams.reverse_face_normal`](ansys.meshing.prime.AddThicknessParams.reverse_face_normal.md#ansys.meshing.prime.AddThicknessParams.reverse_face_normal) | To assign the direction of inflation. |
| [`AddThicknessParams.suggested_part_name`](ansys.meshing.prime.AddThicknessParams.suggested_part_name.md#ansys.meshing.prime.AddThicknessParams.suggested_part_name) | Suggested part name for created patching surfaces. |
| [`AddThicknessParams.thickness`](ansys.meshing.prime.AddThicknessParams.thickness.md#ansys.meshing.prime.AddThicknessParams.thickness) | To assign the offset distance of inflation. |
<!-- vale on -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# print_default

<a id="ansys.meshing.prime.AddThicknessParams.print_default"></a>

#### *static* AddThicknessParams.print_default()

Print the default values of `AddThicknessParams` object.

### Examples

```pycon
>>> AddThicknessParams.print_default()
```

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddThicknessParams.reverse_face_normal

<a id="ansys.meshing.prime.AddThicknessParams.reverse_face_normal"></a>

#### *property* AddThicknessParams.reverse_face_normal *: [bool](https://docs.python.org/3.11/library/functions.html#bool)*

To assign the direction of inflation.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# set_default

<a id="ansys.meshing.prime.AddThicknessParams.set_default"></a>

#### *static* AddThicknessParams.set_default(thickness=None, reverse_face_normal=None, suggested_part_name=None, fix_intersections=None)

Set the default values of the `AddThicknessParams` object.

* **Parameters:**

**thickness: float, optional**
: To assign the offset distance of inflation.

**reverse_face_normal: bool, optional**
: To assign the direction of inflation.

**suggested_part_name: str, optional**
: Suggested part name for created patching surfaces.

**fix_intersections: bool, optional**
: Fix intersections in concave regions.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddThicknessParams.suggested_part_name

<a id="ansys.meshing.prime.AddThicknessParams.suggested_part_name"></a>

#### *property* AddThicknessParams.suggested_part_name *: [str](https://docs.python.org/3.11/library/stdtypes.html#str)*

Suggested part name for created patching surfaces.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddThicknessParams.thickness

<a id="ansys.meshing.prime.AddThicknessParams.thickness"></a>

#### *property* AddThicknessParams.thickness *: [float](https://docs.python.org/3.11/library/functions.html#float)*

To assign the offset distance of inflation.

<!-- !! processed by numpydoc !! -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ansys.meshing.prime.AddThicknessResults.error_code

<a id="ansys.meshing.prime.AddThicknessResults.error_code"></a>

#### *property* AddThicknessResults.error_code *: [ErrorCode](ansys.meshing.prime.ErrorCode.md#ansys.meshing.prime.ErrorCode)*

Error code associated with failure of operation.

<!-- !! processed by numpydoc !! -->
Loading