1
我有幾種方法在構造上變化不大。它們用於設置給定項目(field_name)上的(linux-like)權限。變量oview_perms
,gview_perms
,aview_perms
分別代表所有者,組和匿名權限。這些變量是不可變的,所以這就是爲什麼我將它們設置爲返回。Python - 許多差異很小的方法
也許有一種方法可以簡化它,但仍然保持易讀性?
def set_oview_perm(self, field_name, perm):
self.oview_perms = self._set_field_permission(self.oview_perms, field_name, perm)
def set_gview_perm(self, field_name, perm):
self.gview_perms = self._set_field_permission(self.gview_perms, field_name, perm)
def set_aview_perm(self, field_name, perm):
self.aview_perms = self._set_field_permission(self.aview_perms, field_name, perm)
def set_oedit_perm(self, field_name, perm):
self.oedit_perms = self._set_field_permission(self.oedit_perms, field_name, perm)
def set_gedit_perm(self, field_name, perm):
self.gedit_perms = self._set_field_permission(self.gedit_perms, field_name, perm)
def set_aedit_perm(self, field_name, perm):
self.aedit_perms = self._set_field_permission(self.aedit_perms, field_name, perm)