kopia lustrzana https://github.com/dgtlmoon/changedetection.io
				
				
				
			Code - Getting ready for newer python versions - packing our own strtobool (#2291)
							rodzic
							
								
									21f4ba2208
								
							
						
					
					
						commit
						9449c59fbb
					
				| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
 | 
			
		||||
__version__ = '0.45.17'
 | 
			
		||||
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from json.decoder import JSONDecodeError
 | 
			
		||||
import os
 | 
			
		||||
#os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import os
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
 | 
			
		||||
from flask_expects_json import expects_json
 | 
			
		||||
from changedetectionio import queuedWatchMetaData
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@
 | 
			
		|||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from flask import Blueprint, request, make_response
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from flask import Blueprint, flash, redirect, url_for
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
from changedetectionio.store import ChangeDetectionStore
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import sys
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from loguru import logger
 | 
			
		||||
from changedetectionio.content_fetchers.exceptions import BrowserStepsStepException
 | 
			
		||||
import os
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import queue
 | 
			
		|||
import threading
 | 
			
		||||
import time
 | 
			
		||||
from copy import deepcopy
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from functools import wraps
 | 
			
		||||
from threading import Event
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import os
 | 
			
		||||
import re
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
 | 
			
		||||
from wtforms import (
 | 
			
		||||
    BooleanField,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
import os
 | 
			
		||||
import re
 | 
			
		||||
import time
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ import os
 | 
			
		|||
import hashlib
 | 
			
		||||
import re
 | 
			
		||||
from copy import deepcopy
 | 
			
		||||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
from loguru import logger
 | 
			
		||||
 | 
			
		||||
class difference_detection_processor():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
from distutils.util import strtobool
 | 
			
		||||
from changedetectionio.strtobool import strtobool
 | 
			
		||||
 | 
			
		||||
from flask import (
 | 
			
		||||
    flash
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
# Because strtobool was removed in python 3.12 distutils
 | 
			
		||||
 | 
			
		||||
_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:
 | 
			
		||||
        raise ValueError('"{}" is not a valid bool value'.format(value))
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue