##// END OF EJS Templates
auth: code cleanup, use set literals for py3 compat
marcink -
r2821:ce1c3d8c default
parent child Browse files
Show More
@@ -1304,7 +1304,7 b' class AuthUser(object):'
1304 1304 # since we use heavy caching sometimes it happens that we get
1305 1305 # deleted objects here, we just skip them
1306 1306 pass
1307 return _set or set(['0.0.0.0/0', '::/0'])
1307 return _set or {ip for ip in ['0.0.0.0/0', '::/0']}
1308 1308
1309 1309
1310 1310 def set_available_permissions(settings):
@@ -1636,7 +1636,7 b' class HasRepoPermissionAllDecorator(Perm'
1636 1636 repo_name = self._get_repo_name()
1637 1637
1638 1638 try:
1639 user_perms = set([perms['repositories'][repo_name]])
1639 user_perms = {perms['repositories'][repo_name]}
1640 1640 except KeyError:
1641 1641 log.debug('cannot locate repo with name: `%s` in permissions defs',
1642 1642 repo_name)
@@ -1663,7 +1663,7 b' class HasRepoPermissionAnyDecorator(Perm'
1663 1663 repo_name = self._get_repo_name()
1664 1664
1665 1665 try:
1666 user_perms = set([perms['repositories'][repo_name]])
1666 user_perms = {perms['repositories'][repo_name]}
1667 1667 except KeyError:
1668 1668 log.debug(
1669 1669 'cannot locate repo with name: `%s` in permissions defs',
@@ -1691,7 +1691,7 b' class HasRepoGroupPermissionAllDecorator'
1691 1691 perms = user.permissions
1692 1692 group_name = self._get_repo_group_name()
1693 1693 try:
1694 user_perms = set([perms['repositories_groups'][group_name]])
1694 user_perms = {perms['repositories_groups'][group_name]}
1695 1695 except KeyError:
1696 1696 log.debug(
1697 1697 'cannot locate repo group with name: `%s` in permissions defs',
@@ -1720,7 +1720,7 b' class HasRepoGroupPermissionAnyDecorator'
1720 1720 group_name = self._get_repo_group_name()
1721 1721
1722 1722 try:
1723 user_perms = set([perms['repositories_groups'][group_name]])
1723 user_perms = {perms['repositories_groups'][group_name]}
1724 1724 except KeyError:
1725 1725 log.debug(
1726 1726 'cannot locate repo group with name: `%s` in permissions defs',
@@ -1747,7 +1747,7 b' class HasUserGroupPermissionAllDecorator'
1747 1747 perms = user.permissions
1748 1748 group_name = self._get_user_group_name()
1749 1749 try:
1750 user_perms = set([perms['user_groups'][group_name]])
1750 user_perms = {perms['user_groups'][group_name]}
1751 1751 except KeyError:
1752 1752 return False
1753 1753
@@ -1769,7 +1769,7 b' class HasUserGroupPermissionAnyDecorator'
1769 1769 perms = user.permissions
1770 1770 group_name = self._get_user_group_name()
1771 1771 try:
1772 user_perms = set([perms['user_groups'][group_name]])
1772 user_perms = {perms['user_groups'][group_name]}
1773 1773 except KeyError:
1774 1774 return False
1775 1775
@@ -1882,7 +1882,7 b' class HasRepoPermissionAll(PermsFunction'
1882 1882 self.repo_name = self._get_repo_name()
1883 1883 perms = user.permissions
1884 1884 try:
1885 user_perms = set([perms['repositories'][self.repo_name]])
1885 user_perms = {perms['repositories'][self.repo_name]}
1886 1886 except KeyError:
1887 1887 return False
1888 1888 if self.required_perms.issubset(user_perms):
@@ -1905,7 +1905,7 b' class HasRepoPermissionAny(PermsFunction'
1905 1905 self.repo_name = self._get_repo_name()
1906 1906 perms = user.permissions
1907 1907 try:
1908 user_perms = set([perms['repositories'][self.repo_name]])
1908 user_perms = {perms['repositories'][self.repo_name]}
1909 1909 except KeyError:
1910 1910 return False
1911 1911 if self.required_perms.intersection(user_perms):
@@ -1922,8 +1922,7 b' class HasRepoGroupPermissionAny(PermsFun'
1922 1922 def check_permissions(self, user):
1923 1923 perms = user.permissions
1924 1924 try:
1925 user_perms = set(
1926 [perms['repositories_groups'][self.repo_group_name]])
1925 user_perms = {perms['repositories_groups'][self.repo_group_name]}
1927 1926 except KeyError:
1928 1927 return False
1929 1928 if self.required_perms.intersection(user_perms):
@@ -1940,8 +1939,7 b' class HasRepoGroupPermissionAll(PermsFun'
1940 1939 def check_permissions(self, user):
1941 1940 perms = user.permissions
1942 1941 try:
1943 user_perms = set(
1944 [perms['repositories_groups'][self.repo_group_name]])
1942 user_perms = {perms['repositories_groups'][self.repo_group_name]}
1945 1943 except KeyError:
1946 1944 return False
1947 1945 if self.required_perms.issubset(user_perms):
@@ -1958,7 +1956,7 b' class HasUserGroupPermissionAny(PermsFun'
1958 1956 def check_permissions(self, user):
1959 1957 perms = user.permissions
1960 1958 try:
1961 user_perms = set([perms['user_groups'][self.user_group_name]])
1959 user_perms = {perms['user_groups'][self.user_group_name]}
1962 1960 except KeyError:
1963 1961 return False
1964 1962 if self.required_perms.intersection(user_perms):
@@ -1975,7 +1973,7 b' class HasUserGroupPermissionAll(PermsFun'
1975 1973 def check_permissions(self, user):
1976 1974 perms = user.permissions
1977 1975 try:
1978 user_perms = set([perms['user_groups'][self.user_group_name]])
1976 user_perms = {perms['user_groups'][self.user_group_name]}
1979 1977 except KeyError:
1980 1978 return False
1981 1979 if self.required_perms.issubset(user_perms):
@@ -2011,7 +2009,7 b' class HasPermissionAnyMiddleware(object)'
2011 2009 perms = user.permissions_with_scope({'repo_name': repo_name})
2012 2010
2013 2011 try:
2014 user_perms = set([perms['repositories'][repo_name]])
2012 user_perms = {perms['repositories'][repo_name]}
2015 2013 except Exception:
2016 2014 log.exception('Error while accessing user permissions')
2017 2015 return False
@@ -2094,7 +2092,7 b' class HasRepoPermissionAllApi(_BaseApiPe'
2094 2092 def check_permissions(self, perm_defs, repo_name=None, group_name=None,
2095 2093 user_group_name=None):
2096 2094 try:
2097 _user_perms = set([perm_defs['repositories'][repo_name]])
2095 _user_perms = {perm_defs['repositories'][repo_name]}
2098 2096 except KeyError:
2099 2097 log.warning(traceback.format_exc())
2100 2098 return False
@@ -2107,7 +2105,7 b' class HasRepoPermissionAnyApi(_BaseApiPe'
2107 2105 def check_permissions(self, perm_defs, repo_name=None, group_name=None,
2108 2106 user_group_name=None):
2109 2107 try:
2110 _user_perms = set([perm_defs['repositories'][repo_name]])
2108 _user_perms = {perm_defs['repositories'][repo_name]}
2111 2109 except KeyError:
2112 2110 log.warning(traceback.format_exc())
2113 2111 return False
@@ -2120,7 +2118,7 b' class HasRepoGroupPermissionAnyApi(_Base'
2120 2118 def check_permissions(self, perm_defs, repo_name=None, group_name=None,
2121 2119 user_group_name=None):
2122 2120 try:
2123 _user_perms = set([perm_defs['repositories_groups'][group_name]])
2121 _user_perms = {perm_defs['repositories_groups'][group_name]}
2124 2122 except KeyError:
2125 2123 log.warning(traceback.format_exc())
2126 2124 return False
@@ -2133,7 +2131,7 b' class HasRepoGroupPermissionAllApi(_Base'
2133 2131 def check_permissions(self, perm_defs, repo_name=None, group_name=None,
2134 2132 user_group_name=None):
2135 2133 try:
2136 _user_perms = set([perm_defs['repositories_groups'][group_name]])
2134 _user_perms = {perm_defs['repositories_groups'][group_name]}
2137 2135 except KeyError:
2138 2136 log.warning(traceback.format_exc())
2139 2137 return False
@@ -2146,7 +2144,7 b' class HasUserGroupPermissionAnyApi(_Base'
2146 2144 def check_permissions(self, perm_defs, repo_name=None, group_name=None,
2147 2145 user_group_name=None):
2148 2146 try:
2149 _user_perms = set([perm_defs['user_groups'][user_group_name]])
2147 _user_perms = {perm_defs['user_groups'][user_group_name]}
2150 2148 except KeyError:
2151 2149 log.warning(traceback.format_exc())
2152 2150 return False
General Comments 0
You need to be logged in to leave comments. Login now