@@ -44,13 +44,14 @@ def __init__(
4444 output_folder
4545 ):
4646 super ().__init__ (name = CMD_NAME )
47- self .mapping_suite_id = self ._init_list_input_opts_split (mapping_suite_id )
48- self .file = self ._init_list_input_opts_split (file )
49- self .branch = self ._init_list_input_opts_split (branch )
47+ self .mapping_suite_ids = self ._init_list_input_opts_split (mapping_suite_id )
48+ self .files = self ._init_list_input_opts_split (file )
49+ self .branches = self ._init_list_input_opts_split (branch )
5050 self .mappings_path = mappings_path
5151 self .output_folder = output_folder
5252
53- def _report (self , data , files : list ):
53+ def _report (self , diff , files : list ):
54+ data = diff ['data' ]
5455 report_file_file_name_json = Path (self .output_folder ) / (DEFAULT_REPORT_FILE_NAME + ".json" )
5556 with open (report_file_file_name_json , 'w+' ) as report_file :
5657 report_file .write (json .dumps (data , indent = 2 ))
@@ -60,9 +61,11 @@ def _report(self, data, files: list):
6061 generate_conceptual_mappings_diff_html_report (
6162 ConceptualMappingDiff (
6263 metadata = {
63- "branches" : self .branch ,
64- "mapping_suite_ids" : self .mapping_suite_id ,
65- "files" : files
64+ "branches" : self .branches ,
65+ "mapping_suite_ids" : self .mapping_suite_ids ,
66+ "files" : files ,
67+ "defaults" : diff ['metadata' ]['defaults' ],
68+ "metadata" : diff ['metadata' ]['metadata' ]
6669 },
6770 data = data
6871 ))
@@ -81,12 +84,12 @@ def _mappings_path(self) -> Path:
8184 return mappings_path
8285
8386 def _display_input (self ):
84- if self .branch :
85- self .log (LOG_WARN_TEXT .format ("GIT Branches: " ) + str (self .branch ))
86- if self .mapping_suite_id :
87- self .log (LOG_WARN_TEXT .format ("MappingSuites: " ) + str (self .mapping_suite_id ))
88- if self .file :
89- self .log (LOG_WARN_TEXT .format ("Files: " ) + str (self .file ))
87+ if self .branches :
88+ self .log (LOG_WARN_TEXT .format ("GIT Branches: " ) + str (self .branches ))
89+ if self .mapping_suite_ids :
90+ self .log (LOG_WARN_TEXT .format ("MappingSuites: " ) + str (self .mapping_suite_ids ))
91+ if self .files :
92+ self .log (LOG_WARN_TEXT .format ("Files: " ) + str (self .files ))
9093
9194 def run_cmd (self ):
9295 self ._display_input ()
@@ -95,49 +98,51 @@ def run_cmd(self):
9598 filepath1 = None
9699 filepath2 = None
97100
98- file_len = len (self .file )
99- mapping_suite_id_len = len (self .mapping_suite_id )
100- branch_len = len (self .branch )
101+ file_len = len (self .files )
102+ mapping_suite_id_len = len (self .mapping_suite_ids )
103+ branch_len = len (self .branches )
101104
102- if not self .branch :
103- if self .file and file_len == 2 :
104- filepath1 = self .file [0 ]
105+ if not self .branches :
106+ if self .files and file_len == 2 :
107+ filepath1 = self .files [0 ]
105108 assert Path (filepath1 ).is_file ()
106- filepath2 = self .file [1 ]
109+ filepath2 = self .files [1 ]
107110 assert Path (filepath2 ).is_file ()
108- elif self .mapping_suite_id :
111+ elif self .mapping_suite_ids :
109112 mappings_path = self ._mappings_path ()
110113 if mapping_suite_id_len == 2 :
111- filepath1 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_id [0 ])
114+ filepath1 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_ids [0 ])
112115 assert Path (filepath1 ).is_file ()
113- filepath2 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_id [1 ])
116+ filepath2 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_ids [1 ])
114117 assert Path (filepath2 ).is_file ()
115118 elif mapping_suite_id_len == 1 and file_len == 1 :
116- filepath1 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_id [0 ])
119+ filepath1 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_ids [0 ])
117120 assert Path (filepath1 ).is_file ()
118- filepath2 = self .file [0 ]
121+ filepath2 = str ( Path ( self .files [0 ]). resolve ())
119122 assert Path (filepath2 ).is_file ()
120123
121124 error = None
122125 if filepath1 and filepath2 :
123126 diff = mapping_suite_diff_files_conceptual_mappings ([Path (filepath1 ), Path (filepath2 )])
124- elif self .branch :
127+ elif self .branches :
125128 assert mapping_suite_id_len > 0
126- if branch_len == 1 and mapping_suite_id_len == 1 and not self .file :
129+ if branch_len == 1 and mapping_suite_id_len == 1 and not self .files :
127130 mappings_path = self ._mappings_path ()
128- filepath2 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_id [0 ])
131+ filepath2 = self ._conceptual_mappings_file_path (mappings_path , self .mapping_suite_ids [0 ])
129132 else :
130- filepath2 = (self .file [0 ] if file_len == 1 else None )
133+ filepath2 = (self .files [0 ] if file_len == 1 else None )
131134
132135 diff = mapping_suite_diff_repo_conceptual_mappings (
133- branch_or_tag_name = self .branch ,
134- mapping_suite_id = self .mapping_suite_id ,
136+ branch_or_tag_name = self .branches ,
137+ mapping_suite_id = self .mapping_suite_ids ,
135138 filepath = Path (filepath2 ) if filepath2 else None
136139 )
137140 else :
138141 error = Exception ("Cannot do a diff with provided input!" )
139142
140- self ._report (data = diff , files = [filepath1 , filepath2 ])
143+ if not error :
144+ self ._report (diff = diff , files = [filepath1 , filepath2 ])
145+
141146 self .run_cmd_result (error )
142147
143148
0 commit comments