about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/InboxWritable.pm2
-rw-r--r--lib/PublicInbox/LeiImport.pm2
-rw-r--r--lib/PublicInbox/LeiInput.pm4
-rw-r--r--lib/PublicInbox/MboxReader.pm5
4 files changed, 9 insertions, 4 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index c2baeba6..eeebc485 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -172,7 +172,7 @@ sub _mbox_eml_cb { # MboxReader->mbox* callback
 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 e769fba8..e587ada8 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -96,7 +96,7 @@ error reading $input: $!
                         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 89585a52..776b3151 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -18,7 +18,7 @@ sub check_input_format ($;$) {
         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 @@ sub prepare_inputs {
                         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 f93c2ec6..6302d1fa 100644
--- a/lib/PublicInbox/MboxReader.pm
+++ b/lib/PublicInbox/MboxReader.pm
@@ -133,4 +133,9 @@ sub mboxcl2 {
 
 sub new { bless \(my $x), __PACKAGE__ }
 
+sub reads {
+        my $ifmt = $_[-1];
+        $ifmt =~ /\Ambox(?:rd|cl|cl2|o)\z/ ? __PACKAGE__->can($ifmt) : undef
+}
+
 1;