def previous_sxs(cfr_title, cfr_part, stop_version):
    """The SxS layer relies on all notices that came before a particular
    version"""
    for previous_version in entry.FinalVersion(cfr_title, cfr_part):
        yield entry.SxS(previous_version)
        if previous_version == stop_version:
            break
def previous_sxs(cfr_title, cfr_part, stop_version):
    """The SxS layer relies on all notices that came before a particular
    version"""
    sub_entries = entry.FinalVersion(cfr_title, cfr_part).sub_entries()
    version_ids = [e.path[-1] for e in sub_entries]
    for previous_version in version_ids:
        yield entry.SxS(previous_version)
        if previous_version == stop_version:
            break
Exemple #3
0
def create_version_entry_if_needed(volume, cfr_part):
    """Only write the version entry if it doesn't already exist. If we
    overwrote one, we'd be invalidating all related trees, etc."""
    version_id = _version_id(volume.year, cfr_part)
    version_entries = entry.FinalVersion(volume.title, cfr_part)

    if version_id not in version_entries:
        (version_entries / version_id).write(
            Version(identifier=version_id,
                    effective=volume.publication_date,
                    published=volume.publication_date))
Exemple #4
0
def create_version_entry_if_needed(volume, cfr_part):
    """Only write the version entry if it doesn't already exist. If we
    overwrote one, we'd be invalidating all related trees, etc."""
    version_id = _version_id(volume.year, cfr_part)
    version_dir = entry.FinalVersion(volume.title, cfr_part)

    if version_id not in [c.path[-1] for c in version_dir.sub_entries()]:
        (version_dir / version_id).write(
            Version(version_id,
                    effective=volume.publication_date,
                    fr_citation=Citation(volume.vol_num, 1)))
Exemple #5
0
def write_if_needed(cfr_title, cfr_part, version_ids, xmls, delays_by_version):
    """All versions which are stale (either because they were never create or
    because their dependency has been updated) are written to disk. If any
    dependency is missing, an exception is raised"""
    version_dir = entry.FinalVersion(cfr_title, cfr_part)
    deps = generate_dependencies(version_dir, version_ids, delays_by_version)
    for version_id in version_ids:
        version_entry = version_dir / version_id
        deps.validate_for(version_entry)
        if deps.is_stale(version_entry):
            write_to_disk(xmls[version_id], version_entry,
                          delays_by_version.get(version_id))
Exemple #6
0
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)