Skip to content

Commit

Permalink
add to_ordered_dict()
Browse files Browse the repository at this point in the history
  • Loading branch information
vinta committed Oct 23, 2013
1 parent 1dcf8e3 commit dc5aecc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion haul/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8

from collections import OrderedDict
import mimetypes
import re

Expand Down Expand Up @@ -191,8 +192,8 @@ class HaulResult(object):
"""

def __init__(self):
self.content_type = None
self.url = None
self.content_type = None
self.title = None
self.finder_image_urls = []
self.extender_image_urls = []
Expand All @@ -216,3 +217,18 @@ def image_urls(self):

def to_dict(self):
return self.__dict__

def to_ordered_dict(self):
order_keys = (
'url',
'content_type',
'title',
'finder_image_urls',
'extender_image_urls',
)

d = OrderedDict()
for key in order_keys:
d[key] = getattr(self, key)

return d

0 comments on commit dc5aecc

Please sign in to comment.