Skip to content

Commit 0988b1e

Browse files
committed
refactor configuration.py
1 parent f9b6755 commit 0988b1e

File tree

5 files changed

+60
-105
lines changed

5 files changed

+60
-105
lines changed

modules/swagger-codegen/src/main/resources/python/configuration.mustache

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,22 @@ import six
1414
from six.moves import http_client as httplib
1515

1616

17-
class TypeWithDefault(type):
18-
def __init__(cls, name, bases, dct):
19-
super(TypeWithDefault, cls).__init__(name, bases, dct)
20-
cls._default = None
21-
22-
def __call__(cls):
23-
if cls._default is None:
24-
cls._default = type.__call__(cls)
25-
return cls._two_level_copy(cls._default)
26-
27-
def set_default(cls, default):
28-
cls._default = cls._two_level_copy(default)
29-
30-
def _two_level_copy(cls, obj):
31-
newone = copy.copy(obj)
32-
for key in obj.__dict__.keys():
33-
newone.__dict__[key] = copy.copy(obj.__dict__[key])
34-
return newone
35-
36-
37-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
17+
class Configuration(object):
3818
"""NOTE: This class is auto generated by the swagger code generator program.
3919

4020
Ref: https://github.com/swagger-api/swagger-codegen
4121
Do not edit the class manually.
4222
"""
4323

24+
_default = None
25+
4426
def __init__(self):
4527
"""Constructor"""
28+
if self._default:
29+
for key in self._default.__dict__.keys():
30+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
31+
return
32+
4633
# Default Base url
4734
self.host = "{{{basePath}}}"
4835
# Temp file folder for downloading files
@@ -101,6 +88,10 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
10188
# Safe chars for path_param
10289
self.safe_chars_for_path_param = ''
10390

91+
@classmethod
92+
def set_default(cls, default):
93+
cls._default = default
94+
10495
@property
10596
def logger_file(self):
10697
"""The logger file.

samples/client/petstore-security-test/python/petstore_api/configuration.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,22 @@
2323
from six.moves import http_client as httplib
2424

2525

26-
class TypeWithDefault(type):
27-
def __init__(cls, name, bases, dct):
28-
super(TypeWithDefault, cls).__init__(name, bases, dct)
29-
cls._default = None
30-
31-
def __call__(cls):
32-
if cls._default is None:
33-
cls._default = type.__call__(cls)
34-
return cls._two_level_copy(cls._default)
35-
36-
def set_default(cls, default):
37-
cls._default = cls._two_level_copy(default)
38-
39-
def _two_level_copy(cls, obj):
40-
newone = copy.copy(obj)
41-
for key in obj.__dict__.keys():
42-
newone.__dict__[key] = copy.copy(obj.__dict__[key])
43-
return newone
44-
45-
46-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
26+
class Configuration(object):
4727
"""NOTE: This class is auto generated by the swagger code generator program.
4828
4929
Ref: https://github.com/swagger-api/swagger-codegen
5030
Do not edit the class manually.
5131
"""
5232

33+
_default = None
34+
5335
def __init__(self):
5436
"""Constructor"""
37+
if self._default:
38+
for key in self._default.__dict__.keys():
39+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
40+
return
41+
5542
# Default Base url
5643
self.host = "https://petstore.swagger.io */ ' \" =end -- \\r\\n \\n \\r/v2 */ ' \" =end -- \\r\\n \\n \\r"
5744
# Temp file folder for downloading files
@@ -110,6 +97,10 @@ def __init__(self):
11097
# Safe chars for path_param
11198
self.safe_chars_for_path_param = ''
11299

100+
@classmethod
101+
def set_default(cls, default):
102+
cls._default = default
103+
113104
@property
114105
def logger_file(self):
115106
"""The logger file.

samples/client/petstore/python-asyncio/petstore_api/configuration.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,22 @@
2323
from six.moves import http_client as httplib
2424

2525

26-
class TypeWithDefault(type):
27-
def __init__(cls, name, bases, dct):
28-
super(TypeWithDefault, cls).__init__(name, bases, dct)
29-
cls._default = None
30-
31-
def __call__(cls):
32-
if cls._default is None:
33-
cls._default = type.__call__(cls)
34-
return cls._two_level_copy(cls._default)
35-
36-
def set_default(cls, default):
37-
cls._default = cls._two_level_copy(default)
38-
39-
def _two_level_copy(cls, obj):
40-
newone = copy.copy(obj)
41-
for key in obj.__dict__.keys():
42-
newone.__dict__[key] = copy.copy(obj.__dict__[key])
43-
return newone
44-
45-
46-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
26+
class Configuration(object):
4727
"""NOTE: This class is auto generated by the swagger code generator program.
4828
4929
Ref: https://github.com/swagger-api/swagger-codegen
5030
Do not edit the class manually.
5131
"""
5232

33+
_default = None
34+
5335
def __init__(self):
5436
"""Constructor"""
37+
if self._default:
38+
for key in self._default.__dict__.keys():
39+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
40+
return
41+
5542
# Default Base url
5643
self.host = "http://petstore.swagger.io:80/v2"
5744
# Temp file folder for downloading files
@@ -110,6 +97,10 @@ def __init__(self):
11097
# Safe chars for path_param
11198
self.safe_chars_for_path_param = ''
11299

100+
@classmethod
101+
def set_default(cls, default):
102+
cls._default = default
103+
113104
@property
114105
def logger_file(self):
115106
"""The logger file.

samples/client/petstore/python-tornado/petstore_api/configuration.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,22 @@
2323
from six.moves import http_client as httplib
2424

2525

26-
class TypeWithDefault(type):
27-
def __init__(cls, name, bases, dct):
28-
super(TypeWithDefault, cls).__init__(name, bases, dct)
29-
cls._default = None
30-
31-
def __call__(cls):
32-
if cls._default is None:
33-
cls._default = type.__call__(cls)
34-
return cls._two_level_copy(cls._default)
35-
36-
def set_default(cls, default):
37-
cls._default = cls._two_level_copy(default)
38-
39-
def _two_level_copy(cls, obj):
40-
newone = copy.copy(obj)
41-
for key in obj.__dict__.keys():
42-
newone.__dict__[key] = copy.copy(obj.__dict__[key])
43-
return newone
44-
45-
46-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
26+
class Configuration(object):
4727
"""NOTE: This class is auto generated by the swagger code generator program.
4828
4929
Ref: https://github.com/swagger-api/swagger-codegen
5030
Do not edit the class manually.
5131
"""
5232

33+
_default = None
34+
5335
def __init__(self):
5436
"""Constructor"""
37+
if self._default:
38+
for key in self._default.__dict__.keys():
39+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
40+
return
41+
5542
# Default Base url
5643
self.host = "http://petstore.swagger.io:80/v2"
5744
# Temp file folder for downloading files
@@ -110,6 +97,10 @@ def __init__(self):
11097
# Safe chars for path_param
11198
self.safe_chars_for_path_param = ''
11299

100+
@classmethod
101+
def set_default(cls, default):
102+
cls._default = default
103+
113104
@property
114105
def logger_file(self):
115106
"""The logger file.

samples/client/petstore/python/petstore_api/configuration.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,22 @@
2323
from six.moves import http_client as httplib
2424

2525

26-
class TypeWithDefault(type):
27-
def __init__(cls, name, bases, dct):
28-
super(TypeWithDefault, cls).__init__(name, bases, dct)
29-
cls._default = None
30-
31-
def __call__(cls):
32-
if cls._default is None:
33-
cls._default = type.__call__(cls)
34-
return cls._two_level_copy(cls._default)
35-
36-
def set_default(cls, default):
37-
cls._default = cls._two_level_copy(default)
38-
39-
def _two_level_copy(cls, obj):
40-
newone = copy.copy(obj)
41-
for key in obj.__dict__.keys():
42-
newone.__dict__[key] = copy.copy(obj.__dict__[key])
43-
return newone
44-
45-
46-
class Configuration(six.with_metaclass(TypeWithDefault, object)):
26+
class Configuration(object):
4727
"""NOTE: This class is auto generated by the swagger code generator program.
4828
4929
Ref: https://github.com/swagger-api/swagger-codegen
5030
Do not edit the class manually.
5131
"""
5232

33+
_default = None
34+
5335
def __init__(self):
5436
"""Constructor"""
37+
if self._default:
38+
for key in self._default.__dict__.keys():
39+
self.__dict__[key] = copy.copy(self._default.__dict__[key])
40+
return
41+
5542
# Default Base url
5643
self.host = "http://petstore.swagger.io:80/v2"
5744
# Temp file folder for downloading files
@@ -110,6 +97,10 @@ def __init__(self):
11097
# Safe chars for path_param
11198
self.safe_chars_for_path_param = ''
11299

100+
@classmethod
101+
def set_default(cls, default):
102+
cls._default = default
103+
113104
@property
114105
def logger_file(self):
115106
"""The logger file.

0 commit comments

Comments
 (0)