Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 07785ea

Browse filesBrowse files
committed
Add support for python 2.5.
1 parent 2b589c5 commit 07785ea
Copy full SHA for 07785ea

5 files changed

+47-42Lines changed: 47 additions & 42 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CHANGELOG‎

Copy file name to clipboardExpand all lines: CHANGELOG
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
== Version 0.1.2
2+
3+
* Add python 2.5 compatibility
4+
15
== Version 0.1.1
26

3-
* Make creating a session simpler wtih django
7+
* Make creating a session simpler with django
48

59
== Version 0.1.0
610

Collapse file

‎lib/resources.py‎

Copy file name to clipboardExpand all lines: lib/resources.py
+23-22Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@ def encode(self, options):
1818
# pyactiveresource (version 1.0.1) doesn't support encoding to_json
1919
return pyactiveresource.util.to_xml(options)
2020

21-
@property
22-
def primary_key(self):
21+
def __get_primary_key(self):
2322
return self._primary_key
2423

25-
@primary_key.setter
26-
def primary_key(self, value):
24+
def __set_primary_key(self, value):
2725
self._primary_key = value
2826

29-
@property
30-
def id(self):
27+
primary_key = property(__get_primary_key, __set_primary_key, None,
28+
'Primary key to identity the resource (defaults to "id")')
29+
30+
def __get_id(self):
3131
if self._primary_key != "id":
3232
return getattr(self, self._primary_key)
3333
else:
3434
return super(self.__class__, self).__getattr__("id")
3535

36-
@id.setter
37-
def id(self, value):
36+
def __set_id(self, value):
3837
if self._primary_key != "id":
3938
return setattr(self, self._primary_key, value)
4039
else:
4140
return super(self.__class__, self).__setattr__("id", value)
4241

42+
id = property(__get_id, __set_id, None, 'Value stored in the primary key')
43+
4344
class Shop(ShopifyResource):
4445
@classmethod
4546
def current(cls):
@@ -127,7 +128,7 @@ def price_range(self):
127128
min_price = min(prices)
128129
max_price = max(prices)
129130
if min_price != max_price:
130-
return "{0} - {1}".format(f % min_price, f % max_price)
131+
return "%f - %f" % (f % min_price, f % max_price)
131132
else:
132133
return f % min_price
133134

@@ -150,15 +151,15 @@ class Variant(ShopifyResource):
150151
@classmethod
151152
def prefix(cls, options={}):
152153
product_id = options.get("product_id")
153-
return "/admin/" if product_id is None else "/admin/products/{0}".format(product_id)
154+
return "/admin/" if product_id is None else "/admin/products/%s" % (product_id)
154155

155156

156157
class Image(ShopifyResource):
157158
_prefix_source = "/admin/products/$product_id/"
158159

159160
def __getattr__(self, name):
160161
if name in ["pico", "icon", "thumb", "small", "compact", "medium", "large", "grande", "original"]:
161-
return re.sub(r"/(.*)\.(\w{2,4})", r"\1_{0}.\2".format(name), self.src)
162+
return re.sub(r"/(.*)\.(\w{2,4})", r"\1_%s.\2" % (name), self.src)
162163
else:
163164
return super(self.__class__, self).__getattr__(name)
164165

@@ -201,7 +202,7 @@ class Metafield(ShopifyResource):
201202

202203
@classmethod
203204
def prefix(cls, options={}):
204-
return "/admin/" if options.get("resource") is None else "/admin/{0}/{1}".format(options["resource"], options["resource_id"])
205+
return "/admin/" if options.get("resource") is None else "/admin/%s/%s" % (options["resource"], options["resource_id"])
205206

206207

207208
class Comment(ShopifyResource):
@@ -241,7 +242,7 @@ class Event(ShopifyResource):
241242

242243
@classmethod
243244
def prefix(cls, options={}):
244-
return "/admin/" if options.get("resource") is None else "/admin/{0}/{1}/".format(options["resource"], options["resource_id"])
245+
return "/admin/" if options.get("resource") is None else "/admin/%s/%s/" % (options["resource"], options["resource_id"])
245246

246247

247248
class Customer(ShopifyResource):
@@ -262,14 +263,14 @@ class Asset(ShopifyResource):
262263

263264
@classmethod
264265
def prefix(cls, options={}):
265-
return "/admin/" if options.get("theme_id") is None else "/admin/themes/{0}/".format(options["theme_id"])
266+
return "/admin/" if options.get("theme_id") is None else "/admin/themes/%s/" % (options["theme_id"])
266267

267268
@classmethod
268269
def _element_path(cls, id, prefix_options={}, query_options=None):
269270
if query_options is None:
270271
prefix_options, query_options = cls._split_options(prefix_options)
271-
return "{0}{1}.{2}{3}".format(cls.prefix(prefix_options), cls.plural,
272-
cls.format.extension, cls._query_string(query_options))
272+
return "%s%s.%s%s" % (cls.prefix(prefix_options), cls.plural,
273+
cls.format.extension, cls._query_string(query_options))
273274

274275
@classmethod
275276
def find(cls, key=None, **kwargs):
@@ -282,22 +283,22 @@ def find(cls, key=None, **kwargs):
282283
params = {"asset[key]": key}
283284
params.update(kwargs)
284285
theme_id = params.get("theme_id")
285-
path_prefix = "/admin/themes/{0}".format(theme_id) if theme_id else "/admin"
286-
return cls.find_one("{0}/assets.{1}".format(path_prefix, cls.format.extension), **params)
286+
path_prefix = "/admin/themes/%s" % (theme_id) if theme_id else "/admin"
287+
return cls.find_one("%s/assets.%s" % (path_prefix, cls.format.extension), **params)
287288

288-
@property
289-
def value(self):
289+
def __get_value(self):
290290
data = self.attributes.get("value")
291291
if data:
292292
return data
293293
data = self.attributes.get("attachment")
294294
if data:
295295
return base64.b64decode(data)
296296

297-
@value.setter
298-
def value(self, data):
297+
def __set_value(self, data):
299298
self.attach(data)
300299

300+
value = property(__get_value, __set_value, None, "The asset's value or attachment")
301+
301302
def attach(self, data):
302303
self.attachment = base64.b64encode(data)
303304

Collapse file

‎lib/session.py‎

Copy file name to clipboardExpand all lines: lib/session.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def shop(self):
7777
@classmethod
7878
def create_permission_url(cls, shop_url):
7979
shop_url = cls.__prepare_url(shop_url)
80-
return "{0}://{1}/admin/api/auth?api_key={2}".format(cls.protocol, shop_url, cls.api_key)
80+
return "%s://%s/admin/api/auth?api_key=%s" % (cls.protocol, shop_url, cls.api_key)
8181

8282
@property
8383
def site(self):
84-
return "{0}://{1}:{2}@{3}/admin".format(self.protocol, self.api_key, self.__computed_password(), self.url)
84+
return "%s://%s:%s@%s/admin" % (self.protocol, self.api_key, self.__computed_password(), self.url)
8585

8686
def __computed_password(self):
8787
return md5(self.secret + self.token).hexdigest()
Collapse file

‎scripts/shopify_api.py‎

Copy file name to clipboardExpand all lines: scripts/shopify_api.py
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def run_task(cls, task=None, *args):
5252
if len(matches) == 1:
5353
task = matches[0]
5454
else:
55-
print >>sys.stderr, 'Could not find task "{0}".'.format(task)
55+
print >>sys.stderr, 'Could not find task "%s".' % (task)
5656

5757
task_func = getattr(cls, task)
5858
task_func(*args)
@@ -64,7 +64,7 @@ def help(cls, task=None):
6464
usage_list = []
6565
for task in iter(cls._tasks):
6666
task_func = getattr(cls, task)
67-
usage_string = " {0} {1}".format(cls._prog, task_func.usage)
67+
usage_string = " %s %s" % (cls._prog, task_func.usage)
6868
desc = task_func.__doc__.splitlines()[0]
6969
usage_list.append((usage_string, desc))
7070
max_len = reduce(lambda m, item: max(m, len(item[0])), usage_list, 0)
@@ -73,15 +73,15 @@ def help(cls, task=None):
7373
for line, desc in usage_list:
7474
task_func = getattr(cls, task)
7575
if desc:
76-
line = "{0}{1} # {2}".format(line, " " * (max_len - len(line)), desc)
76+
line = "%s%s # %s" % (line, " " * (max_len - len(line)), desc)
7777
if len(line) > cols:
7878
line = line[:cols - 3] + "..."
7979
print(line)
8080
else:
8181
task_func = getattr(cls, task)
8282
print("Usage:")
83-
print(" {0} {1}".format(cls._prog, task_func.usage))
84-
print()
83+
print(" %s %s" % (cls._prog, task_func.usage))
84+
print("")
8585
print(task_func.__doc__)
8686

8787

@@ -108,12 +108,12 @@ def add(cls, connection):
108108
raise ConfigFileError("There is already a config file at " + filename)
109109
else:
110110
config = dict(protocol='https')
111-
domain = raw_input("Domain? (leave blank for {0}.myshopify.com) ".format(connection))
111+
domain = raw_input("Domain? (leave blank for %s.myshopify.com) " % (connection))
112112
if not domain.strip():
113-
domain = "{0}.myshopify.com".format(connection)
113+
domain = "%s.myshopify.com" % (connection)
114114
config['domain'] = domain
115-
print()
116-
print("open https://{0}/admin/api in your browser to get API credentials".format(domain))
115+
print("")
116+
print("open https://%s/admin/api in your browser to get API credentials" % (domain))
117117
config['api_key'] = raw_input("API key? ")
118118
config['password'] = raw_input("Password? ")
119119
if not os.path.isdir(cls._shop_config_dir):
@@ -144,7 +144,7 @@ def edit(cls, connection=None):
144144
if editor:
145145
subprocess.call([editor, filename])
146146
else:
147-
print "Please set an editor in the EDITOR environment variable"
147+
print("Please set an editor in the EDITOR environment variable")
148148
else:
149149
cls._no_config_file_error(filename)
150150

@@ -156,8 +156,8 @@ def show(cls, connection=None):
156156
connection = cls._default_connection()
157157
filename = cls._get_config_filename(connection)
158158
if os.path.exists(filename):
159-
print filename
160-
print file(filename).read()
159+
print(filename)
160+
print(file(filename).read())
161161
else:
162162
cls._no_config_file_error(filename)
163163

@@ -187,7 +187,7 @@ def console(cls, connection=None):
187187
cls._no_config_file_error(filename)
188188

189189
config = yaml.safe_load(file(filename).read())
190-
print("using {0}".format(config["domain"]))
190+
print("using %s" % (config["domain"]))
191191
shopify.ShopifyResource.site = cls._get_site_from_config(config)
192192

193193
start_interpreter(shopify=shopify)
@@ -225,7 +225,7 @@ def _get_site_from_config(cls, config):
225225
api_key = config.get("api_key")
226226
password = config.get("password")
227227
domain = config.get("domain")
228-
return "{0}://{1}:{2}@{3}/admin".format(protocol, api_key, password, domain)
228+
return "%s://%s:%s@%s/admin" % (protocol, api_key, password, domain)
229229

230230
@classmethod
231231
def _is_default(cls, connection):
@@ -237,5 +237,5 @@ def _no_config_file_error(cls, filename):
237237

238238
try:
239239
Tasks.run_task(*sys.argv[1:])
240-
except ConfigFileError as e:
241-
print e
240+
except ConfigFileError, e:
241+
print(e)
Collapse file

‎setup.py‎

Copy file name to clipboardExpand all lines: setup.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from distutils.core import setup
22

33
NAME='ShopifyAPI'
4-
VERSION='0.1.1'
4+
VERSION='0.1.2'
55
DESCRIPTION='Shopify API for Python'
66
LONG_DESCRIPTION="""\
77
The ShopifyAPI library allows python developers to programmatically

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.