当前位置: 首页>>代码示例>>Python>>正文


Python C.red方法代码示例

本文整理汇总了Python中fancy.ANSI.C.red方法的典型用法代码示例。如果您正苦于以下问题:Python C.red方法的具体用法?Python C.red怎么用?Python C.red使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fancy.ANSI.C的用法示例。


在下文中一共展示了C.red方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
	def __init__(self, idir, name2file):
		super(Sleigh, self).__init__('', idir)
		self.venues = []
		self.n2f = name2file
		jsons = {}
		skip4Now = []
		for d in glob.glob(idir+'/*.json'):
			if d.split('/')[-1].split('.')[0] in skip4Now:
				print(C.red('Skipping') + ' ' + C.purple(d) + ' ' + C.red('for now'))
				continue
			jsons[d.split('/')[-1].split('.')[0]] = d
		for d in glob.glob(idir+'/*'):
			cont = False
			for end in ('.md', '.json', '/frem', '/edif'):
				if d.endswith(end):
					cont = True
			if d.split('/')[-1] in skip4Now:
				print(C.red('Skipping') + ' ' + C.purple(d) + ' ' + C.red('for now'))
				cont = True
			if cont:
				continue
			if d.split('/')[-1] not in jsons.keys():
				print(C.red('Legacy non-top definition of'), d)
				self.venues.append(Venue(d, idir, name2file, self))
			else:
				self.venues.append(Venue(d, idir, name2file, self))
开发者ID:bibtex,项目名称:bibsleigh,代码行数:28,代码来源:AST.py

示例2: checkreport

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkreport(fn, o):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('FIXD'))
	r = checkon(fn, o)
	# non-verbose mode by default
	if verbose or r != 0:
		report(statuses[r], fn)
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:9,代码来源:refine-giveNames.py

示例3: checkreport

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkreport(fn, o):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('WARN'))
	r, msg = checkon(fn, o)
	# non-verbose mode by default
	if verbose or r != 0:
		print('[ {} ] {}: {}'.format(statuses[r], fn, msg))
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:9,代码来源:analyse-bibtex.py

示例4: checkreport

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkreport(m, o):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('FIXD'))
	r = checkon(m, o)
	# non-verbose mode by default
	if verbose or r != 0:
		print('[ {} ] {}'.format(statuses[r], o.filename))
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:9,代码来源:refine-liftProceedings.py

示例5: processSortedRel

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def processSortedRel(r):
	# [ {"x" : Y } ] where Y can be a string or a sorted rel
	global pcx
	acc = []
	for el in r:
		ename = list(el.keys())[0]
		evals = el[ename]
		if os.path.isfile(outputdir + '/stuff/' + ename.lower() + '.png'):
			img = '<img src="../stuff/{1}.png" alt="{0}" width="30px"/> '.format(ename, ename.lower())
		else:
			img = ''
		if isinstance(evals, str):
			plst = sorted(matchfromsleigh(sleigh, evals), key=sortbypages)
			pcx += len(plst)
			ptxt = '<dl class="toc">'+'\n'.join([p.getItem() for p in plst])+'</dl>'
		elif isinstance(evals, list) and isinstance(evals[0], str):
			plst = sorted(matchfromsleigh(sleigh, evals), key=sortbypages)
			pcx += len(plst)
			ptxt = '<dl class="toc">'+'\n'.join([p.getItem() for p in plst])+'</dl>'
		elif isinstance(evals, list) and isinstance(evals[0], dict):
			ptxt = processSortedRel(evals)
		else:
			print(C.red('ERROR:'), 'unrecornised bundle structure', evals)
		acc.append('<dl><dt>{}{}</dt><dd>{}</dl>'.format(img, ename, ptxt))
	return '\n'.join(acc)
开发者ID:bibtex,项目名称:bibsleigh,代码行数:27,代码来源:export-bundles.py

示例6: checkon

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkon(fn, o):
	if not os.path.exists(fn) or os.path.isdir(fn):
		fn = fn + '.json'
	if not os.path.exists(fn):
		# if it still does not exist, let us create a minimal one
		f = open(fn, 'w')
		f.write('{{\n\t"title": "{name}",\n\t"type": "proceedings",\n\t"year": {year}\n}}'.format(\
			name=fn.split('/')[-1][:-5].replace('-', ' '),
			year=findYear(fn.split('/')[-1])\
		))
		f.close()
		print('[ {} ] {}'.format(C.yellow('MADE'), fn))
		return 2
	f = open(fn, 'r')
	lines = f.readlines()[1:-1]
	f.close()
	for line in lines:
		if line.find('"year"') > -1 and findYear(line) > 3000:
			os.remove(fn)
			print('[ {} ] {}'.format(C.red('KILL'), fn))
			return 1
	flines = sorted([strictstrip(s) for s in lines])
	plines = sorted([strictstrip(s) for s in o.getJSON().split('\n')[1:-1]])
	if flines != plines:
		f1 = [line for line in flines if line not in plines]
		f2 = [line for line in plines if line not in flines]
		print('∆:', f1, '\nvs', f2)
	if flines == plines:
		return 0
	else:
		return 1
开发者ID:bibtex,项目名称:bibsleigh,代码行数:33,代码来源:refine-checkJson.py

示例7: report

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def report(fn, r):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('UNEX'))
	special = ('', '- no crossref found!', '- illegal crossref')
	# non-verbose mode by default
	if verbose or r != 0:
		print('[ {} ] {} {}'.format(statuses[r], fn, special[r]))
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:9,代码来源:refine-findTangled.py

示例8: parseJSON

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def parseJSON(fn):
	# print('Parsing',fn,'...')
	try:
		j = json.load(open(fn, 'r'))
		j['FILE'] = fn
		return j
	except ValueError:
		print(C.red('JSON parse error'), 'on', fn)
		return {}
开发者ID:bibtex,项目名称:bibsleigh,代码行数:11,代码来源:JSON.py

示例9: checkreport

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkreport(fn, o, br):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('FIXD'))
	if br:
		r = checkbrand(fn, br)
	else:
		r = checkon(fn, o)
	# non-verbose mode by default
	if verbose or r != 0:
		print('[ {} ] {}'.format(statuses[r], fn))
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:12,代码来源:refine-stem.py

示例10: checkreport

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkreport(fn, o):
	statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('FIXD'))
	if isinstance(o, int):
		r = o
	else:
		r = checkon(fn, o)
	# non-verbose mode by default
	if verbose or r != 0:
		print('[ {} ] {}'.format(statuses[r], fn))
	return r
开发者ID:bibtex,项目名称:bibsleigh,代码行数:12,代码来源:refine-sortJson.py

示例11: checkon

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkon(m, o):
	# if no common model found, we failed
	if not m:
		return 1
	if 'type' in m.keys() and m['type'] in ('inproceedings', 'article'):
		m['type'] = 'proceedings'
	if 'type' in m.keys() and m['type'] == 'incollection':
		m['type'] = 'book'
	if 'crossref' in m.keys():
		del m['crossref']
	if 'booktitle' in m.keys():
		m['title'] = m['booktitle']
		del m['booktitle']
	if 'booktitleshort' in m.keys():
		# TODO: ???
		del m['booktitleshort']
	r = 0
	n = {}
	for k in m.keys():
		if o.get(k) == m[k]:
			if verbose:
				print(C.blue('Confirmed:  '), k, 'as', m[k])
		else:
			if verbose:
				print(C.red('Conflicted: '), k, 'as', m[k], 'vs', o.get(k))
			v = heurichoose(k, m[k], o.json[k]) if k in o.json.keys() else m[k]
			if verbose:
				print(C.yellow('Settled for:'), v)
			n[k] = v
			r = 2
	if r == 0:
		return r
	if r == 2 and not n:
		# nothing to fix?!
		return 0
	if not os.path.exists(o.filename):
		return 0
	if os.path.isdir(o.filename):
		fn = o.filename + '.json'
	else:
		fn = o.filename
	if os.path.exists(fn):
		f = open(fn, 'r')
		lines = f.read()
		f.close()
		if lines != o.getJSON():
			# strange, should be equal (run all normalisers first!)
			return 1
	for k in n.keys():
		o.json[k] = n[k]
	f = open(fn, 'w')
	f.write(o.getJSON())
	f.close()
	return 2
开发者ID:bibtex,项目名称:bibsleigh,代码行数:56,代码来源:refine-liftProceedings.py

示例12: guessYear

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def guessYear(p):
	cys = [int(w) for w in p.split('-') if len(w) == 4 and w.isdigit()]
	if len(cys) == 1:
		return cys[0]
	else:
		j = sleigh.seekByKey(p)
		if 'year' in j.json.keys():
			return j.get('year')
		elif 'year' in dir(j):
			return j.year
		else:
			print('[ {} ] {}'.format(C.red('YEAR'), p))
			return 0
开发者ID:bibtex,项目名称:bibsleigh,代码行数:15,代码来源:refine-sortJson.py

示例13: sortbypages

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def sortbypages(z):
	if 'pages' not in z.json.keys():
		print(C.red('No pages at all in '+z.getKey()))
		return 0
	p1, _ = z.getPagesTuple()
	y = z.get('year')
	if isinstance(y, str):
		# non-correcting robustness
		return 0
	# a trick to have several volumes within one conference
	v = z.get('volume')
	if isinstance(v, int) or v.isdigit():
		y += int(v)
	return y + p1 / 10000. if p1 else y
开发者ID:bibtex,项目名称:bibsleigh,代码行数:16,代码来源:AST.py

示例14: dblpify

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def dblpify(s):
	# http://dblp.uni-trier.de/pers/hd/e/Elbaum:Sebastian_G=
	if s in dis.keys():
		return dis[s]
	if s.find(' ') < 0:
		print('[', C.red('NAME'), ']', 'Unconventional full name:', s)
		cx[1] += 1
		return dblpLatin(s)+':'
	ws = s.split(' ')
	i = -1
	if ws[i] in ('Jr', 'Jr.'):
		i -= 1
	sur = dblpLatin(' '.join(ws[i:]))
	rest = dblpLatin(' '.join(ws[:i])).replace(' ', '_')
	for c in ".'-":
		rest = rest.replace(c, '=')
	return sur+':'+rest
开发者ID:bibtex,项目名称:bibsleigh,代码行数:19,代码来源:refine-xmatch-people.py

示例15: checkon

# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import red [as 别名]
def checkon(fn, o):
	if not os.path.exists(fn) or os.path.isdir(fn):
		fn = fn + '.json'
	if 'title' not in o.json.keys():
		if verbose:
			print('No title in', o.getKey())
		return 1 # no title
	# check for a different language - to avoid stemming altogether
	if o.tags and ('german' in o.tags or 'french' in o.tags or 'portuguese' in o.tags):
		if 'stemmed' in o.json.keys():
			# if stemmed before marked foreign, remove this info
			del o.json['stemmed']
			F = open(fn, 'w')
			F.write(o.getJSON())
			F.close()
			return 2
		else:
			return 0
	changed = False
	### champion variant: snowballstemmer - runs in ~13.5s for 96027 titles
	stemmer = snowballstemmer.stemmer('english').stemWords
	### disregarded variant: snowballstemmer porter - considered outdated
	# stemmer = snowballstemmer.stemmer('porter').stemWords
	### disregarded variant: stemming - too slow, runs in ~33s for 96027 titles
	# stemmer = lambda xs: [stemming.porter2.stem(x) for x in xs]
	### disregarded variant: nltk - worse on verbs ending with -ze
	# stemmer3 = lambda xs: [SnowballStemmer("english").stem(x) for x in xs]
	### end variants
	stemmed = stemmer(string2words(o.get('title')))
	if '' in stemmed:
		print('“{}” is a title of {} and it has an empty word'.format(o.get('title'), C.red(o.getKey())))
		print(string2words(o.get('title')))
		print(stemmer(string2words(o.get('title'))))
	ALLSTEMS.update(stemmed)
	if o.get('stemmed') != stemmed:
		o.json['stemmed'] = stemmed
		changed = True
	if changed:
		F = open(fn, 'w')
		F.write(o.getJSON())
		F.close()
		return 2
	else:
		return 0
开发者ID:bibtex,项目名称:bibsleigh,代码行数:46,代码来源:refine-stem.py


注:本文中的fancy.ANSI.C.red方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。