diff --git a/modules/openapi-generator/src/main/resources/python/rest.mustache b/modules/openapi-generator/src/main/resources/python/rest.mustache index 4740f10fd0035c6beeb5d98f1960dfe6dfdafc50..d300c4a1e8fb1cdeb2ab9697f297a1982980335a 100644 --- a/modules/openapi-generator/src/main/resources/python/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/rest.mustache @@ -11,7 +11,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from {{packageName}}.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -285,16 +286,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -309,6 +312,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -321,12 +325,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -335,4 +339,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy}) diff --git a/samples/client/petstore/python/petstore_api/rest.py b/samples/client/petstore/python/petstore_api/rest.py index e264c456aab0a31e060f36fd07a6996ca3224076..3c10df7e3cb217370171066b0b62fb6454dc2670 100644 --- a/samples/client/petstore/python/petstore_api/rest.py +++ b/samples/client/petstore/python/petstore_api/rest.py @@ -19,7 +19,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from petstore_api.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -293,16 +294,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -317,6 +320,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -329,12 +333,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -343,4 +347,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy}) diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py index e264c456aab0a31e060f36fd07a6996ca3224076..3c10df7e3cb217370171066b0b62fb6454dc2670 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py @@ -19,7 +19,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from petstore_api.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -293,16 +294,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -317,6 +320,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -329,12 +333,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -343,4 +347,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy}) diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/rest.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/rest.py index 636f31b19a369778149496ffef8629cd0585a368..0a4b5f56ed0e2719e018ad94ac58a31637391276 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/rest.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/rest.py @@ -19,7 +19,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from x_auth_id_alias.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from x_auth_id_alias.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -293,16 +294,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -317,6 +320,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -329,12 +333,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -343,4 +347,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy}) diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/rest.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/rest.py index 2ad59429196cd86ec3ca5319771722f384b24ea9..7ba6c4d952501c2b18287ba986f19abf826b48b2 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/rest.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/rest.py @@ -19,7 +19,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from dynamic_servers.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from dynamic_servers.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -293,16 +294,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -317,6 +320,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -329,12 +333,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -343,4 +347,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy}) diff --git a/samples/openapi3/client/petstore/python/petstore_api/rest.py b/samples/openapi3/client/petstore/python/petstore_api/rest.py index e264c456aab0a31e060f36fd07a6996ca3224076..3c10df7e3cb217370171066b0b62fb6454dc2670 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python/petstore_api/rest.py @@ -19,7 +19,8 @@ from urllib.request import proxy_bypass_environment import urllib3 import ipaddress -from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError +from petstore_api.exceptions import ApiException, UnauthorizedException, \ + ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) @@ -293,16 +294,18 @@ class RESTClientObject(object): _request_timeout=_request_timeout, body=body) + # end of class RESTClientObject def is_ipv4(target): """ Test if IPv4 address or not """ try: - chk = ipaddress.IPv4Address(target) + ipaddress.IPv4Address(target) return True except ipaddress.AddressValueError: return False + def in_ipv4net(target, net): """ Test if target belongs to given IPv4 network """ @@ -317,6 +320,7 @@ def in_ipv4net(target, net): except ipaddress.NetmaskValueError: return False + def should_bypass_proxies(url, no_proxy=None): """ Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url. @@ -329,12 +333,12 @@ def should_bypass_proxies(url, no_proxy=None): return True # special cases - if no_proxy in [None , '']: + if no_proxy in [None, '']: return False if no_proxy == '*': return True - no_proxy = no_proxy.lower().replace(' ',''); + no_proxy = no_proxy.lower().replace(' ', '') entries = ( host for host in no_proxy.split(',') if host ) @@ -343,4 +347,4 @@ def should_bypass_proxies(url, no_proxy=None): for item in entries: if in_ipv4net(parsed.hostname, item): return True - return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} ) + return proxy_bypass_environment(parsed.hostname, {'no': no_proxy})