@@ -38,7 +38,7 @@ class ShopifyResourceMeta(ResourceMeta):
38
38
def connection (cls ):
39
39
"""HTTP connection for the current thread"""
40
40
local = cls ._threadlocal
41
- if not getattr (local , ' connection' , None ):
41
+ if not getattr (local , " connection" , None ):
42
42
# Make sure these variables are no longer affected by other threads.
43
43
local .user = cls .user
44
44
local .password = cls .password
@@ -54,7 +54,7 @@ def connection(cls):
54
54
return local .connection
55
55
56
56
def get_user (cls ):
57
- return getattr (cls ._threadlocal , ' user' , ShopifyResource ._user )
57
+ return getattr (cls ._threadlocal , " user" , ShopifyResource ._user )
58
58
59
59
def set_user (cls , value ):
60
60
cls ._threadlocal .connection = None
@@ -63,7 +63,7 @@ def set_user(cls, value):
63
63
user = property (get_user , set_user , None , "The username for HTTP Basic Auth." )
64
64
65
65
def get_password (cls ):
66
- return getattr (cls ._threadlocal , ' password' , ShopifyResource ._password )
66
+ return getattr (cls ._threadlocal , " password" , ShopifyResource ._password )
67
67
68
68
def set_password (cls , value ):
69
69
cls ._threadlocal .connection = None
@@ -72,7 +72,7 @@ def set_password(cls, value):
72
72
password = property (get_password , set_password , None , "The password for HTTP Basic Auth." )
73
73
74
74
def get_site (cls ):
75
- return getattr (cls ._threadlocal , ' site' , ShopifyResource ._site )
75
+ return getattr (cls ._threadlocal , " site" , ShopifyResource ._site )
76
76
77
77
def set_site (cls , value ):
78
78
cls ._threadlocal .connection = None
@@ -82,49 +82,49 @@ def set_site(cls, value):
82
82
host = parts .hostname
83
83
if parts .port :
84
84
host += ":" + str (parts .port )
85
- new_site = urllib .parse .urlunparse ((parts .scheme , host , parts .path , '' , '' , '' ))
85
+ new_site = urllib .parse .urlunparse ((parts .scheme , host , parts .path , "" , "" , "" ))
86
86
ShopifyResource ._site = cls ._threadlocal .site = new_site
87
87
if parts .username :
88
88
cls .user = urllib .parse .unquote (parts .username )
89
89
if parts .password :
90
90
cls .password = urllib .parse .unquote (parts .password )
91
91
92
- site = property (get_site , set_site , None , ' The base REST site to connect to.' )
92
+ site = property (get_site , set_site , None , " The base REST site to connect to." )
93
93
94
94
def get_timeout (cls ):
95
- return getattr (cls ._threadlocal , ' timeout' , ShopifyResource ._timeout )
95
+ return getattr (cls ._threadlocal , " timeout" , ShopifyResource ._timeout )
96
96
97
97
def set_timeout (cls , value ):
98
98
cls ._threadlocal .connection = None
99
99
ShopifyResource ._timeout = cls ._threadlocal .timeout = value
100
100
101
- timeout = property (get_timeout , set_timeout , None , ' Socket timeout for HTTP requests' )
101
+ timeout = property (get_timeout , set_timeout , None , " Socket timeout for HTTP requests" )
102
102
103
103
def get_headers (cls ):
104
- if not hasattr (cls ._threadlocal , ' headers' ):
104
+ if not hasattr (cls ._threadlocal , " headers" ):
105
105
cls ._threadlocal .headers = ShopifyResource ._headers .copy ()
106
106
return cls ._threadlocal .headers
107
107
108
108
def set_headers (cls , value ):
109
109
cls ._threadlocal .headers = value
110
110
111
- headers = property (get_headers , set_headers , None , ' The headers sent with HTTP requests' )
111
+ headers = property (get_headers , set_headers , None , " The headers sent with HTTP requests" )
112
112
113
113
def get_format (cls ):
114
- return getattr (cls ._threadlocal , ' format' , ShopifyResource ._format )
114
+ return getattr (cls ._threadlocal , " format" , ShopifyResource ._format )
115
115
116
116
def set_format (cls , value ):
117
117
cls ._threadlocal .connection = None
118
118
ShopifyResource ._format = cls ._threadlocal .format = value
119
119
120
- format = property (get_format , set_format , None , ' Encoding used for request and responses' )
120
+ format = property (get_format , set_format , None , " Encoding used for request and responses" )
121
121
122
122
def get_prefix_source (cls ):
123
123
"""Return the prefix source, by default derived from site."""
124
124
try :
125
125
return cls .override_prefix ()
126
126
except AttributeError :
127
- if hasattr (cls , ' _prefix_source' ):
127
+ if hasattr (cls , " _prefix_source" ):
128
128
return cls .site + cls ._prefix_source
129
129
else :
130
130
return cls .site
@@ -133,33 +133,33 @@ def set_prefix_source(cls, value):
133
133
"""Set the prefix source, which will be rendered into the prefix."""
134
134
cls ._prefix_source = value
135
135
136
- prefix_source = property (get_prefix_source , set_prefix_source , None , ' prefix for lookups for this type of object.' )
136
+ prefix_source = property (get_prefix_source , set_prefix_source , None , " prefix for lookups for this type of object." )
137
137
138
138
def get_version (cls ):
139
- if hasattr (cls ._threadlocal , ' version' ) or ShopifyResource ._version :
140
- return getattr (cls ._threadlocal , ' version' , ShopifyResource ._version )
139
+ if hasattr (cls ._threadlocal , " version" ) or ShopifyResource ._version :
140
+ return getattr (cls ._threadlocal , " version" , ShopifyResource ._version )
141
141
elif ShopifyResource ._site is not None :
142
- return ShopifyResource ._site .split ('/' )[- 1 ]
142
+ return ShopifyResource ._site .split ("/" )[- 1 ]
143
143
144
144
def set_version (cls , value ):
145
145
ShopifyResource ._version = cls ._threadlocal .version = value
146
146
147
- version = property (get_version , set_version , None , ' Shopify Api Version' )
147
+ version = property (get_version , set_version , None , " Shopify Api Version" )
148
148
149
149
def get_url (cls ):
150
- return getattr (cls ._threadlocal , ' url' , ShopifyResource ._url )
150
+ return getattr (cls ._threadlocal , " url" , ShopifyResource ._url )
151
151
152
152
def set_url (cls , value ):
153
153
ShopifyResource ._url = cls ._threadlocal .url = value
154
154
155
- url = property (get_url , set_url , None , ' Base URL including protocol and shopify domain' )
155
+ url = property (get_url , set_url , None , " Base URL including protocol and shopify domain" )
156
156
157
157
158
158
@six .add_metaclass (ShopifyResourceMeta )
159
159
class ShopifyResource (ActiveResource , mixins .Countable ):
160
160
_format = formats .JSONFormat
161
161
_threadlocal = threading .local ()
162
- _headers = {' User-Agent' : ' ShopifyPythonAPI/%s Python/%s' % (shopify .VERSION , sys .version .split (' ' , 1 )[0 ])}
162
+ _headers = {" User-Agent" : " ShopifyPythonAPI/%s Python/%s" % (shopify .VERSION , sys .version .split (" " , 1 )[0 ])}
163
163
_version = None
164
164
_url = None
165
165
@@ -182,7 +182,7 @@ def activate_session(cls, session):
182
182
cls .user = None
183
183
cls .password = None
184
184
cls .version = session .api_version .name
185
- cls .headers [' X-Shopify-Access-Token' ] = session .token
185
+ cls .headers [" X-Shopify-Access-Token" ] = session .token
186
186
187
187
@classmethod
188
188
def clear_session (cls ):
@@ -191,7 +191,7 @@ def clear_session(cls):
191
191
cls .user = None
192
192
cls .password = None
193
193
cls .version = None
194
- cls .headers .pop (' X-Shopify-Access-Token' , None )
194
+ cls .headers .pop (" X-Shopify-Access-Token" , None )
195
195
196
196
@classmethod
197
197
def find (cls , id_ = None , from_ = None , ** kwargs ):
0 commit comments