Example #1
0
class ReDirect:

    def __init__(self, newPath):
        self.registry = Registry()
        self.curPath = self.registry.readKey("savepath")
        self.newPath = newPath.replace("/", "\\")

        # Make sure the paths are different
        # TODO Display a message
        if self.curPath.lower() == self.newPath.lower():
            return False

        # Make sure the new path exists
        if not os.path.exists(self.newPath):
            os.makedirs(self.newPath)

        # Update the registry key
        self.registry.writeKey("savepath", self.newPath)

        # Move the saves
        for f in self.__findSaves():
            distutils.file_util.move_file(
                os.path.join(self.curPath, f),
                os.path.join(self.newPath, f)
            )

    def __findSaves(self):
        for f in os.listdir(self.curPath):
            fl = f.lower()
            if fl.endswith(".gs") or fl.endswith(".gsi"):
                yield f
Example #2
0
class ReDirect:
    def __init__(self, newPath):
        self.registry = Registry()
        self.curPath = self.registry.readKey("savepath")
        self.newPath = newPath.replace("/", "\\")

        # Make sure the paths are different
        # TODO Display a message
        if self.curPath.lower() == self.newPath.lower():
            return False

        # Make sure the new path exists
        if not os.path.exists(self.newPath):
            os.makedirs(self.newPath)

        # Update the registry key
        self.registry.writeKey("savepath", self.newPath)

        # Move the saves
        for f in self.__findSaves():
            distutils.file_util.move_file(os.path.join(self.curPath, f),
                                          os.path.join(self.newPath, f))

    def __findSaves(self):
        for f in os.listdir(self.curPath):
            fl = f.lower()
            if fl.endswith(".gs") or fl.endswith(".gsi"):
                yield f