<commit_before>package toscaviewer

// This is a basic example
// Thanks http://thenewstack.io/make-a-restful-json-api-go/ for the tutorial
import (
	"fmt"
	"github.com/owulveryck/toscalib"
	"io"
)
// PrintDot convert the ToscaDefinitionure in dot format
// in order to generate a graph with graphviz
// This function is mostly used for debugging purpose and may change a lot in the future
func PrintDot(w io.Writer, topology toscalib.ToscaDefinition) {
	fmt.Fprintf(w, "digraph G {\n")
	fmt.Fprintf(w, "\tgraph [ rankdir = \"LR\" ];\n")
	for nodeName, nodeDetail := range topology.TopologyTemplate.NodeTemplates {
		// If requirements are found
		fmt.Fprintf(w,"\t\"%v\" [ label = \"%v\" shape = circle color=blue]\n",nodeName,nodeName)
		fmt.Fprintf(w,"\t\"%v\" [ label = \"%v\" shape = record color=red]\n",nodeDetail.Type,nodeDetail.Type)
		fmt.Fprintf(w,"\t\"%v\" -> \"%v\" [ color = red ]\n",nodeDetail.Type,nodeName)
		if nodeDetail.Requirements != nil {
			for _, requirementType := range nodeDetail.Requirements {
				for requirementTypeProp, value := range requirementType {
					fmt.Fprintf(w, "\t%v -> %v [label = %v];\n", nodeName, value["node"], requirementTypeProp)
				}
			}
		}
	}
	fmt.Fprintf(w, "}\n")
}<commit_msg>Code is ok according to the implementation of the NodeTemplate in the toscalib<commit_after>package toscaviewer

// This is a basic example
// Thanks http://thenewstack.io/make-a-restful-json-api-go/ for the tutorial
import (
	"fmt"
	"github.com/owulveryck/toscalib"
	"io"
)

// PrintDot convert the ToscaDefinitionure in dot format
// in order to generate a graph with graphviz
// This function is mostly used for debugging purpose and may change a lot in the future
func PrintDot(w io.Writer, topology toscalib.ToscaDefinition) {
	fmt.Fprintf(w, "digraph G {\n")
	fmt.Fprintf(w, "\tgraph [ rankdir = \"LR\" ];\n")
	for nodeName, nodeDetail := range topology.TopologyTemplate.NodeTemplates {
		// If requirements are found
		fmt.Fprintf(w, "\t\"%v\" [ label = \"%v\" shape = circle color=blue]\n", nodeName, nodeName)
		fmt.Fprintf(w, "\t\"%v\" [ label = \"%v\" shape = record color=red]\n", nodeDetail.Type, nodeDetail.Type)
		fmt.Fprintf(w, "\t\"%v\" -> \"%v\" [ color = red ]\n", nodeDetail.Type, nodeName)
		if nodeDetail.Requirements != nil {
		        fmt.Printf("DEBUG: %v\n",nodeDetail.Requirements)
			for _, requirementAssignements := range nodeDetail.Requirements {
			    for requirementName , requirementAssignement := range requirementAssignements {
				fmt.Fprintf(w, "\t%v -> %v [label = %v];\n", nodeName, requirementAssignement.Node, requirementName)
			    }
			}
		}
	}
	fmt.Fprintf(w, "}\n")
}
{'fraction_non_alphanumeric': 0.15433962264150944, 'fraction_numerical': 0.0, 'mean_word_length': 3.8112522686025407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3166872', 'n_tokens_mistral': 941, 'n_tokens_neox': 891, 'n_words': 241}