Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Testing can show the presense of bugs, but not their absence. -- Dijkstra


devel / comp.lang.python / Re: How to test for maildir 'folder' in Python?

SubjectAuthor
* How to test for maildir 'folder' in Python?Chris Green
+* Re: How to test for maildir 'folder' in Python?Cameron Simpson
|`- Re: How to test for maildir 'folder' in Python?Chris Green
`* Re: How to test for maildir 'folder' in Python?Barry Scott
 `* Re: How to test for maildir 'folder' in Python?Chris Green
  `- Re: How to test for maildir 'folder' in Python?Barry

1
How to test for maildir 'folder' in Python?

<dd9ubi-r545.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16783&group=comp.lang.python#16783

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: How to test for maildir 'folder' in Python?
Date: Sat, 22 Jan 2022 21:26:37 +0000
Lines: 19
Message-ID: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 6pZYEnw+k2R3RZCcxRN1EQzD7gQyIXfSULCiWKgWptnenarDQ=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:/yDNJhKG94GRvfLQ/uqUqlJApKQ=
User-Agent: tin/2.4.6-20210226 ("Glen Albyn") (Linux/5.13.0-27-generic (x86_64))
 by: Chris Green - Sat, 22 Jan 2022 21:26 UTC

I have a script that walks a quite deep tree of mail messages to find
and archive old messages. I'm trying to convert it from mbox to
maildir (as I now store my mail in maildir format).

So I need to test whether a point I have reached in the hierarchy is a
maildir mailbox or not. Using mbox format it's easy because 'folders'
are directories and mailboxes are files. However with maildir the
'folders' have directories within them so the simple tree walking goes
down a level too far and finds 'folders' which aren't mailboxes called
'cur', 'new' and 'tmp'.

Is there any 'ready made' way in python to tell whether a directory is
a maildir mailbox? If not I suppose I'll simply have to check if
there are 'cur', 'new' and 'tmp' directories within the directory
which may or may not be a maildir.

--
Chris Green
·

Re: How to test for maildir 'folder' in Python?

<mailman.239.1642895026.3079.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16785&group=comp.lang.python#16785

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: How to test for maildir 'folder' in Python?
Date: Sun, 23 Jan 2022 10:43:35 +1100
Lines: 21
Message-ID: <mailman.239.1642895026.3079.python-list@python.org>
References: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
<YeyWp3wZUhE31sct@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de 88se27Em8gxkmLSNehtJvgg0NwfqldVi7vl66J765n1A==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'pypi': 0.05; 'apparently':
0.09; 'something,': 0.09; 'subject:test': 0.09; 'cheers,': 0.11;
'subject:Python': 0.12; 'cameron': 0.16; 'directories': 0.16;
'fetching': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au':
0.16; 'from:name:cameron simpson': 0.16; 'mailbox?': 0.16;
'message-id:@cskk.homeip.net': 0.16; 'received:13.237': 0.16;
'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16;
'subject:folder': 0.16; 'wrote:': 0.16; 'python': 0.16; 'reached':
0.17; "aren't": 0.19; 'to:addr:python-list': 0.20; 'subject:How':
0.23; 'chris': 0.28; 'goes': 0.28; 'suggest': 0.28; 'header:User-
Agent:1': 0.30; 'module': 0.31; 'but': 0.32; "i'll": 0.33;
'subject:for': 0.33; 'there': 0.33; 'header:In-Reply-To:1': 0.34;
'received:au': 0.35; 'using': 0.37; "it's": 0.37; 'class': 0.37;
'directory': 0.37; 'way': 0.38; 'files.': 0.40; 'tell': 0.60;
'format': 0.62; 'simply': 0.63; 'received:13': 0.64;
'received:userid': 0.66; 'exactly': 0.68; 'mailboxes': 0.69;
'within': 0.69; 'easy': 0.74; 'finds': 0.76; 'mailbox': 0.91;
'green': 0.96
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
User-Agent: Mutt/2.1.4 (2021-12-11)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YeyWp3wZUhE31sct@cskk.homeip.net>
X-Mailman-Original-References: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
 by: Cameron Simpson - Sat, 22 Jan 2022 23:43 UTC

On 22Jan2022 21:26, Chris Green <cl@isbd.net> wrote:
>So I need to test whether a point I have reached in the hierarchy is a
>maildir mailbox or not. Using mbox format it's easy because 'folders'
>are directories and mailboxes are files. However with maildir the
>'folders' have directories within them so the simple tree walking goes
>down a level too far and finds 'folders' which aren't mailboxes called
>'cur', 'new' and 'tmp'.
>
>Is there any 'ready made' way in python to tell whether a directory is
>a maildir mailbox? If not I suppose I'll simply have to check if
>there are 'cur', 'new' and 'tmp' directories within the directory
>which may or may not be a maildir.

I was hoping that the provided mailbox/Maildir class had something, but
apparently not.

So I suggest fetching my cs.mailutils module from PyPI and using its
ismaildir(path) function, which does exactly what you describe.

Cheers,
Cameron Simpson <cs@cskk.id.au>

Re: How to test for maildir 'folder' in Python?

<9fivbi-h0k7.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16787&group=comp.lang.python#16787

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: How to test for maildir 'folder' in Python?
Date: Sun, 23 Jan 2022 09:07:21 +0000
Lines: 29
Message-ID: <9fivbi-h0k7.ln1@esprimo.zbmc.eu>
References: <dd9ubi-r545.ln1@esprimo.zbmc.eu> <YeyWp3wZUhE31sct@cskk.homeip.net> <mailman.239.1642895026.3079.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net FMNAJf+TmiHgBttvSeDZKwvvWZwd/lIDidvh6J21Ih/sNSgIc=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:Aqw0T5hbEgIpXcEHbbk+A9w+NBM=
User-Agent: tin/2.4.6-20210226 ("Glen Albyn") (Linux/5.13.0-27-generic (x86_64))
 by: Chris Green - Sun, 23 Jan 2022 09:07 UTC

Cameron Simpson <cs@cskk.id.au> wrote:
> On 22Jan2022 21:26, Chris Green <cl@isbd.net> wrote:
> >So I need to test whether a point I have reached in the hierarchy is a
> >maildir mailbox or not. Using mbox format it's easy because 'folders'
> >are directories and mailboxes are files. However with maildir the
> >'folders' have directories within them so the simple tree walking goes
> >down a level too far and finds 'folders' which aren't mailboxes called
> >'cur', 'new' and 'tmp'.
> >
> >Is there any 'ready made' way in python to tell whether a directory is
> >a maildir mailbox? If not I suppose I'll simply have to check if
> >there are 'cur', 'new' and 'tmp' directories within the directory
> >which may or may not be a maildir.
>
> I was hoping that the provided mailbox/Maildir class had something, but
> apparently not.
>
So was I! :-) It seems strange that something isn't provided as it's
rather fundamental to handling maildir.

> So I suggest fetching my cs.mailutils module from PyPI and using its
> ismaildir(path) function, which does exactly what you describe.
>
Thanks Cameron.

--
Chris Green
·

Re: How to test for maildir 'folder' in Python?

<mailman.241.1642940440.3079.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16788&group=comp.lang.python#16788

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: bar...@barrys-emacs.org (Barry Scott)
Newsgroups: comp.lang.python
Subject: Re: How to test for maildir 'folder' in Python?
Date: Sun, 23 Jan 2022 12:20:30 +0000
Lines: 48
Message-ID: <mailman.241.1642940440.3079.python-list@python.org>
References: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
<C9ADD9DB-7C68-4E7E-AE4B-152922F24B1D@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\))
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de q03Kmyfc82WtyVJcqVm1QwwL6aVYPf6NTOcmRbvuaovA==
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.018
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list':
0.09; 'from:addr:barry': 0.09; 'messages.': 0.09;
'received:217.70': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'subject:test': 0.09;
'subject:Python': 0.12; 'cc:no real name:2**0': 0.14;
'url:mailman': 0.15; '2022,': 0.16; 'barry': 0.16; 'directories':
0.16; 'encoding': 0.16; 'from:addr:barrys-emacs.org': 0.16;
'from:name:barry scott': 0.16; 'mailbox?': 0.16; 'message-id
:@barrys-emacs.org': 0.16; 'subject:folder': 0.16; 'wrote:': 0.16;
'python': 0.16; 'reached': 0.17; 'uses': 0.19; "aren't": 0.19;
'cc:addr:python.org': 0.20; 'subject:How': 0.23; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25;
'old': 0.27; 'chris': 0.28; 'goes': 0.28; 'deep': 0.31; 'url-
ip:188/8': 0.31; '(as': 0.32; 'structure': 0.32; "i'm": 0.33;
"i'll": 0.33; 'subject:for': 0.33; 'there': 0.33; 'script': 0.33;
'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'using': 0.37;
"it's": 0.37; 'directory': 0.37; 'way': 0.38; 'quite': 0.39;
'files.': 0.40; 'tell': 0.60; 'format': 0.62; 'simply': 0.63;
'between': 0.63; 'down': 0.64; 'shows': 0.67; 'received:217':
0.67; 'mailboxes': 0.69; 'within': 0.69; 'easy': 0.74; 'finds':
0.76; 'client': 0.82; '"."': 0.84; 'parts.': 0.84; 'tmp': 0.84;
'walks': 0.84; 'inbox': 0.91; 'mailbox': 0.91; 'green': 0.96
In-Reply-To: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
X-Mailer: Apple Mail (2.3693.40.0.1.81)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <C9ADD9DB-7C68-4E7E-AE4B-152922F24B1D@barrys-emacs.org>
X-Mailman-Original-References: <dd9ubi-r545.ln1@esprimo.zbmc.eu>
 by: Barry Scott - Sun, 23 Jan 2022 12:20 UTC

> On 22 Jan 2022, at 21:26, Chris Green <cl@isbd.net> wrote:
>
> I have a script that walks a quite deep tree of mail messages to find
> and archive old messages. I'm trying to convert it from mbox to
> maildir (as I now store my mail in maildir format).
>
> So I need to test whether a point I have reached in the hierarchy is a
> maildir mailbox or not. Using mbox format it's easy because 'folders'
> are directories and mailboxes are files. However with maildir the
> 'folders' have directories within them so the simple tree walking goes
> down a level too far and finds 'folders' which aren't mailboxes called
> 'cur', 'new' and 'tmp'.
>
> Is there any 'ready made' way in python to tell whether a directory is
> a maildir mailbox? If not I suppose I'll simply have to check if
> there are 'cur', 'new' and 'tmp' directories within the directory
> which may or may not be a maildir.

You do not need to walk the tree.

The structure is
Maildir/cur, new, tmp - The INBOX
Maildir/<encoded-mail-folder>/cur, new, tmp

The encoding prefixed with a "." and uses a "." between folder name parts.

An example from my Maildir is ".Python.Users/" for a folder that client
shows as Python/Users

You can see this by doing:

ls -a ~/Maildir

Barry

>
> --
> Chris Green
> ·
> --
> https://mail.python.org/mailman/listinfo/python-list

Re: How to test for maildir 'folder' in Python?

<oqvvbi-mbf8.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16790&group=comp.lang.python#16790

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: How to test for maildir 'folder' in Python?
Date: Sun, 23 Jan 2022 12:55:20 +0000
Lines: 63
Message-ID: <oqvvbi-mbf8.ln1@esprimo.zbmc.eu>
References: <dd9ubi-r545.ln1@esprimo.zbmc.eu> <C9ADD9DB-7C68-4E7E-AE4B-152922F24B1D@barrys-emacs.org> <mailman.241.1642940440.3079.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 9DESJw9wZuIE4UBGai1lQwwqRag5DnrviYPS0aWyKl+uDFQL0=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:T+m8uflc6QdrghonZgk9SxpMU1I=
User-Agent: tin/2.4.6-20210226 ("Glen Albyn") (Linux/5.13.0-27-generic (x86_64))
 by: Chris Green - Sun, 23 Jan 2022 12:55 UTC

Barry Scott <barry@barrys-emacs.org> wrote:
>
>
> > On 22 Jan 2022, at 21:26, Chris Green <cl@isbd.net> wrote:
> >
> > I have a script that walks a quite deep tree of mail messages to find
> > and archive old messages. I'm trying to convert it from mbox to
> > maildir (as I now store my mail in maildir format).
> >
> > So I need to test whether a point I have reached in the hierarchy is a
> > maildir mailbox or not. Using mbox format it's easy because 'folders'
> > are directories and mailboxes are files. However with maildir the
> > 'folders' have directories within them so the simple tree walking goes
> > down a level too far and finds 'folders' which aren't mailboxes called
> > 'cur', 'new' and 'tmp'.
> >
> > Is there any 'ready made' way in python to tell whether a directory is
> > a maildir mailbox? If not I suppose I'll simply have to check if
> > there are 'cur', 'new' and 'tmp' directories within the directory
> > which may or may not be a maildir.
>
> You do not need to walk the tree.
>
> The structure is
> Maildir/cur, new, tmp - The INBOX
> Maildir/<encoded-mail-folder>/cur, new, tmp
>
> The encoding prefixed with a "." and uses a "." between folder name parts.
>
> An example from my Maildir is ".Python.Users/" for a folder that client
> shows as Python/Users
>
> You can see this by doing:
>
> ls -a ~/Maildir
>
You're talking about one specific (and IMHO not very good) way of
creating a maildir hierarchy. Here's what I see on my system:-

chris@esprimo$ cd mail
/home/chris/mail
chris@esprimo$ ls -a
. .. Gm In Ju Li Tm folder
chris@esprimo$ ls -a folder
. apexLodge entertainment greville houseHome maxMum reshapers tractor
.. archive family hardware internet money riding travel
Scans boating france health isbd pcc software ukraa
Shopping buySellAdmin friends holidays jrml personal telecoms vehicles
chris@esprimo$ ls -a folder/Shopping
. cabin cycling garden maxine pets stationery
.. car diy giftsEtc maxmum photography telecoms
apexLodge clothesEtc electrical groupon medicine riding toolstation
boat computer electronics houseHome motorcycle screwfix
books cpc food jrml music sportsEtc

No dot prefixes and my maildir hierarchy is a *real* directory hierarchy so
all the other file management utilities on my system can be used easily.

--
Chris Green
·

Re: How to test for maildir 'folder' in Python?

<mailman.248.1642973648.3079.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16798&group=comp.lang.python#16798

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: bar...@barrys-emacs.org (Barry)
Newsgroups: comp.lang.python
Subject: Re: How to test for maildir 'folder' in Python?
Date: Sun, 23 Jan 2022 21:33:56 +0000
Lines: 83
Message-ID: <mailman.248.1642973648.3079.python-list@python.org>
References: <oqvvbi-mbf8.ln1@esprimo.zbmc.eu>
<A0329D2D-80C8-4B73-89D9-F64AEB1E545B@barrys-emacs.org>
Mime-Version: 1.0 (1.0)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de qR+OeG6MRceo0wdpZHlYIwLRubcpG6bH0Vej4CVb/bkA==
Return-Path: <barry@barrys-emacs.org>
X-Original-To: Python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.067
X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'cc:addr:python-list':
0.09; 'electrical': 0.09; 'from:addr:barry': 0.09; 'messages.':
0.09; 'received:217.70': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'subject:test': 0.09;
'subject:Python': 0.12; 'cc:no real name:2**0': 0.14;
'url:mailman': 0.15; '2022,': 0.16; '>>>>': 0.16; 'barry': 0.16;
'directories': 0.16; 'easily.': 0.16; 'electronics': 0.16;
'encoding': 0.16; 'from:addr:barrys-emacs.org': 0.16; 'holidays':
0.16; 'mailbox?': 0.16; 'message-id:@barrys-emacs.org': 0.16;
'scans': 0.16; 'subject:folder': 0.16; 'utilities': 0.16;
'wrote:': 0.16; 'python': 0.16; 'reached': 0.17; 'uses': 0.19;
"aren't": 0.19; 'hardware': 0.19; 'cc:addr:python.org': 0.20;
'subject:How': 0.23; '(and': 0.25; 'url-ip:188.166.95.178/32':
0.25; 'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25;
'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25; 'creating': 0.27;
'old': 0.27; '>>>': 0.28; 'chris': 0.28; 'goes': 0.28; 'computer':
0.29; 'deep': 0.31; 'url-ip:188/8': 0.31; '(as': 0.32;
'structure': 0.32; "i'm": 0.33; "i'll": 0.33; 'subject:for': 0.33;
'there': 0.33; 'script': 0.33; 'travel': 0.34; 'header:In-Reply-
To:1': 0.34; 'trying': 0.35; 'using': 0.37; "it's": 0.37;
'directory': 0.37; 'file': 0.38; 'way': 0.38; 'quite': 0.39;
'use': 0.39; 'files.': 0.40; 'family': 0.60; 'tell': 0.60;
'format': 0.62; 'service.': 0.62; 'simply': 0.63; 'between': 0.63;
'health': 0.63; 'personal': 0.64; 'down': 0.64; 'music': 0.64;
'shows': 0.67; 'received:217': 0.67; 'management': 0.68;
'mailboxes': 0.69; 'skip:/ 10': 0.69; 'within': 0.69; 'money':
0.71; 'easy': 0.74; 'finds': 0.76; 'france': 0.76; 'food': 0.78;
'client': 0.82; '"."': 0.84; 'boat': 0.84; 'car': 0.84; 'cycling':
0.84; 'garden': 0.84; 'medicine': 0.84; 'scott': 0.84; 'tmp':
0.84; 'walks': 0.84; 'inbox': 0.91; 'mailbox': 0.91; 'shopping':
0.91; 'friends': 0.96; 'green': 0.96
In-Reply-To: <oqvvbi-mbf8.ln1@esprimo.zbmc.eu>
X-Mailer: iPad Mail (19C63)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <A0329D2D-80C8-4B73-89D9-F64AEB1E545B@barrys-emacs.org>
X-Mailman-Original-References: <oqvvbi-mbf8.ln1@esprimo.zbmc.eu>
 by: Barry - Sun, 23 Jan 2022 21:33 UTC

> On 23 Jan 2022, at 17:08, Chris Green <cl@isbd.net> wrote:
>
> Barry Scott <barry@barrys-emacs.org> wrote:
>>
>>
>>>> On 22 Jan 2022, at 21:26, Chris Green <cl@isbd.net> wrote:
>>>
>>> I have a script that walks a quite deep tree of mail messages to find
>>> and archive old messages. I'm trying to convert it from mbox to
>>> maildir (as I now store my mail in maildir format).
>>>
>>> So I need to test whether a point I have reached in the hierarchy is a
>>> maildir mailbox or not. Using mbox format it's easy because 'folders'
>>> are directories and mailboxes are files. However with maildir the
>>> 'folders' have directories within them so the simple tree walking goes
>>> down a level too far and finds 'folders' which aren't mailboxes called
>>> 'cur', 'new' and 'tmp'.
>>>
>>> Is there any 'ready made' way in python to tell whether a directory is
>>> a maildir mailbox? If not I suppose I'll simply have to check if
>>> there are 'cur', 'new' and 'tmp' directories within the directory
>>> which may or may not be a maildir.
>>
>> You do not need to walk the tree.
>>
>> The structure is
>> Maildir/cur, new, tmp - The INBOX
>> Maildir/<encoded-mail-folder>/cur, new, tmp
>>
>> The encoding prefixed with a "." and uses a "." between folder name parts..
>>
>> An example from my Maildir is ".Python.Users/" for a folder that client
>> shows as Python/Users
>>
>> You can see this by doing:
>>
>> ls -a ~/Maildir
>>
> You're talking about one specific (and IMHO not very good) way of
> creating a maildir hierarchy. Here's what I see on my system:

Oh right! That is imposed by dovecot that I use for the imap service.

Barry

> chris@esprimo$ cd mail
> /home/chris/mail
> chris@esprimo$ ls -a
> . .. Gm In Ju Li Tm folder
> chris@esprimo$ ls -a folder
> . apexLodge entertainment greville houseHome maxMum reshapers tractor
> .. archive family hardware internet money riding travel
> Scans boating france health isbd pcc software ukraa
> Shopping buySellAdmin friends holidays jrml personal telecoms vehicles
> chris@esprimo$ ls -a folder/Shopping
> . cabin cycling garden maxine pets stationery
> .. car diy giftsEtc maxmum photography telecoms
> apexLodge clothesEtc electrical groupon medicine riding toolstation
> boat computer electronics houseHome motorcycle screwfix
> books cpc food jrml music sportsEtc
>
> No dot prefixes and my maildir hierarchy is a *real* directory hierarchy so
> all the other file management utilities on my system can be used easily.
>
>
>
> --
> Chris Green
> ·
> --
> https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor