(mirror_url, codename,
                          suites=DEFAULT_SUITES,
                          components=VALID_COMPONENTS,
                          enable_sources=False)
return '\n'.join(lines)
Generate the contents of ``/etc/apt/sources.list`` for a Debian system.

    :param mirror_url: The base URL of the mirror (a string).
    :param codename: The codename of a Debian release (a string like 'wheezy'
                     or 'jessie') or a Debian release class (a string like
                     'stable', 'testing', etc).
    :param suites: An iterable of strings (defaults to
                   :data:`DEFAULT_SUITES`, refer to
                   :data:`VALID_SUITES` for details).
    :param components: An iterable of strings (refer to
                       :data:`VALID_COMPONENTS` for details).
    :param enable_sources: :data:`True` to include ``deb-src`` entries,
                           :data:`False` to omit them.
    :returns: The suggested contents of ``/etc/apt/sources.list`` (a string).
Generate the contents of ``/etc/apt/sources.list`` for a Debian system.
Generate the contents of / etc / apt / sources . list for a Debian system .
def generate_sources_list(mirror_url, codename,
                          suites=DEFAULT_SUITES,
                          components=VALID_COMPONENTS,
                          enable_sources=False):
    """
    Generate the contents of ``/etc/apt/sources.list`` for a Debian system.

    :param mirror_url: The base URL of the mirror (a string).
    :param codename: The codename of a Debian release (a string like 'wheezy'
                     or 'jessie') or a Debian release class (a string like
                     'stable', 'testing', etc).
    :param suites: An iterable of strings (defaults to
                   :data:`DEFAULT_SUITES`, refer to
                   :data:`VALID_SUITES` for details).
    :param components: An iterable of strings (refer to
                       :data:`VALID_COMPONENTS` for details).
    :param enable_sources: :data:`True` to include ``deb-src`` entries,
                           :data:`False` to omit them.
    :returns: The suggested contents of ``/etc/apt/sources.list`` (a string).
    """
    # Validate the suites.
    invalid_suites = [s for s in suites if s not in VALID_SUITES]
    if invalid_suites:
        msg = "Invalid Debian suite(s) given! (%s)"
        raise ValueError(msg % invalid_suites)
    # Validate the components.
    invalid_components = [c for c in components if c not in VALID_COMPONENTS]
    if invalid_components:
        msg = "Invalid Debian component(s) given! (%s)"
        raise ValueError(msg % invalid_components)
    # Generate the /etc/apt/sources.list file contents.
    lines = []
    directives = ('deb', 'deb-src') if enable_sources else ('deb',)
    for suite in suites:
        for directive in directives:
            lines.append(format(
                '{directive} {mirror} {suite} {components}', directive=directive,
                mirror=(OLD_RELEASES_URL if mirrors_are_equal(mirror_url, OLD_RELEASES_URL)
                        else (SECURITY_URL if suite == 'security' else mirror_url)),
                suite=(codename if suite == 'release' else (
                    ('%s/updates' % codename if suite == 'security'
                     else codename + '-' + suite))),
                components=' '.join(components),
            ))
    return '\n'.join(lines)
def generate_sources_list ( mirror_url , codename , suites = DEFAULT_SUITES , components = VALID_COMPONENTS , enable_sources = False ) : # Validate the suites. invalid_suites = [ s for s in suites if s not in VALID_SUITES ] if invalid_suites : msg = "Invalid Debian suite(s) given! (%s)" raise ValueError ( msg % invalid_suites ) # Validate the components. invalid_components = [ c for c in components if c not in VALID_COMPONENTS ] if invalid_components : msg = "Invalid Debian component(s) given! (%s)" raise ValueError ( msg % invalid_components ) # Generate the /etc/apt/sources.list file contents. lines = [ ] directives = ( 'deb' , 'deb-src' ) if enable_sources else ( 'deb' , ) for suite in suites : for directive in directives : lines . append ( format ( '{directive} {mirror} {suite} {components}' , directive = directive , mirror = ( OLD_RELEASES_URL if mirrors_are_equal ( mirror_url , OLD_RELEASES_URL ) else ( SECURITY_URL if suite == 'security' else mirror_url ) ) , suite = ( codename if suite == 'release' else ( ( '%s/updates' % codename if suite == 'security' else codename + '-' + suite ) ) ) , components = ' ' . join ( components ) , ) ) return '\n' . join ( lines )