def last_versions(cfr_title, cfr_part): """Run through all known versions of this regulation and pull out versions which are the last to be included before an annual edition""" have_annual_edition = {} path = entry.Version(cfr_title, cfr_part) if len(path) == 0: raise click.UsageError("No versions found. Run `versions`?") for version_id in path: version = (path / version_id).read() pub_date = annual.date_of_annual_after(cfr_title, version.effective) if pub_date < date.today(): have_annual_edition[pub_date.year] = version.identifier for year in sorted(have_annual_edition.keys()): yield LastVersionInYear(have_annual_edition[year], year)
def last_versions(cfr_title, cfr_part): """Run through all known versions of this regulation and pull out versions which are the last to be included before an annual edition""" have_annual_edition = {} path = entry.FinalVersion(cfr_title, cfr_part) if len(path) == 0: raise click.UsageError("No versions found. Run `versions`?") for version_id in path: version = (path / version_id).read() pub_date = annual.date_of_annual_after(cfr_title, version.effective) have_annual_edition[pub_date.year] = version.identifier for year in sorted(have_annual_edition.keys()): if annual.find_volume(year, cfr_title, cfr_part): yield LastVersionInYear(have_annual_edition[year], year) else: logger.warning("%s edition for %s CFR %s not published yet", year, cfr_title, cfr_part)
def last_versions(cfr_title, cfr_part): """Run through all known versions of this regulation and pull out versions which are the last to be included before an annual edition""" have_annual_edition = {} path = entry.FinalVersion(cfr_title, cfr_part) if not any(path.sub_entries()): raise click.UsageError("No versions found. Run `versions`?") for subpath in path.sub_entries(): version = subpath.read() pub_date = annual.date_of_annual_after(cfr_title, version.effective) have_annual_edition[pub_date.year] = version.identifier for year in sorted(have_annual_edition): if annual.find_volume(year, cfr_title, cfr_part): yield LastVersionInYear(have_annual_edition[year], year) else: logger.warning("%s edition for %s CFR %s not published yet", year, cfr_title, cfr_part)