Skip to content

Instantly share code, notes, and snippets.

@hockeybuggy
Created July 17, 2015 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hockeybuggy/3c817f9c1db4da3a9fc1 to your computer and use it in GitHub Desktop.
Save hockeybuggy/3c817f9c1db4da3a9fc1 to your computer and use it in GitHub Desktop.
Camelize problem in pyactive resource
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-40-94d5373ebb80> in <module>()
----> 1 p = sh_api.client.Order.find(status="any", limit=250, page=38)
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in find(cls, id_, from_, **kwargs)
383 return cls._find_single(id_, **kwargs)
384
--> 385 return cls._find_every(from_=from_, **kwargs)
386
387 @classmethod
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _find_every(cls, from_, **kwargs)
522 path = cls._collection_path(prefix_options, query_options)
523 return cls._build_list(cls.connection.get(path, cls.headers),
--> 524 prefix_options)
525
526 @classmethod
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _build_list(cls, elements, prefix_options)
553 # slice elements to ensure that this is a list-type object not a dict
554 for element in elements[:]:
--> 555 resources.append(cls(element, prefix_options))
556 return resources
557
/data/virtualenv/satellite/lib/python2.7/site-packages/shopify/base.pyc in __init__(self, attributes, prefix_options)
125 if attributes is not None and prefix_options is None:
126 prefix_options, attributes = self.__class__._split_options(attributes)
--> 127 return super(ShopifyResource, self).__init__(attributes, prefix_options)
128
129 def is_new(self):
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in __init__(self, attributes, prefix_options)
360 else:
361 self._prefix_options = {}
--> 362 self._update(attributes)
363 self.errors = Errors(self)
364 self._initialized = True
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _update(self, attributes)
960 if klass is None:
961 klass = self._find_class_for_collection(key)
--> 962 attr.append(klass(child))
963 else:
964 attr.append(child)
/data/virtualenv/satellite/lib/python2.7/site-packages/shopify/base.pyc in __init__(self, attributes, prefix_options)
125 if attributes is not None and prefix_options is None:
126 prefix_options, attributes = self.__class__._split_options(attributes)
--> 127 return super(ShopifyResource, self).__init__(attributes, prefix_options)
128
129 def is_new(self):
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in __init__(self, attributes, prefix_options)
360 else:
361 self._prefix_options = {}
--> 362 self._update(attributes)
363 self.errors = Errors(self)
364 self._initialized = True
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _update(self, attributes)
952 if isinstance(value, dict):
953 klass = self._find_class_for(key)
--> 954 attr = klass(value)
955 elif isinstance(value, list):
956 klass = None
/data/virtualenv/satellite/lib/python2.7/site-packages/shopify/base.pyc in __init__(self, attributes, prefix_options)
125 if attributes is not None and prefix_options is None:
126 prefix_options, attributes = self.__class__._split_options(attributes)
--> 127 return super(ShopifyResource, self).__init__(attributes, prefix_options)
128
129 def is_new(self):
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in __init__(self, attributes, prefix_options)
360 else:
361 self._prefix_options = {}
--> 362 self._update(attributes)
363 self.errors = Errors(self)
364 self._initialized = True
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _update(self, attributes)
951 for key, value in six.iteritems(attributes):
952 if isinstance(value, dict):
--> 953 klass = self._find_class_for(key)
954 attr = klass(value)
955 elif isinstance(value, list):
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/activeresource.pyc in _find_class_for(cls, element_name, class_name, create_missing)
1001 element_name = util.underscore(class_name)
1002 elif not class_name:
-> 1003 class_name = util.camelize(element_name)
1004
1005 module_path = cls.__module__.split('.')
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/util.pyc in camelize(word)
197 """
198 return ''.join(w[0].upper() + w[1:]
--> 199 for w in re.sub('[^A-Z^a-z^0-9^:]+', ' ', word).split(' '))
200
201
/data/virtualenv/satellite/lib/python2.7/site-packages/pyactiveresource/util.pyc in <genexpr>((w,))
197 """
198 return ''.join(w[0].upper() + w[1:]
--> 199 for w in re.sub('[^A-Z^a-z^0-9^:]+', ' ', word).split(' '))
200
201
IndexError: string index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment