Commit 4155a68 1 parent 236e4b4 commit 4155a68 Copy full SHA for 4155a68
File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ def collection(self) -> CollectionData | None:
281
281
LOG .warning (
282
282
"The detected galaxy.yml file (%s) is incomplete, missing %s" ,
283
283
galaxy_file ,
284
- missing_keys ,
284
+ util . oxford_comma ( missing_keys ) ,
285
285
)
286
286
return None
287
287
Original file line number Diff line number Diff line change @@ -597,3 +597,25 @@ def print_as_yaml(data: object) -> None:
597
597
# https://github.com/Textualize/rich/discussions/990#discussioncomment-342217
598
598
result = Syntax (code = safe_dump (data ), lexer = "yaml" , background_color = "default" )
599
599
console .print (result )
600
+
601
+
602
+ def oxford_comma (listed : Iterable [bool | str | Path ], condition : str = "and" ) -> str :
603
+ """Format a list into a sentence.
604
+
605
+ Args:
606
+ listed: List of string entries to modify
607
+ condition: String to splice into string, usually 'and'
608
+
609
+ Returns:
610
+ Modified string
611
+ """
612
+ match [f"'{ entry !s} '" for entry in listed ]:
613
+ case []:
614
+ return ""
615
+ case [one ]:
616
+ return one
617
+ case [one , two ]:
618
+ return f"{ one } { condition } { two } "
619
+ case [* front , back ]:
620
+ return f"{ ', ' .join (s for s in front )} , { condition } { back } "
621
+ return ""
You can’t perform that action at this time.
0 commit comments