* [PATCH 00/11] lei IMAP read support
@ 2021-02-17 10:06 7% Eric Wong
2021-02-17 10:07 6% ` [PATCH 05/11] lei import: move check_input_format to lei Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-02-17 10:06 UTC (permalink / raw)
To: meta
IMAP write support for search results is planned, but testing
could get tricky...
Still unsure about some UI bits w.r.t --format/-f:
https://public-inbox.org/meta/20210217044032.GA17934@dcvr/
convert and import should support parallel network xfers,
NNTP reads, and eventually JMAP...
convert and import don't support compressed mboxes, yet.
Eric Wong (11):
lei: bless config
watch: move imap_common_init to NetReader
watch: connect to NNTP and IMAP in config order
lei import: start rearranging code for IMAP support
lei import: move check_input_format to lei
tests: setup_public_inboxes: use IMAP-friendly newsgroups
t/lei_to_mail: remove unnecessary arg passing
lei convert: mail format conversion sub-command
lei import: add IMAP, (maildir|mbox*):$PATHNAME support
lei: consolidate the bulk of the IPC code
lei: check for IMAP auth errors
MANIFEST | 11 +-
lib/PublicInbox/GitCredential.pm | 18 ++-
lib/PublicInbox/LEI.pm | 62 +++++++-
lib/PublicInbox/LeiAuth.pm | 70 +++++++++
lib/PublicInbox/LeiConvert.pm | 137 +++++++++++++++++
lib/PublicInbox/LeiDedupe.pm | 2 +-
lib/PublicInbox/LeiImport.pm | 156 +++++++++++++-------
lib/PublicInbox/LeiMirror.pm | 19 +--
lib/PublicInbox/LeiOverview.pm | 7 +-
lib/PublicInbox/LeiToMail.pm | 5 +-
lib/PublicInbox/MdirReader.pm | 26 ++++
lib/PublicInbox/NetReader.pm | 242 +++++++++++++++++++++++++++++--
lib/PublicInbox/TestCommon.pm | 15 +-
lib/PublicInbox/Watch.pm | 82 ++---------
t/{home1 => home2}/.gitignore | 0
t/{home1 => home2}/Makefile | 0
t/{home1 => home2}/README | 0
t/lei-convert.t | 36 +++++
t/lei-import-imap.t | 28 ++++
t/lei-import-maildir.t | 4 +-
t/lei_to_mail.t | 14 +-
t/net_reader-imap.t | 40 +++++
xt/lei-auth-fail.t | 20 +++
23 files changed, 820 insertions(+), 174 deletions(-)
create mode 100644 lib/PublicInbox/LeiAuth.pm
create mode 100644 lib/PublicInbox/LeiConvert.pm
rename t/{home1 => home2}/.gitignore (100%)
rename t/{home1 => home2}/Makefile (100%)
rename t/{home1 => home2}/README (100%)
create mode 100644 t/lei-convert.t
create mode 100644 t/lei-import-imap.t
create mode 100644 t/net_reader-imap.t
create mode 100644 xt/lei-auth-fail.t
^ permalink raw reply [relevance 7%]
* [PATCH 05/11] lei import: move check_input_format to lei
2021-02-17 10:06 7% [PATCH 00/11] lei IMAP read support Eric Wong
@ 2021-02-17 10:07 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-02-17 10:07 UTC (permalink / raw)
To: meta
We'll be supporting "lei convert" in a future change; so it
makes sense to share a common internal API for common error
messages.
---
lib/PublicInbox/LEI.pm | 14 ++++++++++++++
lib/PublicInbox/LeiImport.pm | 17 ++---------------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 12deedd8..1fa9f751 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -391,6 +391,20 @@ sub fail ($$;$) {
undef;
}
+sub check_input_format ($;$) {
+ my ($self, $files) = @_;
+ my $fmt = $self->{opt}->{'format'};
+ if (!$fmt) {
+ my $err = $files ? "regular file(s):\n@$files" : '--stdin';
+ return fail($self, "--format unset for $err");
+ }
+ return 1 if $fmt eq 'eml';
+ # XXX: should this handle {gz,bz2,xz}? that's currently in LeiToMail
+ require PublicInbox::MboxReader;
+ PublicInbox::MboxReader->can($fmt) ||
+ fail($self, "--format=$fmt unrecognized");
+}
+
sub out ($;@) {
my $self = shift;
return if print { $self->{1} // return } @_; # likely
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index b25d7e97..32f3a467 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -29,19 +29,6 @@ sub import_done { # EOF callback for main daemon
$imp->wq_wait_old(\&import_done_wait, $lei);
}
-sub check_fmt ($;$) {
- my ($lei, $f) = @_;
- my $fmt = $lei->{opt}->{'format'};
- if (!$fmt) {
- my $err = $f ? "regular file(s):\n@$f" : '--stdin';
- return $lei->fail("--format unset for $err");
- }
- return 1 if $fmt eq 'eml';
- require PublicInbox::MboxReader;
- PublicInbox::MboxReader->can($fmt) ||
- $lei->fail( "--format=$fmt unrecognized\n");
-}
-
sub do_import {
my ($lei) = @_;
my $ops = {
@@ -82,7 +69,7 @@ sub call { # the main "lei import" method
if ($lei->{opt}->{stdin}) {
@argv and return
$lei->fail("--stdin and locations (@argv) do not mix");
- check_fmt($lei) or return;
+ $lei->check_input_format or return;
$self->{0} = $lei->{0};
} else {
my @f;
@@ -95,7 +82,7 @@ sub call { # the main "lei import" method
$lei->{nrd}->add_url($x);
}
}
- if (@f) { check_fmt($lei, \@f) or return }
+ if (@f) { $lei->check_input_format(\@f) or return }
if ($lei->{nrd} && (my @err = $lei->{nrd}->errors)) {
return $lei->fail(@err);
}
^ permalink raw reply related [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-02-17 10:06 7% [PATCH 00/11] lei IMAP read support Eric Wong
2021-02-17 10:07 6% ` [PATCH 05/11] lei import: move check_input_format to lei Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).