def readFile(self, file): # open file f = open(file, "r") # create project obj p = Project() # for each line in the file for line in f.readlines(): # split by the ":" split = line.split(":") # assign attributes if split[0] == "ProjectName": p.projectName = split[1] elif split[0] == "LastWorkedOn": p.lastWorkedOn = split[1] elif split[0] == "Path": p.projectPath = split[1] p.gitLog = self.getLogFile(p.projectPath) elif split[0] == "Description": p.projectDescription = split[1] elif split[0] == "WhereDidILeaveIt": p.whereDidILeaveIt = split[1] elif split[0] == "NextSteps": p.nextSteps = split[1] # close the file! f.close() # return created project return p
def updateProject(self, projectName): # for each file in the directory for file in os.listdir(self.installationDirectory): # if the file is a .myproj file pname = projectName if not pname.endswith(".myproj"): pname = pname + ".myproj" if file == pname: newp = Project() p = self.readFile(self.installationDirectory + os.sep + file) newp.projectName = input("ProjectName[" + p.projectName.replace("\n", "") + "]: ") if newp.projectName == "": newp.projectName = p.projectName newp.projectDescription = input("Description[" + p.projectDescription[0:10].replace("\n", "") + "...]: ") if newp.projectDescription == "": newp.projectDescription = p.projectDescription newp.projectPath = input("Path[" + p.projectPath.replace("\n", "") + "...]: ") if newp.projectPath == "": newp.projectPath = p.projectPath dt = str(datetime.datetime.now().isoformat()).replace(":", ".") newp.lastWorkedOn = input("LastWorkedOn[" + p.lastWorkedOn.replace("\n", "") + "]: ") if newp.lastWorkedOn == "": newp.lastWorkedOn = dt newp.whereDidILeaveIt = input("WhereDidILeaveIt[" + p.whereDidILeaveIt[0:10].replace("\n", "") + "...]: ") if newp.whereDidILeaveIt == "": newp.whereDidILeaveIt = p.whereDidILeaveIt newp.nextSteps = input("NextSteps[" + p.nextSteps[0:10].replace("\n", "") + "...]: ") if newp.nextSteps == "": newp.nextSteps = p.nextSteps f = open(self.installationDirectory + os.sep + file, "w") f.write("ProjectName:" + newp.projectName + "\n") f.write("Description:" + newp.projectDescription + "\n") f.write("Path:" + newp.projectPath + "\n") f.write("LastWorkedOn:" + newp.lastWorkedOn + "\n") f.write("WhereDidILeaveIt:" + newp.whereDidILeaveIt + "\n") f.write("NextSteps:" + newp.nextSteps + "\n") f.close() return print("No project found with that name!")
def createNew(self): p = Project() p.projectName = input("ProjectName: ") p.projectDescription = input("Description: ") p.projectPath = input("Absolute Path: ") dt = str(datetime.datetime.now().isoformat()).replace(":", ".") p.lastWorkedOn = input("LastWorkedOn [" + dt + "]: ") if p.lastWorkedOn == "": p.lastWorkedOn = dt p.whereDidILeaveIt = input("WhereDidILeaveIt: ") p.nextSteps = input("NextSteps: ") f = open(self.installationDirectory + p.projectName + ".myproj", 'w+') f.write("ProjectName:" + p.projectName + "\n") f.write("Description:" + p.projectDescription + "\n") f.write("Path:" + p.projectPath + "\n") f.write("LastWorkedOn:" + p.lastWorkedOn + "\n") f.write("WhereDidILeaveIt:" + p.whereDidILeaveIt + "\n") f.write("NextSteps:" + p.nextSteps + "\n") f.close()