From 6e714314f04b0c188f048f1677e80d93a51b0781 Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 12 Sep 2021 23:52:54 +0200 Subject: [PATCH 1/3] [enh] Support bytes in write_to_file --- moulinette/utils/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moulinette/utils/filesystem.py b/moulinette/utils/filesystem.py index 9b1456d9..0b1f350a 100644 --- a/moulinette/utils/filesystem.py +++ b/moulinette/utils/filesystem.py @@ -119,7 +119,7 @@ def write_to_file(file_path, data, file_mode="w"): file_mode -- Mode used when writing the file. Option meant to be used by append_to_file to avoid duplicating the code of this function. """ - assert isinstance(data, str) or isinstance( + assert isinstance(data, str) or isinstance(data, bytes) or isinstance( data, list ), "Error: data '%s' should be either a string or a list but is of type '%s'" % ( data, @@ -136,7 +136,7 @@ def write_to_file(file_path, data, file_mode="w"): ) # If data is a list, check elements are strings and build a single string - if not isinstance(data, str): + if isinstance(data, list): for element in data: assert isinstance( element, str From 2543e5c8ab72fe290b7fa52c6a19eccb1eea4abd Mon Sep 17 00:00:00 2001 From: zamentur Date: Sun, 12 Sep 2021 21:56:17 +0000 Subject: [PATCH 2/3] :art: Format Python code with Black --- moulinette/utils/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moulinette/utils/filesystem.py b/moulinette/utils/filesystem.py index 0b1f350a..d075b83d 100644 --- a/moulinette/utils/filesystem.py +++ b/moulinette/utils/filesystem.py @@ -119,8 +119,8 @@ def write_to_file(file_path, data, file_mode="w"): file_mode -- Mode used when writing the file. Option meant to be used by append_to_file to avoid duplicating the code of this function. """ - assert isinstance(data, str) or isinstance(data, bytes) or isinstance( - data, list + assert ( + isinstance(data, str) or isinstance(data, bytes) or isinstance(data, list) ), "Error: data '%s' should be either a string or a list but is of type '%s'" % ( data, type(data), From 08f7866f7731d67f42127681cfec2f4a465644a9 Mon Sep 17 00:00:00 2001 From: ljf Date: Tue, 14 Sep 2021 21:14:32 +0200 Subject: [PATCH 3/3] [fix] Prefill input with long color question --- moulinette/interfaces/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index df812738..6e1eb8cd 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -550,9 +550,10 @@ class Interface: if is_password: return getpass.getpass(colorize(m18n.g("colon", message), color)) elif not is_multiline: + print(colorize(m18n.g("colon", message), color), end="") set_startup_hook(lambda: insert_text(prefill)) try: - value = input(colorize(m18n.g("colon", message), color)) + value = input() finally: set_startup_hook() return value