Exemplo n.º 1
0
def read_control(filename):
    recommends = []
    predepends = []
    depends = []
    section = ''
    maintainer = ''
    arch = ''

    with open(filename) as deb_file:
        try:
            extracts = utils.deb_extract_control(deb_file)
            control = apt_pkg.TagSection(extracts)
        except:
            print(formatted_text("can't parse control info"))
            raise

    control_keys = list(control.keys())

    if "Pre-Depends" in control:
        predepends_str = control["Pre-Depends"]
        predepends = split_depends(predepends_str)

    if "Depends" in control:
        depends_str = control["Depends"]
        # create list of dependancy lists
        depends = split_depends(depends_str)

    if "Recommends" in control:
        recommends_str = control["Recommends"]
        recommends = split_depends(recommends_str)

    if "Section" in control:
        section_str = control["Section"]

        c_match = re_contrib.search(section_str)
        nf_match = re_nonfree.search(section_str)
        if c_match:
            # contrib colour
            section = colour_output(section_str, 'contrib')
        elif nf_match:
            # non-free colour
            section = colour_output(section_str, 'nonfree')
        else:
            # main
            section = colour_output(section_str, 'main')
    if "Architecture" in control:
        arch_str = control["Architecture"]
        arch = colour_output(arch_str, 'arch')

    if "Maintainer" in control:
        maintainer = control["Maintainer"]
        localhost = re_localhost.search(maintainer)
        if localhost:
            #highlight bad email
            maintainer = colour_output(maintainer, 'maintainer')
        else:
            maintainer = escape_if_needed(maintainer)

    return (control, control_keys, section, predepends, depends, recommends,
            arch, maintainer)
Exemplo n.º 2
0
def read_control (filename):
    recommends = []
    depends = []
    section = ''
    maintainer = ''
    arch = ''

    deb_file = utils.open_file(filename)
    try:
        extracts = utils.deb_extract_control(deb_file)
        control = apt_pkg.TagSection(extracts)
    except:
        print formatted_text("can't parse control info")
        deb_file.close()
        raise

    deb_file.close()

    control_keys = control.keys()

    if "Depends" in control:
        depends_str = control["Depends"]
        # create list of dependancy lists
        depends = split_depends(depends_str)

    if "Recommends" in control:
        recommends_str = control["Recommends"]
        recommends = split_depends(recommends_str)

    if "Section" in control:
        section_str = control["Section"]

        c_match = re_contrib.search(section_str)
        nf_match = re_nonfree.search(section_str)
        if c_match :
            # contrib colour
            section = colour_output(section_str, 'contrib')
        elif nf_match :
            # non-free colour
            section = colour_output(section_str, 'nonfree')
        else :
            # main
            section = colour_output(section_str, 'main')
    if "Architecture" in control:
        arch_str = control["Architecture"]
        arch = colour_output(arch_str, 'arch')

    if "Maintainer" in control:
        maintainer = control["Maintainer"]
        localhost = re_localhost.search(maintainer)
        if localhost:
            #highlight bad email
            maintainer = colour_output(maintainer, 'maintainer')
        else:
            maintainer = escape_if_needed(maintainer)

    return (control, control_keys, section, depends, recommends, arch, maintainer)