6868 "cylc install" even if present in the source directory.
6969"""
7070
71+ from functools import partial
7172from pathlib import Path
73+ import re
7274import sys
73- from typing import Optional , TYPE_CHECKING , List , Callable
74- from functools import partial
75+ from typing import (
76+ TYPE_CHECKING ,
77+ Callable ,
78+ List ,
79+ Optional ,
80+ )
7581
7682from ansimarkup import parse as cparse
7783
7884from cylc .flow .exceptions import (
7985 ServiceFileError ,
8086 WorkflowFilesError ,
8187)
82- from cylc .flow .install import (
83- reinstall_workflow ,
84- )
88+ from cylc .flow .install import reinstall_workflow
8589from cylc .flow .network .multi import call_multi
8690from cylc .flow .option_parsers import (
91+ ID_MULTI_ARG_DOC ,
8792 CylcOptionParser as COP ,
8893 OptionSettings ,
89- ID_MULTI_ARG_DOC
9094)
9195from cylc .flow .pathutil import get_workflow_run_dir
9296from cylc .flow .plugins import run_plugins_async
97+ from cylc .flow .terminal import (
98+ DIM ,
99+ cli_function ,
100+ is_terminal ,
101+ )
93102from cylc .flow .workflow_files import (
94103 get_workflow_source_dir ,
95104 load_contact_file ,
96105)
97- from cylc . flow . terminal import cli_function , DIM , is_terminal
106+
98107
99108if TYPE_CHECKING :
100109 from optparse import Values
@@ -319,7 +328,7 @@ def format_rsync_out(out: str) -> List[str]:
319328
320329 Example:
321330 >>> format_rsync_out(
322- ... 'send foo\ndel. bar\nbaz'
331+ ... 'send >f+++++++++ foo\ndel. *deleting bar\nbaz'
323332 ... '\ncannot delete non-empty directory: opt'
324333 ... ) == [
325334 ... cparse('<green>send foo</green>'),
@@ -331,18 +340,20 @@ def format_rsync_out(out: str) -> List[str]:
331340 """
332341 lines = []
333342 for line in out .splitlines ():
334- if line [0 :4 ] == 'send' :
335- # file added or updated
336- lines .append (cparse (f'<green>{ line } </green>' ))
337- elif line [0 :4 ] == 'del.' :
338- # file deleted
339- lines .append (cparse (f'<red>{ line } </red>' ))
340- elif line == 'cannot delete non-empty directory: opt' :
343+ if line == 'cannot delete non-empty directory: opt' :
341344 # These "cannot delete non-empty directory" messages can arise
342345 # as a result of excluding files within sub-directories.
343- # This opt dir message is likely to occur when a rose-suit .conf
346+ # This opt dir message is likely to occur when a rose-suite .conf
344347 # file is present.
345348 continue
349+ match = re .match (r'^(send|del\.)\s.{11}\s(.*)$' , line )
350+ # .{11} is the itemized changes bit, which users don't need to see
351+ if match :
352+ operation = match .group (1 )
353+ color = 'green' if operation == 'send' else 'red'
354+ lines .append (
355+ cparse (f"<{ color } >{ operation } </{ color } > { match .group (2 )} " )
356+ )
346357 else :
347358 # other uncategorised log line
348359 lines .append (line )
0 commit comments