data_migration/services/squasher.py
def post_processing(self):
        """
        post processing of squashed migration files,
        Drops part of django's squashmigration auto generated
        comments/commands that makes migration files unusable.
        """
        if self.dry_run:
            return

        self.load()
        try:
            os.mkdir(self.temp_directory)
        except FileExistsError:
            pass
        os.rename(self.file_name, self.temp_file_name)
        self._parse_generated_file()
        if not self.requires_action:
            return

        with open(self.temp_file_name, 'r') as read_file,\
             open(self.new_file_name, 'w') as write_file:
            stack_open = False
            line = "–"
            while line != "":
                line = read_file.readline()
                if 'RunPython(' in line:
                    stack_open = True
                    continue

                if stack_open and ')' in line:
                    stack_open = False
                    continue

                found = False
                for elem in self.migration_files_to_touch:
                    if elem.replacement_string in line:
                        found = True
                        index = line.find(elem.replacement_string)
                        next_space = line.find(
                            ' ',
                            index + len(elem.replacement_string)
                        )
                        if next_space == -1:
                            next_space = line.find(
                                ',',
                                index + len(elem.replacement_string)
                            )
                        if next_space == -1:
                            next_space = line.find(
                                '\n',
                                index + len(elem.replacement_string)
                            )
                        elem.replacement_string = line[index:next_space]
                        break

                if stack_open or 'code=' in line or '#' in line or found:
                    continue

                write_file.write(line)

        os.remove(self.temp_file_name)

        post processing of squashed migration files,
        Drops part of django's squashmigration auto generated
        comments/commands that makes migration files unusable.
        
post processing of squashed migration files,
Drops part of django's squashmigration auto generated
comments/commands that makes migration files unusable.
post processing of squashed migration files Drops part of django ' s squashmigration auto generated comments / commands that makes migration files unusable .
def post_processing(self):
        if self.dry_run:
            return
        self.load()
        try:
            os.mkdir(self.temp_directory)
        except FileExistsError:
            pass
        os.rename(self.file_name, self.temp_file_name)
        self._parse_generated_file()
        if not self.requires_action:
            return
        with open(self.temp_file_name, 'r') as read_file,\
             open(self.new_file_name, 'w') as write_file:
            stack_open = False
            line = "–"
            while line != "":
                line = read_file.readline()
                if 'RunPython(' in line:
                    stack_open = True
                    continue
                if stack_open and ')' in line:
                    stack_open = False
                    continue
                found = False
                for elem in self.migration_files_to_touch:
                    if elem.replacement_string in line:
                        found = True
                        index = line.find(elem.replacement_string)
                        next_space = line.find(
                            ' ',
                            index + len(elem.replacement_string)
                        )
                        if next_space == -1:
                            next_space = line.find(
                                ',',
                                index + len(elem.replacement_string)
                            )
                        if next_space == -1:
                            next_space = line.find(
                                '\n',
                                index + len(elem.replacement_string)
                            )
                        elem.replacement_string = line[index:next_space]
                        break
                if stack_open or 'code=' in line or '#' in line or found:
                    continue
                write_file.write(line)
        os.remove(self.temp_file_name)
def post_processing ( self ) : if self . dry_run : return self . load ( ) try : os . mkdir ( self . temp_directory ) except FileExistsError : pass os . rename ( self . file_name , self . temp_file_name ) self . _parse_generated_file ( ) if not self . requires_action : return with open ( self . temp_file_name , 'r' ) as read_file , open ( self . new_file_name , 'w' ) as write_file : stack_open = False line = "–" while line != "" : line = read_file . readline ( ) if 'RunPython(' in line : stack_open = True continue if stack_open and ')' in line : stack_open = False continue found = False for elem in self . migration_files_to_touch : if elem . replacement_string in line : found = True index = line . find ( elem . replacement_string ) next_space = line . find ( ' ' , index + len ( elem . replacement_string ) ) if next_space == - 1 : next_space = line . find ( ',' , index + len ( elem . replacement_string ) ) if next_space == - 1 : next_space = line . find ( '\n' , index + len ( elem . replacement_string ) ) elem . replacement_string = line [ index : next_space ] break if stack_open or 'code=' in line or '#' in line or found : continue write_file . write ( line ) os . remove ( self . temp_file_name )
post processing of squashed migration files,
Drops part of django's squashmigration auto generated
comments/commands that makes migration files unusable.
post processing of squashed migration files Drops part of django ' s squashmigration auto generated comments / commands that makes migration files unusable .
"""
        post processing of squashed migration files,
        Drops part of django's squashmigration auto generated
        comments/commands that makes migration files unusable.
        """
self