lib/PublicInbox/InboxWritable.pm | 2 +- lib/PublicInbox/LeiImport.pm | 2 +- lib/PublicInbox/LeiInput.pm | 4 ++-- lib/PublicInbox/MboxReader.pm | 5 +++++ diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index c2baeba666904ce128435ef36b4e3642cf2f001d..eeebc485156025f1aa1ff38f4b3ba1ebfde31a25 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -172,7 +172,7 @@ sub import_mbox { my ($self, $fh, $variant) = @_; require PublicInbox::MboxReader; - my $cb = PublicInbox::MboxReader->can($variant) or + my $cb = PublicInbox::MboxReader->reads($variant) or die "$variant not supported\n"; my $im = $self->importer(1); $cb->(undef, $fh, \&_mbox_eml_cb, $im, $self->filter); diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index e769fba828c9a85241a6956d6fffe3856dfd0b78..e587ada86b47304654e050ab09deeae4662cc123 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -96,7 +96,7 @@ my $eml = PublicInbox::Eml->new(\$buf); _import_eml($eml, $lei, $kw); } else { # some mbox (->can already checked in call); - my $cb = PublicInbox::MboxReader->can($ifmt) // + my $cb = PublicInbox::MboxReader->reads($ifmt) // die "BUG: bad fmt=$ifmt"; $cb->(undef, $fh, \&_import_eml, $lei, $kw); } diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index 89585a5289e84e8179b81595b5d18a582eda0aff..776b31515439ee0d6fb2a3fd86c395a016e282e4 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -18,7 +18,7 @@ require PublicInbox::MboxLock if $files; require PublicInbox::MboxReader; return 1 if $fmt eq 'eml'; # XXX: should this handle {gz,bz2,xz}? that's currently in LeiToMail - PublicInbox::MboxReader->can($fmt) or + PublicInbox::MboxReader->reads($fmt) or return $lei->fail("--$opt_key=$fmt unrecognized"); 1; } @@ -53,7 +53,7 @@ } if (-f $input_path) { require PublicInbox::MboxLock; require PublicInbox::MboxReader; - PublicInbox::MboxReader->can($ifmt) or return + PublicInbox::MboxReader->reads($ifmt) or return $lei->fail("$ifmt not supported"); } elsif (-d _) { require PublicInbox::MdirReader; diff --git a/lib/PublicInbox/MboxReader.pm b/lib/PublicInbox/MboxReader.pm index f93c2ec634496d8c4ba8d4a7bfde0c8b9ab260a3..6302d1fa540dfada479eb12d4c884512b9137568 100644 --- a/lib/PublicInbox/MboxReader.pm +++ b/lib/PublicInbox/MboxReader.pm @@ -133,4 +133,9 @@ } sub new { bless \(my $x), __PACKAGE__ } +sub reads { + my $ifmt = $_[-1]; + $ifmt =~ /\Ambox(?:rd|cl|cl2|o)\z/ ? __PACKAGE__->can($ifmt) : undef +} + 1;