def rotate_existing_files(self):
        for i in range(self.backupCount - 1, 0, -1):
            source = '{filename}.{extension}.gz'.format(
                filename=self.baseFilename, extension=i)
            dest = '{filename}.{extension}.gz'.format(
                filename=self.baseFilename, extension=i + 1)
            if os.path.exists(source):
                if os.path.exists(dest):
                    os.remove(dest)
                os.rename(source, dest)

        dest = self.baseFilename + ".1.gz"
        if os.path.exists(dest):
            os.remove(dest)
dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlsys_compressedlogging.py/CompressedRotatingFileHandler.rotate_existing_files/original