本文整理汇总了Python中cjh.cli.Cli.hrule方法的典型用法代码示例。如果您正苦于以下问题:Python Cli.hrule方法的具体用法?Python Cli.hrule怎么用?Python Cli.hrule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cjh.cli.Cli
的用法示例。
在下文中一共展示了Cli.hrule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import hrule [as 别名]
def main():
"""
user can create a collection of Thing objects
"""
things = []
label_pile = [str(thing) for thing in things]
enum = Enumeration(label_pile, 'Inventory')
# Start Screen
SHELL.welcome(
'Things',
'This is a test/demonstration of my cjh.shell module and Thing class.')
print('') # pylint: disable=C0325
selection = SHELL.list_menu(MAIN_MENU)
while True:
if selection == 1:
name = form(
enum, selection, lambda: SHELL.input('\nName of thing: '))
something = Thing()
something.label = name
things.append(something)
elif selection == 2:
form(enum, selection, Cli.wait)
elif selection == 3:
discard_menu = ListPrompt(label_pile)
if len(things) > 0:
print('Choose a <Thing> to Discard.') # pylint: disable=C0325
discard = form(
enum, selection, lambda: discard_menu.input(hidden=True))
things.remove(things[discard - 1])
elif selection == 4:
print('\n') # pylint: disable=C0325
sys.exit('Good bye.')
label_pile = [str(thing) for thing in things]
enum = Enumeration(label_pile, 'Inventory')
selection = Cli.make_page(
header='Main Menu', obj=str(enum) + Cli.hrule(
width=.333, string=True),
func=lambda: SHELL.list_menu(MAIN_MENU))
示例2: int
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import hrule [as 别名]
else: ARGS = None
# If ARGS.width is an integer, convert it to be of type int.
# An int for this value means width in columns.
# A decimal < 1 means a percentage of the width of the terminal.
if ARGS is not None and ARGS.width is not None and\
(ARGS.width == int(ARGS.width)):
ARGS.width = int(ARGS.width)
# possible to this automatically?
def populate_args():
"""
Convert args namespace to a dictionary, for use in the Cli.hrule()
method.
"""
kw_dict = {}
if ARGS is not None:
if ARGS.width is not None:
kw_dict.update({'width': ARGS.width})
if ARGS.pattern is not None:
kw_dict.update({'symbols': ARGS.pattern})
if ARGS.center is True:
kw_dict.update({'centered': ARGS.center})
return kw_dict
# print arg_dic
ARG_DICT = populate_args()
if __name__ == '__main__':
Cli.hrule(**ARG_DICT)
示例3: __repr__
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import hrule [as 别名]
def __repr__(self):
string = ''
try:
if self.header_dict['GM'] == '1':
string += 'Game: Go\n'
elif self.header_dict['GM'] == '2':
string += 'Game: Reversi\n'
except:pass
try:
string += "Size: {} x {}\n".format(self.header_dict['SZ'])
except:pass
try:
string += "{} vs. {}\n".format(self.header_dict['PW'], self.header_dict['PB'])
except:pass
try:
string += "Komi: {}\n".format(self.header_dict['KM'])
except: pass
try:
for game, index in enumerate(self.game_list):
self.game_list[index].header = str(game[1]) + "\n"
except: # type?
pass
### This block doesn't work ###
bullet_items = []
try:
bullet_items.append("SGF generated by {}.".format(self.header['AP']))
except:pass
if 'DT' in self.header:
bullet_items.append(self.header['DT'])
#if "GM" in self.header:
# game = ''
# if self.header['GM'] == '1':
# game = 'go'
# else: game = 'unknown'
# s += ["The game is {}.".format(game)]
if 'RU' in self.header:
bullet_items += ["{} rules.".format(self.header['RU'])]
if 'SZ' in self.header:
bullet_items += ["The board size is {0} × {0}.".format(self.header['SZ'])]
if 'KM' in self.header:
bullet_items += ["Komi is {}.".format(self.header['KM'])]
if 'PB' in self.header:
bullet_items += ["Black Player: {}".format(self.header['PB'])]
if 'PW' in self.header:
bullet_items += ["White Player: {}".format(self.header['PW'])]
self.bullets = ItemList(bullet_items)
###############################
moves_enum = Enumeration(self.moves)
return ('\n' + Cli.term_fx('u', self.label.title()) + #self.ul_label() +
string + #'\n\nself.bullets: ' + str(self.bullets) +
'\nmoves_enum: ' + str(moves_enum) +
'\n' + Cli.hrule(string=True, width=40))