@@ -480,20 +480,17 @@ def abs_or_rel_to(path: Path, base: Path) -> Path:
480
480
return base / path
481
481
482
482
483
- class BugReport :
483
+ class BugReportBase :
484
484
_bug_report : Path
485
485
_command_id : int
486
486
_defn_id : int
487
487
_file_remap : dict [str , str ]
488
488
489
489
def __init__ (self , bug_report : Path ) -> None :
490
- self ._bug_report = bug_report . with_suffix ( '.tar' )
490
+ self ._bug_report = bug_report
491
491
self ._command_id = 0
492
492
self ._defn_id = 0
493
493
self ._file_remap = {}
494
- if self ._bug_report .exists ():
495
- _LOGGER .warning (f'Bug report exists, removing: { self ._bug_report } ' )
496
- self ._bug_report .unlink ()
497
494
498
495
def add_file (self , finput : Path , arcname : Path ) -> None :
499
496
if str (finput ) not in self ._file_remap :
@@ -524,3 +521,26 @@ def _remap_arg(_a: str) -> str:
524
521
shebang = '#!/usr/bin/env bash\n set -euxo pipefail\n '
525
522
self .add_file_contents (shebang + ' ' .join (remapped_args ) + '\n ' , arcname )
526
523
self ._command_id += 1
524
+
525
+
526
+ class BugReport (BugReportBase ):
527
+ def __init__ (self , bug_report : Path ) -> None :
528
+ bug_report = bug_report .with_suffix ('.tar' )
529
+ if bug_report .exists ():
530
+ _LOGGER .warning (f'Bug report exists, removing: { bug_report } ' )
531
+ bug_report .unlink ()
532
+ super ().__init__ (bug_report )
533
+
534
+ def reporter (self , prefix : str ) -> BugReportBase :
535
+ class BugReporter (BugReportBase ):
536
+ _prefix : Path
537
+
538
+ def __init__ (self , bug_report : Path , prefix : Path ) -> None :
539
+ super ().__init__ (bug_report )
540
+ self ._prefix = prefix
541
+
542
+ def add_file (self , finput : Path , arcname : Path ) -> None :
543
+ arcname = self ._prefix / arcname
544
+ super ().add_file (finput , arcname )
545
+
546
+ return BugReporter (self ._bug_report , Path (prefix ))
0 commit comments