<commit_before>use std::old_io::BufferedReader;
use std::old_io::EndOfFile;
use std::old_io::fs::File;

use super::super::context::{BuildContext};
use super::super::packages;
use super::generic::{run_command_at_env, capture_command};


pub fn scan_features(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> {
    let mut res = vec!();
    res.push(packages::BuildEssential);
    if ver == 2 {
        res.push(packages::Python2);
        res.push(packages::Python2Dev);
        res.push(packages::PipPy2);
    } else {
        res.push(packages::Python3);
        res.push(packages::Python3Dev);
        res.push(packages::PipPy3);
    }
    for name in pkgs.iter() {
        if name.as_slice().starts_with("git+") {
            res.push(packages::Git);
        } else if name.as_slice().starts_with("hg+") {
            res.push(packages::Mercurial);
        }
    }
    return res;
}

fn pip_args(ctx: &mut BuildContext, ver: u8) -> Vec<String> {
    let mut args = vec!(
        (if ver == 2 { "python2" } else { "python3" }).to_string(),
        "-m".to_string(), "pip".to_string(),
        "install".to_string(),
        "--ignore-installed".to_string(),
        );
    if ctx.pip_settings.index_urls.len() > 0 {
        let mut indexes = ctx.pip_settings.index_urls.iter();
        if let Some(ref lnk) = indexes.next() {
            args.push(format!("--index-url={}", lnk));
            for lnk in indexes {
                args.push(format!("--extra-index-url={}", lnk));
            }
        }
    }
    ctx.pip_settings.trusted_hosts.iter().map(|h| {
        args.push("--trusted-host".to_string());
        args.push(h.to_string());
    });
    if !ctx.pip_settings.dependencies {<commit_msg>Fix bug of trusted-hosts not actually working<commit_after>use std::old_io::BufferedReader;
use std::old_io::EndOfFile;
use std::old_io::fs::File;

use super::super::context::{BuildContext};
use super::super::packages;
use super::generic::{run_command_at_env, capture_command};


pub fn scan_features(ver: u8, pkgs: &Vec<String>) -> Vec<packages::Package> {
    let mut res = vec!();
    res.push(packages::BuildEssential);
    if ver == 2 {
        res.push(packages::Python2);
        res.push(packages::Python2Dev);
        res.push(packages::PipPy2);
    } else {
        res.push(packages::Python3);
        res.push(packages::Python3Dev);
        res.push(packages::PipPy3);
    }
    for name in pkgs.iter() {
        if name.as_slice().starts_with("git+") {
            res.push(packages::Git);
        } else if name.as_slice().starts_with("hg+") {
            res.push(packages::Mercurial);
        }
    }
    return res;
}

fn pip_args(ctx: &mut BuildContext, ver: u8) -> Vec<String> {
    let mut args = vec!(
        (if ver == 2 { "python2" } else { "python3" }).to_string(),
        "-m".to_string(), "pip".to_string(),
        "install".to_string(),
        "--ignore-installed".to_string(),
        );
    if ctx.pip_settings.index_urls.len() > 0 {
        let mut indexes = ctx.pip_settings.index_urls.iter();
        if let Some(ref lnk) = indexes.next() {
            args.push(format!("--index-url={}", lnk));
            for lnk in indexes {
                args.push(format!("--extra-index-url={}", lnk));
            }
        }
    }
    ctx.pip_settings.trusted_hosts.iter().map(|h| {
        args.push("--trusted-host".to_string());
        args.push(h.to_string());
    }).last();
    if !ctx.pip_settings.dependencies {
{'fraction_non_alphanumeric': 0.17750795027464586, 'fraction_numerical': 0.007516623301532235, 'mean_word_length': 2.6382754994742377, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1333061', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1154, 'n_words': 197}