Need help with generating GUID/UUID values for context variables
See original GitHub issue- Cookiecutter version: 1.6
- Template project url: none
- Python version: 3.7 (virtual env created using win python 3.7 x64)
- Operating System: Windows 10, 64 Bit
Description:
First off many thanks for creating this project ! Here is some context of what I am trying to do and where I need some guidance
- I am trying to use CC to generate new a Visual Studio 2017 solution and project files with a particular folder/file organization that I like
- I was able to most of it working but for the below:
- Parts of the above project, solution files involves generating several unique GUIDs
- my first approach was creating a
pre_gen_project.py
inside thehooks
folder and update/create new variables that could be added to the ones loaded fromcookiecutter.json
or entered by the user - I was however blocked as I could not figure out how to access the context being used by CC and the jinja2 engine
- I proceeded to go over the many issues on github and found some related ones like the following: #60, #102, #180, #288 but no clear answer on how to achieve what I’d like
- I also followed some others issues that suggested creating custom jinja2 extension/filter (#944) but I couldnt figure out how or where to put them in the template folder so the cookiecutter.exe can identify them and pick them up
- Lastly, I also tried going over the CC source code and tried to create a new executable from my script (similar to
cli.py
) that passes the guids via theextra_context
tocookiecutter.main(...)
but ran into some other problems that I am still trying to figure out
Appreciate any pointers on how I can inject GUID values for the context variables
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
Generate UUID Assertion - TechDocs - Broadcom Inc.
The Generate UUID assertion creates any number of universally unique identifiers (UUIDs) and stores them in a context variable.
Read more >How to create a GUID/UUID in Python - Stack Overflow
The uuid module provides immutable UUID objects (the UUID class) and the functions uuid1() , uuid3() , uuid4() , uuid5() for generating ......
Read more >UUID based Value Objects with Spring Boot REST API
An example using UUID : @RestController @RequestMapping("/api/users") ; Notice how the path variable is typed to UUID . What we want to do...
Read more >What is a UUID, and Why Should You Care? - Cockroach Labs
A UUID – that's short for Universally Unique IDentifier, by the way – is a 36-character alphanumeric string that can be used to...
Read more >Java UUID - Javatpoint
import java.util.UUID; · public class UUIDExample · { · public static void main(String[] args) · { · UUID uuid=UUID.randomUUID(); //Generates random UUID ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having a pre-hook for computing values that are injected into the context for use in templates would be very useful.
Computing new Jinja context variables in the pre hook would be a great feature.