本文整理汇总了Python中pyfiglet.Figlet类的典型用法代码示例。如果您正苦于以下问题:Python Figlet类的具体用法?Python Figlet怎么用?Python Figlet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Figlet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_text_font
def set_text_font(text, font):
try:
figlet = Figlet(font=font)
except:
print('weefig: no such font: %s' % (font))
return ""
return figlet.renderText(text)
示例2: header
def header():
subprocess.call(['clear'])
f = Figlet(font='slant')
print('')
print(colored(f.renderText(COMMAND_KEYWORD), 'red', attrs=['bold']))
print('')
print('')
示例3: logo
def logo(version):
"""Print gprMax logo, version, and licencing/copyright information.
Args:
version (str): Version number.
"""
licenseinfo = """
Copyright (C) 2015: The University of Edinburgh
Authors: Craig Warren and Antonis Giannopoulos
gprMax is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gprMax is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gprMax. If not, see <http://www.gnu.org/licenses/>."""
width = 65
url = 'www.gprmax.com'
print('\n{} {} {}'.format('*'*round((width - len(url))/2), url, '*'*round((width - len(url))/2)))
gprMaxlogo = Figlet(font='standard', width=width, justify='center')
print('{}'.format(gprMaxlogo.renderText('gprMax')))
print('{} v{} {}'.format('*'*round((width - len(version))/2), (version), '*'*round((width - len(version))/2)))
print(licenseinfo)
print('\n{}\n'.format('*'*(width+3)))
示例4: inputAndTransform
def inputAndTransform():
dirPath = os.curdir
write = input("What do you want to write? Please input here:\n")
f = Figlet(font='ogre') # 斜体 不slant是默认的字体 是不倾斜的
textWrite = "```\n"+f.renderText(write)+"\n```"
with open("codepic.txt", "w") as f:
f.writelines(textWrite)
示例5: printTitle
def printTitle():
# 腳本頭部
script_name = "NGINX vhost tools"
f = Figlet()
print f.renderText(script_name)
print "Author: JackLam([email protected])"
print ("-"*80)[:80]
示例6: on_cmd
def on_cmd(self, serv, ev, command, args, helper):
u'''%(namespace)s <text> : écrit le texte donné en figlet. Ne gère que
les caractères ASCII.'''
f = Figlet()
args.insert(0, command)
message = ' '.join(args)
figlet_msg = {}
figlet_width = 0
for c in message:
figlet_c = f.renderText(c).split('\n')
added_width = max(len(fc) for fc in figlet_c)
# adding this character will make a too long line
if figlet_width + added_width > self.width:
# flush figlet message
self.privfigletmsg(serv, helper['target'], figlet_msg)
figlet_msg = {}
figlet_width = 0
# adding the character
l = 0
for fc in figlet_c:
figlet_msg[l] = figlet_msg.get(l, '') + fc
l += 1
figlet_width += added_width
# flush figlet message
self.privfigletmsg(serv, helper['target'], figlet_msg)
示例7: figlet_header
def figlet_header(text, font='colossal', smushMode=None):
"""
Prints text with ascii print driver.
See available fonts with Figlet().getFonts()
or pyfiglet.FigletFont.getFonts()
Easy-to-read fonts include:
* Doh (very big)
* Banner3 (Exclusively using '#')
* Block (rather subtil)
* Colossal (Easy to read, but set smushMode to 64 or lower for headers)
* Georgia11 (Very elegant)
* Roman
* Univers
"""
if Figlet is None:
logger.warning("pyfiglet module not available.")
return
## TODO: Add labfluence settings option to change font, etc.
f = Figlet(font=font)
if smushMode is not None:
# pyfiglet default smushMode is calculated by pyfiglet.FigletFont.loadFont()
# For some, e.g. colossal, the resulting smushMode of 128 smushes the characters a bit too much.
# I've made a fork of pyfiglet where you can adjust smushMode directly
# when instantiating a Figlet via argument fontkwargs.
f.Font.smushMode = smushMode
return f.renderText(text)
示例8: crypto_2
def crypto_2():
f = Figlet(font='slant')
print(f.renderText("Compression Session"))
wrap_input("""Crypto 2 - Compression Session""")
wrap_input("""NOTE: you may have to adjust the HOST and PORT in the script
that is about to be run if you are not using the default.""")
wrap_shell_command(["./crypto_02.py"])
示例9: crypto_1
def crypto_1():
f = Figlet(font='slant')
print(f.renderText("Standard Galactic Alphabet"))
wrap_input("""Crypto 1 - Standard Galactic Alphabet""")
wrap_input("""NOTE: you may have to adjust the HOST and PORT in the script
that is about to be run if you are not using the default.""")
wrap_shell_command(["./crypto_01.py", "cat *"])
示例10: ascii_title
def ascii_title():
with term.location(0, 0):
title_text = "Last Layer Algorithm Trainer"
f = Figlet(font="small", width=term.width)
print(term.white(f.renderText(title_text)))
with term.location(0, 5):
print("─" * term.width)
print(term.move_y(6))
示例11: lunch_text
def lunch_text():
_version = pkg_resources.require("lunch")[0].version
f = Figlet(font='smkeyboard')
print f.renderText('LUNCH')
print 'Lunch doesn\'t really do much of anything.'
print 'Version ' + _version
print 'Run lunch --help for a lacking list of arguments.'
示例12: textApi
def textApi(text=None):
user_requested_font = request.args.get('font')
font = getFont(user_requested_font)
text = text or "Send us text!"
fig = Figlet(font=font)
ansi = fig.renderText(text)
return format_request(ansi)
示例13: time_now
def time_now():
'''
Return current time in Figlet format.
'''
time_heading = '===============Time===============\n'
now = datetime.datetime.now().strftime("%H:%M")
f = Figlet(font='doom')
time_details = f.renderText(now).rstrip() + '\n'
return (time_heading + time_details).decode('utf-8')
示例14: startupMessage
def startupMessage(self):
'''
Spiffy looking startup banner.'
'''
figlet = Figlet(font='slant')
for line in figlet.renderText('sevcol IO\ngateway').splitlines():
self.log.info(line)
self.log.info('Version %s' % VERSION)
示例15: main
def main():
parser = OptionParser(version=__version__)
parser.add_option('-s', '--show', action='store_true', default=False,
help='pause at each failure and compare output '
'(default: %default)')
opts, args = parser.parse_args()
f = Figlet()
ok = 0
fail = 0
failed = []
skip = ['runic'] # known bug..
for font in f.getFonts():
if font in skip: continue
f.setFont(font=font)
outputPyfiglet = f.renderText('foo')
fontpath = os.path.join('pyfiglet', 'fonts', font)
if os.path.isfile(fontpath + '.flf'):
cmd = ('figlet', '-d', 'pyfiglet/fonts', '-f', font, 'foo')
elif os.path.isfile(fontpath + '.tlf'):
cmd = ('toilet', '-d', 'pyfiglet/fonts', '-f', font, 'foo')
else:
raise Exception('Missing font file: '+fontpath)
p = Popen(cmd, bufsize=1,stdout=PIPE)
outputFiglet = p.communicate()[0].decode('ascii', 'replace')
if outputPyfiglet == outputFiglet:
print('[OK] %s' % font)
ok += 1
continue
print('[FAIL] %s' % font)
fail += 1
failed.append(font)
if opts.show is True:
print('[PYTHON] *** %s\n\n' % font)
dump(outputPyfiglet)
print('[FIGLET] *** %s\n\n' % font)
dump(outputFiglet)
raw_input()
print('OK = %d, FAIL = %d' % (ok, fail))
if len(failed) > 0:
print('FAILED = %s' % repr(failed))
return 0