unitedstates/congress — pull request #92 by GPHemsley (2013-11-01 17:02:03+00:00)
Title: Improve caching of YAML files, and other fun stuff.

- Improve caching of YAML files.
- Simplify creation of new legislator maps and create new person-congresses and congress-persons maps.
- Mark `get_govtrack_person_id()` and `UnmatchedIdentifer` as deprecated in favor of `get_person_id()`.

---

This creates the function `cached_yaml_load()` which tries to use a cached (pickle) version of a file before it attempts to load the YAML file (which could take a while). It also creates the functions `pickle_load()`, `pickle_write()`, `get_cache_filename()`, and `check_cached_file()` to reduce code duplication and simplify common calls.

To facilitate the caching process, the primary `congress-legislators` directory is moved to the root, leaving the `cache` version only for cached pickle files. (Note: I haven't updated `committee_meetings.py` or anything else to reflect these changes.)

Beyond that, I have genericized and standardized the creation of maps (like the person-ID map), again to reduce code duplication and simplify things. As a result, I have changed the filename used as a cache, but it takes much less time to regenerate the maps as long as the base YAML files are cached OK. (This means that the wait time is relegated to only when the YAML files are actually updated.)

In order to facilitate the generation of the Congress-related maps, I added a `get_term_congresses()` function. It is unreliable in that it fails to take into account many factors which may influence how the start and end dates of a term relate to which Congress(es) the person is in (abbreviated first Senate terms, appointments, deaths, resignations, etc.), but I think it's better than nothing, and it paves the way for drop-in replacement once Congress data is actually included in the YAML files (per unitedstates/congress-legislators#41, or whatever else).

One other thing: I have made explicit that `get_govtrack_person_id()` and `UnmatchedIdentifer` (note the typo) are deprecated in favor of `get_person_id()`. This was implicit when I originally introduced the function, but I wanted to clarify in order to encourage migration.