aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/parts.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-15 11:47:46 +0300
committerFilipp Lepalaan <f@230.to>2013-05-15 11:47:46 +0300
commit47db98b2449009f8bf80fe9d30fb6bfe4a331341 (patch)
treeac6a23f620cec675c87a8421b40a4a21b2b2c1cc /gsxws/parts.py
parent28b982e69b87c57d5d520b59c68f7bc32bbf9ea4 (diff)
downloadpy-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.tar.gz
py-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.tar.bz2
py-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.zip
Fixed stocking orders
Diffstat (limited to 'gsxws/parts.py')
-rw-r--r--gsxws/parts.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/gsxws/parts.py b/gsxws/parts.py
index a371ea3..536c6aa 100644
--- a/gsxws/parts.py
+++ b/gsxws/parts.py
@@ -1,11 +1,19 @@
import urllib
import tempfile
+
+from lookups import Lookup
from core import GsxObject, GsxError
class Part(GsxObject):
+ """
+ A service part
+
+ >>> Part('922-7913').lookup().stockPrice
+ 6.16
+ """
def lookup(self):
- lookup = Lookup(**self.data)
+ lookup = Lookup(**self._data)
return lookup.parts()
def fetch_image(self):
@@ -15,19 +23,21 @@ class Part(GsxObject):
if self.partNumber is None:
raise GsxError("Cannot fetch part image without part number")
- image = '%s_350_350.gif' % self.partNumber
- url = 'https://km.support.apple.com.edgekey.net/kb/imageService.jsp?image=%s' % image
+ image = "%s_350_350.gif" % self.partNumber
+ url = "https://km.support.apple.com.edgekey.net/kb/imageService.jsp?image=%s" % image
tmpfile = tempfile.mkstemp(suffix=image)
try:
return urllib.urlretrieve(url, tmpfile[1])[0]
except Exception, e:
- raise GsxError('Failed to fetch part image: %s' % e)
+ raise GsxError("Failed to fetch part image: %s" % e)
if __name__ == '__main__':
+ import sys
import doctest
+ import logging
from core import connect
logging.basicConfig(level=logging.DEBUG)
- connect(*sys.argv[1:4])
+ connect(*sys.argv[1:5])
doctest.testmod()