1
1
from .utils import format_environment
2
2
3
3
4
- class ProxyConfig ():
4
+ class ProxyConfig (dict ):
5
5
'''
6
6
Hold the client's proxy configuration
7
7
'''
8
+ @property
9
+ def http (self ):
10
+ return self ['http' ]
8
11
9
- def __init__ (self , http = None , https = None , ftp = None , no_proxy = None ):
10
- self .http = http
11
- self .https = https
12
- self .ftp = ftp
13
- self .no_proxy = no_proxy
12
+ @http .setter
13
+ def http (self , value ):
14
+ self ['http' ] = value
15
+
16
+ @property
17
+ def https (self ):
18
+ return self ['https' ]
19
+
20
+ @https .setter
21
+ def https (self , value ):
22
+ self ['https' ] = value
23
+
24
+ @property
25
+ def ftp (self ):
26
+ return self ['ftp' ]
27
+
28
+ @ftp .setter
29
+ def ftp (self , value ):
30
+ self ['ftp' ] = value
31
+
32
+ @property
33
+ def no_proxy (self ):
34
+ return self ['no_proxy' ]
35
+
36
+ @no_proxy .setter
37
+ def no_proxy (self , value ):
38
+ self ['no_proxy' ] = value
14
39
15
40
@staticmethod
16
41
def from_dict (config ):
@@ -22,10 +47,11 @@ def from_dict(config):
22
47
https://docs.docker.com/network/proxy/#configure-the-docker-client
23
48
'''
24
49
return ProxyConfig (
25
- http = config .get ('httpProxy' , None ),
26
- https = config .get ('httpsProxy' , None ),
27
- ftp = config .get ('ftpProxy' , None ),
28
- no_proxy = config .get ('noProxy' , None ))
50
+ http = config .get ('httpProxy' ),
51
+ https = config .get ('httpsProxy' ),
52
+ ftp = config .get ('ftpProxy' ),
53
+ no_proxy = config .get ('noProxy' ),
54
+ )
29
55
30
56
def get_environment (self ):
31
57
'''
@@ -58,12 +84,6 @@ def inject_proxy_environment(self, environment):
58
84
# variables defined in "environment" to take precedence.
59
85
return proxy_env + environment
60
86
61
- def __bool__ (self ):
62
- return bool (self .http or self .https or self .ftp or self .no_proxy )
63
-
64
- def __nonzero__ (self ):
65
- return self .__bool__ ()
66
-
67
87
def __str__ (self ):
68
88
return 'ProxyConfig(http={}, https={}, ftp={}, no_proxy={})' .format (
69
89
self .http , self .https , self .ftp , self .no_proxy )
0 commit comments