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


Python Cli.term_fx方法代码示例

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


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

示例1: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import term_fx [as 别名]
def main():
    """
    Reads in a specified file, removes trailing whitespace, and re-saves.
    """
    # Open file and store lines as str list
    try:
        file_handler = open(ARGS.filename, 'r+')
    except IOError:
        print(traceback.format_exc())  # pylint: disable=C0325
        sys.exit()

    lines_of_text = file_handler.readlines()
    file_handler.seek(0)

    # Preview and write text back to file and close file
    print(lines_of_text)  # pylint: disable=C0325
    Cli.wait()
    string = ''
    preview_string = ''
    for index, _ in enumerate(lines_of_text):
        string += lines_of_text[index].rstrip() + '\n'
        preview_string = string.strip() + Cli.term_fx('b', 'EOL')
    pydoc.pipepager(preview_string, cmd='less -R')
    try:
        char = Cli.get_keypress('Write to file?')
        assert char == 'y'
        file_handler.write(string)
    except AssertionError:
        print('File not saved.  Good bye.')  # pylint: disable=C0325
    finally:
        file_handler.close()
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:33,代码来源:trimline.py

示例2: main

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import term_fx [as 别名]
def main():
    """
    Prompt user for a string, then echo it back in bold.
    """
    Cli()
    # Input
    txt = SHELL.input(
        {'EN': 'Something to bolden: ', 'EO': 'Teksto por grasigi: '}[LANG])

    # Output
    if SHELL.interface in ['sh', 'bash', 'dialog', 'SL4A', 'zenity']:
        Cli.term_fx('bp', txt)
    elif SHELL.interface in ['Tk']:
        total_width = len(txt) * AVG_CHAR_WIDTH + 45

        SHELL.center_window(height_=90, width_=total_width, y_offset=100)
        SHELL.main_window.config(bg='white')
        SHELL.msg.config(
            bg='white', width=total_width, font=('serif', 36, 'bold', 'italic'))
        SHELL.msgtxt.set(txt)
        SHELL.main_window.title(txt)
        SHELL.main_window.mainloop()
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:24,代码来源:bold.py

示例3: __repr__

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import term_fx [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))
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:63,代码来源:igo.py

示例4: details

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import term_fx [as 别名]
 def details(self):
     string = '\n{}\n'.format(Cli.term_fx('un', self.label))
     string += '{}\n'.format(self.freq)
     string += self.halfsteps_info()
     return string
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:7,代码来源:music.py

示例5: __str__

# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import term_fx [as 别名]
 def __str__(self):
     s = '\n' + Cli.term_fx('b', self.label)
     s += Cli.term_fx('nu', 'header') + ": {}".format(pprint.pformat(self.header_dict))
     s += "\n\n"
     s += Cli.term_fx('nu', 'moves') + ": {}".format(self.moves)
     return s
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:8,代码来源:igo.py


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