Skip to content

Commit

Permalink
feat: remove strtobool
Browse files Browse the repository at this point in the history
  • Loading branch information
vrenaville committed Sep 5, 2024
1 parent 8046783 commit 7d5a0f2
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base_attachment_object_storage/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import time
from contextlib import closing, contextmanager
from distutils.util import strtobool
from .strtobool import strtobool

import psycopg2

Expand Down
21 changes: 21 additions & 0 deletions base_attachment_object_storage/models/strtobool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
_MAP = {
"y": True,
"yes": True,
"t": True,
"true": True,
"on": True,
"1": True,
"n": False,
"no": False,
"f": False,
"false": False,
"off": False,
"0": False,
}


def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
2 changes: 1 addition & 1 deletion cloud_platform/models/cloud_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import re
from collections import namedtuple
from distutils.util import strtobool
from .strtobool import strtobool

from odoo import api, models
from odoo.tools.config import config
Expand Down
21 changes: 21 additions & 0 deletions cloud_platform/models/strtobool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
_MAP = {
"y": True,
"yes": True,
"t": True,
"true": True,
"on": True,
"1": True,
"n": False,
"no": False,
"f": False,
"false": False,
"off": False,
"0": False,
}


def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
2 changes: 1 addition & 1 deletion logging_json/json_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import threading
import uuid
from distutils.util import strtobool
from .strtobool import strtobool

from odoo import http

Expand Down
21 changes: 21 additions & 0 deletions logging_json/strtobool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
_MAP = {
"y": True,
"yes": True,
"t": True,
"true": True,
"on": True,
"1": True,
"n": False,
"no": False,
"f": False,
"false": False,
"off": False,
"0": False,
}


def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error

0 comments on commit 7d5a0f2

Please sign in to comment.