diff --git a/gitlab-utils/gitlab_utils/spam_util.py b/gitlab-utils/gitlab_utils/spam_util.py index a3d6fcec745412770d251272f43b086a1b6ba7f5..7e9f55e5d7b393258595787dc6fe102f942c98bb 100644 --- a/gitlab-utils/gitlab_utils/spam_util.py +++ b/gitlab-utils/gitlab_utils/spam_util.py @@ -53,7 +53,7 @@ def cli(): @click.option('-o', '--output', type=click.File('w')) def dump_snippets(output) -> None: gl = gitlab.Gitlab.from_config() - with click.progressbar(gl.snippets.public(as_list=False, all=True, lazy=True), label='Listing spam snippets') as snippets: + with click.progressbar(gl.snippets.public(iterator=True, all=True, lazy=True), label='Listing spam snippets') as snippets: for x in snippets: u = gl.users.get(x.author['id']) if not good_user(gl, u): @@ -71,7 +71,7 @@ def parse_user_list(input) -> Iterator[UserName]: @click.option('-o', '--output', type=click.File('w')) def list_bad_users(output) -> None: gl = gitlab.Gitlab.from_config() - with click.progressbar(gl.users.list(as_list=False, all=True, lazy=True), label='Listing users') as users: + with click.progressbar(gl.users.list(iterator=True, all=True, lazy=True), label='Listing users') as users: for user in users: try: if user.username in USER_WHITELIST: @@ -89,7 +89,7 @@ def find_bad_projects(output) -> None: '-phuc-', '-tai-', '-app-', 'thuyet-', '-ly-', 'huong' } gl = gitlab.Gitlab.from_config() - with click.progressbar(gl.projects.list(as_list=False, all=True, lazy=True), label='Listing projects') as projects: + with click.progressbar(gl.projects.list(iterator=True, all=True, lazy=True), label='Listing projects') as projects: for proj in projects: try: if proj.owner['username'] in USER_WHITELIST: @@ -129,7 +129,7 @@ def good_user(gl, u) -> bool: @click.option('--dryrun', is_flag=True) def reject_pending_requests(dryrun: bool): gl = gitlab.Gitlab.from_config() - with click.progressbar(gl.users.list(as_list=False, all=True, lazy=True, without_projects=True), label='Listing users') as users: + with click.progressbar(gl.users.list(iterator=True, all=True, lazy=True, without_projects=True), label='Listing users') as users: for u in users: if u.state == 'blocked_pending_approval': logging.info(f'Rejecting approval request for {u.username}') @@ -190,7 +190,7 @@ def inactive_user(gl, u, thresh: timedelta = timedelta(days=180)) -> bool: @click.option('-o', '--output', type=click.File('w')) def list_inactive_users(output) -> None: gl = gitlab.Gitlab.from_config() - with click.progressbar(gl.users.list(as_list=False, all=True, lazy=True), label='Listing inactive users') as users: + with click.progressbar(gl.users.list(iterator=True, all=True, lazy=True), label='Listing inactive users') as users: for u in users: if inactive_user(gl, u) and not good_user(gl, u): output.write('%-20s # %s\n' % (u.username, u.last_sign_in_at))