You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bi...@apache.org on 2023/03/23 18:18:46 UTC

[storm] branch master updated: [STORM-3902] Print summary of differences between expected and actual DEPENDENCY-LICENSES files. (#3527)

This is an automated email from the ASF dual-hosted git repository.

bipinprasad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e9dddb40 [STORM-3902] Print summary of differences between expected and actual DEPENDENCY-LICENSES files. (#3527)
8e9dddb40 is described below

commit 8e9dddb407ed656c1f99449783aad070a7a2d635
Author: Bipin Prasad <bi...@apache.org>
AuthorDate: Thu Mar 23 14:18:39 2023 -0400

    [STORM-3902] Print summary of differences between expected and actual DEPENDENCY-LICENSES files. (#3527)
---
 dev-tools/validate-license-files.py | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/dev-tools/validate-license-files.py b/dev-tools/validate-license-files.py
index 98e6d0ea2..6f32808f7 100755
--- a/dev-tools/validate-license-files.py
+++ b/dev-tools/validate-license-files.py
@@ -53,23 +53,37 @@ def generate_dependency_licenses():
     print('Done generating DEPENDENCY-LICENSES')
 
 
-def print_file_contents(msg, file1, file2):
+def print_file_contents(msg, file1, file2, show_summary_diff=True, show_file_contents=True):
     """
     Print contents of the files. Used for dumping the actual and expected DEPENDENCY-LICENSES files.
     :param msg: message to print about the files
     :param file1: original file
     :param file2: new file
+    :param show_summary_diff: (optional, default True): if true, then print the summary of differences in the files
+    :param show_file_contents: (optional, default True): if true, then print the contents of the files
     :return:
     """
     f_names = [file1, file2]
     print('*' * 80)
     print('*' * 30 + msg + ' ' + file1 + ',' + file2 + '*' * 30)
-    for i, f_name in enumerate(f_names):
-        print('*' * 30 + ' Start of file ' + f_name + ' ' + '*' * 30)
-        print('(' + str(i) + ') File ' + f_name + ' content is:')
-        print('\t' + '\t'.join(open(f_name).readlines()))
-        print('*' * 30 + ' End of file ' + f_name + ' ' + '*' * 30)
-    print('*' * 80)
+
+    if show_summary_diff:
+        with open(file1, 'r') as f1:
+            with open(file2, 'r') as f2:
+                diff = set(f1).difference(f2)
+        diff.discard('\n')
+        print(f'***** Difference between file {file1} and {file2} *******')
+        for line in diff:
+            print(line)
+        print('*' * 80)
+    if show_file_contents:
+        print('*' * 80)
+        for i, f_name in enumerate(f_names):
+            print('*' * 30 + ' Start of file ' + f_name + ' ' + '*' * 30)
+            print('(' + str(i) + ') File ' + f_name + ' content is:')
+            print('\t' + '\t'.join(open(f_name).readlines()))
+            print('*' * 30 + ' End of file ' + f_name + ' ' + '*' * 30)
+        print('*' * 80)
 
 
 def check_dependency_licenses():