Skip to content

Define libraries dynamically #851

Answered by alexfikl
octvs asked this question in Q&A
May 15, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Hm, yeah, that makes sense. The register_default_settings function just adds things to the default fallback settings which are only seen when using papis.config.get. Libraries unfortunately don't go through that..

For now, you can try this (worked on my system)

import pathlib

basedir = pathlib.Path.home() / 'media' / 'library'
for subdir in basedir.glob('[a-z]*/'):
    libname = subdir.stem
    if libname not in self:
        self.add_section(libname)
    self[libname]['dir'] = str(subdir)

Here self is just the current ConfigParser object that's being initialized. It's a bit hacky, but it should work..

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@octvs
Comment options

@alexfikl
Comment options

Answer selected by octvs
@alexfikl
Comment options

@octvs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants