File: 0003-Remove-distutils-code-in-preparation-for-Python-3.12.patch

package info (click to toggle)
python-django-pgschemas 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 848 kB
  • sloc: python: 3,887; makefile: 33; sh: 10; sql: 2
file content (36 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 21 Jan 2024 19:45:56 +0000
Subject: Remove distutils code in preparation for Python 3.12.

---
 django_pgschemas/management/commands/cloneschema.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/django_pgschemas/management/commands/cloneschema.py b/django_pgschemas/management/commands/cloneschema.py
index f7a2dad..fa6fffc 100644
--- a/django_pgschemas/management/commands/cloneschema.py
+++ b/django_pgschemas/management/commands/cloneschema.py
@@ -1,5 +1,3 @@
-from distutils.util import strtobool
-
 from django.core.checks import Tags, run_checks
 from django.core.management.base import BaseCommand, CommandError
 
@@ -39,11 +37,15 @@ class Command(BaseCommand):
         )
 
     def _ask(self, question):
+        bool_true = ("y", "yes", "t", "true", "on", "1")
+        bool_false = ("n", "no", "f", "false", "off", "0")
         answer = None
         while answer is None:
             try:
-                raw_answer = input(f"{question.strip()} [Y/n] ").strip() or "y"
-                answer = strtobool(raw_answer)
+                raw_answer = input(f"{question.strip()} [Y/n] ").strip().lower() or "y"
+                if raw_answer not in bool_true + bool_false:
+                    raise ValueError()
+                answer = raw_answer in bool_true
             except ValueError:
                 self.stderr.write(f"{raw_answer} is not a valid answer.")
                 pass