<commit_before>#!/usr/bin/env python

"""Version utility"""

import subprocess
import os
import sys

def generate_version_string(libname):

  version_numbers = []
  tokens = []

  gitcmd = 'git'
  if sys.platform.startswith('win'):
    gitcmd = 'git.exe'
  try:
    git_version = subprocess.check_output( [ gitcmd, 'describe', '--long' ], stderr = subprocess.STDOUT ).strip()
    tokens = git_version.split( '-' )
    version_numbers = tokens[0].split( '.' )
  except Exception:
    pass

  version_major = "0"
  version_minor = "0"
  version_revision = "1"
  version_build = "0"
  version_scm = "0"

  if version_numbers and len( version_numbers ) > 2:
    version_major = version_numbers[0]
    version_minor = version_numbers[1]
    version_revision = version_numbers[2]

  if tokens and len( tokens ) > 2:
    version_build = tokens[1]
    version_scm = tokens[2][1:]

  source = """/* ****** AUTOMATICALLY GENERATED, DO NOT EDIT ******
   This file is generated from the git describe command.
   Run the configure script to regeneerate this file */

#include <foundation/foundation.h>

version_t
""" + libname + """_version(void) {
"""
  source += "	return version_make(" + version_major + ", " + version_minor + ", " + version_revision + ", " + version_build + ", 0x" + version_scm + ");\n}\n"<commit_msg>update version generator to add module<commit_after>#!/usr/bin/env python

"""Version utility"""

import subprocess
import os
import sys

def generate_version_string(libname):

  version_numbers = []
  tokens = []

  gitcmd = 'git'
  if sys.platform.startswith('win'):
    gitcmd = 'git.exe'
  try:
    git_version = subprocess.check_output( [ gitcmd, 'describe', '--long' ], stderr = subprocess.STDOUT ).strip()
    tokens = git_version.split( '-' )
    version_numbers = tokens[0].split( '.' )
  except Exception:
    pass

  version_major = "0"
  version_minor = "0"
  version_revision = "1"
  version_build = "0"
  version_scm = "0"

  if version_numbers and len( version_numbers ) > 2:
    version_major = version_numbers[0]
    version_minor = version_numbers[1]
    version_revision = version_numbers[2]

  if tokens and len( tokens ) > 2:
    version_build = tokens[1]
    version_scm = tokens[2][1:]

  module = ""
  if not libname == "foundation":
    module = "_module"

  source = """/* ****** AUTOMATICALLY GENERATED, DO NOT EDIT ******
   This file is generated from the git describe command.
   Run the configure script to regeneerate this file */

#include <foundation/foundation.h>

version_t
""" + libname + module + """_version(void) {
"""
  source += "	return version_make(" + version_major + ", " + version_minor + ", " + version_revision + ", " + version_build + ", 0x" + version_scm + ");\n}\n"
{'fraction_non_alphanumeric': 0.14442815249266863, 'fraction_numerical': 0.010997067448680353, 'mean_word_length': 3.754355400696864, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 9, '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': '2811646', 'n_tokens_mistral': 950, 'n_tokens_neox': 892, 'n_words': 224}