<commit_before>#/usr/bin/python
#encoding=utf-8

from .BinaryRule import *

mapping = {
	'ie' : ALLIE,
	'webkit' : WEBKIT,
	'ie6' : IE6 | STD,
	'ie7' : IE7 | STD,
	'ie8' : IE8 | STD,
	'ie9' : IE9PLUS | STD,
	'ie9plus' : IE9PLUS | STD,
	'ie10': IE9PLUS | STD,
	'chrome' : CHROME | STD,
	'firefox' : FIREFOX | STD,
	'opera' : OPERA | STD,
	'safari' : SAFARI | STD,
	'std' : STD | NONEIE
}

def analyse(text):
	if not text or text == '' or text=='none' or text == 'false':
		return None

	text = text.lower()
	splited = text.split(',')
	browsers = {}

	for browser in splited:
		if mapping.has_key(browser):
			# 不管如何选择，STD的总是要显示的
			browsers[browser] = mapping[browser] | STD
	return browsers

if __name__ == '__main__':
	print(analyse('ie6,std'))<commit_msg>--browsers=all<commit_after>#/usr/bin/python
#encoding=utf-8

from .BinaryRule import *

mapping = {
	'ie' : ALLIE,
	'webkit' : WEBKIT,
	'ie6' : IE6 | STD,
	'ie7' : IE7 | STD,
	'ie8' : IE8 | STD,
	'ie9' : IE9PLUS | STD,
	'ie9plus' : IE9PLUS | STD,
	'ie10': IE9PLUS | STD,
	'chrome' : CHROME | STD,
	'firefox' : FIREFOX | STD,
	'opera' : OPERA | STD,
	'safari' : SAFARI | STD,
	'std' : STD | NONEIE
}

allBrowsers = ','.join([x for x in mapping.keys() if x != 'webkit' and x != 'ie9plus'])

def analyse(text):
	if not text or text == '' or text=='none' or text == 'false':
		return None
	if text == 'all':
		text = allBrowsers
	text = text.lower()
	splited = text.split(',')
	browsers = {}

	for browser in splited:
		if mapping.has_key(browser):
			# 不管如何选择，STD的总是要显示的
			browsers[browser] = mapping[browser] | STD
	return browsers

if __name__ == '__main__':
	print(analyse('ie6,std'))
{'fraction_non_alphanumeric': 0.1783323189287888, 'fraction_numerical': 0.018867924528301886, 'mean_word_length': 3.7241379310344827, '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': '214706', 'n_tokens_mistral': 787, 'n_tokens_neox': 757, 'n_words': 172}