<commit_before>var fs = require('fs');
var tracer = require("tracer").colorConsole();
var mod_url = require('url');
var mod_path = require('path');
var mod_md5 = require('MD5');
var mod_util = require('util');





	// hosts:data.lionhosts[0], // css cdn主机列表
	// image_versions:data.imglist // 数据库图片列表

/**
 * 连接器，处理相对图片路径的各部分，将之拼装为目标格式
 * @param  {[type]} parsed {host,ext,name,version}
 * @return {String}        [description]
 */
function connector(parsed){
	var self = this,
		filelist = self.filelist,
		csspath = parsed.csspath,
		host = parsed.host,
		md5 = parsed.md5,
		ext = parsed.ext,
		name = parsed.name,
		version = parsed.version,
		ret;

	ret = "http://" + host+name+ext+"/"+md5+ext;

	return ret;
}




/**
 * @param {Object} opt
 * @param {String} opt.root css文件的根目录
 * @param {String} opt.host 绝对路径的host地址
 * @param {String} image_version 所有图片文件的结果集，参考DianPing. DP_StaticFileVersion
 */
function CssParser(opt) {
	this.root = opt.root;
	this.hosts = opt.hosts;
	this.filelist = opt.filelist;
	this.connector = opt.connector || connector;
	this._logs = [];
}

CssParser.prototype = {
	log:function(){
		this._logs.forEach(function(lg){
			console.log(lg);
		});
		this._logs = [];
	},
	clearlog:function(){
		this._logs = [];
	},
	/**
	 * 分析path下的所有图片路径<commit_msg>fix pull<commit_after>var fs = require('fs');
var tracer = require("tracer").colorConsole();
var mod_url = require('url');
var mod_path = require('path');
var mod_md5 = require('MD5');
var mod_util = require('util');





	// hosts:data.lionhosts[0], // css cdn主机列表
	// image_versions:data.imglist // 数据库图片列表

/**
 * 连接器，处理相对图片路径的各部分，将之拼装为目标格式
 * @param  {[type]} parsed {host,ext,name,version}
 * @return {String}        [description]
 */
function connector(parsed){
	var self = this,
		filelist = self.filelist,
		csspath = parsed.csspath,
		host = parsed.host,
		md5 = parsed.md5,
		ext = parsed.ext,
		name = parsed.name,
		version = parsed.version,
		ret;

	ret = "http://" + host+name+ext+"/"+md5+ext;

	return ret;
}




/**
 * @param {Object} opt
 * @param {String} opt.root css文件的根目录
 * @param {String} opt.host 绝对路径的host地址
 * @param {String} image_version 所有图片文件的结果集，参考DianPing. DP_StaticFileVersion
 */
function CssParser(opt) {
	this.root = opt.root;
	this.hosts = opt.hosts;
	this.connector = opt.connector || connector;
	this._logs = [];
}

CssParser.prototype = {
	log:function(){
		this._logs.forEach(function(lg){
			console.log(lg);
		});
		this._logs = [];
	},
	clearlog:function(){
		this._logs = [];
	},
	/**
	 * 分析path下的所有图片路径
{'fraction_non_alphanumeric': 0.17298578199052134, 'fraction_numerical': 0.004739336492890996, 'mean_word_length': 3.88996138996139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6166732', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1041, 'n_words': 182}