本文整理汇总了Python中fancy.ANSI.C.blue方法的典型用法代码示例。如果您正苦于以下问题:Python C.blue方法的具体用法?Python C.blue怎么用?Python C.blue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fancy.ANSI.C
的用法示例。
在下文中一共展示了C.blue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkreport
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例2: checkreport
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例3: checkreport
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例4: report
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例5: checkreport
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例6: checkreport
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例7: checkon
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [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
示例8: report
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
def report(one, two):
print('[ {} ] {}'.format(one, two))
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
if __name__ == "__main__":
if len(sys.argv) > 1:
verbose = sys.argv[1] == '-v'
print('{}: {} venues, {} papers\n{}'.format(\
C.purple('BibSLEIGH'),
C.red(len(sleigh.venues)),
C.red(sleigh.numOfPapers()),
C.purple('='*42)))
cx = {0: 0, 1: 0, 2: 0}
for v in sleigh.venues:
for c in v.getConfs():
cx[checkreport(c.filename, c)] += 1
for p in c.papers:
cx[checkreport(p.filename, p)] += 1
print('{} files checked, {} ok, {} fixed, {} failed'.format(\
C.bold(cx[0] + cx[1] + cx[2]),
C.blue(cx[0]),
C.yellow(cx[2]),
C.red(cx[1])))
示例9: chr
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
paperAuths = paperAuths[:-1]
paperAuths.extend(auths)
paperLnk = li.get('id')
hope = li.find_all('a')
if hope and hope[0].get('href').endswith('.pdf'):
paperPdf = urlstart + hope[0].get('href')
else:
paperPdf = ''
paperEntry = {'type': 'inproceedings', 'series': 'CEUR Workshop Proceedings',\
'publisher': 'CEUR-WS.org', 'year': volYear, 'booktitle': volTitles[-1],\
'editor': volEds, 'volume': volNr.split('-')[-1], 'title': paperTitle,\
'author': paperAuths, 'pages': paperPages, 'venue': volVenue}
if paperPdf:
paperEntry['openpdf'] = paperPdf
if paperLnk:
paperEntry['url'] = urlstart + '#' + paperLnk
paperFilename = outputdir.split('/')[-1] + '-' + paperAuths[0].split(' ')[-1]
for a in paperAuths[1:]:
paperFilename += a.split(' ')[-1][0]
if paperFilename in done:
paperFilename += 'a'
while paperFilename in done:
paperFilename = paperFilename[:-1] + chr(ord(paperFilename[-1])+1)
# print(jsonify(paperEntry), '-->', outputdir+'/'+paperFilename+'.json')
f = open(outputdir+'/'+paperFilename+'.json', 'w')
f.write(jsonify(paperEntry))
f.close()
cx += 1
done.append(paperFilename)
print(C.red(volVenue), '-', C.yellow(volTitles[-1]), '-', C.blue(cx), 'papers.')
示例10: report
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
def report(fn1, fn2, r):
statuses = (C.blue(' PASS '), C.red(' FAIL '), C.yellow('RENAME'))
# non-verbose mode by default
if verbose or r != 0:
print('[ {} ] {} → {}'.format(statuses[r], fn1, fn2))
return r
示例11: checkon
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
def checkon(fn, o):
if 'dblpkey' not in o.json.keys():
print('[ {} ] {}'.format(C.red('DONT'), 'DBLP key not found on the entry'))
return 1
mykey = o.get('dblpkey')
# for the rare case of multiple dblpkeys
# (can happen as a DBLP error or when same proceedings span over multiple volumes)
if isinstance(mykey, list):
mykey = mykey[0]
if mykey not in procs.keys():
print('[ {} ] {}'.format(C.red('DONT'), 'DBLP key not found in the dump'))
return 1
title = procs[mykey]
if title.endswith('.'):
title = title[:-1]
ws = title.replace(' - ', ', ').replace(' (', ', ').split(', ')
country = findOneIn(knownCountries, ws)
state = findOneIn(usaStateNames, ws)
found = False
if country:
town = ws[ws.index(country)-1]
state = '?'
# what if "town" is an USA state? (full)
if country == 'USA' and town in usaStateNames:
state = town
town = ws[ws.index(town)-1]
# what if "town" is an USA state? (abbreviated)
if country == 'USA' and town in usaStateAB:
state = usaStateNames[usaStateAB.index(town)]
town = ws[ws.index(town)-1]
# what if "town" is a Canadian state? (full)
if country == 'Canada' and town in canStateNames:
state = town
town = ws[ws.index(town)-1]
# what if "town" is a Canadian state? (abbreviated)
if country == 'Canada' and town in canStateAB:
state = canStateNames[canStateAB.index(town)]
town = ws[ws.index(town)-1]
# the same can happen in the UK
if country in ('UK', 'United Kingdom') and town in ('Scotland', 'Scottland'):
state = town
town = ws[ws.index(town)-1]
# Georgia the country vs Georgia the state
if country == 'Georgia' and town == 'Atlanta':
state = country
country = 'USA'
# near Something
if town.startswith('near '):
town = ws[ws.index(town)-1]
# Luxembourg, Luxembourg
if country == 'Luxembourg':
town = 'Luxembourg'
# Saint-Malo / St. Malo
if country == 'France' and town == 'St. Malo':
town = 'Saint-Malo'
# Florence / Firenze
if country == 'Italy' and town.find('Firenze') > -1:
town = 'Florence'
found = True
elif state:
country = 'USA'
town = ws[ws.index(state)-1]
found = True
else:
# desperate times
for sol in desperateSolutions.keys():
if sol in ws:
town, state, country = desperateSolutions[sol]
found = True
# normalise
if country in countryMap.keys():
country = countryMap[country]
if country == 'United Kingdom' and state == '?':
if town.endswith('London') or town in ('Birmingham', 'York',\
'Coventry', 'Nottingham', 'Lancaster', 'Oxford', 'Manchester',\
'Southampton', 'Norwich', 'Leicester', 'Canterbury'):
state = 'England'
elif town in ('Edinburgh', 'Glasgow'):
state = 'Scotland'
# report
if 'address' in o.json.keys():
print('[ {} ] {}'.format(C.blue('OLDA'), o.get('address')))
if 'location' in o.json.keys():
print('[ {} ] {}'.format(C.blue('OLDL'), o.get('location')))
if found:
# print('[ {} ] {}'.format(C.blue('KNOW'), country))
print('[ {} ] {}'.format(C.blue('AD||'), title))
print('[ {} ] {:30} || {:30} || {:20}'.format(C.blue('AD->'), C.yellow(town), C.yellow(state), C.yellow(country)))
# TODO: perhaps later we can act more aggressively
newaddr = [town, '' if state=='?' else state, country]
if 'address' not in o.json.keys() or newaddr != o.json['address']:
o.json['address'] = newaddr
f = open(o.json['FILE'], 'w')
f.write(o.getJSON())
f.close()
return 2
# nothing changed
return 0
print('[ {} ] {}'.format(C.yellow('AD??'), title))
return 1
示例12: dblpLatin
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
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
if __name__ == "__main__":
verbose = sys.argv[-1] == '-v'
if not os.path.exists('_renameto.json'):
print('Run', C.blue('refine-aliases.py'), 'to build the aliasing/renaming relation and cache it.')
sys.exit(1)
# aka = parseJSON(ienputdir + '/aliases.json')
dis = parseJSON(ienputdir + '/disambig.json')
renameto = parseJSON('_renameto.json')
# Data from the conferenceMetrics repo
csv = []
f = open('../conferenceMetrics/data/SE-conf-roles.csv', 'r')
for line in f.readlines():
# Conference;Year;First Name;Last Name;Sex;Role
csv.append(line.strip().split(';'))
f.close()
f = open('scrap-committees/scraped-by-grammarware.csv', 'r')
for line in f.readlines():
csv.append(line.strip().split(';'))
f.close()
示例13: report
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
def report(s, r):
statuses = (C.blue('PASS'), C.red('FAIL'), C.yellow('FIXD'))
# non-verbose mode by default
if verbose or r != 0:
print('[ {} ] {}'.format(statuses[r], s))
return r
示例14: print
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
return r
if __name__ == "__main__":
verbose = sys.argv[-1] == '-v'
print('{}: {} venues, {} papers\n{}'.format(\
C.purple('BibSLEIGH'),
C.red(len(sleigh.venues)),
C.red(sleigh.numOfPapers()),
C.purple('='*42)))
aka = parseJSON(ienputdir + '/aliases.json')
CX = sum([len(aka[a]) for a in aka])
# self-adaptation heuristic:
# if a manual rule does the same as the other heuristic, it’s dumb
for a in sorted(aka.keys()):
if len(aka[a]) == 1 and aka[a][0] in (nodiaLatin(a), simpleLatin(a)):
print('[ {} ]'.format(C.blue('DUMB')), a, 'aliasing was unnecessary manual work')
elif len(aka[a]) == 2 and (aka[a] == [nodiaLatin(a), simpleLatin(a)] \
or aka[a] == [simpleLatin(a), nodiaLatin(a)]):
print('[ {} ]'.format(C.blue('DUMB')), a, 'aliasing was a lot of unnecessary manual work')
elif nodiaLatin(a) in aka[a] or simpleLatin(a) in aka[a]:
print('[ {} ]'.format(C.blue('DUMB')), a, 'aliasing contains some unnecessary manual work')
# auto-aliasing heuristic:
# for each author with diacritics, its non-diacritic twin is considered harmful
people = set()
for v in sleigh.venues:
for c in v.getConfs():
if 'editor' in c.json:
people.update(listify(c.json['editor']))
for p in c.papers:
if 'author' in p.json:
people.update(listify(p.json['author']))
示例15: open
# 需要导入模块: from fancy.ANSI import C [as 别名]
# 或者: from fancy.ANSI.C import blue [as 别名]
C.purple('='*42)))
bundles = {}
for b in glob.glob(ienputdir + '/bundles/*.json'):
purename = b.split('/')[-1][:-5]
bun = json.load(open(b, 'r'))
prevcx = pcx
uberlist = '<h2>{1} papers</h2>{0}'.format(processSortedRel(bun['contents']), pcx-prevcx)
f = open(outputdir + '/bundle/' + purename + '.html', 'w')
f.write(bunHTML.format(\
title=purename+' bundle',
bundle=bun['name'],
ebundle=escape(purename),
dl=uberlist.replace('href="', 'href="../').replace('../mailto', 'mailto')))
f.close()
bundles[purename] = pcx-prevcx
print('Bundle pages:', C.yellow('{}'.format(len(bundles))), C.blue('generated'))
# now for the index
f = open(outputdir+'/bundle/index.html', 'w')
lst = ['<li><a href="{}.html">{}</a> ({})</li>'.format(\
escape(b),
b,
bundles[b]) for b in sorted(bundles.keys())]
ul = '<ul class="tri">' + '\n'.join(lst) + '</ul>'
f.write(bunListHTML.format(\
title='All specified bundles',
listname='{} bundles known with {} papers'.format(len(bundles), sum(bundles.values())),
ul='<ul class="tri">' + '\n'.join(lst) + '</ul>'))
f.close()
print('Bundle index:', C.blue('created'))
print('{}\nDone with {} venues, {} papers.'.format(\
C.purple('='*42),