Skip to content

Unbind the config_dict from cookiecutter(). Allow it to be passed as an argument.#100

Closed
theladyjaye wants to merge 6 commits intocookiecutter:masterfrom
theladyjaye:master
Closed

Unbind the config_dict from cookiecutter(). Allow it to be passed as an argument.#100
theladyjaye wants to merge 6 commits intocookiecutter:masterfrom
theladyjaye:master

Conversation

@theladyjaye
Copy link
Copy Markdown

Allow the initial config_dict to be passed as an argument to the cookiecuter() function rather than impose the default user config from within cookiecutter().

Note that main() still runs though get_user_config() for the CLI aspect of Cookiecutter. For the user that is composing Cookiecutter in a larger python program, they can decide what config_dict is when calling cookiecutter() from within python assuming they make it conform to the expected keys defined in config.DEFAULT_CONFIG

…iecuter() function rather than impose the default user config. Note that main() still runs though get_user_config() but for the user that is composing cookiecutter in a larger python program, they can decide what the config_dict is when calling cookiecutter from within python.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.92%) when pulling 4ad877e on aventurella:master into 4363909 on audreyr:master.

@theladyjaye
Copy link
Copy Markdown
Author

Ahhh... this is sort of duplicating pull #75 and answering issue #12

My 2c on the difference between the 2 (#100 and #75) conceptually:

#75 still runs though get_user_config() in cookiecutter() which assumes you want to lookup the config from the user path. Granted when this fails you get a copy of DEFAULT_CONFIG but it still leaves the API consumer of cookiecutter() performing a filesystem operation they may not necessarily know they are doing.

For example, they might be using Cookiecutter on the CLI normally which would mean they potentially have a ~/.cookiecutterrc. Now if they decide to create an application that composes Cookiecutter, even though they are no longer using it on the CLI for their purpose, it will still go and read their ~/.cookiecutterrc when calling it from python potentially loading config information they never intended to load. If the API user really wants to load the user's config, I think it's better to have them explicitly load it on their end, AKA in their program they call config.get_user_config() rather than having it automatically called for them.

#100 However must dupe a little bit of functionality found in cookiecutter.config namely the copying of the DEFAULT_CONFIG dict. The API user then needs to perform that copy themselves if they want to pass their own config_dict to cookiecutter(). Actually, I'm going to amend this PR and add a get_default_config() to cookiecutter.config. This will allow an API user a convenience function to call to get the config and not have to know anything about the copying going on behind the scenes. Additionally, config.get_config() and config.get_user_config() can both make use of it as they were both performing a call to copy.copy(DEFAULT_CONFIG) previously.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 3104cda on aventurella:master into 4363909 on audreyr:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.54%) when pulling 8a4e8d6 on aventurella:master into 4363909 on audreyr:master.

@dinopetrone
Copy link
Copy Markdown

+1

2 similar comments
@aubricus
Copy link
Copy Markdown

+1

@rochacbruno
Copy link
Copy Markdown
Contributor

👍

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.94%) when pulling 1887cb4 on aventurella:master into 4363909 on audreyr:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling ef58237 on aventurella:master into 4363909 on audreyr:master.

@pydanny
Copy link
Copy Markdown
Member

pydanny commented Nov 12, 2013

👍

@driesdesmet
Copy link
Copy Markdown

If I understand this correctly, this would allow me to overwrite the default_context both on the command line and using python with higher priority than what's set in cookiecutter.json: +1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@michaeljoseph
Copy link
Copy Markdown
Contributor

@aventurella this needs tests please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaeljoseph
Copy link
Copy Markdown
Contributor

🔔 @aventurella

@theladyjaye
Copy link
Copy Markdown
Author

@michaeljoseph ya, I will get those tests in there, no problem.

Remove improper doc string in cookiecutter.main.cookiecutter.

Add unit test for cookiecutter.main.cookiecutter to test passing in a
custom config_dict.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.28%) when pulling 54992ae on aventurella:master into 4363909 on audreyr:master.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what this means =)

@mgaitan
Copy link
Copy Markdown

mgaitan commented Mar 21, 2014

Hi guys,

this is a bit off topic, but we are in a hack camp in Argentina for the weekend, (#pycamp2014) talking about if we should fork this project. There are many importants PR like this one without any feedback from the core developers.

here some rant
https://twitter.com/tin_nqn_/status/447020239897628672

What do you think ?

@michaeljoseph michaeljoseph removed this from the 0.7.1 milestone Jul 13, 2014
@michaeljoseph
Copy link
Copy Markdown
Contributor

👀 #260

JosephGasiorekUSDS pushed a commit to JosephGasiorekUSDS/cookiecutter that referenced this pull request Jun 30, 2024
…l-tiers-needs-to-be-slugified

slugify CODEOWNERS.md at Tiers 2-4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This issue/PR relates to a feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants