Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
Fixed a bug in poll_profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Guz committed Mar 14, 2013
1 parent 0c1b557 commit 22ceec8
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions scripts/poll_profiles
Original file line number Diff line number Diff line change
Expand Up @@ -268,32 +268,38 @@ def process_edan_all(profile, blacklist=None):
desc_non = item["descriptiveNonRepeating"]
item["_id"] = desc_non["record_ID"]

hier_items = item["freetext"]

for k, v in hier_items.items():
x = (v if isinstance(v, list) else [v])

for hi in x:
if not '@label' in hi:
continue
hid = hi['@label']
htitle = hi['#text']

if hid not in collections:
# Grab series information from item
coll = {}
coll['id'] = hid
coll['title'] = htitle
coll['items'] = []
collections[hid] = coll
else:
coll = collections[hid]
freetext = item["freetext"]

if not "setName" in freetext: # So there is no collection
return True #XML parser need to get True here to continue parsing

colls = freetext["setName"]
it = colls
if not isinstance(colls, list):
it = [colls]

for c in it:
if not "#text" in c:
continue

hid = c["#text"]
htitle = c["#text"]

if hid not in collections:
# Grab series information from item
coll = {}
coll['id'] = hid
coll['title'] = htitle
coll['items'] = []
collections[hid] = coll
else:
coll = collections[hid]

# Create tmp file to hold collections items
coll_fn = cache_file_name(cache_dir, coll['id'])
coll_f = open(coll_fn,'a')
coll_f.write(str(item)+"\n")
coll_f.close()
# Create tmp file to hold collections items
coll_fn = cache_file_name(cache_dir, coll['id'])
coll_f = open(coll_fn,'a')
coll_f.write(str(item)+"\n")
coll_f.close()

return True

Expand Down

0 comments on commit 22ceec8

Please sign in to comment.