classLayerComps(Photoshop):"""The layer comps collection in this document."""def__init__(self,parent):super().__init__(parent=parent)self._flag_as_method("add","removeAll",)def__len__(self):returnself.length@propertydeflength(self):returnlen(self._layers)@propertydef_layers(self):returnlist(self.app)@propertydefparent(self):returnself.app.parent@propertydeftypename(self):returnself.app.typenamedefadd(self,name,comment="No Comment.",appearance=True,position=True,visibility=True,childLayerCompStat=False,):returnLayerComp(self.app.add(name,comment,appearance,position,visibility,childLayerCompStat))defgetByName(self,name):forlayerinself._layers:iflayer.name==name:returnLayerComp(layer)raisePhotoshopPythonAPIError(f'Could not find a layer named "{name}"')defremoveAll(self):self.app.removeAll()def__iter__(self):forlayerinself._layers:yieldLayerComp(layer)