コード例 #1
0
ファイル: asciioutput.py プロジェクト: jmtoball/StudICLI
	def __init__(self, width=80):
		""" Sets up the class and configures the utilized Textwrapper-object"""
		self.width = width
		wrapper = TextWrapper()
		wrapper.width = width	
		wrapper.replace_whitespace = False	
		wrapper.drop_whitespace = False	
		self.wrapper = wrapper
コード例 #2
0
def linewrap(width = None):
    """Returns a function that wraps long lines to a max of 251 characters.
	Note that this function returns a list of lines, which is suitable as the
	argument for the spss.Submit function.
    """
    wrapper = TextWrapper()
    wrapper.width = width or 251
    wrapper.replace_whitespace = True
    wrapper.break_long_words = False
    wrapper.break_on_hyphens = False
    return wrapper.wrap
コード例 #3
0
ファイル: html_reader.py プロジェクト: ramil350/pm_reader
    def get_text(self):
        text = ''.join(self.data)
        text = text.replace('  ', ' ')
        text = text.splitlines()

        wrapper = TextWrapper()
        wrapper.replace_whitespace = False
        wrapper.width = int(self.config.get('FormatOptions', 'line_width'))
        wrapped_text = ''

        for line in text:
            wrapped_text += wrapper.fill(line) + self.LINE_SEPARATOR

        return wrapped_text
コード例 #4
0
def draw_body(card, raw_text, center_y, card_width, chars_per_line):
	text = raw_text.decode('utf-8')
	wrapper = TextWrapper()
	wrapper.width = chars_per_line
	wrapper.replace_whitespace = True
	wrapper.drop_whitespace = False
	lines = wrapper.wrap(text)
	line_width, line_height = body_font.getsize(lines[0])
	y = center_y - (line_height * (float(len(lines)) / 2.0))
	for line in lines:
		line_width, line_height = body_font.getsize(line)
		draw = ImageDraw.Draw(card)
		draw.text(((card_width - line_width) / 2, y), line, font = body_font, fill = (0, 0, 0))
		y += line_height
コード例 #5
0
ファイル: Formatting.py プロジェクト: spattersongt/vippy
def wordWrap(lines, rows, cols):
    """ Format an array of text to a specific number of 
        visible rows and columns """
    wrapped = []

    # Set up a TextWrapper
    wrapper = TextWrapper()
    wrapper.width = cols
    wrapper.expand_tabs = False
    wrapper.replace_whitespace = False
    wrapper.drop_whitespace = False

    for line in lines:
        if len(line) > cols:
            wrapped.extend(wrapper.wrap(line))
        else:
            wrapped.append(line)

        if len(wrapped) >= rows:
            break

    # Return only "rows" in case a word wrap added extra
    return wrapped[:rows]
コード例 #6
0
ファイル: tzprotocol.py プロジェクト: cryptixman/tzmud
# (at your option) any later version.
#
# TZMud 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 TZMud.  If not, see <http://www.gnu.org/licenses/>.


'''The Twisted protocol.'''

from textwrap import TextWrapper
wrapper = TextWrapper()
wrapper.replace_whitespace = False
wrapper.subsequent_indent = '    '
wrap = wrapper.wrap

import re
class Wrapper(TextWrapper):
    def _wrap_chunks(self, chunks):
        lines = []
        if self.width <= 0:
            raise ValueError("invalid width %r (must be > 0)" % self.width)
        chunks.reverse()
        while chunks:
            cur_line = []
            cur_len = 0
            if lines:
                indent = self.subsequent_indent
コード例 #7
0
ファイル: example.py プロジェクト: Charley-fan/metaArray
from misc import filePath, dirPath

# Enviromental variables
demo_dir = join(filePath(__file__).baseDir, 'example')
tty_width = 72
partition = '-' * tty_width
prompt = '>>> '

# Current dir
# current_dir = dirPath('./')


wrapper = TextWrapper()
wrapper.width = tty_width
wrapper.replace_whitespace = False
# wrapper.drop_whitespace = False
wrapper.initial_indent = "- "
wrapper.subsequent_indent = '- '

comment_wrapper = TextWrapper()
comment_wrapper.replace_whitespace = False
# comment_wrapper.drop_whitespace = False
comment_wrapper.width = tty_width
comment_wrapper.subsequent_indent = '# '

class demo_menu:
    """
    Menu object
    
    Contains a list of menu options, as well as the parent menu if exist.
コード例 #8
0
from metaArray.misc import filePath

# Enviromental variables
demo_dir = join(filePath(__file__).baseDir, 'example')
tty_width = 72
partition = '-' * tty_width
prompt = '>>> '

# Current dir
# current_dir = dirPath('./')


wrapper = TextWrapper()
wrapper.width = tty_width
wrapper.replace_whitespace = False
# wrapper.drop_whitespace = False
wrapper.initial_indent = "- "
wrapper.subsequent_indent = '- '

comment_wrapper = TextWrapper()
comment_wrapper.replace_whitespace = False
# comment_wrapper.drop_whitespace = False
comment_wrapper.width = tty_width
comment_wrapper.subsequent_indent = '# '

class demo_menu(object):
    """
    Menu object

    Contains a list of menu options, as well as the parent menu if exist.