本文整理汇总了Python中cjh.cli.Cli.width方法的典型用法代码示例。如果您正苦于以下问题:Python Cli.width方法的具体用法?Python Cli.width怎么用?Python Cli.width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cjh.cli.Cli
的用法示例。
在下文中一共展示了Cli.width方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import width [as 别名]
def main():
"""
Produce output and print to pager.
"""
dummy = TextGen()
print('') # pylint: disable=C0325
text_str = ''
for _ in range(PARAS):
pgraph = Paragraph(dummy.chunk(), int(Cli.width() * 0.6), True)
pgraph.set_lmargin(Cli.width() // 5)
text_str += str(pgraph)
if PAGER is True:
Cli.less(text_str)
else:
print(text_str) # pylint: disable=C0325
示例2: make_title
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import width [as 别名]
def make_title(self):
"""
Print a nice title page.
"""
if self.title:
s = ''
s += ('\n' * (Cli.height() / 2 - 2))
s += (('__' + self.title + '__').replace(' ', '_').center(
Cli.width()))
if self.author:
s += '\n\n' + 'by'.center(
Cli.width()) + '\n\n' + self.author.center(Cli.width())
s += ('\n' * (Cli.height() / 2 - 2))
s += ('-' * Cli.width())
if self.section_no == 0:
s += ('\n' * 4)
return s
else: return '[No title]'
示例3: _initialize_fields
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import width [as 别名]
def _initialize_fields():
self.margin = margin
self.width = Cli.width() - margin * 2
self.tabpoints = margin, self.width
self.author = None
self.title = None
self.date = ''
self.buffer = ''
self.lines = []
self.pgraph_no = 0
self.section_no = 0
self.p_list = []
self.s_list = []
示例4: scan_lines
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import width [as 别名]
def scan_lines(self):
"""
Scan each line in 'lines'
"""
#print "begin scan_lines()"
for line in self.lines:
#print 'begin loop: "{}"'.format(line)
#if line not empty
if line != '' and line != '\n':
#get title
if line.find('\\title') >= 0:
self.title = line[(line.find('{') + 1):(line.find('}'))]
elif line.find('\\author') >= 0:
self.author = line[(line.find('{') + 1):(line.find('}'))]
# If '\section' tag is detected, create a new section and add an
#entry to the table of contents.
elif line.find(r'\section') >= 0:
self.parse_section_tag(line)
elif line.find(r'\hrule') >= 0:
self.buffer = '-' * Cli.width()
self.store_paragraph(True)
# If the current line is not empty, append it to the buffer.
else:
if len(self.s_list) == 0 and len(line) != 0:
Section.count = -1
self.open_new_section() # Introduction")
#print "section=0"
self.buffer += (line + ' ')
# If it's a blank line, we store the Paragraph and prepare to read in
#a new one.
# strip_unknown_tags()
else: self.store_paragraph(False)
示例5: print_toc
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import width [as 别名]
def print_toc(self):
"""
Create a table of contents and print to the screen.
"""
s = ""
any_visible = False
for x in range(len(self.s_list)):
if self.s_list[x].heading[0].isdigit()\
and self.s_list[x].heading[0] != '0':
any_visible = True
if any_visible == True:
s += ''
s += "CONTENTS".center(Cli.width())
s += ''
for section in self.s_list:
if section.heading[0].isdigit() and section.heading[0] != '0':
s += section.heading.center(Cli.width())
s += '\n'
s += ((('-' * (Cli.width() / 2)).center(Cli.width()) + '\n') * 1)
s += ('\n')
s += ((('-' * (Cli.width() / 2)).center(Cli.width()) + '\n') * 1)
s += ('\n')
return s