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);
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);
}
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;
}
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;
sub new { bless \(my $x), __PACKAGE__ }
+sub reads {
+ my $ifmt = $_[-1];
+ $ifmt =~ /\Ambox(?:rd|cl|cl2|o)\z/ ? __PACKAGE__->can($ifmt) : undef
+}
+
1;