Exemple #1
0
 def note(self, string, keyString=None, printOption=False, maxLength=79):
     if keyString == None:
         keyString = 'notes'
     if printOption:
         print string
     for line in textwrap2.wrap(string, maxLength):
         self.post(keyString, line + ' ' * (maxLength - len(line)))
Exemple #2
0
 def note(self, string, keyString=None, printOption=False, maxLength=79):
     if keyString == None:
         keyString = 'notes'
     if printOption:
         print(string)
     for line in textwrap2.wrap(string, maxLength):
         self.post(keyString, line + ' ' * (maxLength - len(line)))
Exemple #3
0
def main():
    parser = argparse.ArgumentParser(
        description="Wrap text file to given width, with hyphenation"
    )
    parser.add_argument("-w", "--width", type=int, default=70, help="Maximum line width")
    parser.add_argument("-l", "--language", default="en_US", help="Text file locale")
    parser.add_argument("path", help="Text file path. Use '-' to read from standard input.")
    args = parser.parse_args()

    hyphenator = Hyphenator(args.language)
    if args.path == "-":
        for content in sys.stdin:
            for line in textwrap2.wrap(content, width=args.width, use_hyphenator=hyphenator):
                print(line)
    else:
        with open(args.path) as f:
            for line in textwrap2.wrap(f.read(), width=args.width, use_hyphenator=hyphenator):
                print(line)
Exemple #4
0
    def update_text(self):
        trans_name = self.translations_win.get_selection_tuple()[1]
        book_name = self.books_win.get_selection_tuple()[1]
        chapter_name = (self.chapters_win.get_selection_tuple()[1], )
        verse = self.verses_win.get_selection_tuple()[1]

        text_title = " {0} {1}:{3} [{2}]".format(book_name,
                                                 str(chapter_name[0]),
                                                 trans_name, verse)

        raw_text = self.reader.get_chapter_text(
            self.books_win.get_selection_tuple()[1],
            self.chapters_win.get_selection_tuple()[1],
            verse_start=verse,
        )
        text = "\n".join(
            wrap(
                raw_text,
                width=self.text_width - 3,
                use_hyphenator=h_en,
            )[0:curses.LINES - 2])

        self.text_win.update_text_title(text_title)
        self.text_win.update_text(text)