diff --git a/CHANGES.txt b/CHANGES.txt index 9325215..b7b4ba5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,5 @@ +v0.4.1 -- Fixed bug inside create_path method that prevented adding simple items to list (only added new objects to list) + v0.4.0 -- Added `force` kwarg to set_nested_value and `create_path` method to PelicanJson object. Also added the `toolbox` module to the application with a handful of functions which may be used to get somewhat the same behavior as a PelicanJson object. v0.3.2 -- Updated documentation and docstrings. diff --git a/README.md b/README.md index 438f796..1b08a01 100644 --- a/README.md +++ b/README.md @@ -183,10 +183,4 @@ Finally, there is also a `find_and_replace` method which searches for a particul 'SOME NEW URL' ``` -This can, of course, be dangerous, so use with caution. - -# TO DO - -* Separate all methods out of `PelicanJson` class for use on free-floating Python dictionaries that come from netsed JSON objects. - -![](http://i.imgur.com/f6bG1XN.jpg) +This can, of course, be dangerous, so use with caution. \ No newline at end of file diff --git a/pelecanus/__init__.py b/pelecanus/__init__.py index 44128cd..64a46a6 100644 --- a/pelecanus/__init__.py +++ b/pelecanus/__init__.py @@ -12,4 +12,4 @@ """ from .pelicanjson import PelicanJson -__version__ = '0.4.0' +__version__ = '0.4.1' diff --git a/pelecanus/pelicanjson.py b/pelecanus/pelicanjson.py index d5ebb03..942f10f 100644 --- a/pelecanus/pelicanjson.py +++ b/pelecanus/pelicanjson.py @@ -259,7 +259,11 @@ def test_path(path): if not isinstance(index, int): errmsg = "Check path. List index must be integer: {}." raise IndexError(errmsg.format(index)) - new_object = PelicanJson(new_json_from_path(rest, newvalue)) + if rest: + new_object = new_json_from_path(rest, newvalue) + new_object = PelicanJson(new_object) + else: + new_object = newvalue edited_list = backfill_append(edit_object, index, new_object) self.set_nested_value(keys_present, edited_list) elif isinstance(edit_object, PelicanJson): diff --git a/test/fixtures/datadoc.json b/test/fixtures/datadoc.json new file mode 100644 index 0000000..8c87bde --- /dev/null +++ b/test/fixtures/datadoc.json @@ -0,0 +1 @@ +{"href": "http://127.0.0.1:8080/docs?tag=npr_api&profile=story", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs?tag=npr_api&profile=someGUIDvalue", "totalitems": 13130, "pagenum": 1, "totalpages": 1313, "rels": ["self"]}, {"href": "http://127.0.0.1:8080/docs?tag=npr_api&profile=someGUIDvalue&offset=10", "pagenum": 2, "rels": ["next"]}, {"href": "http://127.0.0.1:8080/docs?tag=npr_api&profile=someGUIDvalue", "pagenum": 1, "rels": ["first"]}, {"href": "http://127.0.0.1:8080/docs?tag=npr_api&profile=someGUIDvalue&offset=13130", "pagenum": 1313, "rels": ["last"]}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "auth": [{"hints": {"allow": ["GET"], "docs": "http://docs.pmp.io/wiki/Authenticating-with-the-API#testing-access"}, "href": "http://127.0.0.1:8080/auth/credentials", "rels": ["urn:collectiondoc:form:listcredentials"], "title": "List OAuth2 Credentials"}, {"hints": {"allow": ["POST"], "docs": "http://docs.pmp.io/wiki/Authenticating-with-the-API#generating-credentials", "accept-post": ["application/x-www-form-urlencoded"]}, "href": "https://publish-sandbox.pmp.io/auth/credentials", "rels": ["urn:collectiondoc:form:createcredentials"], "title": "Create OAuth2 Credentials"}, {"title": "Remove OAuth2 Credentials", "href-template": "https://publish-sandbox.pmp.io/auth/credentials/{client_id}", "rels": ["urn:collectiondoc:form:removecredentials"], "hints": {"allow": ["DELETE"], "docs": "http://docs.pmp.io/wiki/Authenticating-with-the-API#removing-a-credential"}}, {"hints": {"allow": ["POST"], "docs": "http://docs.pmp.io/wiki/Authentication-Model#token-management", "accept-post": ["application/x-www-form-urlencoded"]}, "href": "http://127.0.0.1:8080/auth/access_token?json_response=fixtures/authdetails.json", "rels": ["urn:collectiondoc:form:issuetoken"], "title": "Issue OAuth2 Token"}, {"hints": {"allow": ["DELETE"], "docs": "http://docs.pmp.io/wiki/Authentication-Model#revoke-a-token"}, "href": "https://publish-sandbox.pmp.io/auth/access_token", "rels": ["urn:collectiondoc:form:revoketoken"], "title": "Revoke OAuth2 Token"}], "edit": [{"hints": {"allow": ["PUT"], "docs": "http://docs.pmp.io/wiki/Collection.doc-JSON-Media-Type", "formats": ["application/vnd.collection.doc+json"]}, "title": "Document Save", "href-template": "https://publish-sandbox.pmp.io/docs/{guid}", "rels": ["urn:collectiondoc:form:documentsave"], "href-vars": {"guid": "http://docs.pmp.io/wiki/Globaly-Unique-Identifiers-for-PMP-Documents"}}, {"hints": {"allow": ["DELETE"]}, "title": "Document Delete", "href-template": "https://publish-sandbox.pmp.io/docs/{guid}", "rels": ["urn:collectiondoc:form:documentdelete"], "href-vars": {"guid": "http://docs.pmp.io/wiki/Globaly-Unique-Identifiers-for-PMP-Documents"}}, {"hints": {"allow": ["POST"], "accept-post": ["multipart/form-data"]}, "href": "https://publish-sandbox.pmp.io/files", "href-vars": {"submission": "http://docs.pmp.io/wiki/Media-File-Upload"}, "rels": ["urn:collectiondoc:form:mediaupload"], "title": "Upload a rich media file"}], "query": [{"hints": {"allow": ["GET"]}, "title": "Access documents", "href-template": "http://127.0.0.1:8080/docs/{guid}{?limit,offset}", "rels": ["urn:collectiondoc:hreftpl:docs"], "href-vars": {"offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "guid": "http://docs.pmp.io/wiki/Globaly-Unique-Identifiers-for-PMP-Documents", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit"}}, {"hints": {"allow": ["GET"]}, "title": "Access profiles", "href-template": "http://127.0.0.1:8080/profiles/{guid}", "rels": ["urn:collectiondoc:hreftpl:profiles"], "href-vars": {"guid": "http://docs.pmp.io/wiki/Globaly-Unique-Identifiers-for-PMP-Documents"}}, {"hints": {"allow": ["GET"]}, "title": "Access schemas", "href-template": "http://127.0.0.1:8080/schemas/{guid}", "rels": ["urn:collectiondoc:hreftpl:schemas"], "href-vars": {"guid": "http://docs.pmp.io/wiki/Globaly-Unique-Identifiers-for-PMP-Documents"}}, {"hints": {"allow": ["GET"]}, "title": "Query for documents", "href-template": "http://127.0.0.1:8080/docs{?guid,limit,offset,searchsort,startdate,enddate,writeable,tag,language,profile,collection,has,distributor,distributorgroup,author,text}", "rels": ["urn:collectiondoc:query:docs"], "href-vars": {"language": "http://docs.pmp.io/wiki/Querying-the-API#language", "has": "http://docs.pmp.io/wiki/Querying-the-API#has", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit", "offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "profile": "http://docs.pmp.io/wiki/Querying-the-API#profile", "startdate": "http://docs.pmp.io/wiki/Querying-the-API#startdate", "enddate": "http://docs.pmp.io/wiki/Querying-the-API#enddate", "text": "http://docs.pmp.io/wiki/Querying-the-API#text", "collection": "http://docs.pmp.io/wiki/Querying-the-API#collection", "distributorgroup": "http://docs.pmp.io/wiki/Querying-the-API#distributorgroup", "author": "http://docs.pmp.io/wiki/Querying-the-API#author", "writeable": "http://docs.pmp.io/wiki/Querying-the-API#writeable", "searchsort": "http://docs.pmp.io/wiki/Querying-the-API#searchsort", "distributor": "http://docs.pmp.io/wiki/Querying-the-API#distributor", "tag": "http://docs.pmp.io/wiki/Querying-the-API#tag", "guid": "http://docs.pmp.io/wiki/Querying-the-API#guid"}}, {"hints": {"allow": ["GET"]}, "title": "Query for profiles", "href-template": "http://127.0.0.1:8080/profiles{?guid,limit,offset,searchsort,startdate,enddate,writeable,tag,collection,text}", "rels": ["urn:collectiondoc:query:profiles"], "href-vars": {"collection": "http://docs.pmp.io/wiki/Querying-the-API#collection", "guid": "http://docs.pmp.io/wiki/Querying-the-API#guid", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit", "text": "http://docs.pmp.io/wiki/Querying-the-API#text", "offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "startdate": "http://docs.pmp.io/wiki/Querying-the-API#startdate", "searchsort": "http://docs.pmp.io/wiki/Querying-the-API#searchsort", "writeable": "http://docs.pmp.io/wiki/Querying-the-API#writeable", "enddate": "http://docs.pmp.io/wiki/Querying-the-API#enddate", "tag": "http://docs.pmp.io/wiki/Querying-the-API#tag"}}, {"hints": {"allow": ["GET"]}, "title": "Query for schemas", "href-template": "http://127.0.0.1:8080/schemas{?guid,limit,offset,searchsort,startdate,enddate,writeable,tag,collection,text}", "rels": ["urn:collectiondoc:query:schemas"], "href-vars": {"collection": "http://docs.pmp.io/wiki/Querying-the-API#collection", "guid": "http://docs.pmp.io/wiki/Querying-the-API#guid", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit", "text": "http://docs.pmp.io/wiki/Querying-the-API#text", "offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "startdate": "http://docs.pmp.io/wiki/Querying-the-API#startdate", "searchsort": "http://docs.pmp.io/wiki/Querying-the-API#searchsort", "writeable": "http://docs.pmp.io/wiki/Querying-the-API#writeable", "enddate": "http://docs.pmp.io/wiki/Querying-the-API#enddate", "tag": "http://docs.pmp.io/wiki/Querying-the-API#tag"}}, {"hints": {"allow": ["GET"]}, "title": "Query for users", "href-template": "http://127.0.0.1:8080/users{?guid,limit,offset,searchsort,startdate,enddate,writeable,tag,collection,text}", "rels": ["urn:collectiondoc:query:users"], "href-vars": {"collection": "http://docs.pmp.io/wiki/Querying-the-API#collection", "guid": "http://docs.pmp.io/wiki/Querying-the-API#guid", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit", "text": "http://docs.pmp.io/wiki/Querying-the-API#text", "offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "startdate": "http://docs.pmp.io/wiki/Querying-the-API#startdate", "searchsort": "http://docs.pmp.io/wiki/Querying-the-API#searchsort", "writeable": "http://docs.pmp.io/wiki/Querying-the-API#writeable", "enddate": "http://docs.pmp.io/wiki/Querying-the-API#enddate", "tag": "http://docs.pmp.io/wiki/Querying-the-API#tag"}}, {"hints": {"allow": ["GET"]}, "title": "Query for groups", "href-template": "http://127.0.0.1:8080/groups{?guid,limit,offset,searchsort,startdate,enddate,writeable,tag,collection,has,text}", "rels": ["urn:collectiondoc:query:groups"], "href-vars": {"has": "http://docs.pmp.io/wiki/Querying-the-API#has", "collection": "http://docs.pmp.io/wiki/Querying-the-API#collection", "guid": "http://docs.pmp.io/wiki/Querying-the-API#guid", "limit": "http://docs.pmp.io/wiki/Querying-the-API#limit", "text": "http://docs.pmp.io/wiki/Querying-the-API#text", "offset": "http://docs.pmp.io/wiki/Querying-the-API#offset", "startdate": "http://docs.pmp.io/wiki/Querying-the-API#startdate", "searchsort": "http://docs.pmp.io/wiki/Querying-the-API#searchsort", "writeable": "http://docs.pmp.io/wiki/Querying-the-API#writeable", "enddate": "http://docs.pmp.io/wiki/Querying-the-API#enddate", "tag": "http://docs.pmp.io/wiki/Querying-the-API#tag"}}]}, "version": "1.0", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/27/brainwave-655288d0287ef9c02011ab447b1a85f27678e501.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "357", "width": "476"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_sq-143d4ce2af08c0608706a12020bd69b6c27caa8d.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "366", "width": "366"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_wide-e817284a7e9d0ec052453de104a34aba85567256.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "274", "width": "487"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:14:07+00:00", "to": "3014-08-27T20:14:07+00:00"}, "title": "When not in use, this desk oven can be stowed upright and it can serve as a secondary screen.", "modified": "2014-08-27T20:14:07+00:00", "created": "2014-08-27T20:14:07+00:00", "description": "When not in use, this desk oven can be stowed upright and it can serve as a secondary screen.", "tags": ["npr_api", "343722595", "343724171"], "published": "2014-08-27T20:14:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_2_-2-sg-b3c37d9c675e661453ce17071fe77ddf193774cb.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "813", "width": "1084"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_2_-2-sg_sq-1822e9ba9bc2419de207a09ccf90f845aa1cb7e2.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "753", "width": "753"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_2_-2-sg_wide-637b383653198e018850bfeb4084cc50877ff0ab.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "490", "width": "871"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/brainwave_2_-2-sg-b3c37d9c675e661453ce17071fe77ddf193774cb.jpg", "type": "image/jpeg", "meta": {"crop": "enlargement", "height": "813", "width": "1084"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:14:08+00:00", "to": "3014-08-27T20:14:08+00:00"}, "title": "No, that's not a printer. It's a desktop microwave.", "modified": "2014-08-27T20:14:08+00:00", "created": "2014-08-27T20:14:08+00:00", "description": "No, that's not a printer. It's a desktop microwave.", "tags": ["npr_api", "343722595", "343749610"], "published": "2014-08-27T20:14:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 2, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/blogs/alltechconsidered/2014/08/27/343722595/weekly-innovation-a-sad-desk-microwave-for-your-sad-desk-lunch?ft=3&f=343722595"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:14:00+00:00", "title": "Weekly Innovation: A Sad Desk Microwave For Your Sad Desk Lunch", "contentencoded": "

Too busy to walk all the way to the kitchen to heat up a meal? The prototype for the BrainWave desktop microwave is the answer. It's exactly what it sounds like: a phone book-size microwave to heat up your frozen lunch, at your desk.

The BrainWave is controlled through a computer program and connects through a USB port, and if you have a specially packaged meal, an RFID-tagged plastic spoon will let you scan the box and send the meal information to the microwave. This will automatically set the heating time. Oh, and the BrainWave can be stored in an upright position, so it can function as a whiteboard when not zapping Lean Cuisines.

Like we mentioned, this is only a prototype that U.K.-based designer Steve Gates came up with in order to graduate, a few years before Kickstarter. So we were curious what happened with the BrainWave and whether it still might become a reality.

\"It would have taken a large investment to have these parts custom produced at a smaller size, which wasn't feasible or economical at the time,\" Gates told NPR, by email. But he hasn't lost hope. \"I've had a lot of interest in the product and should the right circumstances arise, yes I would certainly consider [manufacturing] this.\"

If it does get widely made, it would be the perfect gift for anyone in your life who enjoys sodium-packed meals without any physical exertion. [Read: me.]

And Gates is still coming up with more enhancements. He says he can imagine a portable version of the BrainWave, too. \"Just imagine warming up your toasted sandwich on the tube or bus on your way to work. So it's all ready by the time you're at your desk,\" he says.

A girl can dream.

This post is part of our Weekly Innovation series, in which we explore an interesting idea, design or product that you may not have heard of yet. Do you have an innovation to share? Use this quick form.

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:14:09+00:00", "created": "2014-08-27T20:14:08+00:00", "valid": {"from": "2014-08-27T20:14:08+00:00", "to": "3014-08-27T20:14:08+00:00"}, "hreflang": "en", "teaser": "If this product design becomes a reality, you won't even have to leave your desk to heat up your Lean Cuisine.", "byline": "Elise Hu", "tags": ["npr_api", "343722595"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "There's A Big Leak In America's Water Tower", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "341372550", "343758378"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/20/img_0524-1--913c5ef204bf23b5825945290f19b90a0afa4358.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "2446", "width": "3262"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/img_0524-1-_sq-67a7706cfb26d4307dd5bbbdf6697f38ae313a7e.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "2179", "width": "2179"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/img_0524-1-_wide-f2de03dfd3758287ad71a18f584c665e635f7e47.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "1835", "width": "3263"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/img_0524-1-_slide-6bd2c434d57ad79c50b659e1f079833e4a050f9d.jpg", "type": "image/jpeg", "meta": {"crop": "slide", "height": "2175", "width": "3263"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "title": "Joe Giersch, an ecologist with the U.S. Geological Survey, studies stoneflies that live only in the melt from glaciers and snowpack in the northern Rockies.", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "description": "Joe Giersch, an ecologist with the U.S. Geological Survey, studies stoneflies that live only in the melt from glaciers and snowpack in the northern Rockies.", "tags": ["npr_api", "341372550", "341894539"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/20/meltwater_stonefly-25114bcb87430bee658196eaa7d31892fa8c641a.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "1220", "width": "1627"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/meltwater_stonefly_sq-b1e65801707ce02488d2bc2218e478a03a89657f.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "1236", "width": "1236"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/meltwater_stonefly_wide-e1598683c78e4864f3c4d61fd238bac567c879be.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "1012", "width": "1800"}}, {"href": "http://media.npr.org/assets/img/2014/08/20/meltwater_stonefly-25114bcb87430bee658196eaa7d31892fa8c641a.jpg", "type": "image/jpeg", "meta": {"crop": "enlargement", "height": "1220", "width": "1627"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:10:00+00:00", "to": "3014-08-27T20:10:00+00:00"}, "title": "Lednia tumana is fish food that's long thrived in the glacier-fed streams of Montana's Glacier National Park. But as the glaciers are disappearing, so is the fly.", "modified": "2014-08-27T20:10:00+00:00", "created": "2014-08-27T20:10:00+00:00", "description": "Lednia tumana is fish food that's long thrived in the glacier-fed streams of Montana's Glacier National Park. But as the glaciers are disappearing, so is the fly.", "tags": ["npr_api", "341372550", "341903428"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 3, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/341372550/theres-a-big-leak-in-americas-water-tower?ft=3&f=341372550"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "There's A Big Leak In America's Water Tower", "contentencoded": "

The northern arm of the Rocky Mountains is sometimes called \"the crown of the continent,\" and its jewels are glaciers and snowfields that irrigate large parts of North America during spring thaw.

But the region is getting warmer, even faster than the rest of the world. Scientists now say warming is scrambling the complex relationship between water and nature and could threaten some species with extinction as well as bring hardship to ranchers and farmers already suffering from prolonged drought.

To see how this vast natural irrigation system works, it's best to fly over it. Seated next to Richard Hauer in a Cessna he calls \"Montana Rose,\" I can see snowcapped mountains and wide valleys spread out below. Hauer, an ecologist at the University of Montana, calls this place a giant sponge.

Moist air from the Pacific hits the mountains and falls as snow and ice. The mountains hold that water until spring. Then it melts and runs through the gravel valleys and across big parts of North America.

It's worked that way for millennia. But lately, Hauer says, Montana is warmer, and spring's melt starts earlier. \"When that happens, all that storage of snow and water in the high country will go through the system [the mountains and valleys] much faster,\" he explains. \"It's a change that's taking place because the snowmelt is occurring earlier. ... Basically, if you turn the spigot on earlier, it runs out of water sooner.\"

Running out of water sooner means drier summers \u2014 just when plants, animals and people need it most.

Ecologists like Hauer say there are other changes happening as well \u2014 retreating glaciers, and more flash floods. \"One of the expectations with climate change is that we're going to see a decrease in the permanent streams, particularly in the high alpine, and an increase in the temporary, ephemeral streams,\" Hauer says.

Already, scientists have noted the shrinking of the more than two dozen glaciers in Glacier National Park, as well as the disappearance of some snowfields that once lasted through summer.

Now they're trying to find out how this affects wildlife \u2014 wildlife that's important for holding together the complex food web here.

I join three scientists from the U.S. Geological Survey on a mountainside a couple of thousand feet below Hauer's flight path. We're hiking up into a snowfield in the park, toward a stream flowing down from the snow. \"It's a great place to be if you are an obscure, high-alpine-stream insect,\" says aquatic entomologist Joe Giersch. Obscure insects are Giersch's life. Several species of very rare but important insects live here, in 40-degree meltwater.

Giersch bends over the stream \u2014 it's only a few inches deep \u2014 and turns over a few rocks. In 10 minutes, he finds what he wants: a tiny, brown, wet smudge of a fly. \"All right! This is Lednia tumana.\" It's smaller than the head of a match and, to my eye, is just a brown blob. Giersch assures me that's what it is. \"I've looked at a lot of these,\" he says. He calls the fly \"charismatic microfauna.\"

Charismatic may be a stretch, but micro for sure. Lednia tumana is a stonefly. It spends part of its life in streams, but only icy streams in these mountains. It eats algae and other tiny organisms in the streams, and other insects and fish eat it. Stoneflies are part of a larger food web. Pull out one string, says our hiking companion, Daniel Fagre, and the web starts to come apart.

\"In only a few decades, we're going to lose all the glaciers here,\" says Fagre, a research ecologist with the USGS at the West Glacier Field Station. \"And they've been persistent on the landscape here for 7,000 years \u2014 so suddenly you are having a profound change in just a few decades, and that's very difficult for many organisms to adapt to.\"

What's happening is that as the average temperature increases here, the snow and ice, in effect, retreat up the mountain to colder air. Ecologist Clint Muhlfeld, who also studies this fly, says eventually the ice and the insects will run out of mountain. \"You know, there's nowhere to go,\" he says. \"They're at the top of the continent \u2014 the water tower of the continent \u2014 and it's a squeeze play.\" Muhlfeld notes that the federal government is considering listing Lednia as an endangered species because of the effects of climate change.

Moving farther down the mountain, you can see more signs of this disruption in the way water works here \u2014 in places like Montana's Flathead Lake, for example, one of the biggest lakes in the country.

Jack Stanford, who runs the Flathead Lake Biological Station, has spent decades studying the complex interactions of plants, animals and water. \"The way in which water is deposited first and then transported by the rivers is fundamental to the distribution and abundance of organisms,\" he says.

Some of those organisms \u2014 for instance, salmon \u2014 are important, not only to nature but to people too.

If you get a warmer spring, you get flash floods, because the rain comes in before the snow has melted. It's called a \"rain on snow event,\" and it can be trouble for salmon, which lay eggs in the gravel of stream beds. Rain on snow is like rain falling on pavement \u2014 it creates floods that wash the young salmon away, decimating the population.

\"The way it plays out is that the food web gets a shakeup,\" Stanford says. \"And ... the bottom line is, some players in that complex food web will be winners, and some will be losers.\"

Stanford says humans have already changed the natural world in ways we couldn't predict. Climate change is like putting another pair of dice in play.

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:10:01+00:00", "created": "2014-08-27T20:10:00+00:00", "valid": {"from": "2014-08-27T20:10:00+00:00", "to": "3014-08-27T20:10:00+00:00"}, "hreflang": "en", "teaser": "Peaks around Glacier National Park store water that irrigates a large section of North America. But a warming climate is shrinking that snowpack, with ominous consequences for wildlife and people.", "byline": "Christopher Joyce", "tags": ["npr_api", "341372550"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "Sunni Moderates May Be Key To Turning Back ISIS Extremists", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758257", "343758258"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758257/sunni-moderates-may-be-key-to-turning-back-isis-extremists?ft=3&f=343758257"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "Sunni Moderates May Be Key To Turning Back ISIS Extremists", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "Defeating the militant group Islamic State in the Middle East will depend on getting Sunni Muslims to reject it. And Sunnis, the region's majority religious sect, are divided, insecure and struggling over their identity.", "byline": "Robert Siegel", "tags": ["npr_api", "343758257"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "It's Not Whisky, But Everyone In Scotland Drinks It By The Bottle", "modified": "2014-08-27T20:10:02+00:00", "created": "2014-08-27T20:10:02+00:00", "valid": {"from": "2014-08-27T20:10:02+00:00", "to": "3014-08-27T20:10:02+00:00"}, "tags": ["npr_api", "343727147", "343758342"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru2-8-27-14-ac846b6844de3e4f5385fc933e3dc88495724e89.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "3452", "width": "4603"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru2-8-27-14_sq-eea27d626193383e136fa6099ce6dd8b9279b7ca.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "3281", "width": "3281"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru2-8-27-14_wide-6200e946a2f2acebe920c2dff059bb353ebcd89b.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "2524", "width": "4487"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru2-8-27-14_wide-6200e946a2f2acebe920c2dff059bb353ebcd89b.jpg", "type": "image/jpeg", "meta": {"crop": "enlargement", "height": "2524", "width": "4487"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:10:03+00:00", "to": "3014-08-27T20:10:03+00:00"}, "title": "\"People call Irn Bru Scotland's other national drink, after whisky,\" says Sara Grady, who works for a market research firm.", "modified": "2014-08-27T20:10:03+00:00", "created": "2014-08-27T20:10:03+00:00", "description": "\"People call Irn Bru Scotland's other national drink, after whisky,\" says Sara Grady, who works for a market research firm.", "tags": ["npr_api", "343727147", "343738982"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru-8-27-14-96e5392bf709a8acb0a1f069746d00fd99c9d036.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "3213", "width": "4285"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru-8-27-14_sq-648c806fc24f9b3739bbe6690013a37d41623043.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "3456", "width": "3457"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru-8-27-14_custom-0063bd38fe1cd7ff101107ce333e5933d86ba3a3.jpg", "type": "image/jpeg", "meta": {"crop": "enlargement", "height": "2824", "width": "4285"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/irn-bru-8-27-14_custom-0063bd38fe1cd7ff101107ce333e5933d86ba3a3.jpg", "type": "image/jpeg", "meta": {"crop": "custom", "height": "2824", "width": "4285"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:10:04+00:00", "to": "3014-08-27T20:10:04+00:00"}, "title": "Irn Bru is a hugely popular Scottish soda that may even outsell Coca-Cola in Scotland. It also symbolizes local pride in a place that will vote on whether to break away from the United Kingdom next month.", "modified": "2014-08-27T20:10:04+00:00", "created": "2014-08-27T20:10:04+00:00", "description": "Irn Bru is a hugely popular Scottish soda that may even outsell Coca-Cola in Scotland. It also symbolizes local pride in a place that will vote on whether to break away from the United Kingdom next month.", "tags": ["npr_api", "343727147", "343731415"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 3, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/blogs/parallels/2014/08/27/343727147/its-not-whisky-but-everyone-in-scotland-drinks-it-by-the-bottle?ft=3&f=343727147"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "It's Not Whisky, But Everyone In Scotland Drinks It By The Bottle", "contentencoded": "

For a visitor to Scotland, it can be difficult to understand the local passion for a neon orange soda that locals call \"the brew.\" The drink is Irn Bru (pronounced \"iron brew\").

You can find it from McDonald's to corner stores and pubs across Scotland. It is such a powerful force that it may even outsell Coca-Cola here \u2014 making it one of the few places on the globe where Coke isn't the leading brand.

\"This stuff runs in my blood,\" says Chris Young, as he walks through downtown Glasgow carrying a bottle.

Perhaps he's not a fair sample, though, since he is actually drinking the stuff. The woman with him, Gayle Fergus, has no such bottle. So is she as devoted a fan?

\"Probably more,\" she says.

This seems impossible, given that her buddy claims the soda courses through his veins. But she insists.

\"I've got the pens, I've got the merchandise as well.\" Fergus even speaks longingly of Irn Bru kilts, in bright orange and blue.

These people are not outliers. Even the first person we stop at random on a Glasgow street professes a seemingly unnatural passion for the brew.

\"For my wedding toast, I had Irn Bru in champagne glasses instead of champagne,\" says Laura Calgie.

For the sake of journalistic integrity, it's important to confirm that she has no family connection to the company. She insists she does not, then pauses.

\"I was brought up about 10 minutes away from the factory, so maybe they put something in the water,\" she says.

As Scots prepare to vote on independence next month, the fizzy fervor for this fluorescent fluid may offer some insights into Scottish nationalistic tendencies. When asked why they're so crazy for this Scottish soda, people most often reply, \"Because it's Scottish.\"

\"We're proud of what we have. That's why it outsells Coca-Cola,\" says Fergus. \"Because we're so proud of our own products.\"

At a nearby old-fashioned candy store, shop worker Agnes Plunkett has shelves of Irn Bru-flavored sweets, from sticky taffy to translucent lollipops. Though since these are not officially licensed products, they're spelled \"Iron Brew.\"

\"This is the chews. This is Iron Brew humbugs. Orange flavored as well, orange colored,\" she says, walking down the shelf of candies. Every thing Iron Brew flavored is a great seller, she says. \"Very popular.\"

Plunkett lets a visitor sample one of the hard candies. It starts out sweet, followed by a burst of acidity. And, of course, it's bright orange.

Much of the world treats Scottish icons as kitsch. Kilts. Haggis. Bagpipes. But for Scots, these are potent symbols of national pride. One of Irn Bru's advertising slogans is \"Made in Scotland, from girders.\" Girders, as in the steel beams that hold up buildings.

\"People call Irn Bru Scotland's other national drink, after whisky,\" says Sara Grady of the market research firm Datamonitor Consumer. \"Whereas I think Coke prides itself on being a brand that's the same all over the world, Irn Bru appeals to people because it's so Scottish.\"

Grady explains that she's English, \"and so everything I see of English culture, we're kind of shy about it. Whereas they're just loud and proud.\"

\"In some ways, I guess you could say that while Coca-Cola embodies the American dream, Irn Bru could be the Scottish version of that,\" she says.

At the Irn Bru factory just outside Glasgow, visitors must wear protective earphones. The rattling sound is constant as 96,000 cans an hour fly down the line.

\"We'll sell about the equivalent of 17 cans a second, which is a huge volume to keep up with,\" says brand manager Martin Steele, who's serving as our tour guide.

When the tour is done, I tell Steele that I have a confession.

I still have not actually tasted Irn Bru soda.

\"Shall we do that? Shall I get you a can and you can try it?\" he says. \"Give me two seconds. I'll nip into the factory and get you a can.\"

He brings back an ice-cold bottle, straight off the factory floor. The contents are the color of a sunset in a hazy sky.

I take a sip. And it tastes like ... soda. Sweet. Fizzy. A bit bubble-gummy.

To me, it seems like nothing special. Then again, I'm not Scottish.

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:10:05+00:00", "created": "2014-08-27T20:10:05+00:00", "valid": {"from": "2014-08-27T20:10:05+00:00", "to": "3014-08-27T20:10:05+00:00"}, "hreflang": "en", "teaser": "Irn Bru is a neon orange soda that inspires passion and may help explain the strong independent streak in Scotland as it prepares to vote Sept. 18 on whether to break away from the United Kingdom.", "byline": "Ari Shapiro", "tags": ["npr_api", "343727147"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "Iraqi Christian Village: From Sanctuary To Ghost Town In 2 Months", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343673454", "343758372"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"href": "http://media.npr.org/assets/img/2014/08/27/iraq-alqoush1-e8d2d5775773f278633c2898a15b2afb6ed17457.jpg", "type": "image/jpeg", "meta": {"crop": "standard", "height": "2123", "width": "2830"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/iraq-alqoush1_sq-6e87b63e4be0b8705ade687c99aea885f291fb4c.jpg", "type": "image/jpeg", "meta": {"crop": "square", "height": "573", "width": "573"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/iraq-alqoush1_wide-fda0a7834fec282a8422dc7c1a78a5582b70f037.jpg", "type": "image/jpeg", "meta": {"crop": "wide", "height": "1833", "width": "3259"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/iraq-alqoush1_slide-0f617c6206708076de5074195a950e06fd4a5f18.jpg", "type": "image/jpeg", "meta": {"crop": "enlargement", "height": "1979", "width": "2968"}}, {"href": "http://media.npr.org/assets/img/2014/08/27/iraq-alqoush1_slide-0f617c6206708076de5074195a950e06fd4a5f18.jpg", "type": "image/jpeg", "meta": {"crop": "slide", "height": "1979", "width": "2968"}}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/image"}]}, "version": "1.0", "attributes": {"valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "title": "Rinam Mansour, his mother and his sister Lillian are among the few people still living in Al-Qoush, a Christian village in northern Iraq.", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "description": "Rinam Mansour, his mother and his sister Lillian are among the few people still living in Al-Qoush, a Christian village in northern Iraq.", "tags": ["npr_api", "343673454", "343713150"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 2, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/blogs/parallels/2014/08/27/343673454/iraqi-christian-village-from-sanctuary-to-ghost-town-in-2-months?ft=3&f=343673454"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "Iraqi Christian Village: From Sanctuary To Ghost Town In 2 Months", "contentencoded": "

The northern Iraqi village of Al-Qoush was humming with activity \u2014 and some jitters \u2014 when NPR visited back in June. The Assyrian Christian villagers had opened their schools and homes to Iraqis fleeing the takeover of nearby Mosul by Islamist fighters calling themselves the Islamic State.

But these days, most of Al-Qoush is as silent as the 6th-century monastery overlooking the village from a hill. A few Kurdish security men guard the entrance to the village, primarily concerned with keeping potential looters away from the tidy stone and cement homes.

The villagers fled en masse in early August, when Islamist fighters made a move in Al-Qoush's direction. Now, as Kurdish forces begin to retake territory around Mosul, including the strategic Mosul dam, some families have begun to trickle back to Al-Qoush. Most stay only during daylight hours, however, afraid to stay overnight with Islamic State forces a mere 20 miles away.

Leaving Everything Behind, Yet Again

Raed Salman, 45, is one of the few who's here full time, at least for now. The truck driver's recent history is sadly familiar to many Iraqis.

\"This is the second time I'm displaced. We're originally from Baghdad,\" he says. \"We fled Baghdad; my father and brother were kidnapped. We paid a huge ransom, but they shot and badly wounded my brother. Now we're displaced for a second time.\"

Salman gestures to his large, well-appointed home. He says it took years of high-risk travel on Iraq's deadly highways to save enough money to finish it. But he's resigned to leaving it all behind, once again, because his family's safety comes first.

\"Believe me, there is nowhere in Iraq that is safe for us,\" he says. \"We have Shiite friends in the city of Kut. They say, 'Come live with us. We'll keep you safe.' They're good friends, but what about the future? They could be the next ones displaced.\"

Salman doesn't know where they'll go. Their passports are expired, and he doesn't think there's much chance of renewing them now.

New Pressure On A Dwindling Population

A deep current of fear is once again running through Iraq's Christian minority, which has roots in the earliest days of the faith. Precise counts are impossible to come by, but Christians are believed to have numbered about 1.5 million when the U.S.-led invasion of Iraq began in 2003. Current estimates range from 200,000 to 400,000.

While the Christian exodus from Iraq is extreme and driven by the country's bloodshed, it's a trend that's been underway for decades throughout the Middle East. In the mid-20th century, Christians were estimated to be about 20 percent of the Middle East's population. Today, it's 5 percent at most.

In June, NPR spoke with Rinam Mansour, 30, a teacher who was volunteering to help displaced people from Mosul. Now he sits on his couch, pondering his own future.

\"I was on the church's commission to help displaced people,\" he says. \"They were Shiites, Christians and others. We opened our doors and gave them what we could. And now, we ourselves are the displaced.\"

In numerous interviews with displaced Yazidis, another religious minority in Iraq, many said they envied the Christians because at least they had a church establishment to stand up for them. Mansour laughs bitterly when he hears this.

\"The church protect us? The church people were the first ones to leave,\" he says. \"Maybe Al-Qoush used to be a strong Christian village, but now most people want to leave Iraq. I think only those families with no money, no passports, no friends to help them relocate, will stay.\"

Mansour's sister Lillian has already tried relocating. The United Nations moved her family to Southern California after the last round of anti-Christian violence in 2008. She says because the U.S. was in recession at the time, there were no jobs to be had, so after exhausting all of their options, they decided to return to northern Iraq.

\"When we got back, it took my husband over a year to find work, and then at least things were better than in America,\" she says. \"But just a few months later, all this started.\"

As luck would have it, Lillian's husband found work as a teacher in one of the minority villages around Mount Sinjar just before it was terrorized by Islamic State fighters.

For Rinam Mansour, the future looks bleak. He says the best-case scenario is to give up his home and the relative prestige of teaching, and hope he can land a menial job in a strange country. He believes that if Iraqi Christians are to survive, it won't be in Iraq.

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:10:00+00:00", "created": "2014-08-27T20:10:00+00:00", "valid": {"from": "2014-08-27T20:10:00+00:00", "to": "3014-08-27T20:10:00+00:00"}, "hreflang": "en", "teaser": "Villagers in Al-Qoush opened homes and schools to Iraqis fleeing the advance of the Islamic State. But that was June. Now it's a ghost town, as silent as it's 6th-century monastery.", "byline": "Peter Kenyon", "tags": ["npr_api", "343673454"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "Chicaco Greets Little League National Champs As Returning Heroes", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758273", "343758284"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758273/chicaco-greets-little-league-national-champs-as-returning-heroes?ft=3&f=343758273"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "Chicaco Greets Little League National Champs As Returning Heroes", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "Chicago has gathered for a parade to celebrate the Jackie Robinson West baseball team, which won the U.S. championship at the Little League World Series. Chicago Public Radio's Natalie Moore reports that this all-black team has helped to unify a city reeling from North and South Side segregation, as well as renewed attention on the city's violence.", "byline": "Natalie Moore", "tags": ["npr_api", "343758273"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "Mapping Out The End Days Of The Midterm Campaign", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758229", "343758230"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758229/mapping-out-the-end-days-of-the-midterm-campaign?ft=3&f=343758229"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "Mapping Out The End Days Of The Midterm Campaign", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "The end of August heralds the start to the final phase of the 2014 election season. As primaries wrap up and candidates ready themselves for November, NPR's Charlie Mahtesian lays out the political landscape.", "byline": "Melissa Block", "tags": ["npr_api", "343758229"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "As BK Takes Tim Hortons, Canadians Stay Loyal To Their National Icon", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758243", "343758244"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758243/as-bk-takes-tim-hortons-canadians-stay-loyal-to-their-national-icon?ft=3&f=343758243"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "As BK Takes Tim Hortons, Canadians Stay Loyal To Their National Icon", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "The takeover of Canada's Tim Hortons by Burger King is causing quite the stir in the great white north. Melissa Block talks with Ian Hardy, editor-in-chief of Inside Timmies, a fan site devoted to Tim Hortons, about the Canadian existential crisis over one of the country's cultural icons being taken over by an American corporation.", "tags": ["npr_api", "343758243"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "The Calamity Of The 'Clam,' Every Musician's Headache", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758323", "343758330"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758323/the-calamity-of-the-clam-every-musicians-headache?ft=3&f=343758323"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "The Calamity Of The 'Clam,' Every Musician's Headache", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "As part of an All Things Considered series on trade lingo, music producer Don Was explains the word \"clam\" \u2014 a mistake made by a musical performer.", "tags": ["npr_api", "343758323"]}}, {"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "items": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "rels": ["self"]}], "enclosure": [{"meta": {"duration": null}, "type": "audio/m3u", "href": ""}], "item": [], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/audio"}]}, "version": "1.0", "attributes": {"title": "Meet The Squirrel Whisperer Of Happy Valley", "modified": "2014-08-27T20:09:58+00:00", "created": "2014-08-27T20:09:58+00:00", "valid": {"from": "2014-08-27T20:09:58+00:00", "to": "3014-08-27T20:09:58+00:00"}, "tags": ["npr_api", "343758312", "343758317"], "published": "2014-08-27T20:09:00+00:00", "guid": "someGUIDvalue"}}], "links": {"navigation": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue", "totalitems": 1, "pagenum": 1, "totalpages": 1, "rels": ["self"]}], "alternate": [{"href": "http://www.npr.org/2014/08/27/343758312/meet-the-squirrel-whisperer-of-happy-valley?ft=3&f=343758312"}], "creator": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}], "profile": [{"href": "http://127.0.0.1:8080/profiles/story"}], "item": [{"href": "http://127.0.0.1:8080/docs/someGUIDvalue"}]}, "version": "1.0", "attributes": {"published": "2014-08-27T20:09:00+00:00", "title": "Meet The Squirrel Whisperer Of Happy Valley", "contentencoded": "

Copyright 2014 NPR. To see more, visit http://www.npr.org/.

", "guid": "someGUIDvalue", "modified": "2014-08-27T20:09:59+00:00", "created": "2014-08-27T20:09:59+00:00", "valid": {"from": "2014-08-27T20:09:59+00:00", "to": "3014-08-27T20:09:59+00:00"}, "hreflang": "en", "teaser": "A squirrel at Penn State University has become a social media sensation. Emily Reddy of WPSU reports that undergraduate student Mary Krupa discovered the squirrels on campus were so tame that they'd eat from her hand, soon putting hats on them and even setting up a Facebook page, which now has more \"likes\" than the school's mascot.", "byline": "Emily Reddy", "tags": ["npr_api", "343758312"]}}]} \ No newline at end of file diff --git a/test/test_pelicanjson.py b/test/test_pelicanjson.py index 323ca93..375309c 100644 --- a/test/test_pelicanjson.py +++ b/test/test_pelicanjson.py @@ -12,7 +12,7 @@ current_dir = os.path.abspath(os.path.dirname(__file__)) fixture_dir = os.path.join(current_dir, 'fixtures') # Actual datasets -data = os.path.join(fixture_dir, 'test_data.json') +data = os.path.join(fixture_dir, 'datadoc.json') book = os.path.join(fixture_dir, 'book.json') ricketts = os.path.join(fixture_dir, 'ricketts.json') monterrey = os.path.join(fixture_dir, 'monterrey.json') @@ -281,7 +281,7 @@ def test_create_path_in_dict(self): self.assertEqual(test_rickettsi.get_nested_value(path), "NEWVALUE") - def test_create_path_in_list(self): + def test_create_path_new_object_inside_list(self): test_rickettsi = PelicanJson(self.ricketts) paths = [['query', 'pages', '1422396', 'images', 7, 'title'], ['query', 'normalized', 10, 'NEW']] @@ -298,6 +298,21 @@ def test_create_path_in_list(self): 'normalized'])), 11) + def test_create_path_add_item_to_list(self): + test_item = PelicanJson(self.item) + paths = [['attributes', 'tags', 2], + ['attributes', 'tags', 5]] + check_for_none = paths[1][:-1] + check_for_none.append(4) + test_item.create_path(paths[0], "New value inside list") + self.assertEqual(test_item.get_nested_value(paths[0]), + "New value inside list") + test_item.create_path(paths[1], "New value inside list with None") + self.assertEqual(test_item.get_nested_value(paths[1]), + "New value inside list with None") + self.assertEqual(test_item.get_nested_value(check_for_none), + None) + def test_create_path_raise_badpath(self): test_rickettsi = PelicanJson(self.ricketts) bad_path = [[4, 'query', 'normalized', 0, 'from'], @@ -338,9 +353,11 @@ def test_searchvalue(self): self.assertEqual(list(test_monty.search_value('2014-08-25')), [['results', 1, 'maxdate'], ['results', 3, 'maxdate']]) + npr_api_tag = [['attributes', 'tags', 0], + ['items', 0, 'attributes', 'tags', 0]] pelican_item = PelicanJson(self.item) - self.assertEqual(next(pelican_item.search_value('Cove')), - ['attributes', 'tags', 2]) + for path in pelican_item.search_value('npr_api'): + self.assertIn(path, npr_api_tag) def test_pluck(self): answer = PelicanJson({'to': 'Pelecanus occidentalis', @@ -353,13 +370,13 @@ def test_pluck(self): next(test_pelican.pluck('from', 'Pelecanus_occidentalis'))) pelican_item = PelicanJson(self.item) - self.assertEqual(pelican_item, - next(pelican_item.pluck('version', '1.0'))) + self.assertEqual(pelican_item['attributes'], + next(pelican_item.pluck('byline', 'Emily Reddy'))) def test_get_nested_value(self): pelican_item = PelicanJson(self.item) - answer = pelican_item.get_nested_value(['attributes', 'tags', 2]) - self.assertEqual(answer, 'Cove') + answer = pelican_item.get_nested_value(['attributes', 'tags', 0]) + self.assertEqual(answer, 'npr_api') test_monty = PelicanJson(self.monterrey) answers = [('gov.noaa.ncdc:C00822', ['results', 7, 'uid']), ('gov.noaa.ncdc:C00040', ['results', 0, 'uid'])] @@ -438,11 +455,12 @@ def test_set_nested_value_raises_error(self): for path in index_error_paths: test_rickettsi.set_nested_value(path, "Shouldn't Work") - def test_set_nested_value_force(self): - # Attempt to set paths that previously raised: - # IndexError, KeyError, TypeError + # Attempt to set paths that previously raised: IndexError, KeyError, + # TypeError + def test_set_nested_value_force_key_error(self): test_rickettsi = PelicanJson(self.ricketts) success_msg = "Should now work" + # KeyErrors overidden key_error_paths = [['unknownKey', 'unknownKey2'], ['query-continue', 'unknownKey']] for path in key_error_paths: @@ -452,15 +470,21 @@ def test_set_nested_value_force(self): self.assertEqual(test_rickettsi.get_nested_value(path), success_msg) + def test_set_nested_value_force_type_error(self): + test_rickettsi = PelicanJson(self.ricketts) + success_msg = "Should now work" # TypeErrors overridden: path created type_error_path = ['query-continue', 'extlinks', 'eloffset', 'newdict-with-key'] test_rickettsi.set_nested_value(type_error_path, success_msg, force=True) - self.assertEqual(test_rickettsi.get_nested_value(path), + self.assertEqual(test_rickettsi.get_nested_value(type_error_path), success_msg) + def test_set_nested_value_force_previous_index_error(self): + test_rickettsi = PelicanJson(self.ricketts) + success_msg = "Should now work" # IndexErrors overridden: paths created index_error_paths = [['query', 'normalized', 1, 'from'], ['query', 'normalized', 1, 'to']] @@ -469,6 +493,16 @@ def test_set_nested_value_force(self): self.assertEqual(test_rickettsi.get_nested_value(path), success_msg) + def test_set_nested_value_force_add_to_list(self): + path = ['attributes', 'tags', 4] + test_pelican = PelicanJson(self.item) + test_pelican.set_nested_value(path, 'New Tag', force=True) + new_tag = test_pelican.get_nested_value(path) + self.assertEqual(new_tag, 'New Tag') + none_placeholder = ['attributes', 'tags', 3] + self.assertEqual(test_pelican.get_nested_value(none_placeholder), + None) + def test_find_and_replace(self): test_pelican = PelicanJson(self.pelecanus_occidentalis) test_pelican.find_and_replace('Pelecanus occidentalis',