コード例 #1
0
ファイル: motionManager.py プロジェクト: TheTmirror/MotionNew
    def saveOrUpdateMotion(self, motion):
        dm = DataManager()

        #Prüfen ob die Motion existiert
        #Sie existiert wenn es eine MotionFile mit passendem
        #Namen gibt
        path = None
        if motion.getName() in self.getAllMotionFiles():
            path = self.TEMPLATES_PATH + self.getMotionFile(motion.getName())
            #print(path)
        else:
            i = 0
            plainPath = self.TEMPLATES_PATH + 'template'
            while os.path.exists(plainPath + "%s.txt" % i):
                i = i + 1
            else:
                plainPath = plainPath + "%s.txt" % i

            if not os.path.exists(os.path.dirname(self.TEMPLATES_PATH)):
                os.makedirs(os.path.dirname(self.TEMPLATES_PATH))

            path = plainPath

        dm.saveMotion(motion, path)
        if motion.getName() not in self.__motions:
            self.__motions[motion.getName()] = motion
            self.__motionFiles[motion.getName()] = path

        print('Motion Saved or Updated')
コード例 #2
0
    def saveMotion(self, template):
        dm = DataManager()

        i = 0
        plainPath = self.TEMPLATES_PATH + 'template'
        while os.path.exists(plainPath + "%s.txt" % i):
            i = i + 1
        else:
            plainPath = plainPath + "%s.txt" % i

        if not os.path.exists(os.path.dirname(self.TEMPLATES_PATH)):
            os.makedirs(os.path.dirname(self.TEMPLATES_PATH))

        dm.saveMotion(template, plainPath)
        print('Motion Saved')
コード例 #3
0
 def updateMotion(self, motion):
     dm = DataManager()
     path = self.TEMPLATES_PATH + self.getMotionFile(motion.getName())
     dm.saveMotion(motion, path)
     print('Motion Updated')