New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on cookiecutter #3526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks awesome but I did not perform a deep review as I am still in vacation. Lets get help from at least one more reviewer before acting as we do want to be confident in it.
Enjoy yourself. At least, you made me think I am on the right track. |
@zhan9san Do not forget to fix the linting. |
I am working on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing no documentation change so I assume that it fully transparent to the user ?
src/molecule/generate.py
Outdated
|
||
# Add the Python object to the context dictionary | ||
file_name = os.path.split(context_file)[1] | ||
file_stem = file_name.split(".")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not using something like (untested) ? :
file_name = os.path.basename(context_file)
file_stem = file_name.splitext(file_name)[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @apatard
Thanks for your review.
It is referred to cookiecutter generater.py
They do the same thing getting the filename without extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @apatard
file_name
generated by os.path.basename(context_file)
is string
, which does not have splitext
function.
So I only change the file_name
from os.path.split(context_file)[1]
to os.path.basename(context_file)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @apatard meant os.path.splitext(file_name)[0]
and not file_name.splitext(file_name)[0]
. While I think that would be better, it is a potentially breaking change, since the current code splits at the first .
, while os.path.splitext
splits at the last .
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. You are right.
The file_stem
is generated by os.path.splitext(file_name)[0]
in new commit.
For this specific case, as cookiecutter.json
is used, the value of file_stem
would be cookiecutter
.
All CI, including Would you kindly review this PR? |
@@ -0,0 +1,61 @@ | |||
"""cookiecutter main function.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a lawyer, but if this contains code that was taken from cookiecutter, doesn't it need to carry the license and copyright from cookiecutter? (Same for other code taken from that project.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your reminder.
The cookiecutter license and copyright are added in new commit, referring to how interpolation.py
did.
https://github.com/ansible-community/molecule/blob/04157c3684a46987ba00a6223261e3da30ff5b0c/src/molecule/interpolation.py#L1-L16
Yes, it's a backward compatible migration. |
@apatard @felixfontein Any more concerns? |
If we continue to use |
Closed in favour of #3568 -- please rebase that one. I want to merge that change in a feature branch as cookiecutter had finnally got a new release and we might not need to remove it. Still, i do not want to lose your work. |
Thanks. I think it's not urgent. I'll try to make it work. Besides, if |
Fix #3486
@ssbarnea
Both
cookiecutter
andansible template
are usingJinja
. So I decide to continue to useJinja
as a template engine.To avoid reinventing the wheel, the template render logic is migrated from
cookiecutter
with tailored function and parameters.I'd like to confirm with you whether the above way is accepted.
If yes, I'll add more tests later and fix the lint issue in this PR.
If no, do you have any suggestions?
To do
Do you have any concerns for to-do?
{{
and mark{{
directory deprecated in another PRBackward compatible
Currently, the following commands work as before. It means, this change is backward-compatible, and for other drivers, too.
delegated
by defaultdocker
driverRelated: cookiecutter/cookiecutter#1555 cookiecutter/cookiecutter#1636 cookiecutter/cookiecutter#1642