[sysadmin-bin] inactive-gitlab-users.py: Reformat with black



commit 5a03a71ad4739e50542cf78e2347d8821cd25878
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Mon Jul 22 15:07:06 2019 +0200

    inactive-gitlab-users.py: Reformat with black

 gitlab/inactive-gitlab-users.py | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/gitlab/inactive-gitlab-users.py b/gitlab/inactive-gitlab-users.py
index 2b63a64..196db26 100755
--- a/gitlab/inactive-gitlab-users.py
+++ b/gitlab/inactive-gitlab-users.py
@@ -48,7 +48,7 @@ def get_inactive_users(gl, timedelta_unit, timedelta_value):
         "gentoo.org",
         "igalia.com",
         "gnome.org",
-        "opensuse.org"
+        "opensuse.org",
         "redhat.com",
         "suse.com",
         "ubuntu.com",
@@ -105,7 +105,7 @@ def get_inactive_users(gl, timedelta_unit, timedelta_value):
         ):
             events = user.events.list(all=True)
             if len(events) == 0:
-                userdata['reason'] = "inactivity"
+                userdata["reason"] = "inactivity"
                 results.append(userdata)
                 continue
 
@@ -113,7 +113,7 @@ def get_inactive_users(gl, timedelta_unit, timedelta_value):
             # Some users set URL in bio, check it against surbl
             if re.match("http[s]?://", attrs["bio"], re.IGNORECASE):
                 if check_if_spam(attrs["bio"]):
-                    userdata['reason'] = "spam"
+                    userdata["reason"] = "spam"
                     results.append(userdata)
                     continue
 
@@ -123,16 +123,20 @@ def get_inactive_users(gl, timedelta_unit, timedelta_value):
                 detector = polyglot.detect.Detector(attrs["bio"])
                 lang = detector.language
 
-                if detector.reliable and lang.code in unwanted_langs and lang.confidence > 95:
-                    userdata['reason'] = "language"
+                if (
+                    detector.reliable
+                    and lang.code in unwanted_langs
+                    and lang.confidence > 95
+                ):
+                    userdata["reason"] = "language"
                     results.append(userdata)
                     continue
             except polyglot.detect.base.UnknownLanguage:
                 pass
 
         if attrs["website_url"] and len(attrs["website_url"]) > 0:
-            if check_if_spam(attrs['website_url']):
-                userdata['reason'] = "spam"
+            if check_if_spam(attrs["website_url"]):
+                userdata["reason"] = "spam"
                 results.append(userdata)
                 continue
 
@@ -173,7 +177,7 @@ def trust_all_groups(gl):
 
 
 def trust_2fa_users(gl):
-    users = gl.users.list(all=True, two_factor='enabled', as_list=False)
+    users = gl.users.list(all=True, two_factor="enabled", as_list=False)
 
     for user in users:
         trust_user(gl, user.id)
@@ -198,11 +202,17 @@ if __name__ == "__main__":
         "trust-groups", help="mark users which are member of any group as trusted"
     )
     trust_2fa = subparsers.add_parser(
-        "trust-2fa", help="mark users which have two factor authenticated enabled as trusted"
+        "trust-2fa",
+        help="mark users which have two factor authenticated enabled as trusted",
     )
 
     inactive = subparsers.add_parser("get-inactive", help="get inactive users")
-    inactive.add_argument("-t", "--timedelta", default="months:1", help="grace period for users to become 
active (unit:value)")
+    inactive.add_argument(
+        "-t",
+        "--timedelta",
+        default="months:1",
+        help="grace period for users to become active (unit:value)",
+    )
 
     trust = subparsers.add_parser("trust", help="mark users as trusted")
     trust.add_argument("user_id", nargs="+", help="user IDs to mark as trusted")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]