def IsValid(self):
        errors = [""]

        validid = False
        if self.id is None:
            errors.append("Id undefined")
        elif not isinstance(self.id, int):
            errors.append("Id should be integer")
        else:
            validid = True

        if self.placements is None:
            errors.append("Placements undefined")
        elif not isinstance(self.placements, list):
            errors.append("Placements should be a list")
        elif not all([isinstance(p, ThreeDplacement)
                      for p in self.placements]):
            errors.append("Placements should be placement objects")
        else:
            for p in self.placements:
                b, e = p.IsValid()
                if not b:
                    errors.append(indent(e))

        if len(errors) > 1:
            return False, "Invalid loadingspace" + (
                " with id " + str(self.id)
                if validid else "") + ":" + "\n\t- ".join(map(indent, errors))
        return True, ""
コード例 #2
0
 def IsValid(self):
     errors = [""]
     
     validid = False
     if self.id is None:
         errors.append("Id undefined")
     elif not isinstance(self.id, int):
         errors.append("Id should be integer")
     else:
         validid = True
         
     if self.kindid is None:
         errors.append("Kind id undefined")
     elif not isinstance(self.kindid, int):
         errors.append("Kind id should be integer")
         
     if self.loadingspace is None:
         errors.append("Loadingspace undefined")
     elif not isinstance(self.loadingspace, ThreeDloadingspace):
         errors.append("Expected loadingspace")
     else:
         b,e = self.loadingspace.IsValid()
         if not b:
             errors.append(indent(e))
             
     if len(errors)>1:
         return False, "Invalid box" + (" with id " + str(self.id) if validid else "") + ":" + "\n\t- ".join(map(indent, errors))
     return True,""
    def IsValid(self):
        errors = [""]
        
        validid = False
        if self.id is None:
            errors.append("Id undefined")
        elif not isinstance(self.id, int):
            errors.append("Id should be integer")
        else:
            validid = True
            
        if self.boundingBox is None:
            errors.append("Bounding box undefined")
        elif not isinstance(self.boundingBox, list):
            errors.append("Bounding box should be a list")
        elif None in self.boundingBox or len(self.boundingBox) != 3:
            errors.append("Bounding box should have three dimensions")
        elif not all([isinstance(x, int) for x in self.boundingBox]):
            errors.append("Dimensions of bounding box should be integer")
        elif not all([x > 0 for x in self.boundingBox]):
            errors.append("Dimensions of bounding box should be positive")
            
        if self.position is None:
            errors.append("Position undefined")
        elif not isinstance(self.position, list):
            errors.append("Position should be a list")
        elif None in self.position or len(self.position) != 3:
            errors.append("Position should have three dimensions")
        elif not all([isinstance(x, int) for x in self.position]):
            errors.append("Dimensions of position should be integer")
        elif not all([x >= 0 for x in self.position]):
            errors.append("Dimensions of position should be non-negative")
            
        if self.loadingspace is None:
            errors.append("Loadingspace undefined")
        elif not isinstance(self.loadingspace, ThreeDloadingspace):
            errors.append("Expected loadingspace")
        else:
            b,e = self.loadingspace.IsValid()
            if not b:
                errors.append(indent(e))
                
        if self.quantity is None:
            errors.append("Quantity is undefined")
        elif not isinstance(self.quantity, int):
            errors.append("Quantity should be integer")
        elif not self.quantity >= 0:
            errors.append("Quantity should be non-negative")
        
        if self.orientations is None:
            errors.append("Orientations undefined")
        elif not isinstance(self.orientations, set):
            errors.append("Orientations should be a set")
        elif not ({Orientation.GetFromAlias(alias) for alias in self.orientations}.issubset(Orientation.THIS_SIDE_UP)):
            errors.append("Orientations must be subset of {" + ", ".join(Orientation.THIS_SIDE_UP) + "}, where WLH can be used as alias for WlH")

        if len(errors)>1:
            return False, "Invalid boxkind" + (" with id " + str(self.id) + "" if validid else "") + ":" + "\n\t- ".join(map(indent, errors))
        return True, ""
コード例 #4
0
 def IsValid(self):
     errors = [""]
     
     validid = False
     if self.id is None:
         errors.append("Id undefined")
     elif not isinstance(self.id, int):
         errors.append("Id should be integer")
     else:
         validid = True
         
     if self.kindid is None:
         errors.append("Kind id undefined")
     elif not isinstance(self.kindid, int):
         errors.append("Kind id should be integer")
         
     if self.loadingspaces is None:
         errors.append("Loadingspaces undefined")
     elif not isinstance(self.loadingspaces,list):
         errors.append("Loadingspaces should be a list")
     elif not self.loadingspaces:
         errors.append("No loadingspaces specified")
     elif not all([isinstance(x, ThreeDloadingspace) for x in self.loadingspaces]):
         errors.append("Expected loadingspace")
     else:
         for ls in self.loadingspaces:
             b,e = ls.IsValid()
             if not b:
                 errors.append(indent(e))
         b,e = checkDuplicateIds(self.loadingspaces)
         if not b:
             errors.append(e)
                 
     if len(errors)>1:
         return False, "Invalid container" + (" with id " + str(self.id) if validid else "") + ":" + "\n\t- ".join(map(indent, errors))
     return True,""