Skip to content

Commit

Permalink
Remove jinja and constants not in use
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
  • Loading branch information
vivekrnv committed May 10, 2023
1 parent 261a504 commit a898e8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
27 changes: 7 additions & 20 deletions platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import argparse
import copy
import difflib
import jinja2

from helper import *

Expand All @@ -15,23 +14,8 @@
PATCH_TABLE_LOC = "platform/mellanox/hw-management/hw-mgmt/recipes-kernel/linux/"
PATCH_TABLE_NAME = "Patch_Status_Table.txt"
PATCH_TABLE_DELIMITER = "----------------------"
PATCH_OS_SUBFOLDERS = {"default" : "./linux-{}",
"sonic" : "./linux-{}/sonic",
"opt" : "./linux-{}/sonic",
"cumulus" : "./linux-{}/cumulus"}
PATCH_NAME = "patch name"
SUBVERSION = "subversion"
PATCH_DST = "dst_type"
PATCH_ACCEPTED = "accepted"
PATCH_CANDIDATE = "candidate"
COMMIT_ID = "Upstream commit id"
COMMIT_TEMPLATE = """
{% if changes %} ## Patch List:
{% for key, value in changes.items() %}
* {{key}} : {{value}}
{%- endfor %}
{% endif %}
"""

def trim_array_str(str_list):
ret = [elem.strip() for elem in str_list]
Expand All @@ -40,7 +24,7 @@ def trim_array_str(str_list):
def get_line_elements(line):
columns_raw = line.split("|")
if len(columns_raw) < 3:
return False\
return False
# remove empty firsta and last elem
columns_raw = columns_raw[1:-1]
columns = trim_array_str(columns_raw)
Expand Down Expand Up @@ -111,9 +95,12 @@ def load_patch_table(path, k_version):
return table

def build_commit_description(changes):
base_loader = jinja2.BaseLoader()
template = jinja2.Environment(loader=base_loader).from_string(COMMIT_TEMPLATE)
content = template.render(changes=changes)
if not changes:
return ""
content = "\n"
content = content + " ## Patch List\n"
for key, value in changes.items():
content = content + f"* {key} : {value}\n"
return content

class Data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@

TEST_SLK_COMMIT = """\
Intgerate HW-MGMT 7.0030.0937 Changes
## Patch List:
## Patch List
* 0001-i2c-mlxcpld-Update-module-license.patch : https://github.com/gregkh/linux/commit/f069291bd5fc
* 0002-i2c-mlxcpld-Decrease-polling-time-for-performance-im.patch : https://github.com/gregkh/linux/commit/cb9744178f33
* 0003-i2c-mlxcpld-Add-support-for-I2C-bus-frequency-settin.patch : https://github.com/gregkh/linux/commit/66b0c2846ba8
Expand All @@ -50,6 +48,7 @@
* 0009-i2c-mux-mlxcpld-Extend-driver-to-support-word-addres.patch : https://github.com/gregkh/linux/commit/c52a1c5f5db5
* 0010-i2c-mux-mlxcpld-Extend-supported-mux-number.patch : https://github.com/gregkh/linux/commit/699c0506543e
* 0011-i2c-mux-mlxcpld-Add-callback-to-notify-mux-creation-.patch : https://github.com/gregkh/linux/commit/a39bd92e92b9
"""


Expand Down Expand Up @@ -174,6 +173,8 @@ def test_write_series_diff(self, mock_write_lines):
def test_commit_msg(self):
table = load_patch_table(MOCK_INPUTS_DIR, "5.10.140")
sb, slk = self.action.create_commit_msg(table)
print(slk)
print(TEST_SLK_COMMIT)
assert slk.split() == TEST_SLK_COMMIT.split()
assert sb.split() == TEST_SB_COMMIT.split()

0 comments on commit a898e8f

Please sign in to comment.