(filename)
Parse a CSV file in the format of the ``/usr/share/distro-info/*.csv`` files.

    :param filename: The pathname of the CSV file (a string).
    :returns: A generator of :class:`Release` objects.
Parse a CSV file in the format of the ``/usr/share/distro-info/*.csv`` files.
Parse a CSV file in the format of the / usr / share / distro - info / * . csv files .
def parse_csv_file(filename):
    """
    Parse a CSV file in the format of the ``/usr/share/distro-info/*.csv`` files.

    :param filename: The pathname of the CSV file (a string).
    :returns: A generator of :class:`Release` objects.
    """
    # We import this here to avoid a circular import.
    from apt_smart.backends.debian import LTS_RELEASES
    basename, extension = os.path.splitext(os.path.basename(filename))
    distributor_id = basename.lower()
    with open(filename) as handle:
        for entry in csv.DictReader(handle):
            yield Release(
                codename=entry['codename'],
                is_lts=(
                    entry['series'] in LTS_RELEASES if distributor_id == 'debian' else (
                        'LTS' in entry['version'] if distributor_id == 'ubuntu' else (
                            # Neither Debian nor Ubuntu, let's not assume anything...
                            False
                        )
                    )
                ),
                created_date=parse_date(entry['created']),
                distributor_id=distributor_id,
                eol_date=parse_date(entry['eol']),
                extended_eol_date=(
                    # Special handling for Debian LTS releases.
                    datetime.datetime.fromtimestamp(LTS_RELEASES[entry['series']]).date()
                    if distributor_id == 'debian' and entry['series'] in LTS_RELEASES
                    # Ubuntu LTS releases are defined by the CSV file.
                    else parse_date(entry.get('eol-server'))
                ),
                release_date=parse_date(entry['release']),
                series=entry['series'],
                version=parse_version(entry['version']) if entry['version'] else None,
            )
def parse_csv_file ( filename ) : # We import this here to avoid a circular import. from apt_smart . backends . debian import LTS_RELEASES basename , extension = os . path . splitext ( os . path . basename ( filename ) ) distributor_id = basename . lower ( ) with open ( filename ) as handle : for entry in csv . DictReader ( handle ) : yield Release ( codename = entry [ 'codename' ] , is_lts = ( entry [ 'series' ] in LTS_RELEASES if distributor_id == 'debian' else ( 'LTS' in entry [ 'version' ] if distributor_id == 'ubuntu' else ( # Neither Debian nor Ubuntu, let's not assume anything... False ) ) ) , created_date = parse_date ( entry [ 'created' ] ) , distributor_id = distributor_id , eol_date = parse_date ( entry [ 'eol' ] ) , extended_eol_date = ( # Special handling for Debian LTS releases. datetime . datetime . fromtimestamp ( LTS_RELEASES [ entry [ 'series' ] ] ) . date ( ) if distributor_id == 'debian' and entry [ 'series' ] in LTS_RELEASES # Ubuntu LTS releases are defined by the CSV file. else parse_date ( entry . get ( 'eol-server' ) ) ) , release_date = parse_date ( entry [ 'release' ] ) , series = entry [ 'series' ] , version = parse_version ( entry [ 'version' ] ) if entry [ 'version' ] else None , )