question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 the hooks folder and update/create new variables that could be added to the ones loaded from cookiecutter.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 the extra_context to cookiecutter.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:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

9reactions
gmrcommented, Nov 1, 2018

Having a pre-hook for computing values that are injected into the context for use in templates would be very useful.

6reactions
glenfantcommented, Sep 14, 2018

Computing new Jinja context variables in the pre hook would be a great feature.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found