From d5805df8e7ca29474d31892edb2fc7cf2d98f65d Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 21 May 2019 12:27:15 +0200 Subject: [PATCH] Remove test.py --- test.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index 4e03b67..0000000 --- a/test.py +++ /dev/null @@ -1,36 +0,0 @@ -import textwrap - - -def limit_text(text, character_limit): - """ - This function checks if a string is below 1000000 (1 Million characters). - If it is below that limmit the text will be processed. If it is above the - limit, the text will be splitted into parts below 1 million characters. - Parts will be as long as possible. - Returns a list of strings each below the character limit. - """ - str_list = [] - if(len(text) > character_limit): - cut_off = text.index(" ", character_limit - 10, character_limit) - tmp_strings = [text[:cut_off]] - tmp_strings.append(text[cut_off:]) - for string in tmp_strings: - if(len(string) < character_limit): - str_list.append(string) - elif(len(string) > character_limit): - tmp_strings = limit_text(string, character_limit) - for string in tmp_strings: - str_list.append(string) - else: - str_list.append(text) - return str_list - -def main(): - text = "If true, TextWrapper attempts to detect sentence endings and ensure that sentences are always separated by exactly two spaces. This is generally desired for text in a monospaced font. However, the sentence detection algorithm is imperfect:" - texts = limit_text(text, 50) - lines = textwrap.wrap(text, 50, break_long_words=False) - print("Own version:", texts) - print("Lib:", lines) - -if __name__ == '__main__': - main()