@@ -190,6 +190,25 @@ def apply_or_none(fcn, value):
190190 return fcn (value )
191191
192192
193+ def to_human_readable (value : Any ) -> str :
194+ if isinstance (value , Enum ):
195+ return value .name
196+
197+ if isinstance (value , bool ):
198+ return 'Yes' if value else 'No'
199+
200+ if isinstance (value , Bucket ):
201+ return value .name
202+
203+ if isinstance (value , ApplicationKey ):
204+ return value .id_
205+
206+ if value is None :
207+ return ''
208+
209+ return str (value )
210+
211+
193212class DescriptionGetter :
194213 def __init__ (self , described_cls ):
195214 self .described_cls = described_cls
@@ -2571,8 +2590,8 @@ def alter_one_rule(cls, rule: ReplicationRule) -> Optional[ReplicationRule]:
25712590@B2 .register_subcommand
25722591class ReplicationStatus (Command ):
25732592 """
2574- Inspects files in only source or both source and destination buckets
2575- (potentially from different accounts) and provides detailed replication statistics.
2593+ Inspect files in only source or both source and destination buckets
2594+ (potentially from different accounts) and provide detailed replication statistics.
25762595
25772596 Please be aware that only latest file versions are inspected, so any previous
25782597 file versions are not represented in these statistics.
@@ -2649,13 +2668,14 @@ def run(self, args):
26492668 }
26502669
26512670 if args .output_format == 'json' :
2652- self .output_json (results )
2671+ self ._print_json (results )
26532672 elif args .output_format == 'console' :
2654- self .output_console (results )
2673+ self ._print_console (results )
26552674 elif args .output_format == 'csv' :
26562675 self .output_csv (results )
26572676 else :
26582677 self ._print_stderr (f'ERROR: format "{ args .output_format } " is not supported' )
2678+ return 1
26592679
26602680 return 0
26612681
@@ -2683,29 +2703,13 @@ def get_results_for_rule(
26832703 def filter_results_columns (cls , results : List [dict ], columns : List [str ]) -> List [dict ]:
26842704 return [{key : result [key ] for key in columns } for result in results ]
26852705
2686- @classmethod
2687- def to_human_readable (cls , value : Any ) -> str :
2688- if isinstance (value , Enum ):
2689- return value .name
2690-
2691- if isinstance (value , bool ):
2692- return 'Yes' if value else 'No'
2693-
2694- if value is None :
2695- return ''
2696-
2697- return str (value )
2698-
2699- def output_json (self , results : Dict [str , List [dict ]]) -> None :
2700- self ._print_json (results )
2701-
2702- def output_console (self , results : Dict [str , List [dict ]]) -> None :
2706+ def _print_console (self , results : Dict [str , List [dict ]]) -> None :
27032707 for rule_name , rule_results in results .items ():
27042708 self ._print (f'Replication "{ rule_name } ":' )
27052709 rule_results = [
27062710 {
27072711 key .replace ('_' , '\n ' ): # split key to minimize column size
2708- self . to_human_readable (value )
2712+ to_human_readable (value )
27092713 for key , value in result .items ()
27102714 } for result in rule_results
27112715 ]
@@ -2721,7 +2725,7 @@ def output_csv(self, results: Dict[str, List[dict]]) -> None:
27212725 'rule name' : rule_name ,
27222726 ** {
27232727 key .replace ('_' , '\n ' ): # split key to minimize column size
2724- self . to_human_readable (value )
2728+ to_human_readable (value )
27252729 for key , value in result .items ()
27262730 },
27272731 } for result in rule_results
0 commit comments