@@ -11,17 +11,22 @@ def main() -> None:
1111
1212
1313def read_file (path : str ):
14- if path .endswith ('.json' ):
15- load_data = json .load
16- elif path .endswith (('.yaml' , '.yml' )):
17- load_data = yaml .safe_load
18- else :
19- raise ValueError (f"ERROR: Unsupported format of file { path } ." )
2014 try :
15+ if path .endswith ('.json' ):
16+ load_data = json .load
17+ elif path .endswith (('.yaml' , '.yml' )):
18+ load_data = yaml .safe_load
19+ else :
20+ raise ValueError
21+
2122 with open (path , mode = 'r' , encoding = 'utf-8' ) as file :
2223 return load_data (file )
2324 except OSError as error :
24- raise OSError (f"ERROR: Can't read file { path } . Reason: { error } " )
25+ print (f"ERROR: Can't read file { path } . Reason: { error } " )
26+ return None
27+ except ValueError :
28+ print (f"ERROR: Unsupported format of file { path } ." )
29+ return None
2530
2631
2732def get_list_of_dict_with_sign (data1 , data2 ) -> list :
@@ -73,6 +78,13 @@ def make_str_from_list(items: list) -> str:
7378 return '\n ' .join (list_of_str )
7479
7580
81+ # def check_the_nesting(list_of_dict: list) -> list:
82+ # for item in list_of_dict:
83+ # value = item['value']
84+ # if isinstance(value, dict):
85+ # get_list_of_dict_with_sign(value)
86+
87+
7688def generate_diff (path1 , path2 ) -> str :
7789 dict_data1 = read_file (path1 )
7890 dict_data2 = read_file (path2 )
0 commit comments