Ejemplo n.º 1
0
    def Update_ProjectFile(self, Project_Dir, ProjName):

        MainFilePath = os.path.join(self.NRGsuite_Dir, '.proj')
        UserFilePath = os.path.join(Project_Dir, '.proj')
        Date = General.Get_Date()
        Seconds = time.time()

        LineToAdd = 'Name: ' + ProjName + ' Seconds: ' + str(
            Seconds
        ) + ' LastUsed: ' + Date + ' Creation: ' + Date + ' Path: ' + Project_Dir + '\n'

        NotFound = True

        if os.path.isfile(MainFilePath):
            # Add the project path to the .proj file
            file = open(MainFilePath, 'r')
            ProjFile = file.readlines()
            file.close()

            for line in ProjFile:
                if LineToAdd == line:
                    NotFound = False
                    break

        if NotFound:
            # Add the project path to the .proj file
            ProjFileMain = open(MainFilePath, 'a')
            ProjFileMain.write(LineToAdd)
            ProjFileMain.close()

        # Add the project path to the .proj file
        ProjFileUser = open(UserFilePath, 'w')
        ProjFileUser.write(LineToAdd)
        ProjFileUser.close()
Ejemplo n.º 2
0
    def Update_ProjectFile(self):

        MainFilePath = os.path.join(self.NRGsuite_Dir, '.proj')
        UserFilePath = os.path.join(self.ActualDirPath, '.proj')
        Date = General.Get_Date()
        Seconds = time.time()

        # Add the project path to the .proj file
        file = open(MainFilePath, 'r')
        ProjFile = file.readlines()
        file.close()

        # Update the file
        LineToAdd = 'Name: ' + self.ActualFileName + ' Seconds: ' + str(Seconds) + ' LastUsed: ' + Date + \
                    ' Creation: ' + self.dictProjectList[self.ActualKey][2] + ' Path: ' + self.ActualDirPath + '\n'
        StartLine = 'Name: ' + self.ActualFileName

        WriteFile = open(MainFilePath, 'w')
        NotFound = True

        for line in ProjFile:
            if NotFound and line.startswith(StartLine):
                WriteFile.write(LineToAdd)
                NotFound = False
            else:
                WriteFile.write(line)

        WriteFile.close()

        # Add the project path to the .proj file
        ProjFileUser = open(UserFilePath, 'w')
        ProjFileUser.write(LineToAdd)
        ProjFileUser.close()