Lele Gaifax <l...@metapensiero.it> writes:

> It surely worked without issue for years, but now I get this:
>
>   >>> from notmuch2 import Database
>   >>> db = Database()
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in <module>
>     File "/usr/lib/python3/dist-packages/notmuch2/_database.py", line 160, in 
> __init__
>       raise errors.NotmuchError(ret, msg)
>   notmuch2.NoDatabaseError: Error: could not locate database.
>
> even if Database doc still says that the path argument can be omitted:
>
>  |  :param path: The directory of where the database is stored.  If
>  |     ``None`` the location will be searched according to
>  |     :ref:`database`
>
> Sure enough the configuration contains a "database" section, and the
> default_path() class method is able to look it up:
>
>   >>> Database.default_path()
>   PosixPath('/home/lele/Maildir')
>
> so fixed my problem with a minor tweak, ie doing
>
>   with Database(Database.default_path()) as db:
>       handle_deleted_messages(db)
>       move_spam_to_junk(db)
>
> I wonder where the trouble is is: has something changed in the notmuch2
> bridge, or is the Database documentation out of date?

Yes there was a change to the Database constructor in the notmuch2
python module in 0.34.2. It now uses the library to search for
configuration files and databases, so the semantics are a bit
different. But it is also possible that that default for the config
argument should be changed.

Can you try

    with Database(config=Database.CONFIG.SEARCH) as db:

@Floris: when I made the change to the Database constructor, I chose the
default as CONFIG.NONE because this matched the previous semantics
_except_ for finding the database path. But since I don't want to use
the ad hoc default_path method anymore, maybe a better default would be
CONFIG.SEARCH. I guess most users of the python bindings will be OK with
the the configuration values in .notmuch-config being loaded by default.
What do you think?





_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to