Example #1
0
 def save_file(self, a_folder, a_file, a_text, a_force_new=False):
     """ Writes a file to disk and updates the project
         history to reflect the changes
     """
     f_full_path = os.path.join(*(str(x) for x in (self.project_folder,
                                                   a_folder, a_file)))
     if not a_force_new and os.path.isfile(f_full_path):
         f_old = pydaw_util.pydaw_read_file_text(f_full_path)
         if f_old == a_text:
             return None
         f_existed = 1
     else:
         f_old = ""
         f_existed = 0
     pydaw_util.pydaw_write_file_text(f_full_path, a_text)
     return f_existed, f_old
Example #2
0
 def save_file(self, a_folder, a_file, a_text, a_force_new=False):
     """ Writes a file to disk and updates the project
         history to reflect the changes
     """
     f_full_path = os.path.join(
         *(str(x) for x in (self.project_folder, a_folder, a_file)))
     if not a_force_new and os.path.isfile(f_full_path):
         f_old = pydaw_util.pydaw_read_file_text(f_full_path)
         if f_old == a_text:
             return None
         f_existed = 1
     else:
         f_old = ""
         f_existed = 0
     pydaw_util.pydaw_write_file_text(f_full_path, a_text)
     return f_existed, f_old
Example #3
0
    def verify_history(self):
        print("Verifying history db...")
        f_result = \
"""
The text below (if any) will show the differences between what's in
the history database and the files in the project directory.
There should not be any differences, ever.  If there are differences,
that indicates a bug in PyDAW.
-------------------------------------------------------------------------------

"""
        for root, dirs, files in os.walk(self.project_dir):
            for f_file in files:
                if f_file == "history.db" or f_file.endswith(".wav") or \
                root.endswith("samplegraph") or f_file == "default.pywavs":
                    continue
                f_current_file = "{}/{}".format(root, f_file)
                f_current_text = pydaw_util.pydaw_read_file_text(
                    f_current_file)
                if root == self.project_dir:
                    f_dir_name = ""
                else:
                    f_dir_name = root.split("/")[-1]
                print("Testing file {}/{}".format(f_dir_name, f_file))
                f_history_text = self.get_latest_version_of_file(
                    f_dir_name, f_file)
                if f_current_text != f_history_text:
                    if f_history_text is None:
                        f_history_arr = []
                    else:
                        f_history_arr = f_history_text.split("\n")
                    for f_line in difflib.unified_diff(
                    f_current_text.split("\n"), f_history_arr,
                    f_current_file, "History version"):
                        f_result += f_line + "\n"
        return f_result