Changes from jobs_api to parse_requirements

This is now a nearly completely verbatim copy-paste of
parse_requirements() from jobs.py.  As soon as both branches are merged,
this should probably be refactored so we don't have two nearly identical
functions for this.