Skip to content

Commit

Permalink
No usar OrderedDict para self.anuncios
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloCastellano committed Oct 6, 2016
1 parent cfd7521 commit 3cc980e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bormeparser/borme.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import six

from lxml import etree
from collections import OrderedDict

try:
# Python 3
Expand Down Expand Up @@ -423,7 +422,10 @@ def from_file(cls, filename):
raise NotImplementedError

def _set_anuncios(self, anuncios):
self.anuncios = OrderedDict()
"""
anuncios: [BormeAnuncio]
"""
self.anuncios = {}
for anuncio in anuncios:
self.anuncios[anuncio.id] = anuncio
self.anuncios_rango = (min(self.anuncios.keys()), max(self.anuncios.keys()))
Expand All @@ -447,7 +449,7 @@ def get_anuncios_ids(self):
"""
[BormeAnuncio]
"""
return list(self.anuncios.keys())
return sorted(self.anuncios.keys())

def get_anuncios(self):
"""
Expand Down Expand Up @@ -533,7 +535,7 @@ def set_default(obj):
@classmethod
def from_json(self, filename):
with open(filename) as fp:
d = json.load(fp, object_pairs_hook=OrderedDict)
d = json.load(fp)
cve = d['cve']
date = datetime.datetime.strptime(d['date'], '%Y-%m-%d').date()
seccion = d['seccion'] # TODO: SECCION.from_borme()
Expand Down
1 change: 1 addition & 0 deletions bormeparser/tests/test_borme.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_json(self):
fp = tempfile.NamedTemporaryFile()
filename = fp.name
fp.close()

converted = self.borme.to_json(filename)
self.assertTrue(converted)

Expand Down

0 comments on commit 3cc980e

Please sign in to comment.