Code Monkey home page Code Monkey logo

Comments (10)

hroncok avatar hroncok commented on September 13, 2024

As a workaround, I can use config_opts["dnf.conf"] which seems to work both with dnf and dnf5.

from mock.

xsuchy avatar xsuchy commented on September 13, 2024
  1. config_opts.package_manager does not exist. config_opts is a dictionary.

  2. You can use this:

include('fedora-39-x86_64.cfg')

config_opts['__jinja_expand']=True
config_opts[f"{config_opts['package_manager']}.conf"] += """                                                                                                                                 
# whatever
"""
config_opts['__jinja_expand']=False

This is because of https://github.com/xsuchy/templated-dictionary?tab=readme-ov-file#enabling-expansion which has other reason that is stored somewhere in git-log. I can dig it up if you are really curious.

This is normally not needed for values, but required for keys. I should probably document it.

from mock.

hroncok avatar hroncok commented on September 13, 2024

config_opts.package_manager somehow exists. I don't know how, but it does.

from mock.

hroncok avatar hroncok commented on September 13, 2024
>>> from templated_dictionary import TemplatedDictionary
>>> td = TemplatedDictionary()
>>> td['package_manager'] = 'dnf'
>>> td.package_manager
'dnf'

from mock.

hroncok avatar hroncok commented on September 13, 2024

TemplatedDictionary stores the value:key pairs in self.__dict__, making them accessible as attributes.

from mock.

hroncok avatar hroncok commented on September 13, 2024

As a side issue I've opened xsuchy/templated-dictionary#4

from mock.

praiskup avatar praiskup commented on September 13, 2024

@xsuchy wrote:

You can use this:

include('fedora-39-x86_64.cfg')

config_opts['__jinja_expand']=True
config_opts[f"{config_opts['package_manager']}.conf"] += """

Actually you can not, jinja is only supported in values, not in keys.

from mock.

praiskup avatar praiskup commented on September 13, 2024

Actually you can not, jinja is only supported in values, not in keys.

Wrong -> that's a f-string, not jinja. Sorry, you can use that. But ... it is unnecessary, you can simply use dnf.conf instead of abstracting the package_manager out. dnf.conf and yum.conf is completely equivalent key (these are aliased to each other).

from mock.

hroncok avatar hroncok commented on September 13, 2024

(This issue is not blocking me in any way. But it is a regression nevertheless. If you decide to wontfix it, I'm OK with that.)

from mock.

praiskup avatar praiskup commented on September 13, 2024

I'm careful to call this a regression because a) Jinja in the
TemplatedDictionary keys never worked, and yet b) it is expected to use Jinja in
TemplatedDictionary values. So your change in #1332 was fine from this
perspective.

So such a problem happens when we use config_opts values for specifying
config_opts keys. This limiting factor was always there - and nothing has
changed or regressed for several Mock releases.

This admittedly was/is a serious problem, though. The copr mock-config used to
provide the unfortunate output
(config_opts[f"{config_opts['package_manager']}.conf"] = ... ), and if cached
by our user - the problem still keeps appearing somewhere in the wild.

I decided to WONTFIX this particular instance of Jinja-in-key problem before
:-) because I thought there was no better way to achieve the result. But now I
think there is, namely using the logic from #1347.

from mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.