Exemplo n.º 1
0
 def get_config_diff(self, file_path=None):
     '''
     Method to show current values vs those (saved) in a file.
     Will return a formatted string to show the difference
     '''
     #Create formatted string representation of dict values
     text1 = self._config_namespaces._to_json().splitlines()
     #Create formatted string representation of values in file
     file_path = file_path or self.simplecli_config_file
     file_dict = get_dict_from_file(file_path=file_path) or {}
     text2 = json.dumps(file_dict, sort_keys=True, indent=4).splitlines()
     diff = difflib.unified_diff(text2, text1, lineterm='')
     return '\n'.join(diff)
Exemplo n.º 2
0
 def get_config_diff(self, file_path=None):
     """
     Method to show current values vs those (saved) in a file.
     Will return a formatted string to show the difference
     """
     # Create formatted string representation of dict values
     text1 = self._config_namespaces._to_json().splitlines()
     # Create formatted string representation of values in file
     file_path = file_path or self.simplecli_config_file
     file_dict = get_dict_from_file(file_path=file_path) or {}
     text2 = json.dumps(file_dict, sort_keys=True, indent=4).splitlines()
     diff = difflib.unified_diff(text2, text1, lineterm="")
     return "\n".join(diff)
Exemplo n.º 3
0
 def _get_dict_from_file(self, file_path=None):
     file_path = file_path or self.config_file_path
     return get_dict_from_file(file_path)
Exemplo n.º 4
0
 def _get_dict_from_file(self, file_path=None):
     file_path = file_path or self.config_file_path
     return get_dict_from_file(file_path)